Commit c0356f1f authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[turbofan] Pass new.target to arguments adaptor trampoline.

This changes the interface descriptor for the arguments adaptor to also
contain an explicit register for the new.target value. Note that the
stub still clobbers the register for now.

This is a preparatory CL to allows us passing new.target in a register
instead of via a side-channel through the construct stub frame.

R=bmeurer@chromium.org
BUG=v8:4544
LOG=n

Review URL: https://codereview.chromium.org/1457313002

Cr-Commit-Position: refs/heads/master@{#32117}
parent 4bb6e7c8
......@@ -358,6 +358,7 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
Register registers[] = {
r1, // JSFunction
r3, // the new target
r0, // actual number of arguments
r2, // expected number of arguments
};
......
......@@ -387,6 +387,7 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
Register registers[] = {
x1, // JSFunction
x3, // the new target
x0, // actual number of arguments
x2, // expected number of arguments
};
......
......@@ -1817,11 +1817,11 @@ Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) {
flags |= CallDescriptor::kSupportsTailCalls;
}
Node* new_target = jsgraph()->UndefinedConstant();
Node* argument_count = jsgraph()->Int32Constant(arity);
if (shared->internal_formal_parameter_count() == arity ||
shared->internal_formal_parameter_count() ==
SharedFunctionInfo::kDontAdaptArgumentsSentinel) {
Node* new_target = jsgraph()->UndefinedConstant();
Node* argument_count = jsgraph()->Int32Constant(arity);
// Patch {node} to a direct call.
node->InsertInput(graph()->zone(), arity + 2, new_target);
node->InsertInput(graph()->zone(), arity + 3, argument_count);
......@@ -1833,9 +1833,10 @@ Reduction JSTypedLowering::ReduceJSCallFunction(Node* node) {
Callable callable = CodeFactory::ArgumentAdaptor(isolate());
node->InsertInput(graph()->zone(), 0,
jsgraph()->HeapConstant(callable.code()));
node->InsertInput(graph()->zone(), 2, jsgraph()->Int32Constant(arity));
node->InsertInput(graph()->zone(), 2, new_target);
node->InsertInput(graph()->zone(), 3, argument_count);
node->InsertInput(
graph()->zone(), 3,
graph()->zone(), 4,
jsgraph()->Int32Constant(shared->internal_formal_parameter_count()));
NodeProperties::ChangeOp(
node, common()->Call(Linkage::GetStubCallDescriptor(
......
......@@ -7977,16 +7977,15 @@ HInstruction* HOptimizedGraphBuilder::NewPlainFunctionCall(HValue* fun,
HInstruction* HOptimizedGraphBuilder::NewArgumentAdaptorCall(
HValue* fun, HValue* context,
int argument_count, HValue* expected_param_count) {
ArgumentAdaptorDescriptor descriptor(isolate());
HValue* new_target = graph()->GetConstantUndefined();
HValue* arity = Add<HConstant>(argument_count - 1);
HValue* op_vals[] = { context, fun, arity, expected_param_count };
HValue* op_vals[] = {context, fun, new_target, arity, expected_param_count};
Handle<Code> adaptor =
isolate()->builtins()->ArgumentsAdaptorTrampoline();
HConstant* adaptor_value = Add<HConstant>(adaptor);
Callable callable = CodeFactory::ArgumentAdaptor(isolate());
HConstant* stub = Add<HConstant>(callable.code());
return New<HCallWithDescriptor>(adaptor_value, argument_count, descriptor,
return New<HCallWithDescriptor>(stub, argument_count, callable.descriptor(),
Vector<HValue*>(op_vals, arraysize(op_vals)));
}
......
......@@ -348,6 +348,7 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
edi, // JSFunction
edx, // the new target
eax, // actual number of arguments
ebx, // expected number of arguments
};
......
......@@ -420,9 +420,8 @@ CallTrampolineDescriptor::BuildCallInterfaceDescriptorFunctionType(
Zone* zone = isolate->interface_descriptor_zone();
Type::FunctionType* function =
Type::FunctionType::New(AnyTagged(zone), Type::Undefined(), 2, zone);
function->InitParameter(0, AnyTagged(zone)); // target
function->InitParameter(
1, UntaggedIntegral32(zone)); // actual number of arguments
function->InitParameter(0, AnyTagged(zone)); // target
function->InitParameter(1, UntaggedIntegral32(zone)); // actual #arguments
return function;
}
......@@ -482,13 +481,11 @@ ArgumentAdaptorDescriptor::BuildCallInterfaceDescriptorFunctionType(
Isolate* isolate, int paramater_count) {
Zone* zone = isolate->interface_descriptor_zone();
Type::FunctionType* function =
Type::FunctionType::New(AnyTagged(zone), Type::Undefined(), 3, zone);
function->InitParameter(0, Type::Receiver()); // JSFunction
function->InitParameter(
1, UntaggedIntegral32(zone)); // actual number of arguments
function->InitParameter(
2,
UntaggedIntegral32(zone)); // expected number of arguments
Type::FunctionType::New(AnyTagged(zone), Type::Undefined(), 4, zone);
function->InitParameter(0, Type::Receiver()); // JSFunction
function->InitParameter(1, AnyTagged(zone)); // the new target
function->InitParameter(2, UntaggedIntegral32(zone)); // actual #arguments
function->InitParameter(3, UntaggedIntegral32(zone)); // expected #arguments
return function;
}
......@@ -499,12 +496,11 @@ ApiFunctionDescriptor::BuildCallInterfaceDescriptorFunctionType(
Zone* zone = isolate->interface_descriptor_zone();
Type::FunctionType* function =
Type::FunctionType::New(AnyTagged(zone), Type::Undefined(), 5, zone);
function->InitParameter(0, AnyTagged(zone)); // callee
function->InitParameter(1, AnyTagged(zone)); // call_data
function->InitParameter(2, AnyTagged(zone)); // holder
function->InitParameter(3, ExternalPointer(zone)); // api_function_address
function->InitParameter(
4, UntaggedIntegral32(zone)); // actual number of arguments
function->InitParameter(0, AnyTagged(zone)); // callee
function->InitParameter(1, AnyTagged(zone)); // call_data
function->InitParameter(2, AnyTagged(zone)); // holder
function->InitParameter(3, ExternalPointer(zone)); // api_function_address
function->InitParameter(4, UntaggedIntegral32(zone)); // actual #arguments
return function;
}
......
......@@ -342,6 +342,7 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
a1, // JSFunction
a3, // the new target
a0, // actual number of arguments
a2, // expected number of arguments
};
......
......@@ -342,6 +342,7 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
a1, // JSFunction
a3, // the new target
a0, // actual number of arguments
a2, // expected number of arguments
};
......
......@@ -341,6 +341,7 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r4, // JSFunction
r6, // the new target
r3, // actual number of arguments
r5, // expected number of arguments
};
......
......@@ -342,6 +342,7 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
rdi, // JSFunction
rdx, // the new target
rax, // actual number of arguments
rbx, // expected number of arguments
};
......
......@@ -348,6 +348,7 @@ void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
edi, // JSFunction
edx, // the new target
eax, // actual number of arguments
ebx, // expected number of arguments
};
......
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