Chromium Code Reviews| Index: src/compiler/linkage.h |
| diff --git a/src/compiler/linkage.h b/src/compiler/linkage.h |
| index 9f3d8347e986c472b5d682b02c0cdf2e4b9a3a30..e155a0e63d5ba276976a3ad3cd2120997f9b88ff 100644 |
| --- a/src/compiler/linkage.h |
| +++ b/src/compiler/linkage.h |
| @@ -18,29 +18,32 @@ namespace internal { |
| namespace compiler { |
| // Describes the location for a parameter or a return value to a call. |
| -// TODO(titzer): replace with Radium locations when they are ready. |
| class LinkageLocation { |
| public: |
| - LinkageLocation(MachineType rep, int location) |
| - : rep_(rep), location_(location) {} |
| - |
| - inline MachineType representation() const { return rep_; } |
| + explicit LinkageLocation(int location) : location_(location) {} |
| static const int16_t ANY_REGISTER = 32767; |
| + static LinkageLocation AnyRegister() { return LinkageLocation(ANY_REGISTER); } |
| + |
| private: |
| friend class CallDescriptor; |
| friend class OperandGenerator; |
| - MachineType rep_; |
| int16_t location_; // >= 0 implies register, otherwise stack slot. |
| }; |
| +typedef Signature<LinkageLocation> LocationSignature; |
| +// Describes a call to various parts of the compiler. Every call has the notion |
| +// of a "target", which is the first input to the call. |
| class CallDescriptor V8_FINAL : public ZoneObject { |
| public: |
| - // Describes whether the first parameter is a code object, a JSFunction, |
| - // or an address--all of which require different machine sequences to call. |
| - enum Kind { kCallCodeObject, kCallJSFunction, kCallAddress }; |
| + // Describes the kind of this call, which determines the target. |
| + enum Kind { |
| + kCallCodeObject, // target is a Code object |
| + kCallJSFunction, // target is a JSFunction object |
| + kCallAddress // target is a machine pointer |
| + }; |
| enum Flag { |
| // TODO(jarin) kLazyDeoptimization and kNeedsFrameState should be unified. |
| @@ -52,33 +55,41 @@ class CallDescriptor V8_FINAL : public ZoneObject { |
| }; |
| DEFINE_FLAGS(Flags, Flag); |
| - CallDescriptor(Kind kind, int8_t return_count, int16_t parameter_count, |
| - int16_t input_count, LinkageLocation* locations, |
| - Operator::Property properties, RegList callee_saved_registers, |
| - Flags flags, const char* debug_name = "") |
| + CallDescriptor(Kind kind, MachineType target_type, LinkageLocation target_loc, |
| + MachineSignature* machine_sig, LocationSignature* location_sig, |
| + int js_param_count, Operator::Property properties, |
| + RegList callee_saved_registers, Flags flags, |
| + const char* debug_name = "") |
| : kind_(kind), |
| - return_count_(return_count), |
| - parameter_count_(parameter_count), |
| - input_count_(input_count), |
| - locations_(locations), |
| + target_type_(target_type), |
| + target_loc_(target_loc), |
| + machine_sig_(machine_sig), |
| + location_sig_(location_sig), |
| + js_param_count_(js_param_count), |
| properties_(properties), |
| callee_saved_registers_(callee_saved_registers), |
| flags_(flags), |
| - debug_name_(debug_name) {} |
| + debug_name_(debug_name) { |
| + DCHECK_EQ(machine_sig->ReturnCount(), location_sig->ReturnCount()); |
| + DCHECK_EQ(machine_sig->ParamCount(), location_sig->ParamCount()); |
| + } |
| + |
| // Returns the kind of this call. |
| Kind kind() const { return kind_; } |
| // Returns {true} if this descriptor is a call to a JSFunction. |
| bool IsJSFunctionCall() const { return kind_ == kCallJSFunction; } |
| - // The number of return values from this call, usually 0 or 1. |
| - int ReturnCount() const { return return_count_; } |
| + // The number of return values from this call. |
| + int ReturnCount() const { return machine_sig_->ReturnCount(); } |
| - // The number of JavaScript parameters to this call, including receiver, |
| - // but not the context. |
| - int ParameterCount() const { return parameter_count_; } |
| + // The number of JavaScript parameters to this call, including the receiver |
| + // object. |
| + int JSParamCount() const { return js_param_count_; } |
| - int InputCount() const { return input_count_; } |
| + // The total number of inputs to this call, which includes the target, |
| + // receiver, context, etc. |
| + int InputCount() const { return 1 + machine_sig_->ParamCount(); } |
| int FrameStateCount() const { return NeedsFrameState() ? 1 : 0; } |
| @@ -87,13 +98,23 @@ class CallDescriptor V8_FINAL : public ZoneObject { |
| bool NeedsFrameState() const { return flags() & kNeedsFrameState; } |
| LinkageLocation GetReturnLocation(int index) { |
| - DCHECK(index < return_count_); |
| - return locations_[0 + index]; // return locations start at 0. |
| + return location_sig_->GetReturn(index); |
| } |
| LinkageLocation GetInputLocation(int index) { |
| - DCHECK(index < input_count_ + 1); // input_count + 1 is the context. |
| - return locations_[return_count_ + index]; // inputs start after returns. |
| + if (index == 0) return target_loc_; |
| + return location_sig_->GetParam(index - 1); |
| + } |
| + |
| + MachineSignature* GetMachineSignature() { return machine_sig_; } |
| + |
| + MachineType GetReturnType(int index) { |
| + return machine_sig_->GetReturn(index); |
| + } |
| + |
| + MachineType GetInputType(int index) { |
| + if (index == 0) return target_type_; |
| + return machine_sig_->GetParam(index - 1); |
| } |
| // Operator properties describe how this call can be optimized, if at all. |
| @@ -108,10 +129,11 @@ class CallDescriptor V8_FINAL : public ZoneObject { |
| friend class Linkage; |
| Kind kind_; |
| - int8_t return_count_; |
| - int16_t parameter_count_; |
| - int16_t input_count_; |
| - LinkageLocation* locations_; |
| + MachineType target_type_; |
| + LinkageLocation target_loc_; |
| + MachineSignature* machine_sig_; |
| + LocationSignature* location_sig_; |
| + int js_param_count_; |
| Operator::Property properties_; |
| RegList callee_saved_registers_; |
| Flags flags_; |
| @@ -168,13 +190,17 @@ class Linkage : public ZoneObject { |
| // for the host platform. This simplified calling convention only supports |
| // integers and pointers of one word size each, i.e. no floating point, |
| // structs, pointers to members, etc. |
| - static CallDescriptor* GetSimplifiedCDescriptor( |
| - Zone* zone, int num_params, MachineType return_type, |
| - const MachineType* param_types); |
| + static CallDescriptor* GetSimplifiedCDescriptor(Zone* zone, |
| + MachineSignature* sig); |
| // Get the location of an (incoming) parameter to this function. |
| LinkageLocation GetParameterLocation(int index) { |
| - return incoming_->GetInputLocation(index + 1); |
| + return incoming_->GetInputLocation(index + 1); // + 1 to skip target. |
| + } |
| + |
| + // Get the machine type of an (incoming) parameter to this function. |
| + MachineType GetParameterType(int index) { |
|
Benedikt Meurer
2014/09/02 08:37:41
Nit: const
titzer
2014/09/02 12:13:52
Done.
|
| + return incoming_->GetInputType(index + 1); // + 1 to skip target. |
| } |
| // Get the location where this function should place its return value. |
| @@ -182,6 +208,9 @@ class Linkage : public ZoneObject { |
| return incoming_->GetReturnLocation(0); |
| } |
| + // Get the machine type of this function's return value. |
| + MachineType GetReturnType() { return incoming_->GetReturnType(0); } |
|
Benedikt Meurer
2014/09/02 08:37:41
Nit: const
titzer
2014/09/02 12:13:52
Done.
|
| + |
| // Get the frame offset for a given spill slot. The location depends on the |
| // calling convention and the specific frame layout, and may thus be |
| // architecture-specific. Negative spill slots indicate arguments on the |