From: mstarzinger Date: Tue, 29 Sep 2015 15:53:08 +0000 (-0700) Subject: [turbofan] Pass scope infos as static operator parameters. X-Git-Tag: upstream/4.7.83~31 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8dfe18559c730e22d02be77993a775a250178227;p=platform%2Fupstream%2Fv8.git [turbofan] Pass scope infos as static operator parameters. This changes the operators for JSCreate[Block|Script]Context to take their ScopeInfo as a static parameter as opposed to a value input and in turn allows for easier access to that parameter during lowerings. R=jarin@chromium.org Review URL: https://codereview.chromium.org/1379593002 Cr-Commit-Position: refs/heads/master@{#31009} --- diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index 8e5137ea2..f8f010d81 100644 --- a/src/compiler/ast-graph-builder.cc +++ b/src/compiler/ast-graph-builder.cc @@ -3132,9 +3132,9 @@ Node* AstGraphBuilder::BuildLocalScriptContext(Scope* scope) { DCHECK(scope->is_script_scope()); // Allocate a new local context. - const Operator* op = javascript()->CreateScriptContext(); - Node* scope_info = jsgraph()->Constant(scope->GetScopeInfo(isolate())); - Node* local_context = NewNode(op, GetFunctionClosure(), scope_info); + Handle scope_info = scope->GetScopeInfo(isolate()); + const Operator* op = javascript()->CreateScriptContext(scope_info); + Node* local_context = NewNode(op, GetFunctionClosure()); PrepareFrameState(local_context, BailoutId::Prologue()); return local_context; @@ -3145,9 +3145,9 @@ Node* AstGraphBuilder::BuildLocalBlockContext(Scope* scope) { DCHECK(scope->is_block_scope()); // Allocate a new local context. - const Operator* op = javascript()->CreateBlockContext(); - Node* scope_info = jsgraph()->Constant(scope->GetScopeInfo(isolate())); - Node* local_context = NewNode(op, scope_info, GetFunctionClosureForContext()); + Handle scope_info = scope->GetScopeInfo(isolate()); + const Operator* op = javascript()->CreateBlockContext(scope_info); + Node* local_context = NewNode(op, GetFunctionClosureForContext()); return local_context; } diff --git a/src/compiler/js-generic-lowering.cc b/src/compiler/js-generic-lowering.cc index 2d4210dff..eac056578 100644 --- a/src/compiler/js-generic-lowering.cc +++ b/src/compiler/js-generic-lowering.cc @@ -114,21 +114,12 @@ REPLACE_COMPARE_IC_CALL_WITH_LANGUAGE_MODE(JSGreaterThanOrEqual, Token::GTE) void JSGenericLowering::Lower##op(Node* node) { \ ReplaceWithRuntimeCall(node, fun); \ } -REPLACE_RUNTIME_CALL(JSCreate, Runtime::kAbort) REPLACE_RUNTIME_CALL(JSCreateFunctionContext, Runtime::kNewFunctionContext) REPLACE_RUNTIME_CALL(JSCreateWithContext, Runtime::kPushWithContext) -REPLACE_RUNTIME_CALL(JSCreateBlockContext, Runtime::kPushBlockContext) REPLACE_RUNTIME_CALL(JSCreateModuleContext, Runtime::kPushModuleContext) -REPLACE_RUNTIME_CALL(JSCreateScriptContext, Runtime::kNewScriptContext) #undef REPLACE_RUNTIME -#define REPLACE_UNIMPLEMENTED(op) \ - void JSGenericLowering::Lower##op(Node* node) { UNIMPLEMENTED(); } -REPLACE_UNIMPLEMENTED(JSYield) -#undef REPLACE_UNIMPLEMENTED - - static CallDescriptor::Flags FlagsForNode(Node* node) { CallDescriptor::Flags result = CallDescriptor::kNoFlags; if (OperatorProperties::GetFrameStateInputCount(node->op()) > 0) { @@ -491,6 +482,9 @@ void JSGenericLowering::LowerJSLoadDynamicContext(Node* node) { } +void JSGenericLowering::LowerJSCreate(Node* node) { UNIMPLEMENTED(); } + + void JSGenericLowering::LowerJSCreateArguments(Node* node) { const CreateArgumentsParameters& p = CreateArgumentsParametersOf(node->op()); switch (p.type()) { @@ -537,6 +531,20 @@ void JSGenericLowering::LowerJSCreateCatchContext(Node* node) { } +void JSGenericLowering::LowerJSCreateBlockContext(Node* node) { + Handle scope_info = OpParameter>(node); + node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info)); + ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext); +} + + +void JSGenericLowering::LowerJSCreateScriptContext(Node* node) { + Handle scope_info = OpParameter>(node); + node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info)); + ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext); +} + + void JSGenericLowering::LowerJSCallConstruct(Node* node) { int arity = OpParameter(node); CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL); @@ -786,6 +794,9 @@ void JSGenericLowering::LowerJSForInStep(Node* node) { } +void JSGenericLowering::LowerJSYield(Node* node) { UNIMPLEMENTED(); } + + void JSGenericLowering::LowerJSStackCheck(Node* node) { Node* effect = NodeProperties::GetEffectInput(node); Node* control = NodeProperties::GetControlInput(node); diff --git a/src/compiler/js-operator.cc b/src/compiler/js-operator.cc index d70803468..37369f697 100644 --- a/src/compiler/js-operator.cc +++ b/src/compiler/js-operator.cc @@ -474,9 +474,7 @@ const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) { V(StackCheck, Operator::kNoProperties, 0, 0) \ V(CreateFunctionContext, Operator::kNoProperties, 1, 1) \ V(CreateWithContext, Operator::kNoProperties, 2, 1) \ - V(CreateBlockContext, Operator::kNoProperties, 2, 1) \ - V(CreateModuleContext, Operator::kNoProperties, 2, 1) \ - V(CreateScriptContext, Operator::kNoProperties, 2, 1) + V(CreateModuleContext, Operator::kNoProperties, 2, 1) #define CACHED_OP_LIST_WITH_LANGUAGE_MODE(V) \ @@ -785,6 +783,28 @@ const Operator* JSOperatorBuilder::CreateCatchContext( name); // parameter } + +const Operator* JSOperatorBuilder::CreateBlockContext( + const Handle& scpope_info) { + return new (zone()) Operator1, Handle::equal_to, + Handle::hash>( // -- + IrOpcode::kJSCreateBlockContext, Operator::kNoProperties, // opcode + "JSCreateBlockContext", // name + 1, 1, 1, 1, 1, 2, // counts + scpope_info); // parameter +} + + +const Operator* JSOperatorBuilder::CreateScriptContext( + const Handle& scpope_info) { + return new (zone()) Operator1, Handle::equal_to, + Handle::hash>( // -- + IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode + "JSCreateScriptContext", // name + 1, 1, 1, 1, 1, 2, // counts + scpope_info); // parameter +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/src/compiler/js-operator.h b/src/compiler/js-operator.h index 4846add6c..88b2dd304 100644 --- a/src/compiler/js-operator.h +++ b/src/compiler/js-operator.h @@ -559,13 +559,12 @@ class JSOperatorBuilder final : public ZoneObject { const Operator* StackCheck(); - // TODO(titzer): nail down the static parts of each of these context flavors. const Operator* CreateFunctionContext(); const Operator* CreateCatchContext(const Handle& name); const Operator* CreateWithContext(); - const Operator* CreateBlockContext(); + const Operator* CreateBlockContext(const Handle& scpope_info); const Operator* CreateModuleContext(); - const Operator* CreateScriptContext(); + const Operator* CreateScriptContext(const Handle& scpope_info); private: Zone* zone() const { return zone_; } diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc index c77d994c2..7c25afcfa 100644 --- a/src/compiler/js-typed-lowering.cc +++ b/src/compiler/js-typed-lowering.cc @@ -1296,16 +1296,15 @@ Reduction JSTypedLowering::ReduceJSCreateWithContext(Node* node) { Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) { DCHECK_EQ(IrOpcode::kJSCreateBlockContext, node->opcode()); - Node* const input = NodeProperties::GetValueInput(node, 0); - HeapObjectMatcher minput(input); - DCHECK(minput.HasValue()); // TODO(mstarzinger): Make ScopeInfo static. - int context_length = Handle::cast(minput.Value())->ContextLength(); + Handle scope_info = OpParameter>(node); + int context_length = scope_info->ContextLength(); if (FLAG_turbo_allocate && context_length < kBlockContextAllocationLimit) { // JSCreateBlockContext(s:scope[length < limit], f) Node* const effect = NodeProperties::GetEffectInput(node); Node* const control = NodeProperties::GetControlInput(node); Node* const closure = NodeProperties::GetValueInput(node, 1); Node* const context = NodeProperties::GetContextInput(node); + Node* const extension = jsgraph()->Constant(scope_info); Node* const load = graph()->NewNode( simplified()->LoadField( AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), @@ -1315,7 +1314,7 @@ Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) { a.AllocateArray(context_length, factory()->block_context_map()); a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); - a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), input); + a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); a.Store(AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX), load); for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->TheHoleConstant()); diff --git a/src/compiler/operator.h b/src/compiler/operator.h index 0cd0aaf1c..eba430f92 100644 --- a/src/compiler/operator.h +++ b/src/compiler/operator.h @@ -217,6 +217,13 @@ inline Handle const& OpParameter(const Operator* op) { ->parameter(); } +template <> +inline Handle const& OpParameter(const Operator* op) { + return reinterpret_cast< + const Operator1, Handle::equal_to, + Handle::hash>*>(op)->parameter(); +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/test/unittests/compiler/js-context-relaxation-unittest.cc b/test/unittests/compiler/js-context-relaxation-unittest.cc index c0cdeb383..4cc8f1750 100644 --- a/test/unittests/compiler/js-context-relaxation-unittest.cc +++ b/test/unittests/compiler/js-context-relaxation-unittest.cc @@ -201,11 +201,12 @@ TEST_F(JSContextRelaxationTest, Node* const input1 = Parameter(1); Node* const context = Parameter(2); Node* const outer_context = Parameter(3); - const Operator* op = javascript()->CreateBlockContext(); + Handle scope_info = Handle::null(); + const Operator* op = javascript()->CreateBlockContext(scope_info); Node* const effect = graph()->start(); Node* const control = graph()->start(); - Node* nested_context = graph()->NewNode( - op, graph()->start(), graph()->start(), outer_context, effect, control); + Node* nested_context = + graph()->NewNode(op, graph()->start(), outer_context, effect, control); Node* const frame_state_2 = ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); Node* node = @@ -224,14 +225,14 @@ TEST_F(JSContextRelaxationTest, Node* const input1 = Parameter(1); Node* const context = Parameter(2); Node* const outer_context = Parameter(3); - const Operator* op = javascript()->CreateScriptContext(); + Handle scope_info = Handle::null(); + const Operator* op = javascript()->CreateScriptContext(scope_info); Node* const frame_state_1 = ShallowFrameStateChain(outer_context, CALL_MAINTAINS_NATIVE_CONTEXT); Node* const effect = graph()->start(); Node* const control = graph()->start(); - Node* nested_context = - graph()->NewNode(op, graph()->start(), graph()->start(), outer_context, - frame_state_1, effect, control); + Node* nested_context = graph()->NewNode(op, graph()->start(), outer_context, + frame_state_1, effect, control); Node* const frame_state_2 = ShallowFrameStateChain(nested_context, CALL_MAINTAINS_NATIVE_CONTEXT); Node* node = diff --git a/test/unittests/compiler/js-operator-unittest.cc b/test/unittests/compiler/js-operator-unittest.cc index 1ea5a652d..a1f397373 100644 --- a/test/unittests/compiler/js-operator-unittest.cc +++ b/test/unittests/compiler/js-operator-unittest.cc @@ -84,9 +84,7 @@ const SharedOperator kSharedOperators[] = { SHARED(InstanceOf, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), SHARED(CreateFunctionContext, Operator::kNoProperties, 1, 0, 1, 1, 1, 1, 2), SHARED(CreateWithContext, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2), - SHARED(CreateBlockContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1, 2), SHARED(CreateModuleContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1, 2), - SHARED(CreateScriptContext, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2) #undef SHARED };