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