Index: src/compiler/js-graph.cc |
diff --git a/src/compiler/js-graph.cc b/src/compiler/js-graph.cc |
index b229306d2b99333f38bd8597cbd8ef020cf1ac25..285a96fed9fcba36efcfda2efd32119e0c063d00 100644 |
--- a/src/compiler/js-graph.cc |
+++ b/src/compiler/js-graph.cc |
@@ -13,90 +13,95 @@ namespace compiler { |
Node* JSGraph::ImmovableHeapConstant(Handle<Object> object) { |
PrintableUnique<Object> unique = |
PrintableUnique<Object>::CreateImmovable(zone(), object); |
- return NewNode(common()->HeapConstant(unique)); |
+ return graph()->NewNode(common()->HeapConstant(unique)); |
} |
-Node* JSGraph::NewNode(Operator* op) { |
- Node* node = graph()->NewNode(op); |
- typer_->Init(node); |
+Node* JSGraph::CacheNode(SetOncePointer<Node>* cache, Node* node) { |
+ cache->set(node); |
+ return node; |
+} |
+ |
+ |
+Node* JSGraph::CachedNode(SetOncePointer<Node>* cache) { |
+ Node* node = cache->get(); |
+ graph()->Decorate(node); |
return node; |
} |
Node* JSGraph::CEntryStubConstant() { |
- if (!c_entry_stub_constant_.is_set()) { |
- c_entry_stub_constant_.set( |
- ImmovableHeapConstant(CEntryStub(isolate(), 1).GetCode())); |
- } |
- return c_entry_stub_constant_.get(); |
+ return c_entry_stub_constant_.is_set() |
titzer
2014/10/01 08:18:11
This decorates the node every time you get it. Tha
|
+ ? CachedNode(&c_entry_stub_constant_) |
+ : CacheNode(&c_entry_stub_constant_, |
+ ImmovableHeapConstant(CEntryStub(isolate(), 1).GetCode())); |
} |
Node* JSGraph::UndefinedConstant() { |
- if (!undefined_constant_.is_set()) { |
- undefined_constant_.set( |
- ImmovableHeapConstant(factory()->undefined_value())); |
- } |
- return undefined_constant_.get(); |
+ return undefined_constant_.is_set() |
+ ? CachedNode(&undefined_constant_) |
+ : CacheNode(&undefined_constant_, |
+ ImmovableHeapConstant(factory()->undefined_value())); |
} |
Node* JSGraph::TheHoleConstant() { |
- if (!the_hole_constant_.is_set()) { |
- the_hole_constant_.set(ImmovableHeapConstant(factory()->the_hole_value())); |
- } |
- return the_hole_constant_.get(); |
+ return the_hole_constant_.is_set() |
+ ? CachedNode(&the_hole_constant_) |
+ : CacheNode(&the_hole_constant_, |
+ ImmovableHeapConstant(factory()->the_hole_value())); |
} |
Node* JSGraph::TrueConstant() { |
- if (!true_constant_.is_set()) { |
- true_constant_.set(ImmovableHeapConstant(factory()->true_value())); |
- } |
- return true_constant_.get(); |
+ return true_constant_.is_set() |
+ ? CachedNode(&true_constant_) |
+ : CacheNode(&true_constant_, |
+ ImmovableHeapConstant(factory()->true_value())); |
} |
Node* JSGraph::FalseConstant() { |
- if (!false_constant_.is_set()) { |
- false_constant_.set(ImmovableHeapConstant(factory()->false_value())); |
- } |
- return false_constant_.get(); |
+ return false_constant_.is_set() |
+ ? CachedNode(&false_constant_) |
+ : CacheNode(&false_constant_, |
+ ImmovableHeapConstant(factory()->false_value())); |
} |
Node* JSGraph::NullConstant() { |
- if (!null_constant_.is_set()) { |
- null_constant_.set(ImmovableHeapConstant(factory()->null_value())); |
- } |
- return null_constant_.get(); |
+ return null_constant_.is_set() |
+ ? CachedNode(&null_constant_) |
+ : CacheNode(&null_constant_, |
+ ImmovableHeapConstant(factory()->null_value())); |
} |
Node* JSGraph::ZeroConstant() { |
- if (!zero_constant_.is_set()) zero_constant_.set(NumberConstant(0.0)); |
- return zero_constant_.get(); |
+ return zero_constant_.is_set() |
+ ? CachedNode(&zero_constant_) |
+ : CacheNode(&zero_constant_, NumberConstant(0.0)); |
} |
Node* JSGraph::OneConstant() { |
- if (!one_constant_.is_set()) one_constant_.set(NumberConstant(1.0)); |
- return one_constant_.get(); |
+ return one_constant_.is_set() |
+ ? CachedNode(&one_constant_) |
+ : CacheNode(&one_constant_, NumberConstant(1.0)); |
} |
Node* JSGraph::NaNConstant() { |
- if (!nan_constant_.is_set()) { |
- nan_constant_.set(NumberConstant(base::OS::nan_value())); |
- } |
- return nan_constant_.get(); |
+ return nan_constant_.is_set() |
+ ? CachedNode(&nan_constant_) |
+ : CacheNode(&nan_constant_, NumberConstant(base::OS::nan_value())); |
} |
Node* JSGraph::HeapConstant(PrintableUnique<Object> value) { |
// TODO(turbofan): canonicalize heap constants using Unique<T> |
- return NewNode(common()->HeapConstant(value)); |
+ return graph()->NewNode(common()->HeapConstant(value)); |
} |
@@ -147,7 +152,9 @@ Node* JSGraph::Constant(int32_t value) { |
Node* JSGraph::Int32Constant(int32_t value) { |
Node** loc = cache_.FindInt32Constant(value); |
if (*loc == NULL) { |
- *loc = NewNode(common()->Int32Constant(value)); |
+ *loc = graph()->NewNode(common()->Int32Constant(value)); |
+ } else { |
+ graph()->Decorate(*loc); |
} |
return *loc; |
} |
@@ -156,7 +163,9 @@ Node* JSGraph::Int32Constant(int32_t value) { |
Node* JSGraph::NumberConstant(double value) { |
Node** loc = cache_.FindNumberConstant(value); |
if (*loc == NULL) { |
- *loc = NewNode(common()->NumberConstant(value)); |
+ *loc = graph()->NewNode(common()->NumberConstant(value)); |
+ } else { |
+ graph()->Decorate(*loc); |
} |
return *loc; |
} |
@@ -165,7 +174,9 @@ Node* JSGraph::NumberConstant(double value) { |
Node* JSGraph::Float64Constant(double value) { |
Node** loc = cache_.FindFloat64Constant(value); |
if (*loc == NULL) { |
- *loc = NewNode(common()->Float64Constant(value)); |
+ *loc = graph()->NewNode(common()->Float64Constant(value)); |
+ } else { |
+ graph()->Decorate(*loc); |
} |
return *loc; |
} |
@@ -174,7 +185,7 @@ Node* JSGraph::Float64Constant(double value) { |
Node* JSGraph::ExternalConstant(ExternalReference reference) { |
Node** loc = cache_.FindExternalConstant(reference); |
if (*loc == NULL) { |
- *loc = NewNode(common()->ExternalConstant(reference)); |
+ *loc = graph()->NewNode(common()->ExternalConstant(reference)); |
} |
return *loc; |
} |