diff --git a/src/compiler/bytecode-graph-builder.cc b/src/compiler/bytecode-graph-builder.cc index 4c14267479..5620dcf3e0 100644 --- a/src/compiler/bytecode-graph-builder.cc +++ b/src/compiler/bytecode-graph-builder.cc @@ -741,27 +741,33 @@ void BytecodeGraphBuilder::VisitMov() { environment()->BindRegister(bytecode_iterator().GetRegisterOperand(1), value); } -Node* BytecodeGraphBuilder::BuildLoadGlobal(uint32_t feedback_slot_index, +Node* BytecodeGraphBuilder::BuildLoadGlobal(Handle name, + uint32_t feedback_slot_index, TypeofMode typeof_mode) { VectorSlotPair feedback = CreateVectorSlotPair(feedback_slot_index); DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC, feedback_vector()->GetKind(feedback.slot())); - Handle name(feedback_vector()->GetName(feedback.slot())); const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode); return NewNode(op, GetFunctionClosure()); } void BytecodeGraphBuilder::VisitLdaGlobal() { PrepareEagerCheckpoint(); - Node* node = BuildLoadGlobal(bytecode_iterator().GetIndexOperand(0), - TypeofMode::NOT_INSIDE_TYPEOF); + Handle name = + Handle::cast(bytecode_iterator().GetConstantForIndexOperand(0)); + uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1); + Node* node = + BuildLoadGlobal(name, feedback_slot_index, TypeofMode::NOT_INSIDE_TYPEOF); environment()->BindAccumulator(node, Environment::kAttachFrameState); } void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeof() { PrepareEagerCheckpoint(); - Node* node = BuildLoadGlobal(bytecode_iterator().GetIndexOperand(0), - TypeofMode::INSIDE_TYPEOF); + Handle name = + Handle::cast(bytecode_iterator().GetConstantForIndexOperand(0)); + uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1); + Node* node = + BuildLoadGlobal(name, feedback_slot_index, TypeofMode::INSIDE_TYPEOF); environment()->BindAccumulator(node, Environment::kAttachFrameState); } @@ -950,8 +956,10 @@ void BytecodeGraphBuilder::BuildLdaLookupGlobalSlot(TypeofMode typeof_mode) { // Fast path, do a global load. { PrepareEagerCheckpoint(); - Node* node = - BuildLoadGlobal(bytecode_iterator().GetIndexOperand(1), typeof_mode); + Handle name = + Handle::cast(bytecode_iterator().GetConstantForIndexOperand(0)); + uint32_t feedback_slot_index = bytecode_iterator().GetIndexOperand(1); + Node* node = BuildLoadGlobal(name, feedback_slot_index, typeof_mode); environment()->BindAccumulator(node, Environment::kAttachFrameState); } diff --git a/src/compiler/bytecode-graph-builder.h b/src/compiler/bytecode-graph-builder.h index 6994226dc3..a78699bad4 100644 --- a/src/compiler/bytecode-graph-builder.h +++ b/src/compiler/bytecode-graph-builder.h @@ -136,7 +136,8 @@ class BytecodeGraphBuilder { void ClearNonLiveSlotsInFrameStates(); void BuildCreateArguments(CreateArgumentsType type); - Node* BuildLoadGlobal(uint32_t feedback_slot_index, TypeofMode typeof_mode); + Node* BuildLoadGlobal(Handle name, uint32_t feedback_slot_index, + TypeofMode typeof_mode); void BuildStoreGlobal(LanguageMode language_mode); void BuildNamedStore(LanguageMode language_mode); void BuildKeyedStore(LanguageMode language_mode); diff --git a/src/compiler/js-generic-lowering.cc b/src/compiler/js-generic-lowering.cc index c2ac2bb842..389a10a9d9 100644 --- a/src/compiler/js-generic-lowering.cc +++ b/src/compiler/js-generic-lowering.cc @@ -219,9 +219,10 @@ void JSGenericLowering::LowerJSLoadGlobal(Node* node) { jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset - kHeapObjectTag), effect, control); - node->InsertInput(zone(), 0, jsgraph()->SmiConstant(p.feedback().index())); - node->ReplaceInput(1, vector); - node->ReplaceInput(4, effect); + node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name())); + node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index())); + node->ReplaceInput(2, vector); + node->ReplaceInput(5, effect); ReplaceWithStubCall(node, callable, flags); } diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc index b1d87d62dc..9374e516b0 100644 --- a/src/crankshaft/hydrogen.cc +++ b/src/crankshaft/hydrogen.cc @@ -5334,7 +5334,8 @@ void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) { Callable callable = CodeFactory::LoadGlobalICInOptimizedCode( isolate(), ast_context()->typeof_mode()); HValue* stub = Add(callable.code()); - HValue* values[] = {slot_value, vector_value}; + HValue* name = Add(variable->name()); + HValue* values[] = {name, slot_value, vector_value}; HCallWithDescriptor* instr = New( Code::LOAD_GLOBAL_IC, stub, 0, callable.descriptor(), ArrayVector(values)); diff --git a/src/full-codegen/full-codegen.cc b/src/full-codegen/full-codegen.cc index ee5e8881ba..dbd74ab8a0 100644 --- a/src/full-codegen/full-codegen.cc +++ b/src/full-codegen/full-codegen.cc @@ -499,11 +499,11 @@ void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, TypeofMode typeof_mode) { -#ifdef DEBUG Variable* var = proxy->var(); DCHECK(var->IsUnallocated() || (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); -#endif + __ Move(LoadDescriptor::NameRegister(), var->name()); + EmitLoadSlot(LoadGlobalDescriptor::SlotRegister(), proxy->VariableFeedbackSlot()); Handle code = CodeFactory::LoadGlobalIC(isolate(), typeof_mode).code(); diff --git a/src/ic/accessor-assembler.cc b/src/ic/accessor-assembler.cc index e2e34e9ee3..2f1a97ec17 100644 --- a/src/ic/accessor-assembler.cc +++ b/src/ic/accessor-assembler.cc @@ -1170,8 +1170,7 @@ void AccessorAssemblerImpl::LoadGlobalIC(const LoadICParameters* p) { Node* native_context = LoadNativeContext(p->context); Node* receiver = LoadContextElement(native_context, Context::EXTENSION_INDEX); - Node* fake_name = IntPtrConstant(0); - TailCallStub(descriptor, handler, p->context, receiver, fake_name, p->slot, + TailCallStub(descriptor, handler, p->context, receiver, p->name, p->slot, p->vector); } Bind(&miss); @@ -1569,22 +1568,24 @@ void AccessorAssemblerImpl::GenerateLoadICProtoArray() { void AccessorAssemblerImpl::GenerateLoadGlobalIC() { typedef LoadGlobalICStub::Descriptor Descriptor; + Node* name = Parameter(Descriptor::kName); Node* slot = Parameter(Descriptor::kSlot); Node* vector = Parameter(Descriptor::kVector); Node* context = Parameter(Descriptor::kContext); - LoadICParameters p(context, nullptr, nullptr, slot, vector); + LoadICParameters p(context, nullptr, name, slot, vector); LoadGlobalIC(&p); } void AccessorAssemblerImpl::GenerateLoadGlobalICTrampoline() { typedef LoadGlobalICTrampolineStub::Descriptor Descriptor; + Node* name = Parameter(Descriptor::kName); Node* slot = Parameter(Descriptor::kSlot); Node* context = Parameter(Descriptor::kContext); Node* vector = LoadTypeFeedbackVectorForStub(); - LoadICParameters p(context, nullptr, nullptr, slot, vector); + LoadICParameters p(context, nullptr, name, slot, vector); LoadGlobalIC(&p); } diff --git a/src/interface-descriptors.cc b/src/interface-descriptors.cc index d14b1a1011..0a25717949 100644 --- a/src/interface-descriptors.cc +++ b/src/interface-descriptors.cc @@ -92,22 +92,24 @@ void LoadDescriptor::InitializePlatformSpecific( void LoadGlobalDescriptor::InitializePlatformIndependent( CallInterfaceDescriptorData* data) { - // kSlot - MachineType machine_types[] = {MachineType::TaggedSigned()}; + // kName, kSlot + MachineType machine_types[] = {MachineType::AnyTagged(), + MachineType::TaggedSigned()}; data->InitializePlatformIndependent(arraysize(machine_types), 0, machine_types); } void LoadGlobalDescriptor::InitializePlatformSpecific( CallInterfaceDescriptorData* data) { - Register registers[] = {LoadWithVectorDescriptor::SlotRegister()}; + Register registers[] = {NameRegister(), SlotRegister()}; data->InitializePlatformSpecific(arraysize(registers), registers); } void LoadGlobalWithVectorDescriptor::InitializePlatformIndependent( CallInterfaceDescriptorData* data) { - // kSlot, kVector - MachineType machine_types[] = {MachineType::TaggedSigned(), + // kName, kSlot, kVector + MachineType machine_types[] = {MachineType::AnyTagged(), + MachineType::TaggedSigned(), MachineType::AnyTagged()}; data->InitializePlatformIndependent(arraysize(machine_types), 0, machine_types); @@ -115,8 +117,7 @@ void LoadGlobalWithVectorDescriptor::InitializePlatformIndependent( void LoadGlobalWithVectorDescriptor::InitializePlatformSpecific( CallInterfaceDescriptorData* data) { - Register registers[] = {LoadWithVectorDescriptor::SlotRegister(), - LoadWithVectorDescriptor::VectorRegister()}; + Register registers[] = {NameRegister(), SlotRegister(), VectorRegister()}; data->InitializePlatformSpecific(arraysize(registers), registers); } diff --git a/src/interface-descriptors.h b/src/interface-descriptors.h index 821a99b55d..08a0bb3214 100644 --- a/src/interface-descriptors.h +++ b/src/interface-descriptors.h @@ -306,10 +306,14 @@ class LoadDescriptor : public CallInterfaceDescriptor { class LoadGlobalDescriptor : public CallInterfaceDescriptor { public: - DEFINE_PARAMETERS(kSlot) + DEFINE_PARAMETERS(kName, kSlot) DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadGlobalDescriptor, CallInterfaceDescriptor) + static const Register NameRegister() { + return LoadDescriptor::NameRegister(); + } + static const Register SlotRegister() { return LoadDescriptor::SlotRegister(); } @@ -400,7 +404,7 @@ class LoadICProtoArrayDescriptor : public LoadWithVectorDescriptor { class LoadGlobalWithVectorDescriptor : public LoadGlobalDescriptor { public: - DEFINE_PARAMETERS(kSlot, kVector) + DEFINE_PARAMETERS(kName, kSlot, kVector) DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadGlobalWithVectorDescriptor, LoadGlobalDescriptor) diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc index 900aefcaa4..176eddaa4c 100644 --- a/src/interpreter/bytecode-array-builder.cc +++ b/src/interpreter/bytecode-array-builder.cc @@ -433,13 +433,14 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::MoveRegister(Register from, return *this; } -BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal(int feedback_slot, - TypeofMode typeof_mode) { +BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal( + const Handle name, int feedback_slot, TypeofMode typeof_mode) { + size_t name_index = GetConstantPoolEntry(name); if (typeof_mode == INSIDE_TYPEOF) { - OutputLdaGlobalInsideTypeof(feedback_slot); + OutputLdaGlobalInsideTypeof(name_index, feedback_slot); } else { DCHECK_EQ(typeof_mode, NOT_INSIDE_TYPEOF); - OutputLdaGlobal(feedback_slot); + OutputLdaGlobal(name_index, feedback_slot); } return *this; } diff --git a/src/interpreter/bytecode-array-builder.h b/src/interpreter/bytecode-array-builder.h index 0a8cbe5181..0f7d0312be 100644 --- a/src/interpreter/bytecode-array-builder.h +++ b/src/interpreter/bytecode-array-builder.h @@ -84,7 +84,8 @@ class V8_EXPORT_PRIVATE BytecodeArrayBuilder final BytecodeArrayBuilder& LoadFalse(); // Global loads to the accumulator and stores from the accumulator. - BytecodeArrayBuilder& LoadGlobal(int feedback_slot, TypeofMode typeof_mode); + BytecodeArrayBuilder& LoadGlobal(const Handle name, int feedback_slot, + TypeofMode typeof_mode); BytecodeArrayBuilder& StoreGlobal(const Handle name, int feedback_slot, LanguageMode language_mode); diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc index fc7b1155d9..547258a553 100644 --- a/src/interpreter/bytecode-generator.cc +++ b/src/interpreter/bytecode-generator.cc @@ -1819,7 +1819,8 @@ void BytecodeGenerator::BuildVariableLoad(Variable* variable, break; } case VariableLocation::UNALLOCATED: { - builder()->LoadGlobal(feedback_index(slot), typeof_mode); + builder()->LoadGlobal(variable->name(), feedback_index(slot), + typeof_mode); break; } case VariableLocation::CONTEXT: { diff --git a/src/interpreter/bytecodes.h b/src/interpreter/bytecodes.h index 91304f5fb3..15dc3711f2 100644 --- a/src/interpreter/bytecodes.h +++ b/src/interpreter/bytecodes.h @@ -38,8 +38,9 @@ namespace interpreter { V(LdaConstant, AccumulatorUse::kWrite, OperandType::kIdx) \ \ /* Globals */ \ - V(LdaGlobal, AccumulatorUse::kWrite, OperandType::kIdx) \ - V(LdaGlobalInsideTypeof, AccumulatorUse::kWrite, OperandType::kIdx) \ + V(LdaGlobal, AccumulatorUse::kWrite, OperandType::kIdx, OperandType::kIdx) \ + V(LdaGlobalInsideTypeof, AccumulatorUse::kWrite, OperandType::kIdx, \ + OperandType::kIdx) \ V(StaGlobalSloppy, AccumulatorUse::kRead, OperandType::kIdx, \ OperandType::kIdx) \ V(StaGlobalStrict, AccumulatorUse::kRead, OperandType::kIdx, \ diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc index 9128ee9840..02c4f64797 100644 --- a/src/interpreter/interpreter.cc +++ b/src/interpreter/interpreter.cc @@ -425,21 +425,23 @@ void Interpreter::DoMov(InterpreterAssembler* assembler) { __ Dispatch(); } -Node* Interpreter::BuildLoadGlobal(Callable ic, Node* context, +Node* Interpreter::BuildLoadGlobal(Callable ic, Node* context, Node* name_index, Node* feedback_slot, InterpreterAssembler* assembler) { typedef LoadGlobalWithVectorDescriptor Descriptor; // Load the global via the LoadGlobalIC. Node* code_target = __ HeapConstant(ic.code()); + Node* name = __ LoadConstantPoolEntry(name_index); Node* smi_slot = __ SmiTag(feedback_slot); Node* type_feedback_vector = __ LoadTypeFeedbackVector(); return __ CallStub(ic.descriptor(), code_target, context, + Arg(Descriptor::kName, name), Arg(Descriptor::kSlot, smi_slot), Arg(Descriptor::kVector, type_feedback_vector)); } -// LdaGlobal +// LdaGlobal // // Load the global with name in constant pool entry into the // accumulator using FeedBackVector slot outside of a typeof. @@ -449,13 +451,14 @@ void Interpreter::DoLdaGlobal(InterpreterAssembler* assembler) { Node* context = __ GetContext(); - Node* raw_slot = __ BytecodeOperandIdx(0); - Node* result = BuildLoadGlobal(ic, context, raw_slot, assembler); + Node* name_index = __ BytecodeOperandIdx(0); + Node* raw_slot = __ BytecodeOperandIdx(1); + Node* result = BuildLoadGlobal(ic, context, name_index, raw_slot, assembler); __ SetAccumulator(result); __ Dispatch(); } -// LdaGlobalInsideTypeof +// LdaGlobalInsideTypeof // // Load the global with name in constant pool entry into the // accumulator using FeedBackVector slot inside of a typeof. @@ -465,8 +468,9 @@ void Interpreter::DoLdaGlobalInsideTypeof(InterpreterAssembler* assembler) { Node* context = __ GetContext(); - Node* raw_slot = __ BytecodeOperandIdx(0); - Node* result = BuildLoadGlobal(ic, context, raw_slot, assembler); + Node* name_index = __ BytecodeOperandIdx(0); + Node* raw_slot = __ BytecodeOperandIdx(1); + Node* result = BuildLoadGlobal(ic, context, name_index, raw_slot, assembler); __ SetAccumulator(result); __ Dispatch(); } @@ -656,7 +660,8 @@ void Interpreter::DoLdaLookupGlobalSlot(Runtime::FunctionId function_id, isolate_, function_id == Runtime::kLoadLookupSlotInsideTypeof ? INSIDE_TYPEOF : NOT_INSIDE_TYPEOF); - Node* result = BuildLoadGlobal(ic, context, feedback_slot, assembler); + Node* result = + BuildLoadGlobal(ic, context, name_index, feedback_slot, assembler); __ SetAccumulator(result); __ Dispatch(); } diff --git a/src/interpreter/interpreter.h b/src/interpreter/interpreter.h index b10ae2e451..1b55864d7c 100644 --- a/src/interpreter/interpreter.h +++ b/src/interpreter/interpreter.h @@ -141,6 +141,7 @@ class Interpreter { // Generates code to load a global. compiler::Node* BuildLoadGlobal(Callable ic, compiler::Node* context, + compiler::Node* name_index, compiler::Node* feedback_slot, InterpreterAssembler* assembler); diff --git a/test/cctest/interpreter/bytecode_expectations/CallGlobal.golden b/test/cctest/interpreter/bytecode_expectations/CallGlobal.golden index 40be0533c1..beb9a30222 100644 --- a/test/cctest/interpreter/bytecode_expectations/CallGlobal.golden +++ b/test/cctest/interpreter/bytecode_expectations/CallGlobal.golden @@ -14,17 +14,18 @@ snippet: " " frame size: 2 parameter count: 1 -bytecode array length: 14 +bytecode array length: 15 bytecodes: [ /* 27 E> */ B(StackCheck), /* 32 S> */ B(LdaUndefined), B(Star), R(1), - B(LdaGlobal), U8(4), + B(LdaGlobal), U8(0), U8(4), B(Star), R(0), /* 39 E> */ B(Call), R(0), R(1), U8(1), U8(2), /* 44 S> */ B(Return), ] constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["t"], ] handlers: [ ] @@ -37,12 +38,12 @@ snippet: " " frame size: 5 parameter count: 1 -bytecode array length: 26 +bytecode array length: 27 bytecodes: [ /* 34 E> */ B(StackCheck), /* 39 S> */ B(LdaUndefined), B(Star), R(1), - B(LdaGlobal), U8(4), + B(LdaGlobal), U8(0), U8(4), B(Star), R(0), B(LdaSmi), U8(1), B(Star), R(2), @@ -54,6 +55,7 @@ bytecodes: [ /* 58 S> */ B(Return), ] constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["t"], ] handlers: [ ] diff --git a/test/cctest/interpreter/bytecode_expectations/CallNew.golden b/test/cctest/interpreter/bytecode_expectations/CallNew.golden index eb5b0630f4..f60f73e065 100644 --- a/test/cctest/interpreter/bytecode_expectations/CallNew.golden +++ b/test/cctest/interpreter/bytecode_expectations/CallNew.golden @@ -14,15 +14,16 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 11 +bytecode array length: 12 bytecodes: [ /* 45 E> */ B(StackCheck), - /* 50 S> */ B(LdaGlobal), U8(4), + /* 50 S> */ B(LdaGlobal), U8(0), U8(4), B(Star), R(0), /* 57 E> */ B(New), R(0), R(0), U8(0), U8(2), /* 68 S> */ B(Return), ] constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["bar"], ] handlers: [ ] @@ -35,10 +36,10 @@ snippet: " " frame size: 2 parameter count: 1 -bytecode array length: 17 +bytecode array length: 18 bytecodes: [ /* 58 E> */ B(StackCheck), - /* 63 S> */ B(LdaGlobal), U8(4), + /* 63 S> */ B(LdaGlobal), U8(0), U8(4), B(Star), R(0), B(LdaSmi), U8(3), B(Star), R(1), @@ -47,6 +48,7 @@ bytecodes: [ /* 82 S> */ B(Return), ] constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["bar"], ] handlers: [ ] @@ -64,10 +66,10 @@ snippet: " " frame size: 4 parameter count: 1 -bytecode array length: 25 +bytecode array length: 26 bytecodes: [ /* 100 E> */ B(StackCheck), - /* 105 S> */ B(LdaGlobal), U8(4), + /* 105 S> */ B(LdaGlobal), U8(0), U8(4), B(Star), R(0), B(LdaSmi), U8(3), B(Star), R(1), @@ -80,6 +82,7 @@ bytecodes: [ /* 130 S> */ B(Return), ] constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["bar"], ] handlers: [ ] diff --git a/test/cctest/interpreter/bytecode_expectations/ContextVariables.golden b/test/cctest/interpreter/bytecode_expectations/ContextVariables.golden index f4b7943740..7b8a34d1c1 100644 --- a/test/cctest/interpreter/bytecode_expectations/ContextVariables.golden +++ b/test/cctest/interpreter/bytecode_expectations/ContextVariables.golden @@ -390,7 +390,7 @@ snippet: " " frame size: 3 parameter count: 1 -bytecode array length: 791 +bytecode array length: 792 bytecodes: [ B(CreateFunctionContext), U8(254), B(PushContext), R(0), @@ -903,7 +903,7 @@ bytecodes: [ /* 3435 E> */ B(StaCurrentContextSlot), U8(255), /* 3438 S> */ B(LdaUndefined), B(Star), R(2), - B(LdaGlobal), U8(4), + B(LdaGlobal), U8(0), U8(4), B(Star), R(1), /* 3438 E> */ B(Call), R(1), R(2), U8(1), U8(2), /* 3454 S> */ B(LdaSmi), U8(100), @@ -912,6 +912,7 @@ bytecodes: [ /* 3468 S> */ B(Return), ] constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["eval"], ] handlers: [ ] diff --git a/test/cctest/interpreter/bytecode_expectations/DeclareGlobals.golden b/test/cctest/interpreter/bytecode_expectations/DeclareGlobals.golden index 00fa0180e6..948e04287e 100644 --- a/test/cctest/interpreter/bytecode_expectations/DeclareGlobals.golden +++ b/test/cctest/interpreter/bytecode_expectations/DeclareGlobals.golden @@ -104,7 +104,7 @@ snippet: " " frame size: 4 parameter count: 1 -bytecode array length: 31 +bytecode array length: 32 bytecodes: [ B(LdaConstant), U8(0), B(Star), R(1), @@ -115,7 +115,7 @@ bytecodes: [ /* 0 E> */ B(StackCheck), /* 16 S> */ B(LdaUndefined), B(Star), R(2), - B(LdaGlobal), U8(2), + B(LdaGlobal), U8(1), U8(2), B(Star), R(1), /* 16 E> */ B(Call), R(1), R(2), U8(1), U8(4), B(Star), R(0), @@ -123,6 +123,7 @@ bytecodes: [ ] constant pool: [ FIXED_ARRAY_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["f"], ] handlers: [ ] diff --git a/test/cctest/interpreter/bytecode_expectations/GlobalCompoundExpressions.golden b/test/cctest/interpreter/bytecode_expectations/GlobalCompoundExpressions.golden index f8bece5c39..57403bc402 100644 --- a/test/cctest/interpreter/bytecode_expectations/GlobalCompoundExpressions.golden +++ b/test/cctest/interpreter/bytecode_expectations/GlobalCompoundExpressions.golden @@ -14,10 +14,10 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 13 +bytecode array length: 14 bytecodes: [ /* 26 E> */ B(StackCheck), - /* 31 S> */ B(LdaGlobal), U8(2), + /* 31 S> */ B(LdaGlobal), U8(0), U8(2), B(Star), R(0), B(BitwiseAndSmi), U8(1), R(0), U8(4), /* 45 E> */ B(StaGlobalSloppy), U8(0), U8(5), @@ -37,10 +37,10 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 13 +bytecode array length: 14 bytecodes: [ /* 27 E> */ B(StackCheck), - /* 32 S> */ B(LdaGlobal), U8(2), + /* 32 S> */ B(LdaGlobal), U8(0), U8(2), B(Star), R(0), B(AddSmi), U8(1), R(0), U8(4), /* 51 E> */ B(StaGlobalSloppy), U8(0), U8(5), diff --git a/test/cctest/interpreter/bytecode_expectations/GlobalCountOperators.golden b/test/cctest/interpreter/bytecode_expectations/GlobalCountOperators.golden index 1e0d530af5..a6090aadf0 100644 --- a/test/cctest/interpreter/bytecode_expectations/GlobalCountOperators.golden +++ b/test/cctest/interpreter/bytecode_expectations/GlobalCountOperators.golden @@ -14,10 +14,10 @@ snippet: " " frame size: 0 parameter count: 1 -bytecode array length: 9 +bytecode array length: 10 bytecodes: [ /* 26 E> */ B(StackCheck), - /* 31 S> */ B(LdaGlobal), U8(2), + /* 31 S> */ B(LdaGlobal), U8(0), U8(2), B(Inc), U8(6), /* 40 E> */ B(StaGlobalSloppy), U8(0), U8(4), /* 48 S> */ B(Return), @@ -36,10 +36,10 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 15 +bytecode array length: 16 bytecodes: [ /* 26 E> */ B(StackCheck), - /* 31 S> */ B(LdaGlobal), U8(2), + /* 31 S> */ B(LdaGlobal), U8(0), U8(2), B(ToNumber), R(0), B(Ldar), R(0), B(Dec), U8(6), @@ -61,10 +61,10 @@ snippet: " " frame size: 0 parameter count: 1 -bytecode array length: 9 +bytecode array length: 10 bytecodes: [ /* 27 E> */ B(StackCheck), - /* 46 S> */ B(LdaGlobal), U8(2), + /* 46 S> */ B(LdaGlobal), U8(0), U8(2), B(Dec), U8(6), /* 55 E> */ B(StaGlobalStrict), U8(0), U8(4), /* 68 S> */ B(Return), @@ -83,10 +83,10 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 15 +bytecode array length: 16 bytecodes: [ /* 27 E> */ B(StackCheck), - /* 32 S> */ B(LdaGlobal), U8(2), + /* 32 S> */ B(LdaGlobal), U8(0), U8(2), B(ToNumber), R(0), B(Ldar), R(0), B(Inc), U8(6), diff --git a/test/cctest/interpreter/bytecode_expectations/GlobalDelete.golden b/test/cctest/interpreter/bytecode_expectations/GlobalDelete.golden index e9540bb446..b717c71bea 100644 --- a/test/cctest/interpreter/bytecode_expectations/GlobalDelete.golden +++ b/test/cctest/interpreter/bytecode_expectations/GlobalDelete.golden @@ -16,16 +16,17 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 10 +bytecode array length: 11 bytecodes: [ /* 32 E> */ B(StackCheck), - /* 39 S> */ B(LdaGlobal), U8(2), + /* 39 S> */ B(LdaGlobal), U8(0), U8(2), B(Star), R(0), - B(LdaConstant), U8(0), + B(LdaConstant), U8(1), B(DeletePropertySloppy), R(0), /* 58 S> */ B(Return), ] constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], ONE_BYTE_INTERNALIZED_STRING_TYPE ["x"], ] handlers: [ @@ -42,16 +43,17 @@ snippet: " " frame size: 1 parameter count: 1 -bytecode array length: 10 +bytecode array length: 11 bytecodes: [ /* 28 E> */ B(StackCheck), - /* 51 S> */ B(LdaGlobal), U8(2), + /* 51 S> */ B(LdaGlobal), U8(0), U8(2), B(Star), R(0), B(LdaSmi), U8(1), B(DeletePropertyStrict), R(0), /* 71 S> */ B(Return), ] constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], ] handlers: [ ] diff --git a/test/cctest/interpreter/bytecode_expectations/LoadGlobal.golden b/test/cctest/interpreter/bytecode_expectations/LoadGlobal.golden index 9c1c1b3701..addfa78a98 100644 --- a/test/cctest/interpreter/bytecode_expectations/LoadGlobal.golden +++ b/test/cctest/interpreter/bytecode_expectations/LoadGlobal.golden @@ -14,13 +14,14 @@ snippet: " " frame size: 0 parameter count: 1 -bytecode array length: 4 +bytecode array length: 5 bytecodes: [ /* 21 E> */ B(StackCheck), - /* 26 S> */ B(LdaGlobal), U8(2), + /* 26 S> */ B(LdaGlobal), U8(0), U8(2), /* 36 S> */ B(Return), ] constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], ] handlers: [ ] @@ -33,13 +34,14 @@ snippet: " " frame size: 0 parameter count: 1 -bytecode array length: 4 +bytecode array length: 5 bytecodes: [ /* 27 E> */ B(StackCheck), - /* 32 S> */ B(LdaGlobal), U8(2), + /* 32 S> */ B(LdaGlobal), U8(0), U8(2), /* 42 S> */ B(Return), ] constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["t"], ] handlers: [ ] @@ -52,13 +54,14 @@ snippet: " " frame size: 0 parameter count: 1 -bytecode array length: 4 +bytecode array length: 5 bytecodes: [ /* 17 E> */ B(StackCheck), - /* 22 S> */ B(LdaGlobal), U8(2), + /* 22 S> */ B(LdaGlobal), U8(0), U8(2), /* 32 S> */ B(Return), ] constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], ] handlers: [ ] @@ -201,7 +204,7 @@ snippet: " " frame size: 0 parameter count: 2 -bytecode array length: 650 +bytecode array length: 652 bytecodes: [ /* 17 E> */ B(StackCheck), /* 25 S> */ B(Nop), @@ -460,11 +463,12 @@ bytecodes: [ /* 1286 E> */ B(LdaNamedProperty), R(arg0), U8(0), U8(254), /* 1295 S> */ B(Nop), /* 1296 E> */ B(Wide), B(LdaNamedProperty), R16(arg0), U16(0), U16(256), - /* 1305 S> */ B(Wide), B(LdaGlobal), U16(258), + /* 1305 S> */ B(Wide), B(LdaGlobal), U16(1), U16(258), /* 1315 S> */ B(Return), ] constant pool: [ ONE_BYTE_INTERNALIZED_STRING_TYPE ["name"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], ] handlers: [ ] diff --git a/test/cctest/interpreter/bytecode_expectations/Typeof.golden b/test/cctest/interpreter/bytecode_expectations/Typeof.golden index 5e15e5981e..d5ab090594 100644 --- a/test/cctest/interpreter/bytecode_expectations/Typeof.golden +++ b/test/cctest/interpreter/bytecode_expectations/Typeof.golden @@ -39,14 +39,15 @@ snippet: " " frame size: 0 parameter count: 1 -bytecode array length: 5 +bytecode array length: 6 bytecodes: [ /* 22 E> */ B(StackCheck), - /* 28 S> */ B(LdaGlobalInsideTypeof), U8(2), + /* 28 S> */ B(LdaGlobalInsideTypeof), U8(0), U8(2), B(TypeOf), /* 46 S> */ B(Return), ] constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["x"], ] handlers: [ ] diff --git a/test/unittests/interpreter/bytecode-array-builder-unittest.cc b/test/unittests/interpreter/bytecode-array-builder-unittest.cc index 9be82b566f..887d73fff4 100644 --- a/test/unittests/interpreter/bytecode-array-builder-unittest.cc +++ b/test/unittests/interpreter/bytecode-array-builder-unittest.cc @@ -77,8 +77,8 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { // Emit global load / store operations. Handle name = factory->NewStringFromStaticChars("var_name"); - builder.LoadGlobal(1, TypeofMode::NOT_INSIDE_TYPEOF) - .LoadGlobal(1, TypeofMode::INSIDE_TYPEOF) + builder.LoadGlobal(name, 1, TypeofMode::NOT_INSIDE_TYPEOF) + .LoadGlobal(name, 1, TypeofMode::INSIDE_TYPEOF) .StoreGlobal(name, 1, LanguageMode::SLOPPY) .StoreGlobal(name, 1, LanguageMode::STRICT); @@ -285,14 +285,14 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { Handle wide_name = factory->NewStringFromStaticChars("var_wide_name"); // Emit wide global load / store operations. - builder.LoadGlobal(1024, TypeofMode::NOT_INSIDE_TYPEOF) - .LoadGlobal(1024, TypeofMode::INSIDE_TYPEOF) - .LoadGlobal(1024, TypeofMode::INSIDE_TYPEOF) + builder.LoadGlobal(name, 1024, TypeofMode::NOT_INSIDE_TYPEOF) + .LoadGlobal(name, 1024, TypeofMode::INSIDE_TYPEOF) + .LoadGlobal(name, 1024, TypeofMode::INSIDE_TYPEOF) .StoreGlobal(name, 1024, LanguageMode::SLOPPY) .StoreGlobal(wide_name, 1, LanguageMode::STRICT); // Emit extra wide global load. - builder.LoadGlobal(1024 * 1024, TypeofMode::NOT_INSIDE_TYPEOF); + builder.LoadGlobal(name, 1024 * 1024, TypeofMode::NOT_INSIDE_TYPEOF); // Emit wide load / store property operations. builder.LoadNamedProperty(reg, wide_name, 0) diff --git a/test/unittests/interpreter/bytecode-array-iterator-unittest.cc b/test/unittests/interpreter/bytecode-array-iterator-unittest.cc index 894134a959..01c5e9e9c5 100644 --- a/test/unittests/interpreter/bytecode-array-iterator-unittest.cc +++ b/test/unittests/interpreter/bytecode-array-iterator-unittest.cc @@ -60,7 +60,7 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { .ForInPrepare(reg_0, triple) .CallRuntime(Runtime::kLoadIC_Miss, reg_0) .Debugger() - .LoadGlobal(0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) + .LoadGlobal(name, 0x10000000, TypeofMode::NOT_INSIDE_TYPEOF) .Return(); // Test iterator sees the expected output from the builder. @@ -268,8 +268,8 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { CHECK_EQ(iterator.current_bytecode(), Bytecode::kLdaGlobal); CHECK_EQ(iterator.current_offset(), offset); CHECK_EQ(iterator.current_operand_scale(), OperandScale::kQuadruple); - CHECK_EQ(iterator.current_bytecode_size(), 6); - CHECK_EQ(iterator.GetIndexOperand(0), 0x10000000u); + CHECK_EQ(iterator.current_bytecode_size(), 10); + CHECK_EQ(iterator.GetIndexOperand(1), 0x10000000u); offset += Bytecodes::Size(Bytecode::kLdaGlobal, OperandScale::kQuadruple) + kPrefixByteSize; iterator.Advance(); diff --git a/test/unittests/interpreter/bytecode-pipeline-unittest.cc b/test/unittests/interpreter/bytecode-pipeline-unittest.cc index c4388e8fed..63da076c4a 100644 --- a/test/unittests/interpreter/bytecode-pipeline-unittest.cc +++ b/test/unittests/interpreter/bytecode-pipeline-unittest.cc @@ -68,11 +68,12 @@ TEST_F(BytecodeNodeTest, Constructor2) { } TEST_F(BytecodeNodeTest, Constructor3) { - uint32_t operands[] = {0x11}; - BytecodeNode node(Bytecode::kLdaGlobal, operands[0]); + uint32_t operands[] = {0x11, 0x22}; + BytecodeNode node(Bytecode::kLdaGlobal, operands[0], operands[1]); CHECK_EQ(node.bytecode(), Bytecode::kLdaGlobal); - CHECK_EQ(node.operand_count(), 1); + CHECK_EQ(node.operand_count(), 2); CHECK_EQ(node.operand(0), operands[0]); + CHECK_EQ(node.operand(1), operands[1]); CHECK(!node.source_info().is_valid()); }