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(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r1, // JSFunction
......
......@@ -198,7 +198,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
x1, // JSFunction
......
......@@ -1208,7 +1208,7 @@ namespace internal {
/* Wasm */ \
ASM(WasmCompileLazy) \
TFC(WasmAllocateHeapNumber, AllocateHeapNumber, 1) \
TFC(WasmArgumentsAdaptor, ArgumentAdaptor, 1) \
TFC(WasmArgumentsAdaptor, ArgumentsAdaptor, 1) \
TFC(WasmCallJavaScript, CallTrampoline, 1) \
TFC(WasmGrowMemory, WasmGrowMemory, 1) \
TFC(WasmStackGuard, NoContext, 1) \
......
......@@ -63,7 +63,7 @@ TF_BUILTIN(WasmArgumentsAdaptor, WasmBuiltinsAssembler) {
TNode<Object> argc2 = UncheckedParameter(Descriptor::kExpectedArgumentsCount);
TNode<Code> target =
LoadBuiltinFromFrame(Builtins::kArgumentsAdaptorTrampoline);
TailCallStub(ArgumentAdaptorDescriptor{}, target, context, function,
TailCallStub(ArgumentsAdaptorDescriptor{}, target, context, function,
new_target, argc1, argc2);
}
......
......@@ -2116,10 +2116,6 @@ void Builtins::Generate_ConstructFunction(MacroAssembler* masm) {
__ AssertConstructor(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;
// Jump to JSBuiltinsConstructStub or JSConstructStubGeneric.
......@@ -2128,10 +2124,16 @@ void Builtins::Generate_ConstructFunction(MacroAssembler* masm) {
Immediate(SharedFunctionInfo::ConstructAsBuiltinBit::kMask));
__ 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),
RelocInfo::CODE_TARGET);
__ 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),
RelocInfo::CODE_TARGET);
}
......@@ -2220,28 +2222,32 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- eax : actual number of arguments
// -- ebx : expected number of arguments
// -- ecx : expected number of arguments
// -- edx : new target (passed through to callee)
// -- edi : function (passed through to callee)
// -----------------------------------
const Register kExpectedNumberOfArgumentsRegister = ecx;
Label invoke, dont_adapt_arguments, stack_overflow;
__ IncrementCounter(masm->isolate()->counters()->arguments_adaptors(), 1);
Label enough, too_few;
__ cmp(ebx, SharedFunctionInfo::kDontAdaptArgumentsSentinel);
__ cmp(kExpectedNumberOfArgumentsRegister,
SharedFunctionInfo::kDontAdaptArgumentsSentinel);
__ j(equal, &dont_adapt_arguments);
__ cmp(eax, ebx);
__ cmp(eax, kExpectedNumberOfArgumentsRegister);
__ j(less, &too_few);
{ // Enough parameters: Actual >= expected.
__ bind(&enough);
EnterArgumentsAdaptorFrame(masm);
// edi is used as a scratch register. It should be restored from the frame
// when needed.
Generate_StackOverflowCheck(masm, ebx, ecx, &stack_overflow);
Generate_StackOverflowCheck(masm, kExpectedNumberOfArgumentsRegister, ebx,
&stack_overflow);
// 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;
__ lea(edi, Operand(ebp, eax, times_4, offset));
__ mov(eax, -1); // account for receiver
......@@ -2251,7 +2257,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
__ inc(eax);
__ push(Operand(edi, 0));
__ sub(edi, Immediate(kPointerSize));
__ cmp(eax, ebx);
__ cmp(eax, kExpectedNumberOfArgumentsRegister);
__ j(less, &copy);
// eax now contains the expected number of arguments.
__ jmp(&invoke);
......@@ -2262,16 +2268,17 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
EnterArgumentsAdaptorFrame(masm);
// edi is used as a scratch register. It should be restored from the frame
// when needed.
Generate_StackOverflowCheck(masm, ebx, ecx, &stack_overflow);
Generate_StackOverflowCheck(masm, kExpectedNumberOfArgumentsRegister, ebx,
&stack_overflow);
// Remember expected arguments in ecx.
__ mov(ecx, ebx);
// Remember expected arguments in ebx.
__ mov(ebx, kExpectedNumberOfArgumentsRegister);
// Copy receiver and all actual arguments.
const int offset = StandardFrameConstants::kCallerSPOffset;
__ lea(edi, Operand(ebp, eax, times_4, offset));
// ebx = expected - actual.
__ sub(ebx, eax);
// ecx = expected - actual.
__ sub(kExpectedNumberOfArgumentsRegister, eax);
// eax = -actual - 1
__ neg(eax);
__ sub(eax, Immediate(1));
......@@ -2289,11 +2296,11 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
__ bind(&fill);
__ inc(eax);
__ push(Immediate(masm->isolate()->factory()->undefined_value()));
__ cmp(eax, ebx);
__ cmp(eax, kExpectedNumberOfArgumentsRegister);
__ j(less, &fill);
// Restore expected arguments.
__ mov(eax, ecx);
__ mov(eax, ebx);
}
// Call the entry point.
......
......@@ -218,7 +218,7 @@ Callable CodeFactory::FastNewFunctionContext(Isolate* isolate,
// static
Callable CodeFactory::ArgumentAdaptor(Isolate* isolate) {
return Callable(BUILTIN_CODE(isolate, ArgumentsAdaptorTrampoline),
ArgumentAdaptorDescriptor{});
ArgumentsAdaptorDescriptor{});
}
// static
......
......@@ -4533,7 +4533,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
}
call_descriptor = Linkage::GetStubCallDescriptor(
mcgraph()->zone(), ArgumentAdaptorDescriptor{}, 1 + wasm_count,
mcgraph()->zone(), ArgumentsAdaptorDescriptor{}, 1 + wasm_count,
CallDescriptor::kNoFlags, Operator::kNoProperties,
StubCallMode::kCallWasmRuntimeStub);
......
......@@ -172,8 +172,9 @@ void ConstructStubDescriptor::InitializePlatformSpecific(
// eax : number of arguments
// edx : the new target
// edi : the target to call
// ebx : allocation site or undefined
Register registers[] = {edi, edx, eax, ebx};
// ecx : allocation site or undefined
// TODO(jgruber): Remove the unused allocation site parameter.
Register registers[] = {edi, edx, eax, ecx};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
......@@ -201,13 +202,13 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
edi, // JSFunction
edx, // the new target
eax, // actual number of arguments
ebx, // expected number of arguments
ecx, // expected number of arguments
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
......
......@@ -1079,6 +1079,9 @@ void MacroAssembler::InvokePrologue(const ParameterCount& expected,
}
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);
if (flag == CALL_FUNCTION) {
Call(adaptor, RelocInfo::CODE_TARGET);
......
......@@ -60,7 +60,7 @@ namespace internal {
V(StringAt) \
V(StringSubstring) \
V(GetProperty) \
V(ArgumentAdaptor) \
V(ArgumentsAdaptor) \
V(ApiCallback) \
V(ApiGetter) \
V(GrowArrayElements) \
......@@ -775,6 +775,7 @@ class ConstructWithArrayLikeDescriptor : public CallInterfaceDescriptor {
// TODO(ishell): consider merging this with ArrayConstructorDescriptor
class ConstructStubDescriptor : public CallInterfaceDescriptor {
public:
// TODO(jgruber): Remove the unused allocation site parameter.
DEFINE_JS_PARAMETERS(kAllocationSite)
DEFINE_JS_PARAMETER_TYPES(MachineType::AnyTagged());
......@@ -895,11 +896,11 @@ class StringSubstringDescriptor final : public CallInterfaceDescriptor {
DECLARE_DESCRIPTOR(StringSubstringDescriptor, CallInterfaceDescriptor)
};
class ArgumentAdaptorDescriptor : public CallInterfaceDescriptor {
class ArgumentsAdaptorDescriptor : public CallInterfaceDescriptor {
public:
DEFINE_JS_PARAMETERS(kExpectedArgumentsCount)
DEFINE_JS_PARAMETER_TYPES(MachineType::Int32())
DECLARE_DESCRIPTOR(ArgumentAdaptorDescriptor, CallInterfaceDescriptor)
DECLARE_DESCRIPTOR(ArgumentsAdaptorDescriptor, CallInterfaceDescriptor)
};
class CppBuiltinAdaptorDescriptor : public CallInterfaceDescriptor {
......
......@@ -194,7 +194,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
a1, // JSFunction
......
......@@ -194,7 +194,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
a1, // JSFunction
......
......@@ -194,7 +194,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r4, // JSFunction
......
......@@ -192,7 +192,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r3, // JSFunction
......
......@@ -195,7 +195,7 @@ void BinaryOpDescriptor::InitializePlatformSpecific(
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
void ArgumentsAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
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