| 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;
|
| }
|
|
|
|
|
|
|