| Index: src/compiler/js-graph.cc
|
| diff --git a/src/compiler/js-graph.cc b/src/compiler/js-graph.cc
|
| index 1f3c25d06aae1f9969f5d8283af8d51bb7783af5..8171f1b9a808a6fe72d9997c556db411ce78b8ed 100644
|
| --- a/src/compiler/js-graph.cc
|
| +++ b/src/compiler/js-graph.cc
|
| @@ -17,77 +17,60 @@ Node* JSGraph::ImmovableHeapConstant(Handle<HeapObject> object) {
|
| }
|
|
|
|
|
| +#define CACHED(name, expr) \
|
| + cached_nodes_[name] ? cached_nodes_[name] : (cached_nodes_[name] = (expr))
|
| +
|
| +
|
| Node* JSGraph::CEntryStubConstant(int result_size) {
|
| if (result_size == 1) {
|
| - if (!c_entry_stub_constant_.is_set()) {
|
| - c_entry_stub_constant_.set(
|
| - ImmovableHeapConstant(CEntryStub(isolate(), 1).GetCode()));
|
| - }
|
| - return c_entry_stub_constant_.get();
|
| + return CACHED(kCEntryStubConstant,
|
| + ImmovableHeapConstant(CEntryStub(isolate(), 1).GetCode()));
|
| }
|
| -
|
| return ImmovableHeapConstant(CEntryStub(isolate(), result_size).GetCode());
|
| }
|
|
|
|
|
| Node* JSGraph::UndefinedConstant() {
|
| - if (!undefined_constant_.is_set()) {
|
| - undefined_constant_.set(
|
| - ImmovableHeapConstant(factory()->undefined_value()));
|
| - }
|
| - return undefined_constant_.get();
|
| + return CACHED(kUndefinedConstant,
|
| + 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 CACHED(kTheHoleConstant,
|
| + 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 CACHED(kTrueConstant, ImmovableHeapConstant(factory()->true_value()));
|
| }
|
|
|
|
|
| Node* JSGraph::FalseConstant() {
|
| - if (!false_constant_.is_set()) {
|
| - false_constant_.set(ImmovableHeapConstant(factory()->false_value()));
|
| - }
|
| - return false_constant_.get();
|
| + return CACHED(kFalseConstant,
|
| + ImmovableHeapConstant(factory()->false_value()));
|
| }
|
|
|
|
|
| Node* JSGraph::NullConstant() {
|
| - if (!null_constant_.is_set()) {
|
| - null_constant_.set(ImmovableHeapConstant(factory()->null_value()));
|
| - }
|
| - return null_constant_.get();
|
| + return CACHED(kNullConstant, ImmovableHeapConstant(factory()->null_value()));
|
| }
|
|
|
|
|
| Node* JSGraph::ZeroConstant() {
|
| - if (!zero_constant_.is_set()) zero_constant_.set(NumberConstant(0.0));
|
| - return zero_constant_.get();
|
| + return CACHED(kZeroConstant, NumberConstant(0.0));
|
| }
|
|
|
|
|
| Node* JSGraph::OneConstant() {
|
| - if (!one_constant_.is_set()) one_constant_.set(NumberConstant(1.0));
|
| - return one_constant_.get();
|
| + return CACHED(kOneConstant, NumberConstant(1.0));
|
| }
|
|
|
|
|
| Node* JSGraph::NaNConstant() {
|
| - if (!nan_constant_.is_set()) {
|
| - nan_constant_.set(NumberConstant(std::numeric_limits<double>::quiet_NaN()));
|
| - }
|
| - return nan_constant_.get();
|
| + return CACHED(kNaNConstant,
|
| + NumberConstant(std::numeric_limits<double>::quiet_NaN()));
|
| }
|
|
|
|
|
| @@ -201,35 +184,27 @@ Node* JSGraph::ExternalConstant(ExternalReference reference) {
|
|
|
|
|
| Node* JSGraph::EmptyFrameState() {
|
| - if (!empty_frame_state_.is_set()) {
|
| + if (cached_nodes_[kEmptyFrameState] == nullptr) {
|
| Node* values = graph()->NewNode(common()->StateValues(0));
|
| Node* state_node = graph()->NewNode(
|
| common()->FrameState(JS_FRAME, BailoutId::None(),
|
| OutputFrameStateCombine::Ignore()),
|
| values, values, values, NoContextConstant(), UndefinedConstant());
|
| - empty_frame_state_.set(state_node);
|
| + cached_nodes_[kEmptyFrameState] = state_node;
|
| }
|
| - return empty_frame_state_.get();
|
| + return cached_nodes_[kEmptyFrameState];
|
| }
|
|
|
|
|
| Node* JSGraph::DeadControl() {
|
| - if (!dead_control_.is_set()) {
|
| - Node* dead_node = graph()->NewNode(common()->Dead());
|
| - dead_control_.set(dead_node);
|
| - }
|
| - return dead_control_.get();
|
| + return CACHED(kDeadControl, graph()->NewNode(common()->Dead()));
|
| }
|
|
|
|
|
| void JSGraph::GetCachedNodes(NodeVector* nodes) {
|
| cache_.GetCachedNodes(nodes);
|
| - SetOncePointer<Node>* ptrs[] = {
|
| - &c_entry_stub_constant_, &undefined_constant_, &the_hole_constant_,
|
| - &true_constant_, &false_constant_, &null_constant_,
|
| - &zero_constant_, &one_constant_, &nan_constant_};
|
| - for (size_t i = 0; i < arraysize(ptrs); i++) {
|
| - if (ptrs[i]->is_set()) nodes->push_back(ptrs[i]->get());
|
| + for (size_t i = 0; i < arraysize(cached_nodes_); i++) {
|
| + if (cached_nodes_[i]) nodes->push_back(cached_nodes_[i]);
|
| }
|
| }
|
|
|
|
|