| Index: test/cctest/compiler/test-js-context-specialization.cc
|
| diff --git a/test/cctest/compiler/test-js-context-specialization.cc b/test/cctest/compiler/test-js-context-specialization.cc
|
| index e08fef9972bf6c07f7391889e00137efedc47a6c..2450e7cf578c577241c369527c204a8f6dcaf6fb 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);
|
|
|
|
|