Commit d13e9c69 authored by jgruber's avatar jgruber Committed by Commit Bot

[ia32] Unalias kRootRegister in IC, Construct and ArgumentsAdaptor descriptors

This replaces ebx usage in several more interface descriptors.

- IC descriptors already passed most arguments on the stack (updated
  their Register accessors to reflect that).
- The allocation site argument appears to be unused in the
  ConstructStub descriptor. It can probably be removed in a follow-up.

Drive-by: Rename ArgumentAdaptorDescriptor to
ArgumentsAdaptorDescriptor to match the builtin name.

Bug: v8:6666
Change-Id: I4cdf1775a5b4b74491d6d303c49a8af9b6cd3c03
Reviewed-on: https://chromium-review.googlesource.com/1195367
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55495}
parent dd6290d1
...@@ -193,7 +193,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific( ...@@ -193,7 +193,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void ArgumentAdaptorDescriptor::InitializePlatformSpecific( void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
Register registers[] = { Register registers[] = {
r1, // JSFunction r1, // JSFunction
......
...@@ -198,7 +198,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific( ...@@ -198,7 +198,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void ArgumentAdaptorDescriptor::InitializePlatformSpecific( void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
Register registers[] = { Register registers[] = {
x1, // JSFunction x1, // JSFunction
......
...@@ -1208,7 +1208,7 @@ namespace internal { ...@@ -1208,7 +1208,7 @@ namespace internal {
/* Wasm */ \ /* Wasm */ \
ASM(WasmCompileLazy) \ ASM(WasmCompileLazy) \
TFC(WasmAllocateHeapNumber, AllocateHeapNumber, 1) \ TFC(WasmAllocateHeapNumber, AllocateHeapNumber, 1) \
TFC(WasmArgumentsAdaptor, ArgumentAdaptor, 1) \ TFC(WasmArgumentsAdaptor, ArgumentsAdaptor, 1) \
TFC(WasmCallJavaScript, CallTrampoline, 1) \ TFC(WasmCallJavaScript, CallTrampoline, 1) \
TFC(WasmGrowMemory, WasmGrowMemory, 1) \ TFC(WasmGrowMemory, WasmGrowMemory, 1) \
TFC(WasmStackGuard, NoContext, 1) \ TFC(WasmStackGuard, NoContext, 1) \
......
...@@ -63,7 +63,7 @@ TF_BUILTIN(WasmArgumentsAdaptor, WasmBuiltinsAssembler) { ...@@ -63,7 +63,7 @@ TF_BUILTIN(WasmArgumentsAdaptor, WasmBuiltinsAssembler) {
TNode<Object> argc2 = UncheckedParameter(Descriptor::kExpectedArgumentsCount); TNode<Object> argc2 = UncheckedParameter(Descriptor::kExpectedArgumentsCount);
TNode<Code> target = TNode<Code> target =
LoadBuiltinFromFrame(Builtins::kArgumentsAdaptorTrampoline); LoadBuiltinFromFrame(Builtins::kArgumentsAdaptorTrampoline);
TailCallStub(ArgumentAdaptorDescriptor{}, target, context, function, TailCallStub(ArgumentsAdaptorDescriptor{}, target, context, function,
new_target, argc1, argc2); new_target, argc1, argc2);
} }
......
...@@ -2116,10 +2116,6 @@ void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { ...@@ -2116,10 +2116,6 @@ void Builtins::Generate_ConstructFunction(MacroAssembler* masm) {
__ AssertConstructor(edi); __ AssertConstructor(edi);
__ AssertFunction(edi); __ AssertFunction(edi);
// Calling convention for function specific ConstructStubs require
// ebx to contain either an AllocationSite or undefined.
__ LoadRoot(ebx, Heap::kUndefinedValueRootIndex);
Label call_generic_stub; Label call_generic_stub;
// Jump to JSBuiltinsConstructStub or JSConstructStubGeneric. // Jump to JSBuiltinsConstructStub or JSConstructStubGeneric.
...@@ -2128,10 +2124,16 @@ void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { ...@@ -2128,10 +2124,16 @@ void Builtins::Generate_ConstructFunction(MacroAssembler* masm) {
Immediate(SharedFunctionInfo::ConstructAsBuiltinBit::kMask)); Immediate(SharedFunctionInfo::ConstructAsBuiltinBit::kMask));
__ j(zero, &call_generic_stub, Label::kNear); __ j(zero, &call_generic_stub, Label::kNear);
// Calling convention for function specific ConstructStubs require
// ecx to contain either an AllocationSite or undefined.
__ LoadRoot(ecx, Heap::kUndefinedValueRootIndex);
__ Jump(BUILTIN_CODE(masm->isolate(), JSBuiltinsConstructStub), __ Jump(BUILTIN_CODE(masm->isolate(), JSBuiltinsConstructStub),
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
__ bind(&call_generic_stub); __ bind(&call_generic_stub);
// Calling convention for function specific ConstructStubs require
// ecx to contain either an AllocationSite or undefined.
__ LoadRoot(ecx, Heap::kUndefinedValueRootIndex);
__ Jump(BUILTIN_CODE(masm->isolate(), JSConstructStubGeneric), __ Jump(BUILTIN_CODE(masm->isolate(), JSConstructStubGeneric),
RelocInfo::CODE_TARGET); RelocInfo::CODE_TARGET);
} }
...@@ -2220,28 +2222,32 @@ void Builtins::Generate_Construct(MacroAssembler* masm) { ...@@ -2220,28 +2222,32 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
// ----------- S t a t e ------------- // ----------- S t a t e -------------
// -- eax : actual number of arguments // -- eax : actual number of arguments
// -- ebx : expected number of arguments // -- ecx : expected number of arguments
// -- edx : new target (passed through to callee) // -- edx : new target (passed through to callee)
// -- edi : function (passed through to callee) // -- edi : function (passed through to callee)
// ----------------------------------- // -----------------------------------
const Register kExpectedNumberOfArgumentsRegister = ecx;
Label invoke, dont_adapt_arguments, stack_overflow; Label invoke, dont_adapt_arguments, stack_overflow;
__ IncrementCounter(masm->isolate()->counters()->arguments_adaptors(), 1); __ IncrementCounter(masm->isolate()->counters()->arguments_adaptors(), 1);
Label enough, too_few; Label enough, too_few;
__ cmp(ebx, SharedFunctionInfo::kDontAdaptArgumentsSentinel); __ cmp(kExpectedNumberOfArgumentsRegister,
SharedFunctionInfo::kDontAdaptArgumentsSentinel);
__ j(equal, &dont_adapt_arguments); __ j(equal, &dont_adapt_arguments);
__ cmp(eax, ebx); __ cmp(eax, kExpectedNumberOfArgumentsRegister);
__ j(less, &too_few); __ j(less, &too_few);
{ // Enough parameters: Actual >= expected. { // Enough parameters: Actual >= expected.
__ bind(&enough); __ bind(&enough);
EnterArgumentsAdaptorFrame(masm); EnterArgumentsAdaptorFrame(masm);
// edi is used as a scratch register. It should be restored from the frame Generate_StackOverflowCheck(masm, kExpectedNumberOfArgumentsRegister, ebx,
// when needed. &stack_overflow);
Generate_StackOverflowCheck(masm, ebx, ecx, &stack_overflow);
// Copy receiver and all expected arguments. // Copy receiver and all expected arguments.
// edi is used as a scratch register. It should be restored from the frame
// when needed.
const int offset = StandardFrameConstants::kCallerSPOffset; const int offset = StandardFrameConstants::kCallerSPOffset;
__ lea(edi, Operand(ebp, eax, times_4, offset)); __ lea(edi, Operand(ebp, eax, times_4, offset));
__ mov(eax, -1); // account for receiver __ mov(eax, -1); // account for receiver
...@@ -2251,7 +2257,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { ...@@ -2251,7 +2257,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
__ inc(eax); __ inc(eax);
__ push(Operand(edi, 0)); __ push(Operand(edi, 0));
__ sub(edi, Immediate(kPointerSize)); __ sub(edi, Immediate(kPointerSize));
__ cmp(eax, ebx); __ cmp(eax, kExpectedNumberOfArgumentsRegister);
__ j(less, &copy); __ j(less, &copy);
// eax now contains the expected number of arguments. // eax now contains the expected number of arguments.
__ jmp(&invoke); __ jmp(&invoke);
...@@ -2262,16 +2268,17 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { ...@@ -2262,16 +2268,17 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
EnterArgumentsAdaptorFrame(masm); EnterArgumentsAdaptorFrame(masm);
// edi is used as a scratch register. It should be restored from the frame // edi is used as a scratch register. It should be restored from the frame
// when needed. // when needed.
Generate_StackOverflowCheck(masm, ebx, ecx, &stack_overflow); Generate_StackOverflowCheck(masm, kExpectedNumberOfArgumentsRegister, ebx,
&stack_overflow);
// Remember expected arguments in ecx. // Remember expected arguments in ebx.
__ mov(ecx, ebx); __ mov(ebx, kExpectedNumberOfArgumentsRegister);
// Copy receiver and all actual arguments. // Copy receiver and all actual arguments.
const int offset = StandardFrameConstants::kCallerSPOffset; const int offset = StandardFrameConstants::kCallerSPOffset;
__ lea(edi, Operand(ebp, eax, times_4, offset)); __ lea(edi, Operand(ebp, eax, times_4, offset));
// ebx = expected - actual. // ecx = expected - actual.
__ sub(ebx, eax); __ sub(kExpectedNumberOfArgumentsRegister, eax);
// eax = -actual - 1 // eax = -actual - 1
__ neg(eax); __ neg(eax);
__ sub(eax, Immediate(1)); __ sub(eax, Immediate(1));
...@@ -2289,11 +2296,11 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { ...@@ -2289,11 +2296,11 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
__ bind(&fill); __ bind(&fill);
__ inc(eax); __ inc(eax);
__ push(Immediate(masm->isolate()->factory()->undefined_value())); __ push(Immediate(masm->isolate()->factory()->undefined_value()));
__ cmp(eax, ebx); __ cmp(eax, kExpectedNumberOfArgumentsRegister);
__ j(less, &fill); __ j(less, &fill);
// Restore expected arguments. // Restore expected arguments.
__ mov(eax, ecx); __ mov(eax, ebx);
} }
// Call the entry point. // Call the entry point.
......
...@@ -218,7 +218,7 @@ Callable CodeFactory::FastNewFunctionContext(Isolate* isolate, ...@@ -218,7 +218,7 @@ Callable CodeFactory::FastNewFunctionContext(Isolate* isolate,
// static // static
Callable CodeFactory::ArgumentAdaptor(Isolate* isolate) { Callable CodeFactory::ArgumentAdaptor(Isolate* isolate) {
return Callable(BUILTIN_CODE(isolate, ArgumentsAdaptorTrampoline), return Callable(BUILTIN_CODE(isolate, ArgumentsAdaptorTrampoline),
ArgumentAdaptorDescriptor{}); ArgumentsAdaptorDescriptor{});
} }
// static // static
......
...@@ -4533,7 +4533,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder { ...@@ -4533,7 +4533,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
} }
call_descriptor = Linkage::GetStubCallDescriptor( call_descriptor = Linkage::GetStubCallDescriptor(
mcgraph()->zone(), ArgumentAdaptorDescriptor{}, 1 + wasm_count, mcgraph()->zone(), ArgumentsAdaptorDescriptor{}, 1 + wasm_count,
CallDescriptor::kNoFlags, Operator::kNoProperties, CallDescriptor::kNoFlags, Operator::kNoProperties,
StubCallMode::kCallWasmRuntimeStub); StubCallMode::kCallWasmRuntimeStub);
......
...@@ -172,8 +172,9 @@ void ConstructStubDescriptor::InitializePlatformSpecific( ...@@ -172,8 +172,9 @@ void ConstructStubDescriptor::InitializePlatformSpecific(
// eax : number of arguments // eax : number of arguments
// edx : the new target // edx : the new target
// edi : the target to call // edi : the target to call
// ebx : allocation site or undefined // ecx : allocation site or undefined
Register registers[] = {edi, edx, eax, ebx}; // TODO(jgruber): Remove the unused allocation site parameter.
Register registers[] = {edi, edx, eax, ecx};
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
...@@ -201,13 +202,13 @@ void BinaryOpDescriptor::InitializePlatformSpecific( ...@@ -201,13 +202,13 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void ArgumentAdaptorDescriptor::InitializePlatformSpecific( void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
Register registers[] = { Register registers[] = {
edi, // JSFunction edi, // JSFunction
edx, // the new target edx, // the new target
eax, // actual number of arguments eax, // actual number of arguments
ebx, // expected number of arguments ecx, // expected number of arguments
}; };
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
......
...@@ -1079,6 +1079,9 @@ void MacroAssembler::InvokePrologue(const ParameterCount& expected, ...@@ -1079,6 +1079,9 @@ void MacroAssembler::InvokePrologue(const ParameterCount& expected,
} }
if (!definitely_matches) { if (!definitely_matches) {
// TODO(v8:6666): All call-sites should be updated to pass in ecx as the
// expected register to avoid this useless move.
MoveForRootRegisterRefactoring(ecx, ebx);
Handle<Code> adaptor = BUILTIN_CODE(isolate(), ArgumentsAdaptorTrampoline); Handle<Code> adaptor = BUILTIN_CODE(isolate(), ArgumentsAdaptorTrampoline);
if (flag == CALL_FUNCTION) { if (flag == CALL_FUNCTION) {
Call(adaptor, RelocInfo::CODE_TARGET); Call(adaptor, RelocInfo::CODE_TARGET);
......
...@@ -60,7 +60,7 @@ namespace internal { ...@@ -60,7 +60,7 @@ namespace internal {
V(StringAt) \ V(StringAt) \
V(StringSubstring) \ V(StringSubstring) \
V(GetProperty) \ V(GetProperty) \
V(ArgumentAdaptor) \ V(ArgumentsAdaptor) \
V(ApiCallback) \ V(ApiCallback) \
V(ApiGetter) \ V(ApiGetter) \
V(GrowArrayElements) \ V(GrowArrayElements) \
...@@ -775,6 +775,7 @@ class ConstructWithArrayLikeDescriptor : public CallInterfaceDescriptor { ...@@ -775,6 +775,7 @@ class ConstructWithArrayLikeDescriptor : public CallInterfaceDescriptor {
// TODO(ishell): consider merging this with ArrayConstructorDescriptor // TODO(ishell): consider merging this with ArrayConstructorDescriptor
class ConstructStubDescriptor : public CallInterfaceDescriptor { class ConstructStubDescriptor : public CallInterfaceDescriptor {
public: public:
// TODO(jgruber): Remove the unused allocation site parameter.
DEFINE_JS_PARAMETERS(kAllocationSite) DEFINE_JS_PARAMETERS(kAllocationSite)
DEFINE_JS_PARAMETER_TYPES(MachineType::AnyTagged()); DEFINE_JS_PARAMETER_TYPES(MachineType::AnyTagged());
...@@ -895,11 +896,11 @@ class StringSubstringDescriptor final : public CallInterfaceDescriptor { ...@@ -895,11 +896,11 @@ class StringSubstringDescriptor final : public CallInterfaceDescriptor {
DECLARE_DESCRIPTOR(StringSubstringDescriptor, CallInterfaceDescriptor) DECLARE_DESCRIPTOR(StringSubstringDescriptor, CallInterfaceDescriptor)
}; };
class ArgumentAdaptorDescriptor : public CallInterfaceDescriptor { class ArgumentsAdaptorDescriptor : public CallInterfaceDescriptor {
public: public:
DEFINE_JS_PARAMETERS(kExpectedArgumentsCount) DEFINE_JS_PARAMETERS(kExpectedArgumentsCount)
DEFINE_JS_PARAMETER_TYPES(MachineType::Int32()) DEFINE_JS_PARAMETER_TYPES(MachineType::Int32())
DECLARE_DESCRIPTOR(ArgumentAdaptorDescriptor, CallInterfaceDescriptor) DECLARE_DESCRIPTOR(ArgumentsAdaptorDescriptor, CallInterfaceDescriptor)
}; };
class CppBuiltinAdaptorDescriptor : public CallInterfaceDescriptor { class CppBuiltinAdaptorDescriptor : public CallInterfaceDescriptor {
......
...@@ -194,7 +194,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific( ...@@ -194,7 +194,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void ArgumentAdaptorDescriptor::InitializePlatformSpecific( void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
Register registers[] = { Register registers[] = {
a1, // JSFunction a1, // JSFunction
......
...@@ -194,7 +194,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific( ...@@ -194,7 +194,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void ArgumentAdaptorDescriptor::InitializePlatformSpecific( void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
Register registers[] = { Register registers[] = {
a1, // JSFunction a1, // JSFunction
......
...@@ -194,7 +194,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific( ...@@ -194,7 +194,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void ArgumentAdaptorDescriptor::InitializePlatformSpecific( void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
Register registers[] = { Register registers[] = {
r4, // JSFunction r4, // JSFunction
......
...@@ -192,7 +192,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific( ...@@ -192,7 +192,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void ArgumentAdaptorDescriptor::InitializePlatformSpecific( void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
Register registers[] = { Register registers[] = {
r3, // JSFunction r3, // JSFunction
......
...@@ -195,7 +195,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific( ...@@ -195,7 +195,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers); data->InitializePlatformSpecific(arraysize(registers), registers);
} }
void ArgumentAdaptorDescriptor::InitializePlatformSpecific( void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
Register registers[] = { Register registers[] = {
rdi, // JSFunction rdi, // JSFunction
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment