Commit c0c3a231 authored by mtrofin's avatar mtrofin Committed by Commit bot

[turbofan] Robust node caching for relocatable int{32|64}

We should use both the int value as well as the reloc info mode for the
key of a relocatable int{32|64}.

BUG=

Review-Url: https://codereview.chromium.org/2039023002
Cr-Commit-Position: refs/heads/master@{#36762}
parent 0f934866
......@@ -52,12 +52,14 @@ class CommonNodeCache final {
Node** FindHeapConstant(Handle<HeapObject> value);
Node** FindRelocatableInt32Constant(int32_t value) {
return relocatable_int32_constants_.Find(zone(), value);
Node** FindRelocatableInt32Constant(int32_t value, RelocInfoMode rmode) {
return relocatable_int32_constants_.Find(zone(),
std::make_pair(value, rmode));
}
Node** FindRelocatableInt64Constant(int64_t value) {
return relocatable_int64_constants_.Find(zone(), value);
Node** FindRelocatableInt64Constant(int64_t value, RelocInfoMode rmode) {
return relocatable_int64_constants_.Find(zone(),
std::make_pair(value, rmode));
}
// Return all nodes from the cache.
......@@ -73,8 +75,8 @@ class CommonNodeCache final {
IntPtrNodeCache external_constants_;
Int64NodeCache number_constants_;
IntPtrNodeCache heap_constants_;
Int32NodeCache relocatable_int32_constants_;
Int64NodeCache relocatable_int64_constants_;
RelocInt32NodeCache relocatable_int32_constants_;
RelocInt64NodeCache relocatable_int64_constants_;
Zone* const zone_;
DISALLOW_COPY_AND_ASSIGN(CommonNodeCache);
......
......@@ -161,7 +161,8 @@ Node* JSGraph::Int64Constant(int64_t value) {
}
Node* JSGraph::RelocatableInt32Constant(int32_t value, RelocInfo::Mode rmode) {
Node** loc = cache_.FindRelocatableInt32Constant(value);
Node** loc = cache_.FindRelocatableInt32Constant(
value, static_cast<RelocInfoMode>(rmode));
if (*loc == nullptr) {
*loc = graph()->NewNode(common()->RelocatableInt32Constant(value, rmode));
}
......@@ -169,7 +170,8 @@ Node* JSGraph::RelocatableInt32Constant(int32_t value, RelocInfo::Mode rmode) {
}
Node* JSGraph::RelocatableInt64Constant(int64_t value, RelocInfo::Mode rmode) {
Node** loc = cache_.FindRelocatableInt64Constant(value);
Node** loc = cache_.FindRelocatableInt64Constant(
value, static_cast<RelocInfoMode>(rmode));
if (*loc == nullptr) {
*loc = graph()->NewNode(common()->RelocatableInt64Constant(value, rmode));
}
......
......@@ -115,6 +115,9 @@ void NodeCache<Key, Hash, Pred>::GetCachedNodes(ZoneVector<Node*>* nodes) {
template class NodeCache<int32_t>;
template class NodeCache<int64_t>;
template class NodeCache<RelocInt32Key>;
template class NodeCache<RelocInt64Key>;
} // namespace compiler
} // namespace internal
} // namespace v8
......@@ -63,6 +63,14 @@ class NodeCache final {
// Various default cache types.
typedef NodeCache<int32_t> Int32NodeCache;
typedef NodeCache<int64_t> Int64NodeCache;
// All we want is the numeric value of the RelocInfo::Mode enum. We typedef
// below to avoid pulling in assembler.h
typedef char RelocInfoMode;
typedef std::pair<int32_t, RelocInfoMode> RelocInt32Key;
typedef std::pair<int64_t, RelocInfoMode> RelocInt64Key;
typedef NodeCache<RelocInt32Key> RelocInt32NodeCache;
typedef NodeCache<RelocInt64Key> RelocInt64NodeCache;
#if V8_HOST_ARCH_32_BIT
typedef Int32NodeCache IntPtrNodeCache;
#else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment