From 00639c7511356bf0ba50f7f1e990013957c24117 Mon Sep 17 00:00:00 2001 From: mstarzinger Date: Thu, 30 Apr 2015 05:06:20 -0700 Subject: [PATCH] [test] Remove DirectGraphBuilder helper. R=bmeurer@chromium.org TEST=cctest/test-js-context-specialization Review URL: https://codereview.chromium.org/1112343002 Cr-Commit-Position: refs/heads/master@{#28160} --- test/cctest/compiler/graph-builder-tester.h | 15 ----- .../compiler/test-js-context-specialization.cc | 72 ++++++++++++---------- 2 files changed, 38 insertions(+), 49 deletions(-) diff --git a/test/cctest/compiler/graph-builder-tester.h b/test/cctest/compiler/graph-builder-tester.h index ea8507c..ca50c9f 100644 --- a/test/cctest/compiler/graph-builder-tester.h +++ b/test/cctest/compiler/graph-builder-tester.h @@ -19,21 +19,6 @@ namespace v8 { namespace internal { namespace compiler { -// A class that just passes node creation on to the Graph. -class DirectGraphBuilder : public GraphBuilder { - public: - DirectGraphBuilder(Isolate* isolate, Graph* graph) - : GraphBuilder(isolate, graph) {} - virtual ~DirectGraphBuilder() {} - - protected: - virtual Node* MakeNode(const Operator* op, int value_input_count, - Node** value_inputs, bool incomplete) final { - return graph()->NewNode(op, value_input_count, value_inputs, incomplete); - } -}; - - class MachineCallHelper : public CallHelper { public: MachineCallHelper(Isolate* isolate, MachineSignature* machine_sig); diff --git a/test/cctest/compiler/test-js-context-specialization.cc b/test/cctest/compiler/test-js-context-specialization.cc index e08fef9..2450e7c 100644 --- a/test/cctest/compiler/test-js-context-specialization.cc +++ b/test/cctest/compiler/test-js-context-specialization.cc @@ -14,12 +14,10 @@ using namespace v8::internal; using namespace v8::internal::compiler; -class ContextSpecializationTester : public HandleAndZoneScope, - public DirectGraphBuilder { +class ContextSpecializationTester : public HandleAndZoneScope { public: ContextSpecializationTester() - : DirectGraphBuilder(main_isolate(), - new (main_zone()) Graph(main_zone())), + : graph_(new (main_zone()) Graph(main_zone())), common_(main_zone()), javascript_(main_zone()), machine_(main_zone()), @@ -31,8 +29,10 @@ class ContextSpecializationTester : public HandleAndZoneScope, JSOperatorBuilder* javascript() { return &javascript_; } SimplifiedOperatorBuilder* simplified() { return &simplified_; } JSGraph* jsgraph() { return &jsgraph_; } + Graph* graph() { return graph_; } private: + Graph* graph_; CommonOperatorBuilder common_; JSOperatorBuilder javascript_; MachineOperatorBuilder machine_; @@ -44,7 +44,7 @@ class ContextSpecializationTester : public HandleAndZoneScope, TEST(ReduceJSLoadContext) { ContextSpecializationTester t; - Node* start = t.NewNode(t.common()->Start(0)); + Node* start = t.graph()->NewNode(t.common()->Start(0)); t.graph()->SetStart(start); // Make a context and initialize it a bit for this test. @@ -59,28 +59,28 @@ TEST(ReduceJSLoadContext) { Node* const_context = t.jsgraph()->Constant(native); Node* deep_const_context = t.jsgraph()->Constant(subcontext2); - Node* param_context = t.NewNode(t.common()->Parameter(0), start); + Node* param_context = t.graph()->NewNode(t.common()->Parameter(0), start); JSContextSpecializer spec(t.jsgraph()); { // Mutable slot, constant context, depth = 0 => do nothing. - Node* load = t.NewNode(t.javascript()->LoadContext(0, 0, false), - const_context, const_context, start); + Node* load = t.graph()->NewNode(t.javascript()->LoadContext(0, 0, false), + const_context, const_context, start); Reduction r = spec.ReduceJSLoadContext(load); CHECK(!r.Changed()); } { // Mutable slot, non-constant context, depth = 0 => do nothing. - Node* load = t.NewNode(t.javascript()->LoadContext(0, 0, false), - param_context, param_context, start); + Node* load = t.graph()->NewNode(t.javascript()->LoadContext(0, 0, false), + param_context, param_context, start); Reduction r = spec.ReduceJSLoadContext(load); CHECK(!r.Changed()); } { // Mutable slot, constant context, depth > 0 => fold-in parent context. - Node* load = t.NewNode( + Node* load = t.graph()->NewNode( t.javascript()->LoadContext(2, Context::GLOBAL_EVAL_FUN_INDEX, false), deep_const_context, deep_const_context, start); Reduction r = spec.ReduceJSLoadContext(load); @@ -97,8 +97,8 @@ TEST(ReduceJSLoadContext) { { // Immutable slot, constant context, depth = 0 => specialize. - Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true), - const_context, const_context, start); + Node* load = t.graph()->NewNode(t.javascript()->LoadContext(0, slot, true), + const_context, const_context, start); Reduction r = spec.ReduceJSLoadContext(load); CHECK(r.Changed()); CHECK(r.replacement() != load); @@ -116,7 +116,7 @@ TEST(ReduceJSLoadContext) { TEST(ReduceJSStoreContext) { ContextSpecializationTester t; - Node* start = t.NewNode(t.common()->Start(0)); + Node* start = t.graph()->NewNode(t.common()->Start(0)); t.graph()->SetStart(start); // Make a context and initialize it a bit for this test. @@ -131,36 +131,36 @@ TEST(ReduceJSStoreContext) { Node* const_context = t.jsgraph()->Constant(native); Node* deep_const_context = t.jsgraph()->Constant(subcontext2); - Node* param_context = t.NewNode(t.common()->Parameter(0), start); + Node* param_context = t.graph()->NewNode(t.common()->Parameter(0), start); JSContextSpecializer spec(t.jsgraph()); { // Mutable slot, constant context, depth = 0 => do nothing. - Node* load = t.NewNode(t.javascript()->StoreContext(0, 0), const_context, - const_context, start); + Node* load = t.graph()->NewNode(t.javascript()->StoreContext(0, 0), + const_context, const_context, start); Reduction r = spec.ReduceJSStoreContext(load); CHECK(!r.Changed()); } { // Mutable slot, non-constant context, depth = 0 => do nothing. - Node* load = t.NewNode(t.javascript()->StoreContext(0, 0), param_context, - param_context, start); + Node* load = t.graph()->NewNode(t.javascript()->StoreContext(0, 0), + param_context, param_context, start); Reduction r = spec.ReduceJSStoreContext(load); CHECK(!r.Changed()); } { // Immutable slot, constant context, depth = 0 => do nothing. - Node* load = t.NewNode(t.javascript()->StoreContext(0, slot), const_context, - const_context, start); + Node* load = t.graph()->NewNode(t.javascript()->StoreContext(0, slot), + const_context, const_context, start); Reduction r = spec.ReduceJSStoreContext(load); CHECK(!r.Changed()); } { // Mutable slot, constant context, depth > 0 => fold-in parent context. - Node* load = t.NewNode( + Node* load = t.graph()->NewNode( t.javascript()->StoreContext(2, Context::GLOBAL_EVAL_FUN_INDEX), deep_const_context, deep_const_context, start); Reduction r = spec.ReduceJSStoreContext(load); @@ -186,7 +186,7 @@ static void CheckEffectInput(Node* effect, Node* use) { TEST(SpecializeToContext) { ContextSpecializationTester t; - Node* start = t.NewNode(t.common()->Start(0)); + Node* start = t.graph()->NewNode(t.common()->Start(0)); t.graph()->SetStart(start); // Make a context and initialize it a bit for this test. @@ -196,29 +196,33 @@ TEST(SpecializeToContext) { native->set(slot, *expected); Node* const_context = t.jsgraph()->Constant(native); - Node* param_context = t.NewNode(t.common()->Parameter(0), start); + Node* param_context = t.graph()->NewNode(t.common()->Parameter(0), start); JSContextSpecializer spec(t.jsgraph()); { // Check that specialization replaces values and forwards effects // correctly, and folds values from constant and non-constant contexts Node* effect_in = start; - Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true), - const_context, const_context, effect_in); + Node* load = t.graph()->NewNode(t.javascript()->LoadContext(0, slot, true), + const_context, const_context, effect_in); - Node* value_use = t.NewNode(t.simplified()->ChangeTaggedToInt32(), load); - Node* other_load = t.NewNode(t.javascript()->LoadContext(0, slot, true), - param_context, param_context, load); + Node* value_use = + t.graph()->NewNode(t.simplified()->ChangeTaggedToInt32(), load); + Node* other_load = + t.graph()->NewNode(t.javascript()->LoadContext(0, slot, true), + param_context, param_context, load); Node* effect_use = other_load; Node* other_use = - t.NewNode(t.simplified()->ChangeTaggedToInt32(), other_load); + t.graph()->NewNode(t.simplified()->ChangeTaggedToInt32(), other_load); - Node* add = t.NewNode(t.javascript()->Add(LanguageMode::SLOPPY), value_use, - other_use, param_context, other_load, start); + Node* add = + t.graph()->NewNode(t.javascript()->Add(LanguageMode::SLOPPY), value_use, + other_use, param_context, other_load, start); - Node* ret = t.NewNode(t.common()->Return(), add, effect_use, start); - Node* end = t.NewNode(t.common()->End(), ret); + Node* ret = + t.graph()->NewNode(t.common()->Return(), add, effect_use, start); + Node* end = t.graph()->NewNode(t.common()->End(), ret); USE(end); t.graph()->SetEnd(end); -- 2.7.4