From 54636ae4e2dbb076979b832e39bc59878cf75a25 Mon Sep 17 00:00:00 2001 From: "mvstanton@chromium.org" Date: Thu, 17 Jul 2014 11:50:04 +0000 Subject: [PATCH] StubCallInterfaceDescriptor and CallInterfaceDescriptor are unified under a base class InterfaceDescriptor. Handling of the context register had to be massaged to effect the unification. This will make it easier to call hydrogen code stubs directly from crankshaft. R=danno@chromium.org Review URL: https://codereview.chromium.org/384403002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22448 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/code-stubs-arm.cc | 75 +++++++++------- src/arm/code-stubs-arm.h | 4 +- src/arm/lithium-arm.cc | 4 +- src/arm/lithium-arm.h | 10 +-- src/arm/lithium-codegen-arm.cc | 2 +- src/arm64/code-stubs-arm64.cc | 88 ++++++++++++------- src/arm64/code-stubs-arm64.h | 4 +- src/arm64/lithium-arm64.cc | 4 +- src/arm64/lithium-arm64.h | 10 +-- src/code-stubs-hydrogen.cc | 16 ++-- src/code-stubs.cc | 86 ++++++++++-------- src/code-stubs.h | 154 +++++++++++++++++---------------- src/deoptimizer.cc | 13 +-- src/hydrogen-instructions.h | 14 +-- src/hydrogen.cc | 16 ++-- src/ia32/code-stubs-ia32.cc | 72 ++++++++------- src/ia32/lithium-ia32.cc | 5 +- src/ia32/lithium-ia32.h | 6 +- src/x64/code-stubs-x64.cc | 66 +++++++------- src/x64/lithium-x64.cc | 4 +- src/x64/lithium-x64.h | 6 +- 21 files changed, 368 insertions(+), 291 deletions(-) diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index 77eaf2237..de285bb2f 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -17,7 +17,7 @@ namespace internal { void FastNewClosureStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r2 }; + Register registers[] = { cp, r2 }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry); @@ -26,21 +26,21 @@ void FastNewClosureStub::InitializeInterfaceDescriptor( void FastNewContextStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r1 }; + Register registers[] = { cp, r1 }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void ToNumberStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r0 }; + Register registers[] = { cp, r0 }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void NumberToStringStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r0 }; + Register registers[] = { cp, r0 }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry); @@ -49,8 +49,9 @@ void NumberToStringStub::InitializeInterfaceDescriptor( void FastCloneShallowArrayStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r3, r2, r1 }; + Register registers[] = { cp, r3, r2, r1 }; Representation representations[] = { + Representation::Tagged(), Representation::Tagged(), Representation::Smi(), Representation::Tagged() }; @@ -64,7 +65,7 @@ void FastCloneShallowArrayStub::InitializeInterfaceDescriptor( void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r3, r2, r1, r0 }; + Register registers[] = { cp, r3, r2, r1, r0 }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry); @@ -73,14 +74,14 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( void CreateAllocationSiteStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r2, r3 }; + Register registers[] = { cp, r2, r3 }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void RegExpConstructResultStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r2, r1, r0 }; + Register registers[] = { cp, r2, r1, r0 }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); @@ -89,7 +90,7 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor( void TransitionElementsKindStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r0, r1 }; + Register registers[] = { cp, r0, r1 }; Address entry = Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry; descriptor->Initialize(ARRAY_SIZE(registers), registers, @@ -99,7 +100,7 @@ void TransitionElementsKindStub::InitializeInterfaceDescriptor( void CompareNilICStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r0 }; + Register registers[] = { cp, r0 }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(CompareNilIC_Miss)); descriptor->SetMissHandler( @@ -107,10 +108,14 @@ void CompareNilICStub::InitializeInterfaceDescriptor( } +const Register InterfaceDescriptor::ContextRegister() { return cp; } + + static void InitializeArrayConstructorDescriptor( CodeStubInterfaceDescriptor* descriptor, int constant_stack_parameter_count) { // register state + // cp -- context // r0 -- number of arguments // r1 -- function // r2 -- allocation site with elements kind @@ -118,7 +123,7 @@ static void InitializeArrayConstructorDescriptor( Runtime::kArrayConstructor)->entry; if (constant_stack_parameter_count == 0) { - Register registers[] = { r1, r2 }; + Register registers[] = { cp, r1, r2 }; descriptor->Initialize(ARRAY_SIZE(registers), registers, deopt_handler, NULL, @@ -126,8 +131,9 @@ static void InitializeArrayConstructorDescriptor( JS_FUNCTION_STUB_MODE); } else { // stack param count needs (constructor pointer, and single argument) - Register registers[] = { r1, r2, r0 }; + Register registers[] = { cp, r1, r2, r0 }; Representation representations[] = { + Representation::Tagged(), Representation::Tagged(), Representation::Tagged(), Representation::Integer32() }; @@ -146,13 +152,14 @@ static void InitializeInternalArrayConstructorDescriptor( CodeStubInterfaceDescriptor* descriptor, int constant_stack_parameter_count) { // register state + // cp -- context // r0 -- number of arguments // r1 -- constructor function Address deopt_handler = Runtime::FunctionForId( Runtime::kInternalArrayConstructor)->entry; if (constant_stack_parameter_count == 0) { - Register registers[] = { r1 }; + Register registers[] = { cp, r1 }; descriptor->Initialize(ARRAY_SIZE(registers), registers, deopt_handler, NULL, @@ -160,8 +167,9 @@ static void InitializeInternalArrayConstructorDescriptor( JS_FUNCTION_STUB_MODE); } else { // stack param count needs (constructor pointer, and single argument) - Register registers[] = { r1, r0 }; + Register registers[] = { cp, r1, r0 }; Representation representations[] = { + Representation::Tagged(), Representation::Tagged(), Representation::Integer32() }; descriptor->Initialize(ARRAY_SIZE(registers), registers, @@ -195,7 +203,7 @@ void ArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( void ToBooleanStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r0 }; + Register registers[] = { cp, r0 }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(ToBooleanIC_Miss)); descriptor->SetMissHandler( @@ -223,7 +231,7 @@ void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( void BinaryOpICStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r1, r0 }; + Register registers[] = { cp, r1, r0 }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(BinaryOpIC_Miss)); descriptor->SetMissHandler( @@ -233,7 +241,7 @@ void BinaryOpICStub::InitializeInterfaceDescriptor( void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r2, r1, r0 }; + Register registers[] = { cp, r2, r1, r0 }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite)); } @@ -241,7 +249,7 @@ void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor( void StringAddStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { r1, r0 }; + Register registers[] = { cp, r1, r0 }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kStringAdd)->entry); @@ -249,23 +257,23 @@ void StringAddStub::InitializeInterfaceDescriptor( void CallDescriptors::InitializeForIsolate(Isolate* isolate) { - static PlatformCallInterfaceDescriptor default_descriptor = - PlatformCallInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS); + static PlatformInterfaceDescriptor default_descriptor = + PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS); - static PlatformCallInterfaceDescriptor noInlineDescriptor = - PlatformCallInterfaceDescriptor(NEVER_INLINE_TARGET_ADDRESS); + static PlatformInterfaceDescriptor noInlineDescriptor = + PlatformInterfaceDescriptor(NEVER_INLINE_TARGET_ADDRESS); { CallInterfaceDescriptor* descriptor = isolate->call_descriptor(Isolate::ArgumentAdaptorCall); - Register registers[] = { r1, // JSFunction - cp, // context + Register registers[] = { cp, // context + r1, // JSFunction r0, // actual number of arguments r2, // expected number of arguments }; Representation representations[] = { - Representation::Tagged(), // JSFunction Representation::Tagged(), // context + Representation::Tagged(), // JSFunction Representation::Integer32(), // actual number of arguments Representation::Integer32(), // expected number of arguments }; @@ -314,18 +322,18 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) { { CallInterfaceDescriptor* descriptor = isolate->call_descriptor(Isolate::ApiFunctionCall); - Register registers[] = { r0, // callee + Register registers[] = { cp, // context + r0, // callee r4, // call_data r2, // holder r1, // api_function_address - cp, // context }; Representation representations[] = { + Representation::Tagged(), // context Representation::Tagged(), // callee Representation::Tagged(), // call_data Representation::Tagged(), // holder Representation::External(), // api_function_address - Representation::Tagged(), // context }; descriptor->Initialize(ARRAY_SIZE(registers), registers, representations, &default_descriptor); @@ -355,18 +363,19 @@ void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) { isolate()->counters()->code_stubs()->Increment(); CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor(); - int param_count = descriptor->register_param_count(); + int param_count = descriptor->GetEnvironmentParameterCount(); { // Call the runtime system in a fresh internal frame. FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); - ASSERT(descriptor->register_param_count() == 0 || - r0.is(descriptor->GetParameterRegister(param_count - 1))); + ASSERT(param_count == 0 || + r0.is(descriptor->GetEnvironmentParameterRegister( + param_count - 1))); // Push arguments for (int i = 0; i < param_count; ++i) { - __ push(descriptor->GetParameterRegister(i)); + __ push(descriptor->GetEnvironmentParameterRegister(i)); } ExternalReference miss = descriptor->miss_handler(); - __ CallExternalReference(miss, descriptor->register_param_count()); + __ CallExternalReference(miss, param_count); } __ Ret(); diff --git a/src/arm/code-stubs-arm.h b/src/arm/code-stubs-arm.h index 5fa19d626..f7456ef8a 100644 --- a/src/arm/code-stubs-arm.h +++ b/src/arm/code-stubs-arm.h @@ -403,9 +403,9 @@ class NameDictionaryLookupStub: public PlatformCodeStub { }; -class PlatformCallInterfaceDescriptor { +class PlatformInterfaceDescriptor { public: - explicit PlatformCallInterfaceDescriptor( + explicit PlatformInterfaceDescriptor( TargetAddressStorageMode storage_mode) : storage_mode_(storage_mode) { } diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index 90ff02394..6071846c3 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -1083,7 +1083,7 @@ LInstruction* LChunkBuilder::DoCallJSFunction( LInstruction* LChunkBuilder::DoCallWithDescriptor( HCallWithDescriptor* instr) { - const CallInterfaceDescriptor* descriptor = instr->descriptor(); + const InterfaceDescriptor* descriptor = instr->descriptor(); LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList ops(instr->OperandCount(), zone()); @@ -2411,7 +2411,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { CodeStubInterfaceDescriptor* descriptor = info()->code_stub()->GetInterfaceDescriptor(); int index = static_cast(instr->index()); - Register reg = descriptor->GetParameterRegister(index); + Register reg = descriptor->GetEnvironmentParameterRegister(index); return DefineFixed(result, reg); } } diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h index 3d7f72b9e..095640d86 100644 --- a/src/arm/lithium-arm.h +++ b/src/arm/lithium-arm.h @@ -1850,18 +1850,18 @@ class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> { class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> { public: - LCallWithDescriptor(const CallInterfaceDescriptor* descriptor, + LCallWithDescriptor(const InterfaceDescriptor* descriptor, const ZoneList& operands, Zone* zone) : descriptor_(descriptor), - inputs_(descriptor->environment_length() + 1, zone) { - ASSERT(descriptor->environment_length() + 1 == operands.length()); + inputs_(descriptor->GetRegisterParameterCount() + 1, zone) { + ASSERT(descriptor->GetRegisterParameterCount() + 1 == operands.length()); inputs_.AddAll(operands, zone); } LOperand* target() const { return inputs_[0]; } - const CallInterfaceDescriptor* descriptor() { return descriptor_; } + const InterfaceDescriptor* descriptor() { return descriptor_; } private: DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor") @@ -1871,7 +1871,7 @@ class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> { int arity() const { return hydrogen()->argument_count() - 1; } - const CallInterfaceDescriptor* descriptor_; + const InterfaceDescriptor* descriptor_; ZoneList inputs_; // Iterator support. diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 13dd7b707..87ad6d9d5 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -3970,7 +3970,7 @@ void LCodeGen::DoCallWithDescriptor(LCallWithDescriptor* instr) { LConstantOperand* target = LConstantOperand::cast(instr->target()); Handle code = Handle::cast(ToHandle(target)); generator.BeforeCall(__ CallSize(code, RelocInfo::CODE_TARGET)); - PlatformCallInterfaceDescriptor* call_descriptor = + PlatformInterfaceDescriptor* call_descriptor = instr->descriptor()->platform_specific_descriptor(); __ Call(code, RelocInfo::CODE_TARGET, TypeFeedbackId::None(), al, call_descriptor->storage_mode()); diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc index 7126628c7..035ab18a5 100644 --- a/src/arm64/code-stubs-arm64.cc +++ b/src/arm64/code-stubs-arm64.cc @@ -16,8 +16,9 @@ namespace internal { void FastNewClosureStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x2: function info - Register registers[] = { x2 }; + Register registers[] = { cp, x2 }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry); @@ -26,24 +27,27 @@ void FastNewClosureStub::InitializeInterfaceDescriptor( void FastNewContextStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x1: function - Register registers[] = { x1 }; + Register registers[] = { cp, x1 }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void ToNumberStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x0: value - Register registers[] = { x0 }; + Register registers[] = { cp, x0 }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void NumberToStringStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x0: value - Register registers[] = { x0 }; + Register registers[] = { cp, x0 }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry); @@ -52,11 +56,13 @@ void NumberToStringStub::InitializeInterfaceDescriptor( void FastCloneShallowArrayStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x3: array literals array // x2: array literal index // x1: constant elements - Register registers[] = { x3, x2, x1 }; + Register registers[] = { cp, x3, x2, x1 }; Representation representations[] = { + Representation::Tagged(), Representation::Tagged(), Representation::Smi(), Representation::Tagged() }; @@ -70,11 +76,12 @@ void FastCloneShallowArrayStub::InitializeInterfaceDescriptor( void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x3: object literals array // x2: object literal index // x1: constant properties // x0: object literal flags - Register registers[] = { x3, x2, x1, x0 }; + Register registers[] = { cp, x3, x2, x1, x0 }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry); @@ -83,19 +90,21 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( void CreateAllocationSiteStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x2: feedback vector // x3: call feedback slot - Register registers[] = { x2, x3 }; + Register registers[] = { cp, x2, x3 }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void RegExpConstructResultStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x2: length // x1: index (of last match) // x0: string - Register registers[] = { x2, x1, x0 }; + Register registers[] = { cp, x2, x1, x0 }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); @@ -104,9 +113,10 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor( void TransitionElementsKindStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x0: value (js_array) // x1: to_map - Register registers[] = { x0, x1 }; + Register registers[] = { cp, x0, x1 }; Address entry = Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry; descriptor->Initialize(ARRAY_SIZE(registers), registers, @@ -116,8 +126,9 @@ void TransitionElementsKindStub::InitializeInterfaceDescriptor( void CompareNilICStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x0: value to compare - Register registers[] = { x0 }; + Register registers[] = { cp, x0 }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(CompareNilIC_Miss)); descriptor->SetMissHandler( @@ -125,9 +136,13 @@ void CompareNilICStub::InitializeInterfaceDescriptor( } +const Register InterfaceDescriptor::ContextRegister() { return cp; } + + static void InitializeArrayConstructorDescriptor( CodeStubInterfaceDescriptor* descriptor, int constant_stack_parameter_count) { + // cp: context // x1: function // x2: allocation site with elements kind // x0: number of arguments to the constructor function @@ -135,7 +150,7 @@ static void InitializeArrayConstructorDescriptor( Runtime::kArrayConstructor)->entry; if (constant_stack_parameter_count == 0) { - Register registers[] = { x1, x2 }; + Register registers[] = { cp, x1, x2 }; descriptor->Initialize(ARRAY_SIZE(registers), registers, deopt_handler, NULL, @@ -143,8 +158,9 @@ static void InitializeArrayConstructorDescriptor( JS_FUNCTION_STUB_MODE); } else { // stack param count needs (constructor pointer, and single argument) - Register registers[] = { x1, x2, x0 }; + Register registers[] = { cp, x1, x2, x0 }; Representation representations[] = { + Representation::Tagged(), Representation::Tagged(), Representation::Tagged(), Representation::Integer32() }; @@ -180,13 +196,14 @@ void ArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( static void InitializeInternalArrayConstructorDescriptor( CodeStubInterfaceDescriptor* descriptor, int constant_stack_parameter_count) { + // cp: context // x1: constructor function // x0: number of arguments to the constructor function Address deopt_handler = Runtime::FunctionForId( Runtime::kInternalArrayConstructor)->entry; if (constant_stack_parameter_count == 0) { - Register registers[] = { x1 }; + Register registers[] = { cp, x1 }; descriptor->Initialize(ARRAY_SIZE(registers), registers, deopt_handler, NULL, @@ -194,8 +211,9 @@ static void InitializeInternalArrayConstructorDescriptor( JS_FUNCTION_STUB_MODE); } else { // stack param count needs (constructor pointer, and single argument) - Register registers[] = { x1, x0 }; + Register registers[] = { cp, x1, x0 }; Representation representations[] = { + Representation::Tagged(), Representation::Tagged(), Representation::Integer32() }; descriptor->Initialize(ARRAY_SIZE(registers), registers, @@ -229,8 +247,9 @@ void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( void ToBooleanStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x0: value - Register registers[] = { x0 }; + Register registers[] = { cp, x0 }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(ToBooleanIC_Miss)); descriptor->SetMissHandler( @@ -240,9 +259,10 @@ void ToBooleanStub::InitializeInterfaceDescriptor( void BinaryOpICStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x1: left operand // x0: right operand - Register registers[] = { x1, x0 }; + Register registers[] = { cp, x1, x0 }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(BinaryOpIC_Miss)); descriptor->SetMissHandler( @@ -252,10 +272,11 @@ void BinaryOpICStub::InitializeInterfaceDescriptor( void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x2: allocation site // x1: left operand // x0: right operand - Register registers[] = { x2, x1, x0 }; + Register registers[] = { cp, x2, x1, x0 }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite)); } @@ -263,9 +284,10 @@ void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor( void StringAddStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { + // cp: context // x1: left operand // x0: right operand - Register registers[] = { x1, x0 }; + Register registers[] = { cp, x1, x0 }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kStringAdd)->entry); @@ -273,23 +295,23 @@ void StringAddStub::InitializeInterfaceDescriptor( void CallDescriptors::InitializeForIsolate(Isolate* isolate) { - static PlatformCallInterfaceDescriptor default_descriptor = - PlatformCallInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS); + static PlatformInterfaceDescriptor default_descriptor = + PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS); - static PlatformCallInterfaceDescriptor noInlineDescriptor = - PlatformCallInterfaceDescriptor(NEVER_INLINE_TARGET_ADDRESS); + static PlatformInterfaceDescriptor noInlineDescriptor = + PlatformInterfaceDescriptor(NEVER_INLINE_TARGET_ADDRESS); { CallInterfaceDescriptor* descriptor = isolate->call_descriptor(Isolate::ArgumentAdaptorCall); - Register registers[] = { x1, // JSFunction - cp, // context + Register registers[] = { cp, // context + x1, // JSFunction x0, // actual number of arguments x2, // expected number of arguments }; Representation representations[] = { - Representation::Tagged(), // JSFunction Representation::Tagged(), // context + Representation::Tagged(), // JSFunction Representation::Integer32(), // actual number of arguments Representation::Integer32(), // expected number of arguments }; @@ -338,18 +360,18 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) { { CallInterfaceDescriptor* descriptor = isolate->call_descriptor(Isolate::ApiFunctionCall); - Register registers[] = { x0, // callee + Register registers[] = { cp, // context + x0, // callee x4, // call_data x2, // holder x1, // api_function_address - cp, // context }; Representation representations[] = { + Representation::Tagged(), // context Representation::Tagged(), // callee Representation::Tagged(), // call_data Representation::Tagged(), // holder Representation::External(), // api_function_address - Representation::Tagged(), // context }; descriptor->Initialize(ARRAY_SIZE(registers), registers, representations, &default_descriptor); @@ -365,22 +387,22 @@ void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) { isolate()->counters()->code_stubs()->Increment(); CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor(); - int param_count = descriptor->register_param_count(); + int param_count = descriptor->GetEnvironmentParameterCount(); { // Call the runtime system in a fresh internal frame. FrameScope scope(masm, StackFrame::INTERNAL); - ASSERT((descriptor->register_param_count() == 0) || - x0.Is(descriptor->GetParameterRegister(param_count - 1))); + ASSERT((param_count == 0) || + x0.Is(descriptor->GetEnvironmentParameterRegister(param_count - 1))); // Push arguments MacroAssembler::PushPopQueue queue(masm); for (int i = 0; i < param_count; ++i) { - queue.Queue(descriptor->GetParameterRegister(i)); + queue.Queue(descriptor->GetEnvironmentParameterRegister(i)); } queue.PushQueued(); ExternalReference miss = descriptor->miss_handler(); - __ CallExternalReference(miss, descriptor->register_param_count()); + __ CallExternalReference(miss, param_count); } __ Ret(); diff --git a/src/arm64/code-stubs-arm64.h b/src/arm64/code-stubs-arm64.h index 9520be9b3..a21f315a0 100644 --- a/src/arm64/code-stubs-arm64.h +++ b/src/arm64/code-stubs-arm64.h @@ -459,9 +459,9 @@ class StringCompareStub: public PlatformCodeStub { }; -class PlatformCallInterfaceDescriptor { +class PlatformInterfaceDescriptor { public: - explicit PlatformCallInterfaceDescriptor( + explicit PlatformInterfaceDescriptor( TargetAddressStorageMode storage_mode) : storage_mode_(storage_mode) { } diff --git a/src/arm64/lithium-arm64.cc b/src/arm64/lithium-arm64.cc index 34311163d..9ac108c32 100644 --- a/src/arm64/lithium-arm64.cc +++ b/src/arm64/lithium-arm64.cc @@ -1031,7 +1031,7 @@ LInstruction* LChunkBuilder::DoCallJSFunction( LInstruction* LChunkBuilder::DoCallWithDescriptor( HCallWithDescriptor* instr) { - const CallInterfaceDescriptor* descriptor = instr->descriptor(); + const InterfaceDescriptor* descriptor = instr->descriptor(); LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList ops(instr->OperandCount(), zone()); @@ -1967,7 +1967,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { CodeStubInterfaceDescriptor* descriptor = info()->code_stub()->GetInterfaceDescriptor(); int index = static_cast(instr->index()); - Register reg = descriptor->GetParameterRegister(index); + Register reg = descriptor->GetEnvironmentParameterRegister(index); return DefineFixed(result, reg); } } diff --git a/src/arm64/lithium-arm64.h b/src/arm64/lithium-arm64.h index f7be2ed49..771b625ec 100644 --- a/src/arm64/lithium-arm64.h +++ b/src/arm64/lithium-arm64.h @@ -1519,18 +1519,18 @@ class LInteger32ToDouble V8_FINAL : public LTemplateInstruction<1, 1, 0> { class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> { public: - LCallWithDescriptor(const CallInterfaceDescriptor* descriptor, + LCallWithDescriptor(const InterfaceDescriptor* descriptor, const ZoneList& operands, Zone* zone) : descriptor_(descriptor), - inputs_(descriptor->environment_length() + 1, zone) { - ASSERT(descriptor->environment_length() + 1 == operands.length()); + inputs_(descriptor->GetRegisterParameterCount() + 1, zone) { + ASSERT(descriptor->GetRegisterParameterCount() + 1 == operands.length()); inputs_.AddAll(operands, zone); } LOperand* target() const { return inputs_[0]; } - const CallInterfaceDescriptor* descriptor() { return descriptor_; } + const InterfaceDescriptor* descriptor() { return descriptor_; } private: DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor, "call-with-descriptor") @@ -1540,7 +1540,7 @@ class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> { int arity() const { return hydrogen()->argument_count() - 1; } - const CallInterfaceDescriptor* descriptor_; + const InterfaceDescriptor* descriptor_; ZoneList inputs_; // Iterator support. diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc index 547820c7f..27d34b441 100644 --- a/src/code-stubs-hydrogen.cc +++ b/src/code-stubs-hydrogen.cc @@ -39,14 +39,15 @@ class CodeStubGraphBuilderBase : public HGraphBuilder { info_(stub, isolate), context_(NULL) { descriptor_ = stub->GetInterfaceDescriptor(); - parameters_.Reset(new HParameter*[descriptor_->register_param_count()]); + int parameter_count = descriptor_->GetEnvironmentParameterCount(); + parameters_.Reset(new HParameter*[parameter_count]); } virtual bool BuildGraph(); protected: virtual HValue* BuildCodeStub() = 0; HParameter* GetParameter(int parameter) { - ASSERT(parameter < descriptor_->register_param_count()); + ASSERT(parameter < descriptor_->GetEnvironmentParameterCount()); return parameters_[parameter]; } HValue* GetArgumentsLength() { @@ -116,7 +117,7 @@ bool CodeStubGraphBuilderBase::BuildGraph() { isolate()->GetHTracer()->TraceCompilation(&info_); } - int param_count = descriptor_->register_param_count(); + int param_count = descriptor_->GetEnvironmentParameterCount(); HEnvironment* start_environment = graph()->start_environment(); HBasicBlock* next_block = CreateBasicBlock(start_environment); Goto(next_block); @@ -126,11 +127,12 @@ bool CodeStubGraphBuilderBase::BuildGraph() { bool runtime_stack_params = descriptor_->stack_parameter_count().is_valid(); HInstruction* stack_parameter_count = NULL; for (int i = 0; i < param_count; ++i) { - Representation r = descriptor_->GetRegisterParameterRepresentation(i); - HParameter* param = Add(i, HParameter::REGISTER_PARAMETER, r); + Representation r = descriptor_->GetEnvironmentParameterRepresentation(i); + HParameter* param = Add(i, + HParameter::REGISTER_PARAMETER, r); start_environment->Bind(i, param); parameters_[i] = param; - if (descriptor_->IsParameterCountRegister(i)) { + if (descriptor_->IsEnvironmentParameterCountRegister(i)) { param->set_type(HType::Smi()); stack_parameter_count = param; arguments_length_ = stack_parameter_count; @@ -251,7 +253,7 @@ static Handle DoGenerateCode(Stub* stub) { static_cast(stub)->MajorKey(); CodeStubInterfaceDescriptor* descriptor = isolate->code_stub_interface_descriptor(major_key); - if (!descriptor->initialized()) { + if (!descriptor->IsInitialized()) { stub->InitializeInterfaceDescriptor(descriptor); } diff --git a/src/code-stubs.cc b/src/code-stubs.cc index d4745cc3f..3ffe12ab6 100644 --- a/src/code-stubs.cc +++ b/src/code-stubs.cc @@ -16,9 +16,12 @@ namespace v8 { namespace internal { +InterfaceDescriptor::InterfaceDescriptor() + : register_param_count_(-1) { } + + CodeStubInterfaceDescriptor::CodeStubInterfaceDescriptor() - : register_param_count_(-1), - stack_parameter_count_(no_reg), + : stack_parameter_count_(no_reg), hint_stack_parameter_count_(-1), function_mode_(NOT_JS_FUNCTION_STUB_MODE), deoptimization_handler_(NULL), @@ -27,15 +30,18 @@ CodeStubInterfaceDescriptor::CodeStubInterfaceDescriptor() has_miss_handler_(false) { } -void CodeStubInterfaceDescriptor::Initialize( +void InterfaceDescriptor::Initialize( int register_parameter_count, Register* registers, - Address deoptimization_handler, Representation* register_param_representations, - int hint_stack_parameter_count, - StubFunctionMode function_mode) { - // CodeStubInterfaceDescriptor owns a copy of the registers array. + PlatformInterfaceDescriptor* platform_descriptor) { + platform_specific_descriptor_ = platform_descriptor; register_param_count_ = register_parameter_count; + + // An interface descriptor must have a context register. + ASSERT(register_parameter_count > 0 && registers[0].is(ContextRegister())); + + // InterfaceDescriptor owns a copy of the registers array. register_params_.Reset(NewArray(register_parameter_count)); for (int i = 0; i < register_parameter_count; i++) { register_params_[i] = registers[i]; @@ -47,9 +53,24 @@ void CodeStubInterfaceDescriptor::Initialize( register_param_representations_.Reset( NewArray(register_parameter_count)); for (int i = 0; i < register_parameter_count; i++) { + // If there is a context register, the representation must be tagged. + ASSERT(i != 0 || register_param_representations[i].Equals( + Representation::Tagged())); register_param_representations_[i] = register_param_representations[i]; } } +} + + +void CodeStubInterfaceDescriptor::Initialize( + int register_parameter_count, + Register* registers, + Address deoptimization_handler, + Representation* register_param_representations, + int hint_stack_parameter_count, + StubFunctionMode function_mode) { + InterfaceDescriptor::Initialize(register_parameter_count, registers, + register_param_representations); deoptimization_handler_ = deoptimization_handler; @@ -81,22 +102,9 @@ void CallInterfaceDescriptor::Initialize( int register_parameter_count, Register* registers, Representation* param_representations, - PlatformCallInterfaceDescriptor* platform_descriptor) { - // CallInterfaceDescriptor owns a copy of the registers array. - register_param_count_ = register_parameter_count; - register_params_.Reset(NewArray(register_parameter_count)); - for (int i = 0; i < register_parameter_count; i++) { - register_params_[i] = registers[i]; - } - - // Also the register parameter representations. - param_representations_.Reset( - NewArray(register_parameter_count)); - for (int i = 0; i < register_parameter_count; i++) { - param_representations_[i] = param_representations[i]; - } - - platform_specific_descriptor_ = platform_descriptor; + PlatformInterfaceDescriptor* platform_descriptor) { + InterfaceDescriptor::Initialize(register_parameter_count, registers, + param_representations, platform_descriptor); } @@ -574,7 +582,8 @@ void JSEntryStub::FinishCode(Handle code) { void KeyedLoadFastElementStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { LoadIC::ReceiverRegister(), + Register registers[] = { InterfaceDescriptor::ContextRegister(), + LoadIC::ReceiverRegister(), LoadIC::NameRegister() }; STATIC_ASSERT(LoadIC::kParameterCount == 2); descriptor->Initialize(ARRAY_SIZE(registers), registers, @@ -584,7 +593,8 @@ void KeyedLoadFastElementStub::InitializeInterfaceDescriptor( void KeyedLoadDictionaryElementStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { LoadIC::ReceiverRegister(), + Register registers[] = { InterfaceDescriptor::ContextRegister(), + LoadIC::ReceiverRegister(), LoadIC::NameRegister() }; STATIC_ASSERT(LoadIC::kParameterCount == 2); descriptor->Initialize(ARRAY_SIZE(registers), registers, @@ -594,7 +604,8 @@ void KeyedLoadDictionaryElementStub::InitializeInterfaceDescriptor( void KeyedLoadGenericElementStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { LoadIC::ReceiverRegister(), + Register registers[] = { InterfaceDescriptor::ContextRegister(), + LoadIC::ReceiverRegister(), LoadIC::NameRegister() }; STATIC_ASSERT(LoadIC::kParameterCount == 2); descriptor->Initialize( @@ -605,21 +616,24 @@ void KeyedLoadGenericElementStub::InitializeInterfaceDescriptor( void LoadFieldStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { LoadIC::ReceiverRegister() }; + Register registers[] = { InterfaceDescriptor::ContextRegister(), + LoadIC::ReceiverRegister() }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void KeyedLoadFieldStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { LoadIC::ReceiverRegister() }; + Register registers[] = { InterfaceDescriptor::ContextRegister(), + LoadIC::ReceiverRegister() }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void StringLengthStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { LoadIC::ReceiverRegister(), + Register registers[] = { InterfaceDescriptor::ContextRegister(), + LoadIC::ReceiverRegister(), LoadIC::NameRegister() }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } @@ -627,7 +641,8 @@ void StringLengthStub::InitializeInterfaceDescriptor( void KeyedStringLengthStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { LoadIC::ReceiverRegister(), + Register registers[] = { InterfaceDescriptor::ContextRegister(), + LoadIC::ReceiverRegister(), LoadIC::NameRegister() }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } @@ -635,7 +650,8 @@ void KeyedStringLengthStub::InitializeInterfaceDescriptor( void KeyedStoreFastElementStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { KeyedStoreIC::ReceiverRegister(), + Register registers[] = { InterfaceDescriptor::ContextRegister(), + KeyedStoreIC::ReceiverRegister(), KeyedStoreIC::NameRegister(), KeyedStoreIC::ValueRegister() }; descriptor->Initialize( @@ -646,7 +662,8 @@ void KeyedStoreFastElementStub::InitializeInterfaceDescriptor( void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { ValueRegister(), + Register registers[] = { InterfaceDescriptor::ContextRegister(), + ValueRegister(), MapRegister(), KeyRegister(), ObjectRegister() }; @@ -657,7 +674,8 @@ void ElementsTransitionAndStoreStub::InitializeInterfaceDescriptor( void StoreGlobalStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { StoreIC::ReceiverRegister(), + Register registers[] = { InterfaceDescriptor::ContextRegister(), + StoreIC::ReceiverRegister(), StoreIC::NameRegister(), StoreIC::ValueRegister() }; descriptor->Initialize(ARRAY_SIZE(registers), registers, @@ -864,7 +882,7 @@ static void InstallDescriptor(Isolate* isolate, HydrogenCodeStub* stub) { int major_key = stub->MajorKey(); CodeStubInterfaceDescriptor* descriptor = isolate->code_stub_interface_descriptor(major_key); - if (!descriptor->initialized()) { + if (!descriptor->IsInitialized()) { stub->InitializeInterfaceDescriptor(descriptor); } } diff --git a/src/code-stubs.h b/src/code-stubs.h index 5dc9896cf..ac59871ff 100644 --- a/src/code-stubs.h +++ b/src/code-stubs.h @@ -271,7 +271,81 @@ class PlatformCodeStub : public CodeStub { enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; -class CodeStubInterfaceDescriptor { + +class PlatformInterfaceDescriptor; + + +class InterfaceDescriptor { + public: + bool IsInitialized() const { return register_param_count_ >= 0; } + + int GetEnvironmentLength() const { return register_param_count_; } + + int GetRegisterParameterCount() const { return register_param_count_; } + + Register GetParameterRegister(int index) const { + return register_params_[index]; + } + + Representation GetParameterRepresentation(int index) const { + ASSERT(index < register_param_count_); + if (register_param_representations_.get() == NULL) { + return Representation::Tagged(); + } + + return register_param_representations_[index]; + } + + // "Environment" versions of parameter functions. The first register + // parameter (context) is not included. + int GetEnvironmentParameterCount() const { + return GetEnvironmentLength() - 1; + } + + Register GetEnvironmentParameterRegister(int index) const { + return GetParameterRegister(index + 1); + } + + Representation GetEnvironmentParameterRepresentation(int index) const { + return GetParameterRepresentation(index + 1); + } + + // Some platforms have extra information to associate with the descriptor. + PlatformInterfaceDescriptor* platform_specific_descriptor() const { + return platform_specific_descriptor_; + } + + static const Register ContextRegister(); + + protected: + InterfaceDescriptor(); + virtual ~InterfaceDescriptor() {} + + void Initialize(int register_parameter_count, Register* registers, + Representation* register_param_representations, + PlatformInterfaceDescriptor* platform_descriptor = NULL); + + private: + int register_param_count_; + + // The Register params are allocated dynamically by the + // InterfaceDescriptor, and freed on destruction. This is because static + // arrays of Registers cause creation of runtime static initializers + // which we don't want. + SmartArrayPointer register_params_; + // Specifies Representations for the stub's parameter. Points to an array of + // Representations of the same length of the numbers of parameters to the + // stub, or if NULL (the default value), Representation of each parameter + // assumed to be Tagged(). + SmartArrayPointer register_param_representations_; + + PlatformInterfaceDescriptor* platform_specific_descriptor_; + + DISALLOW_COPY_AND_ASSIGN(InterfaceDescriptor); +}; + + +class CodeStubInterfaceDescriptor: public InterfaceDescriptor { public: CodeStubInterfaceDescriptor(); @@ -287,11 +361,6 @@ class CodeStubInterfaceDescriptor { int hint_stack_parameter_count = -1, StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); - bool initialized() const { return register_param_count_ >= 0; } - - int environment_length() const { - return register_param_count_; - } void SetMissHandler(ExternalReference handler) { miss_handler_ = handler; @@ -310,78 +379,41 @@ class CodeStubInterfaceDescriptor { return has_miss_handler_; } - Register GetParameterRegister(int index) const { - return register_params_[index]; - } - - Representation GetRegisterParameterRepresentation(int index) const { - ASSERT(index < register_param_count_); - if (register_param_representations_.get() == NULL) { - return Representation::Tagged(); - } - - return register_param_representations_[index]; - } - - bool IsParameterCountRegister(int index) const { - return GetParameterRegister(index).is(stack_parameter_count_); + bool IsEnvironmentParameterCountRegister(int index) const { + return GetEnvironmentParameterRegister(index).is(stack_parameter_count_); } int GetHandlerParameterCount() const { - int params = environment_length(); + int params = GetEnvironmentParameterCount(); if (handler_arguments_mode_ == PASS_ARGUMENTS) { params += 1; } return params; } - int register_param_count() const { return register_param_count_; } int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } Register stack_parameter_count() const { return stack_parameter_count_; } StubFunctionMode function_mode() const { return function_mode_; } Address deoptimization_handler() const { return deoptimization_handler_; } - Representation* register_param_representations() const { - return register_param_representations_.get(); - } private: - int register_param_count_; - Register stack_parameter_count_; // If hint_stack_parameter_count_ > 0, the code stub can optimize the // return sequence. Default value is -1, which means it is ignored. int hint_stack_parameter_count_; StubFunctionMode function_mode_; - // The Register params are allocated dynamically by the - // CodeStubInterfaceDescriptor, and freed on destruction. This is because - // static arrays of Registers cause creation of runtime static initializers - // which we don't want. - SmartArrayPointer register_params_; - // Specifies Representations for the stub's parameter. Points to an array of - // Representations of the same length of the numbers of parameters to the - // stub, or if NULL (the default value), Representation of each parameter - // assumed to be Tagged(). - SmartArrayPointer register_param_representations_; Address deoptimization_handler_; HandlerArgumentsMode handler_arguments_mode_; ExternalReference miss_handler_; bool has_miss_handler_; - DISALLOW_COPY_AND_ASSIGN(CodeStubInterfaceDescriptor); }; -class PlatformCallInterfaceDescriptor; - - -class CallInterfaceDescriptor { +class CallInterfaceDescriptor: public InterfaceDescriptor { public: - CallInterfaceDescriptor() - : register_param_count_(-1), - register_params_(NULL), - param_representations_(NULL), - platform_specific_descriptor_(NULL) { } + CallInterfaceDescriptor() { } // A copy of the passed in registers and param_representations is made // and owned by the CallInterfaceDescriptor. @@ -392,31 +424,7 @@ class CallInterfaceDescriptor { // The same should go for the CodeStubInterfaceDescriptor class. void Initialize(int register_parameter_count, Register* registers, Representation* param_representations, - PlatformCallInterfaceDescriptor* platform_descriptor = NULL); - - bool initialized() const { return register_param_count_ >= 0; } - - int environment_length() const { - return register_param_count_; - } - - Representation GetParameterRepresentation(int index) const { - return param_representations_[index]; - } - - Register GetParameterRegister(int index) const { - return register_params_[index]; - } - - PlatformCallInterfaceDescriptor* platform_specific_descriptor() const { - return platform_specific_descriptor_; - } - - private: - int register_param_count_; - SmartArrayPointer register_params_; - SmartArrayPointer param_representations_; - PlatformCallInterfaceDescriptor* platform_specific_descriptor_; + PlatformInterfaceDescriptor* platform_descriptor = NULL); }; diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc index d8dff9de8..bf215c8f3 100644 --- a/src/deoptimizer.cc +++ b/src/deoptimizer.cc @@ -1557,9 +1557,11 @@ void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator, // and the standard stack frame slots. Include space for an argument // object to the callee and optionally the space to pass the argument // object to the stub failure handler. - CHECK_GE(descriptor->register_param_count(), 0); - int height_in_bytes = kPointerSize * descriptor->register_param_count() + - sizeof(Arguments) + kPointerSize; + int param_count = descriptor->GetEnvironmentParameterCount(); + CHECK_GE(param_count, 0); + + int height_in_bytes = kPointerSize * param_count + sizeof(Arguments) + + kPointerSize; int fixed_frame_size = StandardFrameConstants::kFixedFrameSize; int input_frame_size = input_->GetFrameSize(); int output_frame_size = height_in_bytes + fixed_frame_size; @@ -1701,11 +1703,12 @@ void Deoptimizer::DoComputeCompiledStubFrame(TranslationIterator* iterator, // Copy the register parameters to the failure frame. int arguments_length_offset = -1; - for (int i = 0; i < descriptor->register_param_count(); ++i) { + for (int i = 0; i < param_count; ++i) { output_frame_offset -= kPointerSize; DoTranslateCommand(iterator, 0, output_frame_offset); - if (!arg_count_known && descriptor->IsParameterCountRegister(i)) { + if (!arg_count_known && + descriptor->IsEnvironmentParameterCountRegister(i)) { arguments_length_offset = output_frame_offset; } } diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 425683c4f..77874b068 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -2322,9 +2322,9 @@ class HCallWithDescriptor V8_FINAL : public HInstruction { static HCallWithDescriptor* New(Zone* zone, HValue* context, HValue* target, int argument_count, - const CallInterfaceDescriptor* descriptor, + const InterfaceDescriptor* descriptor, const Vector& operands) { - ASSERT(operands.length() == descriptor->environment_length()); + ASSERT(operands.length() == descriptor->GetEnvironmentLength()); HCallWithDescriptor* res = new(zone) HCallWithDescriptor(target, argument_count, descriptor, operands, zone); @@ -2344,7 +2344,7 @@ class HCallWithDescriptor V8_FINAL : public HInstruction { return Representation::Tagged(); } else { int par_index = index - 1; - ASSERT(par_index < descriptor_->environment_length()); + ASSERT(par_index < descriptor_->GetEnvironmentLength()); return descriptor_->GetParameterRepresentation(par_index); } } @@ -2363,7 +2363,7 @@ class HCallWithDescriptor V8_FINAL : public HInstruction { return -argument_count_; } - const CallInterfaceDescriptor* descriptor() const { + const InterfaceDescriptor* descriptor() const { return descriptor_; } @@ -2377,11 +2377,11 @@ class HCallWithDescriptor V8_FINAL : public HInstruction { // The argument count includes the receiver. HCallWithDescriptor(HValue* target, int argument_count, - const CallInterfaceDescriptor* descriptor, + const InterfaceDescriptor* descriptor, const Vector& operands, Zone* zone) : descriptor_(descriptor), - values_(descriptor->environment_length() + 1, zone) { + values_(descriptor->GetEnvironmentLength() + 1, zone) { argument_count_ = argument_count; AddOperand(target, zone); for (int i = 0; i < operands.length(); i++) { @@ -2401,7 +2401,7 @@ class HCallWithDescriptor V8_FINAL : public HInstruction { values_[index] = value; } - const CallInterfaceDescriptor* descriptor_; + const InterfaceDescriptor* descriptor_; ZoneList values_; int argument_count_; }; diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 9dc40f09d..0e9b95e69 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -3431,8 +3431,8 @@ HGraph::HGraph(CompilationInfo* info) if (info->IsStub()) { HydrogenCodeStub* stub = info->code_stub(); CodeStubInterfaceDescriptor* descriptor = stub->GetInterfaceDescriptor(); - start_environment_ = - new(zone_) HEnvironment(zone_, descriptor->environment_length()); + start_environment_ = new(zone_) HEnvironment( + zone_, descriptor->GetEnvironmentParameterCount()); } else { TraceInlinedFunction(info->shared_info(), HSourcePosition::Unknown()); start_environment_ = @@ -7349,7 +7349,7 @@ HInstruction* HOptimizedGraphBuilder::NewArgumentAdaptorCall( HValue* arity = Add(argument_count - 1); - HValue* op_vals[] = { fun, context, arity, expected_param_count }; + HValue* op_vals[] = { context, fun, arity, expected_param_count }; Handle adaptor = isolate()->builtins()->ArgumentsAdaptorTrampoline(); @@ -7357,7 +7357,7 @@ HInstruction* HOptimizedGraphBuilder::NewArgumentAdaptorCall( return New( adaptor_value, argument_count, descriptor, - Vector(op_vals, descriptor->environment_length())); + Vector(op_vals, descriptor->GetEnvironmentLength())); } @@ -8587,11 +8587,11 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle function, HValue* api_function_address = Add(ExternalReference(ref)); HValue* op_vals[] = { + context(), Add(function), call_data, holder, - api_function_address, - context() + api_function_address }; CallInterfaceDescriptor* descriptor = @@ -8602,11 +8602,11 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle function, HConstant* code_value = Add(code); ASSERT((sizeof(op_vals) / kPointerSize) == - descriptor->environment_length()); + descriptor->GetEnvironmentLength()); HInstruction* call = New( code_value, argc + 1, descriptor, - Vector(op_vals, descriptor->environment_length())); + Vector(op_vals, descriptor->GetEnvironmentLength())); if (drop_extra) Drop(1); // Drop function. ast_context()->ReturnInstruction(call, ast_id); diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc index 0f0193491..96ca1ba2d 100644 --- a/src/ia32/code-stubs-ia32.cc +++ b/src/ia32/code-stubs-ia32.cc @@ -21,7 +21,7 @@ namespace internal { void FastNewClosureStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { ebx }; + Register registers[] = { esi, ebx }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry); @@ -30,21 +30,22 @@ void FastNewClosureStub::InitializeInterfaceDescriptor( void FastNewContextStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { edi }; + Register registers[] = { esi, edi }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void ToNumberStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { eax }; + // ToNumberStub invokes a function, and therefore needs a context. + Register registers[] = { esi, eax }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void NumberToStringStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { eax }; + Register registers[] = { esi, eax }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry); @@ -53,8 +54,9 @@ void NumberToStringStub::InitializeInterfaceDescriptor( void FastCloneShallowArrayStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { eax, ebx, ecx }; + Register registers[] = { esi, eax, ebx, ecx }; Representation representations[] = { + Representation::Tagged(), Representation::Tagged(), Representation::Smi(), Representation::Tagged() }; @@ -69,7 +71,7 @@ void FastCloneShallowArrayStub::InitializeInterfaceDescriptor( void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { eax, ebx, ecx, edx }; + Register registers[] = { esi, eax, ebx, ecx, edx }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry); @@ -78,14 +80,14 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( void CreateAllocationSiteStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { ebx, edx }; + Register registers[] = { esi, ebx, edx }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void RegExpConstructResultStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { ecx, ebx, eax }; + Register registers[] = { esi, ecx, ebx, eax }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); @@ -94,13 +96,16 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor( void TransitionElementsKindStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { eax, ebx }; + Register registers[] = { esi, eax, ebx }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry); } +const Register InterfaceDescriptor::ContextRegister() { return esi; } + + static void InitializeArrayConstructorDescriptor( Isolate* isolate, CodeStubInterfaceDescriptor* descriptor, @@ -113,7 +118,7 @@ static void InitializeArrayConstructorDescriptor( Runtime::kArrayConstructor)->entry; if (constant_stack_parameter_count == 0) { - Register registers[] = { edi, ebx }; + Register registers[] = { esi, edi, ebx }; descriptor->Initialize(ARRAY_SIZE(registers), registers, deopt_handler, NULL, @@ -121,8 +126,9 @@ static void InitializeArrayConstructorDescriptor( JS_FUNCTION_STUB_MODE); } else { // stack param count needs (constructor pointer, and single argument) - Register registers[] = { edi, ebx, eax }; + Register registers[] = { esi, edi, ebx, eax }; Representation representations[] = { + Representation::Tagged(), Representation::Tagged(), Representation::Tagged(), Representation::Integer32() }; @@ -147,7 +153,7 @@ static void InitializeInternalArrayConstructorDescriptor( Runtime::kInternalArrayConstructor)->entry; if (constant_stack_parameter_count == 0) { - Register registers[] = { edi }; + Register registers[] = { esi, edi }; descriptor->Initialize(ARRAY_SIZE(registers), registers, deopt_handler, NULL, @@ -155,8 +161,9 @@ static void InitializeInternalArrayConstructorDescriptor( JS_FUNCTION_STUB_MODE); } else { // stack param count needs (constructor pointer, and single argument) - Register registers[] = { edi, eax }; + Register registers[] = { esi, edi, eax }; Representation representations[] = { + Representation::Tagged(), Representation::Tagged(), Representation::Integer32() }; descriptor->Initialize(ARRAY_SIZE(registers), registers, @@ -208,7 +215,7 @@ void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( void CompareNilICStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { eax }; + Register registers[] = { esi, eax }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(CompareNilIC_Miss)); descriptor->SetMissHandler( @@ -217,7 +224,7 @@ void CompareNilICStub::InitializeInterfaceDescriptor( void ToBooleanStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { eax }; + Register registers[] = { esi, eax }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(ToBooleanIC_Miss)); descriptor->SetMissHandler( @@ -227,7 +234,7 @@ void ToBooleanStub::InitializeInterfaceDescriptor( void BinaryOpICStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { edx, eax }; + Register registers[] = { esi, edx, eax }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(BinaryOpIC_Miss)); descriptor->SetMissHandler( @@ -237,7 +244,7 @@ void BinaryOpICStub::InitializeInterfaceDescriptor( void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { ecx, edx, eax }; + Register registers[] = { esi, ecx, edx, eax }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite)); } @@ -245,7 +252,7 @@ void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor( void StringAddStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { edx, eax }; + Register registers[] = { esi, edx, eax }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kStringAdd)->entry); @@ -256,14 +263,14 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) { { CallInterfaceDescriptor* descriptor = isolate->call_descriptor(Isolate::ArgumentAdaptorCall); - Register registers[] = { edi, // JSFunction - esi, // context + Register registers[] = { esi, // context + edi, // JSFunction eax, // actual number of arguments ebx, // expected number of arguments }; Representation representations[] = { - Representation::Tagged(), // JSFunction Representation::Tagged(), // context + Representation::Tagged(), // JSFunction Representation::Integer32(), // actual number of arguments Representation::Integer32(), // expected number of arguments }; @@ -297,29 +304,29 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) { CallInterfaceDescriptor* descriptor = isolate->call_descriptor(Isolate::CallHandler); Register registers[] = { esi, // context - edx, // receiver + edx, // name }; Representation representations[] = { - Representation::Tagged(), // context - Representation::Tagged(), // receiver + Representation::Tagged(), // context + Representation::Tagged(), // receiver }; descriptor->Initialize(ARRAY_SIZE(registers), registers, representations); } { CallInterfaceDescriptor* descriptor = isolate->call_descriptor(Isolate::ApiFunctionCall); - Register registers[] = { eax, // callee + Register registers[] = { esi, // context + eax, // callee ebx, // call_data ecx, // holder edx, // api_function_address - esi, // context }; Representation representations[] = { + Representation::Tagged(), // context Representation::Tagged(), // callee Representation::Tagged(), // call_data Representation::Tagged(), // holder Representation::External(), // api_function_address - Representation::Tagged(), // context }; descriptor->Initialize(ARRAY_SIZE(registers), registers, representations); } @@ -334,18 +341,19 @@ void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) { isolate()->counters()->code_stubs()->Increment(); CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor(); - int param_count = descriptor->register_param_count(); + int param_count = descriptor->GetEnvironmentParameterCount(); { // Call the runtime system in a fresh internal frame. FrameScope scope(masm, StackFrame::INTERNAL); - ASSERT(descriptor->register_param_count() == 0 || - eax.is(descriptor->GetParameterRegister(param_count - 1))); + ASSERT(param_count == 0 || + eax.is(descriptor->GetEnvironmentParameterRegister( + param_count - 1))); // Push arguments for (int i = 0; i < param_count; ++i) { - __ push(descriptor->GetParameterRegister(i)); + __ push(descriptor->GetEnvironmentParameterRegister(i)); } ExternalReference miss = descriptor->miss_handler(); - __ CallExternalReference(miss, descriptor->register_param_count()); + __ CallExternalReference(miss, param_count); } __ ret(0); diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index c40828836..feb714759 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -1125,8 +1125,7 @@ LInstruction* LChunkBuilder::DoCallJSFunction( LInstruction* LChunkBuilder::DoCallWithDescriptor( HCallWithDescriptor* instr) { - const CallInterfaceDescriptor* descriptor = instr->descriptor(); - + const InterfaceDescriptor* descriptor = instr->descriptor(); LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList ops(instr->OperandCount(), zone()); ops.Add(target, zone()); @@ -2473,7 +2472,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { CodeStubInterfaceDescriptor* descriptor = info()->code_stub()->GetInterfaceDescriptor(); int index = static_cast(instr->index()); - Register reg = descriptor->GetParameterRegister(index); + Register reg = descriptor->GetEnvironmentParameterRegister(index); return DefineFixed(result, reg); } } diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h index 6afe809ac..4a6ec75b1 100644 --- a/src/ia32/lithium-ia32.h +++ b/src/ia32/lithium-ia32.h @@ -1863,11 +1863,11 @@ class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> { class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> { public: - LCallWithDescriptor(const CallInterfaceDescriptor* descriptor, + LCallWithDescriptor(const InterfaceDescriptor* descriptor, const ZoneList& operands, Zone* zone) - : inputs_(descriptor->environment_length() + 1, zone) { - ASSERT(descriptor->environment_length() + 1 == operands.length()); + : inputs_(descriptor->GetRegisterParameterCount() + 1, zone) { + ASSERT(descriptor->GetRegisterParameterCount() + 1 == operands.length()); inputs_.AddAll(operands, zone); } diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc index 48668d38e..5041d9424 100644 --- a/src/x64/code-stubs-x64.cc +++ b/src/x64/code-stubs-x64.cc @@ -18,7 +18,7 @@ namespace internal { void FastNewClosureStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rbx }; + Register registers[] = { rsi, rbx }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry); @@ -27,21 +27,21 @@ void FastNewClosureStub::InitializeInterfaceDescriptor( void FastNewContextStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rdi }; + Register registers[] = { rsi, rdi }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void ToNumberStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rax }; + Register registers[] = { rsi, rax }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void NumberToStringStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rax }; + Register registers[] = { rsi, rax }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry); @@ -50,8 +50,9 @@ void NumberToStringStub::InitializeInterfaceDescriptor( void FastCloneShallowArrayStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rax, rbx, rcx }; + Register registers[] = { rsi, rax, rbx, rcx }; Representation representations[] = { + Representation::Tagged(), Representation::Tagged(), Representation::Smi(), Representation::Tagged() }; @@ -66,7 +67,7 @@ void FastCloneShallowArrayStub::InitializeInterfaceDescriptor( void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rax, rbx, rcx, rdx }; + Register registers[] = { rsi, rax, rbx, rcx, rdx }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry); @@ -75,14 +76,14 @@ void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( void CreateAllocationSiteStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rbx, rdx }; + Register registers[] = { rsi, rbx, rdx }; descriptor->Initialize(ARRAY_SIZE(registers), registers); } void RegExpConstructResultStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rcx, rbx, rax }; + Register registers[] = { rsi, rcx, rbx, rax }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); @@ -91,13 +92,16 @@ void RegExpConstructResultStub::InitializeInterfaceDescriptor( void TransitionElementsKindStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rax, rbx }; + Register registers[] = { rsi, rax, rbx }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry); } +const Register InterfaceDescriptor::ContextRegister() { return rsi; } + + static void InitializeArrayConstructorDescriptor( CodeStubInterfaceDescriptor* descriptor, int constant_stack_parameter_count) { @@ -109,7 +113,7 @@ static void InitializeArrayConstructorDescriptor( Runtime::kArrayConstructor)->entry; if (constant_stack_parameter_count == 0) { - Register registers[] = { rdi, rbx }; + Register registers[] = { rsi, rdi, rbx }; descriptor->Initialize(ARRAY_SIZE(registers), registers, deopt_handler, NULL, @@ -117,8 +121,9 @@ static void InitializeArrayConstructorDescriptor( JS_FUNCTION_STUB_MODE); } else { // stack param count needs (constructor pointer, and single argument) - Register registers[] = { rdi, rbx, rax }; + Register registers[] = { rsi, rdi, rbx, rax }; Representation representations[] = { + Representation::Tagged(), Representation::Tagged(), Representation::Tagged(), Representation::Integer32() }; @@ -137,13 +142,14 @@ static void InitializeInternalArrayConstructorDescriptor( CodeStubInterfaceDescriptor* descriptor, int constant_stack_parameter_count) { // register state + // rsi -- context // rax -- number of arguments // rdi -- constructor function Address deopt_handler = Runtime::FunctionForId( Runtime::kInternalArrayConstructor)->entry; if (constant_stack_parameter_count == 0) { - Register registers[] = { rdi }; + Register registers[] = { rsi, rdi }; descriptor->Initialize(ARRAY_SIZE(registers), registers, deopt_handler, NULL, @@ -151,8 +157,9 @@ static void InitializeInternalArrayConstructorDescriptor( JS_FUNCTION_STUB_MODE); } else { // stack param count needs (constructor pointer, and single argument) - Register registers[] = { rdi, rax }; + Register registers[] = { rsi, rdi, rax }; Representation representations[] = { + Representation::Tagged(), Representation::Tagged(), Representation::Integer32() }; descriptor->Initialize(ARRAY_SIZE(registers), registers, @@ -204,7 +211,7 @@ void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( void CompareNilICStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rax }; + Register registers[] = { rsi, rax }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(CompareNilIC_Miss)); descriptor->SetMissHandler( @@ -214,7 +221,7 @@ void CompareNilICStub::InitializeInterfaceDescriptor( void ToBooleanStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rax }; + Register registers[] = { rsi, rax }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(ToBooleanIC_Miss)); descriptor->SetMissHandler( @@ -224,7 +231,7 @@ void ToBooleanStub::InitializeInterfaceDescriptor( void BinaryOpICStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rdx, rax }; + Register registers[] = { rsi, rdx, rax }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(BinaryOpIC_Miss)); descriptor->SetMissHandler( @@ -234,7 +241,7 @@ void BinaryOpICStub::InitializeInterfaceDescriptor( void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rcx, rdx, rax }; + Register registers[] = { rsi, rcx, rdx, rax }; descriptor->Initialize(ARRAY_SIZE(registers), registers, FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite)); } @@ -242,7 +249,7 @@ void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor( void StringAddStub::InitializeInterfaceDescriptor( CodeStubInterfaceDescriptor* descriptor) { - Register registers[] = { rdx, rax }; + Register registers[] = { rsi, rdx, rax }; descriptor->Initialize( ARRAY_SIZE(registers), registers, Runtime::FunctionForId(Runtime::kStringAdd)->entry); @@ -253,14 +260,14 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) { { CallInterfaceDescriptor* descriptor = isolate->call_descriptor(Isolate::ArgumentAdaptorCall); - Register registers[] = { rdi, // JSFunction - rsi, // context + Register registers[] = { rsi, // context + rdi, // JSFunction rax, // actual number of arguments rbx, // expected number of arguments }; Representation representations[] = { - Representation::Tagged(), // JSFunction Representation::Tagged(), // context + Representation::Tagged(), // JSFunction Representation::Integer32(), // actual number of arguments Representation::Integer32(), // expected number of arguments }; @@ -305,18 +312,18 @@ void CallDescriptors::InitializeForIsolate(Isolate* isolate) { { CallInterfaceDescriptor* descriptor = isolate->call_descriptor(Isolate::ApiFunctionCall); - Register registers[] = { rax, // callee + Register registers[] = { rsi, // context + rax, // callee rbx, // call_data rcx, // holder rdx, // api_function_address - rsi, // context }; Representation representations[] = { + Representation::Tagged(), // context Representation::Tagged(), // callee Representation::Tagged(), // call_data Representation::Tagged(), // holder Representation::External(), // api_function_address - Representation::Tagged(), // context }; descriptor->Initialize(ARRAY_SIZE(registers), registers, representations); } @@ -331,18 +338,19 @@ void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) { isolate()->counters()->code_stubs()->Increment(); CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor(); - int param_count = descriptor->register_param_count(); + int param_count = descriptor->GetEnvironmentParameterCount(); { // Call the runtime system in a fresh internal frame. FrameScope scope(masm, StackFrame::INTERNAL); - ASSERT(descriptor->register_param_count() == 0 || - rax.is(descriptor->GetParameterRegister(param_count - 1))); + ASSERT(param_count == 0 || + rax.is(descriptor->GetEnvironmentParameterRegister( + param_count - 1))); // Push arguments for (int i = 0; i < param_count; ++i) { - __ Push(descriptor->GetParameterRegister(i)); + __ Push(descriptor->GetEnvironmentParameterRegister(i)); } ExternalReference miss = descriptor->miss_handler(); - __ CallExternalReference(miss, descriptor->register_param_count()); + __ CallExternalReference(miss, param_count); } __ Ret(); diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index c0be3a53b..f1821d355 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -1104,7 +1104,7 @@ LInstruction* LChunkBuilder::DoCallJSFunction( LInstruction* LChunkBuilder::DoCallWithDescriptor( HCallWithDescriptor* instr) { - const CallInterfaceDescriptor* descriptor = instr->descriptor(); + const InterfaceDescriptor* descriptor = instr->descriptor(); LOperand* target = UseRegisterOrConstantAtStart(instr->target()); ZoneList ops(instr->OperandCount(), zone()); @@ -2451,7 +2451,7 @@ LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { CodeStubInterfaceDescriptor* descriptor = info()->code_stub()->GetInterfaceDescriptor(); int index = static_cast(instr->index()); - Register reg = descriptor->GetParameterRegister(index); + Register reg = descriptor->GetEnvironmentParameterRegister(index); return DefineFixed(result, reg); } } diff --git a/src/x64/lithium-x64.h b/src/x64/lithium-x64.h index ee7d160a4..a64f6a1d2 100644 --- a/src/x64/lithium-x64.h +++ b/src/x64/lithium-x64.h @@ -1850,11 +1850,11 @@ class LCallJSFunction V8_FINAL : public LTemplateInstruction<1, 1, 0> { class LCallWithDescriptor V8_FINAL : public LTemplateResultInstruction<1> { public: - LCallWithDescriptor(const CallInterfaceDescriptor* descriptor, + LCallWithDescriptor(const InterfaceDescriptor* descriptor, const ZoneList& operands, Zone* zone) - : inputs_(descriptor->environment_length() + 1, zone) { - ASSERT(descriptor->environment_length() + 1 == operands.length()); + : inputs_(descriptor->GetRegisterParameterCount() + 1, zone) { + ASSERT(descriptor->GetRegisterParameterCount() + 1 == operands.length()); inputs_.AddAll(operands, zone); } -- 2.34.1