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<ScopeInfo> 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;
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<ScopeInfo> scope_info = scope->GetScopeInfo(isolate());
+ const Operator* op = javascript()->CreateBlockContext(scope_info);
+ Node* local_context = NewNode(op, GetFunctionClosureForContext());
return local_context;
}
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) {
}
+void JSGenericLowering::LowerJSCreate(Node* node) { UNIMPLEMENTED(); }
+
+
void JSGenericLowering::LowerJSCreateArguments(Node* node) {
const CreateArgumentsParameters& p = CreateArgumentsParametersOf(node->op());
switch (p.type()) {
}
+void JSGenericLowering::LowerJSCreateBlockContext(Node* node) {
+ Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node);
+ node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
+ ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext);
+}
+
+
+void JSGenericLowering::LowerJSCreateScriptContext(Node* node) {
+ Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node);
+ node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info));
+ ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext);
+}
+
+
void JSGenericLowering::LowerJSCallConstruct(Node* node) {
int arity = OpParameter<int>(node);
CallConstructStub stub(isolate(), SUPER_CONSTRUCTOR_CALL);
}
+void JSGenericLowering::LowerJSYield(Node* node) { UNIMPLEMENTED(); }
+
+
void JSGenericLowering::LowerJSStackCheck(Node* node) {
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
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) \
name); // parameter
}
+
+const Operator* JSOperatorBuilder::CreateBlockContext(
+ const Handle<ScopeInfo>& scpope_info) {
+ return new (zone()) Operator1<Handle<ScopeInfo>, Handle<ScopeInfo>::equal_to,
+ Handle<ScopeInfo>::hash>( // --
+ IrOpcode::kJSCreateBlockContext, Operator::kNoProperties, // opcode
+ "JSCreateBlockContext", // name
+ 1, 1, 1, 1, 1, 2, // counts
+ scpope_info); // parameter
+}
+
+
+const Operator* JSOperatorBuilder::CreateScriptContext(
+ const Handle<ScopeInfo>& scpope_info) {
+ return new (zone()) Operator1<Handle<ScopeInfo>, Handle<ScopeInfo>::equal_to,
+ Handle<ScopeInfo>::hash>( // --
+ IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode
+ "JSCreateScriptContext", // name
+ 1, 1, 1, 1, 1, 2, // counts
+ scpope_info); // parameter
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8
const Operator* StackCheck();
- // TODO(titzer): nail down the static parts of each of these context flavors.
const Operator* CreateFunctionContext();
const Operator* CreateCatchContext(const Handle<String>& name);
const Operator* CreateWithContext();
- const Operator* CreateBlockContext();
+ const Operator* CreateBlockContext(const Handle<ScopeInfo>& scpope_info);
const Operator* CreateModuleContext();
- const Operator* CreateScriptContext();
+ const Operator* CreateScriptContext(const Handle<ScopeInfo>& scpope_info);
private:
Zone* zone() const { return zone_; }
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<ScopeInfo>::cast(minput.Value())->ContextLength();
+ Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(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)),
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());
->parameter();
}
+template <>
+inline Handle<ScopeInfo> const& OpParameter(const Operator* op) {
+ return reinterpret_cast<
+ const Operator1<Handle<ScopeInfo>, Handle<ScopeInfo>::equal_to,
+ Handle<ScopeInfo>::hash>*>(op)->parameter();
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8
Node* const input1 = Parameter(1);
Node* const context = Parameter(2);
Node* const outer_context = Parameter(3);
- const Operator* op = javascript()->CreateBlockContext();
+ Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::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 =
Node* const input1 = Parameter(1);
Node* const context = Parameter(2);
Node* const outer_context = Parameter(3);
- const Operator* op = javascript()->CreateScriptContext();
+ Handle<ScopeInfo> scope_info = Handle<ScopeInfo>::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 =
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
};