Index: src/compiler/linkage.cc |
diff --git a/src/compiler/linkage.cc b/src/compiler/linkage.cc |
index 5b2388cef93885a185e038a2cad175d10ff7526f..1fe62f2ccffe595f0809db771a1644244cd47dc2 100644 |
--- a/src/compiler/linkage.cc |
+++ b/src/compiler/linkage.cc |
@@ -17,10 +17,10 @@ namespace internal { |
namespace compiler { |
namespace { |
-LinkageLocation regloc(Register reg) { |
- return LinkageLocation::ForRegister(reg.code()); |
-} |
+LinkageLocation regloc(Register reg, MachineType type) { |
+ return LinkageLocation::ForRegister(reg.code(), type); |
+} |
MachineType reptyp(Representation representation) { |
switch (representation.kind()) { |
@@ -49,6 +49,7 @@ MachineType reptyp(Representation representation) { |
UNREACHABLE(); |
return MachineType::None(); |
} |
+ |
} // namespace |
@@ -75,6 +76,20 @@ std::ostream& operator<<(std::ostream& os, const CallDescriptor& d) { |
<< d.FrameStateCount() << "t" << d.SupportsTailCalls(); |
} |
+MachineSignature* CallDescriptor::GetMachineSignature(Zone* zone) const { |
+ size_t param_count = ParameterCount(); |
+ size_t return_count = ReturnCount(); |
+ MachineType* types = reinterpret_cast<MachineType*>( |
+ zone->New(sizeof(MachineType*) * (param_count + return_count))); |
+ int current = 0; |
+ for (size_t i = 0; i < return_count; ++i) { |
+ types[current++] = GetReturnType(i); |
+ } |
+ for (size_t i = 0; i < param_count; ++i) { |
+ types[current++] = GetParameterType(i); |
+ } |
+ return new (zone) MachineSignature(return_count, param_count, types); |
+} |
bool CallDescriptor::HasSameReturnLocationsAs( |
const CallDescriptor* other) const { |
@@ -219,39 +234,33 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor( |
const size_t return_count = static_cast<size_t>(function->result_size); |
LocationSignature::Builder locations(zone, return_count, parameter_count); |
- MachineSignature::Builder types(zone, return_count, parameter_count); |
// Add returns. |
if (locations.return_count_ > 0) { |
- locations.AddReturn(regloc(kReturnRegister0)); |
+ locations.AddReturn(regloc(kReturnRegister0, MachineType::AnyTagged())); |
} |
if (locations.return_count_ > 1) { |
- locations.AddReturn(regloc(kReturnRegister1)); |
+ locations.AddReturn(regloc(kReturnRegister1, MachineType::AnyTagged())); |
} |
if (locations.return_count_ > 2) { |
- locations.AddReturn(regloc(kReturnRegister2)); |
- } |
- for (size_t i = 0; i < return_count; i++) { |
- types.AddReturn(MachineType::AnyTagged()); |
+ locations.AddReturn(regloc(kReturnRegister2, MachineType::AnyTagged())); |
} |
// All parameters to the runtime call go on the stack. |
for (int i = 0; i < js_parameter_count; i++) { |
- locations.AddParam( |
- LinkageLocation::ForCallerFrameSlot(i - js_parameter_count)); |
- types.AddParam(MachineType::AnyTagged()); |
+ locations.AddParam(LinkageLocation::ForCallerFrameSlot( |
+ i - js_parameter_count, MachineType::AnyTagged())); |
} |
// Add runtime function itself. |
- locations.AddParam(regloc(kRuntimeCallFunctionRegister)); |
- types.AddParam(MachineType::AnyTagged()); |
+ locations.AddParam( |
+ regloc(kRuntimeCallFunctionRegister, MachineType::AnyTagged())); |
// Add runtime call argument count. |
- locations.AddParam(regloc(kRuntimeCallArgCountRegister)); |
- types.AddParam(MachineType::Pointer()); |
+ locations.AddParam( |
+ regloc(kRuntimeCallArgCountRegister, MachineType::AnyTagged())); |
// Add context. |
- locations.AddParam(regloc(kContextRegister)); |
- types.AddParam(MachineType::AnyTagged()); |
+ locations.AddParam(regloc(kContextRegister, MachineType::AnyTagged())); |
if (!Linkage::NeedsFrameStateInput(function_id)) { |
flags = static_cast<CallDescriptor::Flags>( |
@@ -260,12 +269,12 @@ CallDescriptor* Linkage::GetRuntimeCallDescriptor( |
// The target for runtime calls is a code object. |
MachineType target_type = MachineType::AnyTagged(); |
- LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); |
+ LinkageLocation target_loc = |
+ LinkageLocation::ForAnyRegister(MachineType::AnyTagged()); |
return new (zone) CallDescriptor( // -- |
CallDescriptor::kCallCodeObject, // kind |
target_type, // target MachineType |
target_loc, // target location |
- types.Build(), // machine_sig |
locations.Build(), // location_sig |
js_parameter_count, // stack_parameter_count |
properties, // properties |
@@ -287,43 +296,39 @@ CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr, |
js_parameter_count + new_target_count + num_args_count + context_count; |
LocationSignature::Builder locations(zone, return_count, parameter_count); |
- MachineSignature::Builder types(zone, return_count, parameter_count); |
// All JS calls have exactly one return value. |
- locations.AddReturn(regloc(kReturnRegister0)); |
- types.AddReturn(MachineType::AnyTagged()); |
+ locations.AddReturn(regloc(kReturnRegister0, MachineType::AnyTagged())); |
// All parameters to JS calls go on the stack. |
for (int i = 0; i < js_parameter_count; i++) { |
int spill_slot_index = i - js_parameter_count; |
- locations.AddParam(LinkageLocation::ForCallerFrameSlot(spill_slot_index)); |
- types.AddParam(MachineType::AnyTagged()); |
+ locations.AddParam(LinkageLocation::ForCallerFrameSlot( |
+ spill_slot_index, MachineType::AnyTagged())); |
} |
// Add JavaScript call new target value. |
- locations.AddParam(regloc(kJavaScriptCallNewTargetRegister)); |
- types.AddParam(MachineType::AnyTagged()); |
+ locations.AddParam( |
+ regloc(kJavaScriptCallNewTargetRegister, MachineType::AnyTagged())); |
// Add JavaScript call argument count. |
- locations.AddParam(regloc(kJavaScriptCallArgCountRegister)); |
- types.AddParam(MachineType::Int32()); |
+ locations.AddParam( |
+ regloc(kJavaScriptCallArgCountRegister, MachineType::Int32())); |
// Add context. |
- locations.AddParam(regloc(kContextRegister)); |
- types.AddParam(MachineType::AnyTagged()); |
+ locations.AddParam(regloc(kContextRegister, MachineType::AnyTagged())); |
// The target for JS function calls is the JSFunction object. |
MachineType target_type = MachineType::AnyTagged(); |
// When entering into an OSR function from unoptimized code the JSFunction |
// is not in a register, but it is on the stack in the marker spill slot. |
- LinkageLocation target_loc = is_osr |
- ? LinkageLocation::ForSavedCallerFunction() |
- : regloc(kJSFunctionRegister); |
+ LinkageLocation target_loc = |
+ is_osr ? LinkageLocation::ForSavedCallerFunction() |
+ : regloc(kJSFunctionRegister, MachineType::AnyTagged()); |
return new (zone) CallDescriptor( // -- |
CallDescriptor::kCallJSFunction, // kind |
target_type, // target MachineType |
target_loc, // target location |
- types.Build(), // machine_sig |
locations.Build(), // location_sig |
js_parameter_count, // stack_parameter_count |
Operator::kNoProperties, // properties |
@@ -350,20 +355,16 @@ CallDescriptor* Linkage::GetStubCallDescriptor( |
static_cast<size_t>(js_parameter_count + context_count); |
LocationSignature::Builder locations(zone, return_count, parameter_count); |
- MachineSignature::Builder types(zone, return_count, parameter_count); |
// Add returns. |
if (locations.return_count_ > 0) { |
- locations.AddReturn(regloc(kReturnRegister0)); |
+ locations.AddReturn(regloc(kReturnRegister0, return_type)); |
} |
if (locations.return_count_ > 1) { |
- locations.AddReturn(regloc(kReturnRegister1)); |
+ locations.AddReturn(regloc(kReturnRegister1, return_type)); |
} |
if (locations.return_count_ > 2) { |
- locations.AddReturn(regloc(kReturnRegister2)); |
- } |
- for (size_t i = 0; i < return_count; i++) { |
- types.AddReturn(return_type); |
+ locations.AddReturn(regloc(kReturnRegister2, return_type)); |
} |
// Add parameters in registers and on the stack. |
@@ -371,29 +372,27 @@ CallDescriptor* Linkage::GetStubCallDescriptor( |
if (i < register_parameter_count) { |
// The first parameters go in registers. |
Register reg = descriptor.GetRegisterParameter(i); |
- Representation rep = |
- RepresentationFromType(descriptor.GetParameterType(i)); |
- locations.AddParam(regloc(reg)); |
- types.AddParam(reptyp(rep)); |
+ MachineType type = |
+ reptyp(RepresentationFromType(descriptor.GetParameterType(i))); |
+ locations.AddParam(regloc(reg, type)); |
} else { |
// The rest of the parameters go on the stack. |
int stack_slot = i - register_parameter_count - stack_parameter_count; |
- locations.AddParam(LinkageLocation::ForCallerFrameSlot(stack_slot)); |
- types.AddParam(MachineType::AnyTagged()); |
+ locations.AddParam(LinkageLocation::ForCallerFrameSlot( |
+ stack_slot, MachineType::AnyTagged())); |
} |
} |
// Add context. |
- locations.AddParam(regloc(kContextRegister)); |
- types.AddParam(MachineType::AnyTagged()); |
+ locations.AddParam(regloc(kContextRegister, MachineType::AnyTagged())); |
// The target for stub calls is a code object. |
MachineType target_type = MachineType::AnyTagged(); |
- LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); |
+ LinkageLocation target_loc = |
+ LinkageLocation::ForAnyRegister(MachineType::AnyTagged()); |
return new (zone) CallDescriptor( // -- |
CallDescriptor::kCallCodeObject, // kind |
target_type, // target MachineType |
target_loc, // target location |
- types.Build(), // machine_sig |
locations.Build(), // location_sig |
stack_parameter_count, // stack_parameter_count |
properties, // properties |
@@ -407,22 +406,19 @@ CallDescriptor* Linkage::GetStubCallDescriptor( |
// static |
CallDescriptor* Linkage::GetAllocateCallDescriptor(Zone* zone) { |
LocationSignature::Builder locations(zone, 1, 1); |
- MachineSignature::Builder types(zone, 1, 1); |
- locations.AddParam(regloc(kAllocateSizeRegister)); |
- types.AddParam(MachineType::Int32()); |
+ locations.AddParam(regloc(kAllocateSizeRegister, MachineType::Int32())); |
- locations.AddReturn(regloc(kReturnRegister0)); |
- types.AddReturn(MachineType::AnyTagged()); |
+ locations.AddReturn(regloc(kReturnRegister0, MachineType::AnyTagged())); |
// The target for allocate calls is a code object. |
MachineType target_type = MachineType::AnyTagged(); |
- LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); |
+ LinkageLocation target_loc = |
+ LinkageLocation::ForAnyRegister(MachineType::AnyTagged()); |
return new (zone) CallDescriptor( // -- |
CallDescriptor::kCallCodeObject, // kind |
target_type, // target MachineType |
target_loc, // target location |
- types.Build(), // machine_sig |
locations.Build(), // location_sig |
0, // stack_parameter_count |
Operator::kNoThrow, // properties |
@@ -440,33 +436,30 @@ CallDescriptor* Linkage::GetBytecodeDispatchCallDescriptor( |
const int parameter_count = register_parameter_count + stack_parameter_count; |
LocationSignature::Builder locations(zone, 0, parameter_count); |
- MachineSignature::Builder types(zone, 0, parameter_count); |
// Add parameters in registers and on the stack. |
for (int i = 0; i < parameter_count; i++) { |
if (i < register_parameter_count) { |
// The first parameters go in registers. |
Register reg = descriptor.GetRegisterParameter(i); |
- Representation rep = |
- RepresentationFromType(descriptor.GetParameterType(i)); |
- locations.AddParam(regloc(reg)); |
- types.AddParam(reptyp(rep)); |
+ MachineType type = |
+ reptyp(RepresentationFromType(descriptor.GetParameterType(i))); |
+ locations.AddParam(regloc(reg, type)); |
} else { |
// The rest of the parameters go on the stack. |
int stack_slot = i - register_parameter_count - stack_parameter_count; |
- locations.AddParam(LinkageLocation::ForCallerFrameSlot(stack_slot)); |
- types.AddParam(MachineType::AnyTagged()); |
+ locations.AddParam(LinkageLocation::ForCallerFrameSlot( |
+ stack_slot, MachineType::AnyTagged())); |
} |
} |
// The target for interpreter dispatches is a code entry address. |
MachineType target_type = MachineType::Pointer(); |
- LinkageLocation target_loc = LinkageLocation::ForAnyRegister(); |
+ LinkageLocation target_loc = LinkageLocation::ForAnyRegister(target_type); |
return new (zone) CallDescriptor( // -- |
CallDescriptor::kCallAddress, // kind |
target_type, // target MachineType |
target_loc, // target location |
- types.Build(), // machine_sig |
locations.Build(), // location_sig |
stack_parameter_count, // stack_parameter_count |
Operator::kNoProperties, // properties |
@@ -492,7 +485,8 @@ LinkageLocation Linkage::GetOsrValueLocation(int index) const { |
// Local variable stored in this (callee) stack. |
int spill_index = |
index - first_stack_slot + StandardFrameConstants::kFixedSlotCount; |
- return LinkageLocation::ForCalleeFrameSlot(spill_index); |
+ return LinkageLocation::ForCalleeFrameSlot(spill_index, |
+ MachineType::AnyTagged()); |
} else { |
// Parameter. Use the assigned location from the incoming call descriptor. |
int parameter_index = 1 + index; // skip index 0, which is the target. |
@@ -504,19 +498,21 @@ LinkageLocation Linkage::GetOsrValueLocation(int index) const { |
bool Linkage::ParameterHasSecondaryLocation(int index) const { |
if (!incoming_->IsJSFunctionCall()) return false; |
LinkageLocation loc = GetParameterLocation(index); |
- return (loc == regloc(kJSFunctionRegister) || |
- loc == regloc(kContextRegister)); |
+ return (loc == regloc(kJSFunctionRegister, MachineType::AnyTagged()) || |
+ loc == regloc(kContextRegister, MachineType::AnyTagged())); |
} |
LinkageLocation Linkage::GetParameterSecondaryLocation(int index) const { |
DCHECK(ParameterHasSecondaryLocation(index)); |
LinkageLocation loc = GetParameterLocation(index); |
- if (loc == regloc(kJSFunctionRegister)) { |
- return LinkageLocation::ForCalleeFrameSlot(Frame::kJSFunctionSlot); |
+ if (loc == regloc(kJSFunctionRegister, MachineType::AnyTagged())) { |
+ return LinkageLocation::ForCalleeFrameSlot(Frame::kJSFunctionSlot, |
+ MachineType::AnyTagged()); |
} else { |
- DCHECK(loc == regloc(kContextRegister)); |
- return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot); |
+ DCHECK(loc == regloc(kContextRegister, MachineType::AnyTagged())); |
+ return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot, |
+ MachineType::AnyTagged()); |
} |
} |