Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Unified Diff: src/compiler/js-graph.cc

Issue 1523323005: [turbofan] Implement proper caching of heap constants in the JSGraph. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/js-graph.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-graph.cc
diff --git a/src/compiler/js-graph.cc b/src/compiler/js-graph.cc
index 782236fe0c0c940ff3817d639e9e260e823c42b4..9c1baa00e644f9c5d2091a1f4c7c55909dfa1ac2 100644
--- a/src/compiler/js-graph.cc
+++ b/src/compiler/js-graph.cc
@@ -11,12 +11,6 @@ namespace v8 {
namespace internal {
namespace compiler {
-Node* JSGraph::ImmovableHeapConstant(Handle<HeapObject> value) {
- // TODO(bmeurer): Flatten cons strings here before we canonicalize them?
- return graph()->NewNode(common()->HeapConstant(value));
-}
-
-
#define CACHED(name, expr) \
cached_nodes_[name] ? cached_nodes_[name] : (cached_nodes_[name] = (expr))
@@ -24,43 +18,40 @@ Node* JSGraph::ImmovableHeapConstant(Handle<HeapObject> value) {
Node* JSGraph::CEntryStubConstant(int result_size) {
if (result_size == 1) {
return CACHED(kCEntryStubConstant,
- ImmovableHeapConstant(CEntryStub(isolate(), 1).GetCode()));
+ HeapConstant(CEntryStub(isolate(), 1).GetCode()));
}
- return ImmovableHeapConstant(CEntryStub(isolate(), result_size).GetCode());
+ return HeapConstant(CEntryStub(isolate(), result_size).GetCode());
}
Node* JSGraph::EmptyFixedArrayConstant() {
return CACHED(kEmptyFixedArrayConstant,
- ImmovableHeapConstant(factory()->empty_fixed_array()));
+ HeapConstant(factory()->empty_fixed_array()));
}
Node* JSGraph::UndefinedConstant() {
- return CACHED(kUndefinedConstant,
- ImmovableHeapConstant(factory()->undefined_value()));
+ return CACHED(kUndefinedConstant, HeapConstant(factory()->undefined_value()));
}
Node* JSGraph::TheHoleConstant() {
- return CACHED(kTheHoleConstant,
- ImmovableHeapConstant(factory()->the_hole_value()));
+ return CACHED(kTheHoleConstant, HeapConstant(factory()->the_hole_value()));
}
Node* JSGraph::TrueConstant() {
- return CACHED(kTrueConstant, ImmovableHeapConstant(factory()->true_value()));
+ return CACHED(kTrueConstant, HeapConstant(factory()->true_value()));
}
Node* JSGraph::FalseConstant() {
- return CACHED(kFalseConstant,
- ImmovableHeapConstant(factory()->false_value()));
+ return CACHED(kFalseConstant, HeapConstant(factory()->false_value()));
}
Node* JSGraph::NullConstant() {
- return CACHED(kNullConstant, ImmovableHeapConstant(factory()->null_value()));
+ return CACHED(kNullConstant, HeapConstant(factory()->null_value()));
}
@@ -81,11 +72,12 @@ Node* JSGraph::NaNConstant() {
Node* JSGraph::HeapConstant(Handle<HeapObject> value) {
- // TODO(turbofan): canonicalize heap constants using <magic approach>.
- // TODO(titzer): We could also match against the addresses of immortable
- // immovables here, even without access to the heap, thus always
- // canonicalizing references to them.
- return ImmovableHeapConstant(value);
+ // TODO(bmeurer): Flatten cons strings here before we canonicalize them?
+ Node** loc = cache_.FindHeapConstant(value);
+ if (*loc == nullptr) {
+ *loc = graph()->NewNode(common()->HeapConstant(value));
+ }
+ return *loc;
}
« no previous file with comments | « src/compiler/js-graph.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698