diff --git a/src/code-stubs.cc b/src/code-stubs.cc index d53f6531bb..2d939a9303 100644 --- a/src/code-stubs.cc +++ b/src/code-stubs.cc @@ -4553,16 +4553,14 @@ void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const { Generate(assembler, assembler->Parameter(0), assembler->Parameter(1))); } -void FastNewFunctionContextStub::GenerateAssembly( - CodeStubAssembler* assembler) const { +// static +compiler::Node* FastNewFunctionContextStub::Generate( + CodeStubAssembler* assembler, compiler::Node* function, + compiler::Node* slots, compiler::Node* context) { typedef CodeStubAssembler::Label Label; typedef compiler::Node Node; typedef CodeStubAssembler::Variable Variable; - Node* function = assembler->Parameter(Descriptor::kFunction); - Node* slots = assembler->Parameter(FastNewFunctionContextDescriptor::kSlots); - Node* context = assembler->Parameter(Descriptor::kContext); - Node* min_context_slots = assembler->Int32Constant(Context::MIN_CONTEXT_SLOTS); Node* length = assembler->Int32Add(slots, min_context_slots); @@ -4573,9 +4571,10 @@ void FastNewFunctionContextStub::GenerateAssembly( // Create a new closure from the given function info in new space Node* function_context = assembler->Allocate(size); + Isolate* isolate = assembler->isolate(); assembler->StoreMapNoWriteBarrier( function_context, - assembler->HeapConstant(isolate()->factory()->function_context_map())); + assembler->HeapConstant(isolate->factory()->function_context_map())); assembler->StoreObjectFieldNoWriteBarrier(function_context, Context::kLengthOffset, assembler->SmiFromWord32(length)); @@ -4619,7 +4618,17 @@ void FastNewFunctionContextStub::GenerateAssembly( } assembler->Bind(&after_loop); - assembler->Return(function_context); + return function_context; +} + +void FastNewFunctionContextStub::GenerateAssembly( + CodeStubAssembler* assembler) const { + typedef compiler::Node Node; + Node* function = assembler->Parameter(Descriptor::kFunction); + Node* slots = assembler->Parameter(FastNewFunctionContextDescriptor::kSlots); + Node* context = assembler->Parameter(Descriptor::kContext); + + assembler->Return(Generate(assembler, function, slots, context)); } void CreateAllocationSiteStub::GenerateAheadOfTime(Isolate* isolate) { diff --git a/src/code-stubs.h b/src/code-stubs.h index 47422df558..21a73a238e 100644 --- a/src/code-stubs.h +++ b/src/code-stubs.h @@ -1082,6 +1082,11 @@ class FastNewFunctionContextStub final : public TurboFanCodeStub { explicit FastNewFunctionContextStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} + static compiler::Node* Generate(CodeStubAssembler* assembler, + compiler::Node* function, + compiler::Node* slots, + compiler::Node* context); + private: DEFINE_CALL_INTERFACE_DESCRIPTOR(FastNewFunctionContext); DEFINE_TURBOFAN_CODE_STUB(FastNewFunctionContext, TurboFanCodeStub); diff --git a/src/compiler/bytecode-graph-builder.cc b/src/compiler/bytecode-graph-builder.cc index ba88d6278d..621ca104d8 100644 --- a/src/compiler/bytecode-graph-builder.cc +++ b/src/compiler/bytecode-graph-builder.cc @@ -896,6 +896,13 @@ void BytecodeGraphBuilder::VisitCreateClosure() { environment()->BindAccumulator(closure); } +void BytecodeGraphBuilder::VisitCreateFunctionContext() { + uint32_t slots = bytecode_iterator().GetIndexOperand(0); + const Operator* op = javascript()->CreateFunctionContext(slots); + Node* context = NewNode(op, GetFunctionClosure()); + environment()->BindAccumulator(context); +} + void BytecodeGraphBuilder::BuildCreateArguments(CreateArgumentsType type) { FrameStateBeforeAndAfter states(this); const Operator* op = javascript()->CreateArguments(type); diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc index b205c32b0f..16ae572e32 100644 --- a/src/interpreter/bytecode-array-builder.cc +++ b/src/interpreter/bytecode-array-builder.cc @@ -337,6 +337,11 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CreateClosure( return *this; } +BytecodeArrayBuilder& BytecodeArrayBuilder::CreateFunctionContext(int slots) { + Output(Bytecode::kCreateFunctionContext, UnsignedOperand(slots)); + return *this; +} + BytecodeArrayBuilder& BytecodeArrayBuilder::CreateArguments( CreateArgumentsType type) { // TODO(rmcilroy): Consider passing the type as a bytecode operand rather diff --git a/src/interpreter/bytecode-array-builder.h b/src/interpreter/bytecode-array-builder.h index 39e9cbf644..21bbd1ba7c 100644 --- a/src/interpreter/bytecode-array-builder.h +++ b/src/interpreter/bytecode-array-builder.h @@ -135,6 +135,9 @@ class BytecodeArrayBuilder final : public ZoneObject { BytecodeArrayBuilder& CreateClosure(Handle shared_info, int flags); + // Create a new context with size |slots|. + BytecodeArrayBuilder& CreateFunctionContext(int slots); + // Create a new arguments object in the accumulator. BytecodeArrayBuilder& CreateArguments(CreateArgumentsType type); diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc index 58f6e7288d..38a280a4d7 100644 --- a/src/interpreter/bytecode-generator.cc +++ b/src/interpreter/bytecode-generator.cc @@ -3010,8 +3010,8 @@ void BytecodeGenerator::VisitNewLocalFunctionContext() { .StoreAccumulatorInRegister(scope_info) .CallRuntime(Runtime::kNewScriptContext, closure, 2); } else { - builder()->CallRuntime(Runtime::kNewFunctionContext, - Register::function_closure(), 1); + int slot_count = scope->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; + builder()->CreateFunctionContext(slot_count); } execution_result()->SetResultInAccumulator(); } diff --git a/src/interpreter/bytecodes.h b/src/interpreter/bytecodes.h index 57b1b1b2f3..3c5f9af256 100644 --- a/src/interpreter/bytecodes.h +++ b/src/interpreter/bytecodes.h @@ -227,6 +227,10 @@ namespace interpreter { V(CreateClosure, AccumulatorUse::kWrite, OperandType::kIdx, \ OperandType::kFlag8) \ \ + /* Context allocation */ \ + /* TODO(klaasb) rename Idx or add unsigned Imm OperandType? */ \ + V(CreateFunctionContext, AccumulatorUse::kWrite, OperandType::kIdx) \ + \ /* Arguments allocation */ \ V(CreateMappedArguments, AccumulatorUse::kWrite) \ V(CreateUnmappedArguments, AccumulatorUse::kWrite) \ diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc index 33e945271a..046513700e 100644 --- a/src/interpreter/interpreter.cc +++ b/src/interpreter/interpreter.cc @@ -1717,6 +1717,18 @@ void Interpreter::DoCreateClosure(InterpreterAssembler* assembler) { } } +// CreateFunctionContext +// +// Creates a new context with number of |slots| for the function closure. +void Interpreter::DoCreateFunctionContext(InterpreterAssembler* assembler) { + Node* closure = __ LoadRegister(Register::function_closure()); + Node* slots = __ BytecodeOperandIdx(0); + Node* context = __ GetContext(); + __ SetAccumulator( + FastNewFunctionContextStub::Generate(assembler, closure, slots, context)); + __ Dispatch(); +} + // CreateMappedArguments // // Creates a new mapped arguments object. diff --git a/test/cctest/interpreter/bytecode_expectations/BreakableBlocks.golden b/test/cctest/interpreter/bytecode_expectations/BreakableBlocks.golden index 6be568a0a9..ac37cd37c2 100644 --- a/test/cctest/interpreter/bytecode_expectations/BreakableBlocks.golden +++ b/test/cctest/interpreter/bytecode_expectations/BreakableBlocks.golden @@ -151,9 +151,9 @@ snippet: " " frame size: 6 parameter count: 1 -bytecode array length: 130 +bytecode array length: 127 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(2), B(LdaTheHole), B(StaContextSlot), R(context), U8(4), diff --git a/test/cctest/interpreter/bytecode_expectations/CallLookupSlot.golden b/test/cctest/interpreter/bytecode_expectations/CallLookupSlot.golden index 738b222476..9438503ae4 100644 --- a/test/cctest/interpreter/bytecode_expectations/CallLookupSlot.golden +++ b/test/cctest/interpreter/bytecode_expectations/CallLookupSlot.golden @@ -13,9 +13,9 @@ snippet: " " frame size: 10 parameter count: 1 -bytecode array length: 89 +bytecode array length: 86 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(3), B(PushContext), R(0), B(Ldar), R(this), B(StaContextSlot), R(context), U8(4), diff --git a/test/cctest/interpreter/bytecode_expectations/ClassDeclarations.golden b/test/cctest/interpreter/bytecode_expectations/ClassDeclarations.golden index 1f184253f4..c8dc9c5eeb 100644 --- a/test/cctest/interpreter/bytecode_expectations/ClassDeclarations.golden +++ b/test/cctest/interpreter/bytecode_expectations/ClassDeclarations.golden @@ -124,9 +124,9 @@ snippet: " " frame size: 11 parameter count: 1 -bytecode array length: 126 +bytecode array length: 123 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(2), B(PushContext), R(3), B(LdaTheHole), B(Star), R(2), @@ -196,9 +196,9 @@ snippet: " " frame size: 8 parameter count: 1 -bytecode array length: 75 +bytecode array length: 72 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(3), B(LdaTheHole), B(Star), R(2), diff --git a/test/cctest/interpreter/bytecode_expectations/CompoundExpressions.golden b/test/cctest/interpreter/bytecode_expectations/CompoundExpressions.golden index d48555df70..0a2d8c02c2 100644 --- a/test/cctest/interpreter/bytecode_expectations/CompoundExpressions.golden +++ b/test/cctest/interpreter/bytecode_expectations/CompoundExpressions.golden @@ -111,9 +111,9 @@ snippet: " " frame size: 2 parameter count: 1 -bytecode array length: 28 +bytecode array length: 25 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(0), /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), U8(1), diff --git a/test/cctest/interpreter/bytecode_expectations/ConstVariableContextSlot.golden b/test/cctest/interpreter/bytecode_expectations/ConstVariableContextSlot.golden index ce511b2369..826c302845 100644 --- a/test/cctest/interpreter/bytecode_expectations/ConstVariableContextSlot.golden +++ b/test/cctest/interpreter/bytecode_expectations/ConstVariableContextSlot.golden @@ -13,9 +13,9 @@ snippet: " " frame size: 2 parameter count: 1 -bytecode array length: 24 +bytecode array length: 21 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(1), B(LdaTheHole), B(StaContextSlot), R(context), U8(4), @@ -39,9 +39,9 @@ snippet: " " frame size: 3 parameter count: 1 -bytecode array length: 37 +bytecode array length: 34 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(1), B(LdaTheHole), B(StaContextSlot), R(context), U8(4), @@ -70,9 +70,9 @@ snippet: " " frame size: 4 parameter count: 1 -bytecode array length: 50 +bytecode array length: 47 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(1), B(LdaTheHole), B(StaContextSlot), R(context), U8(4), @@ -106,9 +106,9 @@ snippet: " " frame size: 4 parameter count: 1 -bytecode array length: 52 +bytecode array length: 49 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(1), B(LdaTheHole), B(StaContextSlot), R(context), U8(4), diff --git a/test/cctest/interpreter/bytecode_expectations/ContextParameters.golden b/test/cctest/interpreter/bytecode_expectations/ContextParameters.golden index c1affb47eb..f07e5ce4d7 100644 --- a/test/cctest/interpreter/bytecode_expectations/ContextParameters.golden +++ b/test/cctest/interpreter/bytecode_expectations/ContextParameters.golden @@ -15,9 +15,9 @@ snippet: " " frame size: 1 parameter count: 2 -bytecode array length: 17 +bytecode array length: 14 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(0), B(Ldar), R(arg0), B(StaContextSlot), R(context), U8(4), @@ -38,9 +38,9 @@ snippet: " " frame size: 2 parameter count: 2 -bytecode array length: 22 +bytecode array length: 19 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(1), B(Ldar), R(arg0), B(StaContextSlot), R(context), U8(4), @@ -63,9 +63,9 @@ snippet: " " frame size: 1 parameter count: 5 -bytecode array length: 22 +bytecode array length: 19 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(2), B(PushContext), R(0), B(Ldar), R(arg0), B(StaContextSlot), R(context), U8(5), @@ -88,9 +88,9 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 17 +bytecode array length: 14 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(0), /* 10 E> */ B(StackCheck), /* 26 S> */ B(Ldar), R(this), diff --git a/test/cctest/interpreter/bytecode_expectations/ContextVariables.golden b/test/cctest/interpreter/bytecode_expectations/ContextVariables.golden index a604194d6e..a973d7b71b 100644 --- a/test/cctest/interpreter/bytecode_expectations/ContextVariables.golden +++ b/test/cctest/interpreter/bytecode_expectations/ContextVariables.golden @@ -13,9 +13,9 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 12 +bytecode array length: 9 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(0), /* 30 E> */ B(StackCheck), /* 41 S> */ B(CreateClosure), U8(0), U8(2), @@ -33,9 +33,9 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 17 +bytecode array length: 14 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(0), /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), U8(1), @@ -55,9 +55,9 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 22 +bytecode array length: 19 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(2), B(PushContext), R(0), /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), U8(1), @@ -79,9 +79,9 @@ snippet: " " frame size: 3 parameter count: 1 -bytecode array length: 24 +bytecode array length: 21 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(0), /* 30 E> */ B(StackCheck), /* 41 S> */ B(LdrUndefined), R(2), @@ -105,9 +105,9 @@ snippet: " " frame size: 4 parameter count: 1 -bytecode array length: 46 +bytecode array length: 43 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(0), B(LdaTheHole), B(StaContextSlot), R(context), U8(4), @@ -392,9 +392,9 @@ snippet: " " frame size: 3 parameter count: 1 -bytecode array length: 1043 +bytecode array length: 1040 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(253), B(PushContext), R(0), B(Ldar), R(this), B(StaContextSlot), R(context), U8(4), diff --git a/test/cctest/interpreter/bytecode_expectations/CountOperators.golden b/test/cctest/interpreter/bytecode_expectations/CountOperators.golden index 4ab61200c0..73c2e62f9c 100644 --- a/test/cctest/interpreter/bytecode_expectations/CountOperators.golden +++ b/test/cctest/interpreter/bytecode_expectations/CountOperators.golden @@ -203,9 +203,9 @@ snippet: " " frame size: 2 parameter count: 1 -bytecode array length: 26 +bytecode array length: 23 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(1), /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), U8(1), @@ -229,9 +229,9 @@ snippet: " " frame size: 3 parameter count: 1 -bytecode array length: 30 +bytecode array length: 27 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(1), /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaSmi), U8(1), diff --git a/test/cctest/interpreter/bytecode_expectations/CreateArguments.golden b/test/cctest/interpreter/bytecode_expectations/CreateArguments.golden index edd6f05bcc..1668c81302 100644 --- a/test/cctest/interpreter/bytecode_expectations/CreateArguments.golden +++ b/test/cctest/interpreter/bytecode_expectations/CreateArguments.golden @@ -76,9 +76,9 @@ snippet: " " frame size: 2 parameter count: 2 -bytecode array length: 21 +bytecode array length: 18 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(1), B(Ldar), R(arg0), B(StaContextSlot), R(context), U8(4), @@ -101,9 +101,9 @@ snippet: " " frame size: 2 parameter count: 4 -bytecode array length: 28 +bytecode array length: 25 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(3), B(PushContext), R(1), B(Ldar), R(arg0), B(StaContextSlot), R(context), U8(6), diff --git a/test/cctest/interpreter/bytecode_expectations/Delete.golden b/test/cctest/interpreter/bytecode_expectations/Delete.golden index 4017a7d6ec..035f469ad1 100644 --- a/test/cctest/interpreter/bytecode_expectations/Delete.golden +++ b/test/cctest/interpreter/bytecode_expectations/Delete.golden @@ -103,9 +103,9 @@ snippet: " " frame size: 2 parameter count: 1 -bytecode array length: 29 +bytecode array length: 26 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(0), /* 30 E> */ B(StackCheck), /* 56 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), diff --git a/test/cctest/interpreter/bytecode_expectations/Eval.golden b/test/cctest/interpreter/bytecode_expectations/Eval.golden index 6dfdf95671..f8ee37a398 100644 --- a/test/cctest/interpreter/bytecode_expectations/Eval.golden +++ b/test/cctest/interpreter/bytecode_expectations/Eval.golden @@ -13,9 +13,9 @@ snippet: " " frame size: 10 parameter count: 1 -bytecode array length: 69 +bytecode array length: 66 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(3), B(PushContext), R(0), B(Ldar), R(this), B(StaContextSlot), R(context), U8(4), diff --git a/test/cctest/interpreter/bytecode_expectations/Generators.golden b/test/cctest/interpreter/bytecode_expectations/Generators.golden index 1d94cd6e06..3d3b9dd717 100644 --- a/test/cctest/interpreter/bytecode_expectations/Generators.golden +++ b/test/cctest/interpreter/bytecode_expectations/Generators.golden @@ -15,7 +15,7 @@ snippet: " " frame size: 11 parameter count: 1 -bytecode array length: 200 +bytecode array length: 197 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(20), @@ -23,11 +23,11 @@ bytecodes: [ B(Star), R(1), B(LdaZero), B(TestEqualStrict), R(1), - B(JumpIfTrue), U8(56), + B(JumpIfTrue), U8(53), B(LdaSmi), U8(75), B(Star), R(2), B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(2), B(PushContext), R(0), B(Ldar), R(this), B(StaContextSlot), R(context), U8(4), @@ -108,7 +108,7 @@ bytecodes: [ constant pool: [ ] handlers: [ - [38, 137, 143], + [35, 134, 140], ] --- @@ -118,7 +118,7 @@ snippet: " " frame size: 11 parameter count: 1 -bytecode array length: 293 +bytecode array length: 290 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -126,14 +126,14 @@ bytecodes: [ B(Star), R(1), B(LdaZero), B(TestEqualStrict), R(1), - B(JumpIfTrue), U8(62), + B(JumpIfTrue), U8(59), B(LdaSmi), U8(1), B(TestEqualStrict), R(1), B(JumpIfTrueConstant), U8(0), B(LdaSmi), U8(75), B(Star), R(2), B(CallRuntime), U16(Runtime::kAbort), R(2), U8(1), - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(2), B(PushContext), R(0), B(Ldar), R(this), B(StaContextSlot), R(context), U8(4), @@ -254,7 +254,7 @@ constant pool: [ kInstanceTypeDontCare, ] handlers: [ - [44, 221, 227], + [41, 218, 224], ] --- @@ -264,7 +264,7 @@ snippet: " " frame size: 18 parameter count: 1 -bytecode array length: 772 +bytecode array length: 769 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -272,14 +272,14 @@ bytecodes: [ B(Star), R(4), B(LdaZero), B(TestEqualStrict), R(4), - B(JumpIfTrue), U8(62), + B(JumpIfTrue), U8(59), B(LdaSmi), U8(1), B(TestEqualStrict), R(4), B(JumpIfTrueConstant), U8(3), B(LdaSmi), U8(75), B(Star), R(5), B(CallRuntime), U16(Runtime::kAbort), R(5), U8(1), - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(9), B(PushContext), R(0), B(Ldar), R(this), B(StaContextSlot), R(context), U8(4), @@ -598,9 +598,9 @@ constant pool: [ kInstanceTypeDontCare, ] handlers: [ - [44, 691, 697], - [150, 445, 451], - [153, 399, 401], - [548, 560, 562], + [41, 688, 694], + [147, 442, 448], + [150, 396, 398], + [545, 557, 559], ] diff --git a/test/cctest/interpreter/bytecode_expectations/LetVariableContextSlot.golden b/test/cctest/interpreter/bytecode_expectations/LetVariableContextSlot.golden index 68585dc91a..0b25fbf329 100644 --- a/test/cctest/interpreter/bytecode_expectations/LetVariableContextSlot.golden +++ b/test/cctest/interpreter/bytecode_expectations/LetVariableContextSlot.golden @@ -13,9 +13,9 @@ snippet: " " frame size: 2 parameter count: 1 -bytecode array length: 24 +bytecode array length: 21 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(1), B(LdaTheHole), B(StaContextSlot), R(context), U8(4), @@ -39,9 +39,9 @@ snippet: " " frame size: 3 parameter count: 1 -bytecode array length: 37 +bytecode array length: 34 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(1), B(LdaTheHole), B(StaContextSlot), R(context), U8(4), @@ -70,9 +70,9 @@ snippet: " " frame size: 4 parameter count: 1 -bytecode array length: 45 +bytecode array length: 42 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(1), B(LdaTheHole), B(StaContextSlot), R(context), U8(4), @@ -105,9 +105,9 @@ snippet: " " frame size: 4 parameter count: 1 -bytecode array length: 47 +bytecode array length: 44 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(1), B(PushContext), R(1), B(LdaTheHole), B(StaContextSlot), R(context), U8(4), diff --git a/test/cctest/interpreter/bytecode_expectations/LookupSlot.golden b/test/cctest/interpreter/bytecode_expectations/LookupSlot.golden index 0ce9f01f1d..ed13d254ac 100644 --- a/test/cctest/interpreter/bytecode_expectations/LookupSlot.golden +++ b/test/cctest/interpreter/bytecode_expectations/LookupSlot.golden @@ -13,9 +13,9 @@ snippet: " " frame size: 10 parameter count: 1 -bytecode array length: 71 +bytecode array length: 68 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(3), B(PushContext), R(0), B(Ldar), R(this), B(StaContextSlot), R(context), U8(4), @@ -58,9 +58,9 @@ snippet: " " frame size: 10 parameter count: 1 -bytecode array length: 72 +bytecode array length: 69 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(3), B(PushContext), R(0), B(Ldar), R(this), B(StaContextSlot), R(context), U8(4), @@ -104,9 +104,9 @@ snippet: " " frame size: 10 parameter count: 1 -bytecode array length: 73 +bytecode array length: 70 bytecodes: [ - B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), U8(1), + B(CreateFunctionContext), U8(3), B(PushContext), R(0), B(Ldar), R(this), B(StaContextSlot), R(context), U8(4), diff --git a/test/unittests/interpreter/bytecode-array-builder-unittest.cc b/test/unittests/interpreter/bytecode-array-builder-unittest.cc index f688da793e..cfdb1ce3d7 100644 --- a/test/unittests/interpreter/bytecode-array-builder-unittest.cc +++ b/test/unittests/interpreter/bytecode-array-builder-unittest.cc @@ -104,6 +104,9 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { false); builder.CreateClosure(shared_info, NOT_TENURED); + // Emit create context operation. + builder.CreateFunctionContext(1); + // Emit literal creation operations. builder.CreateRegExpLiteral(factory->NewStringFromStaticChars("a"), 0, 0) .CreateArrayLiteral(factory->NewFixedArray(1), 0, 0)