| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COMPILER_LINKAGE_H_ | 5 #ifndef V8_COMPILER_LINKAGE_H_ |
| 6 #define V8_COMPILER_LINKAGE_H_ | 6 #define V8_COMPILER_LINKAGE_H_ |
| 7 | 7 |
| 8 #include "src/base/flags.h" | 8 #include "src/base/flags.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/compiler/frame.h" | 10 #include "src/compiler/frame.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 Operator::Properties properties() const { return properties_; } | 122 Operator::Properties properties() const { return properties_; } |
| 123 | 123 |
| 124 // Get the callee-saved registers, if any, across this call. | 124 // Get the callee-saved registers, if any, across this call. |
| 125 RegList CalleeSavedRegisters() const { return callee_saved_registers_; } | 125 RegList CalleeSavedRegisters() const { return callee_saved_registers_; } |
| 126 | 126 |
| 127 const char* debug_name() const { return debug_name_; } | 127 const char* debug_name() const { return debug_name_; } |
| 128 | 128 |
| 129 private: | 129 private: |
| 130 friend class Linkage; | 130 friend class Linkage; |
| 131 | 131 |
| 132 Kind kind_; | 132 const Kind kind_; |
| 133 MachineType target_type_; | 133 const MachineType target_type_; |
| 134 LinkageLocation target_loc_; | 134 const LinkageLocation target_loc_; |
| 135 MachineSignature* machine_sig_; | 135 const MachineSignature* const machine_sig_; |
| 136 LocationSignature* location_sig_; | 136 const LocationSignature* const location_sig_; |
| 137 size_t js_param_count_; | 137 const size_t js_param_count_; |
| 138 Operator::Properties properties_; | 138 const Operator::Properties properties_; |
| 139 RegList callee_saved_registers_; | 139 const RegList callee_saved_registers_; |
| 140 Flags flags_; | 140 const Flags flags_; |
| 141 const char* debug_name_; | 141 const char* const debug_name_; |
| 142 |
| 143 DISALLOW_COPY_AND_ASSIGN(CallDescriptor); |
| 142 }; | 144 }; |
| 143 | 145 |
| 144 DEFINE_OPERATORS_FOR_FLAGS(CallDescriptor::Flags) | 146 DEFINE_OPERATORS_FOR_FLAGS(CallDescriptor::Flags) |
| 145 | 147 |
| 146 std::ostream& operator<<(std::ostream& os, const CallDescriptor& d); | 148 std::ostream& operator<<(std::ostream& os, const CallDescriptor& d); |
| 147 std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k); | 149 std::ostream& operator<<(std::ostream& os, const CallDescriptor::Kind& k); |
| 148 | 150 |
| 149 // Defines the linkage for a compilation, including the calling conventions | 151 // Defines the linkage for a compilation, including the calling conventions |
| 150 // for incoming parameters and return value(s) as well as the outgoing calling | 152 // for incoming parameters and return value(s) as well as the outgoing calling |
| 151 // convention for any kind of call. Linkage is generally architecture-specific. | 153 // convention for any kind of call. Linkage is generally architecture-specific. |
| 152 // | 154 // |
| 153 // Can be used to translate {arg_index} (i.e. index of the call node input) as | 155 // Can be used to translate {arg_index} (i.e. index of the call node input) as |
| 154 // well as {param_index} (i.e. as stored in parameter nodes) into an operator | 156 // well as {param_index} (i.e. as stored in parameter nodes) into an operator |
| 155 // representing the architecture-specific location. The following call node | 157 // representing the architecture-specific location. The following call node |
| 156 // layouts are supported (where {n} is the number value inputs): | 158 // layouts are supported (where {n} is the number value inputs): |
| 157 // | 159 // |
| 158 // #0 #1 #2 #3 [...] #n | 160 // #0 #1 #2 #3 [...] #n |
| 159 // Call[CodeStub] code, arg 1, arg 2, arg 3, [...], context | 161 // Call[CodeStub] code, arg 1, arg 2, arg 3, [...], context |
| 160 // Call[JSFunction] function, rcvr, arg 1, arg 2, [...], context | 162 // Call[JSFunction] function, rcvr, arg 1, arg 2, [...], context |
| 161 // Call[Runtime] CEntryStub, arg 1, arg 2, arg 3, [...], fun, #arg, context | 163 // Call[Runtime] CEntryStub, arg 1, arg 2, arg 3, [...], fun, #arg, context |
| 162 class Linkage : public ZoneObject { | 164 class Linkage : public ZoneObject { |
| 163 public: | 165 public: |
| 164 explicit Linkage(CompilationInfo* info); | 166 Linkage(Zone* zone, CompilationInfo* info) |
| 165 explicit Linkage(CompilationInfo* info, CallDescriptor* incoming) | 167 : zone_(zone), incoming_(ComputeIncoming(zone, info)) {} |
| 166 : info_(info), incoming_(incoming) {} | 168 Linkage(Zone* zone, CallDescriptor* incoming) |
| 169 : zone_(zone), incoming_(incoming) {} |
| 170 |
| 171 static CallDescriptor* ComputeIncoming(Zone* zone, CompilationInfo* info); |
| 167 | 172 |
| 168 // The call descriptor for this compilation unit describes the locations | 173 // The call descriptor for this compilation unit describes the locations |
| 169 // of incoming parameters and the outgoing return value(s). | 174 // of incoming parameters and the outgoing return value(s). |
| 170 CallDescriptor* GetIncomingDescriptor() { return incoming_; } | 175 CallDescriptor* GetIncomingDescriptor() const { return incoming_; } |
| 171 CallDescriptor* GetJSCallDescriptor(int parameter_count); | 176 CallDescriptor* GetJSCallDescriptor(int parameter_count) const; |
| 172 static CallDescriptor* GetJSCallDescriptor(int parameter_count, Zone* zone); | 177 static CallDescriptor* GetJSCallDescriptor(int parameter_count, Zone* zone); |
| 173 CallDescriptor* GetRuntimeCallDescriptor(Runtime::FunctionId function, | 178 CallDescriptor* GetRuntimeCallDescriptor( |
| 174 int parameter_count, | 179 Runtime::FunctionId function, int parameter_count, |
| 175 Operator::Properties properties); | 180 Operator::Properties properties) const; |
| 176 static CallDescriptor* GetRuntimeCallDescriptor( | 181 static CallDescriptor* GetRuntimeCallDescriptor( |
| 177 Runtime::FunctionId function, int parameter_count, | 182 Runtime::FunctionId function, int parameter_count, |
| 178 Operator::Properties properties, Zone* zone); | 183 Operator::Properties properties, Zone* zone); |
| 179 | 184 |
| 180 CallDescriptor* GetStubCallDescriptor( | 185 CallDescriptor* GetStubCallDescriptor( |
| 181 CallInterfaceDescriptor descriptor, int stack_parameter_count = 0, | 186 CallInterfaceDescriptor descriptor, int stack_parameter_count = 0, |
| 182 CallDescriptor::Flags flags = CallDescriptor::kNoFlags); | 187 CallDescriptor::Flags flags = CallDescriptor::kNoFlags) const; |
| 183 static CallDescriptor* GetStubCallDescriptor( | 188 static CallDescriptor* GetStubCallDescriptor( |
| 184 CallInterfaceDescriptor descriptor, int stack_parameter_count, | 189 CallInterfaceDescriptor descriptor, int stack_parameter_count, |
| 185 CallDescriptor::Flags flags, Zone* zone); | 190 CallDescriptor::Flags flags, Zone* zone); |
| 186 | 191 |
| 187 // Creates a call descriptor for simplified C calls that is appropriate | 192 // Creates a call descriptor for simplified C calls that is appropriate |
| 188 // for the host platform. This simplified calling convention only supports | 193 // for the host platform. This simplified calling convention only supports |
| 189 // integers and pointers of one word size each, i.e. no floating point, | 194 // integers and pointers of one word size each, i.e. no floating point, |
| 190 // structs, pointers to members, etc. | 195 // structs, pointers to members, etc. |
| 191 static CallDescriptor* GetSimplifiedCDescriptor(Zone* zone, | 196 static CallDescriptor* GetSimplifiedCDescriptor(Zone* zone, |
| 192 MachineSignature* sig); | 197 MachineSignature* sig); |
| 193 | 198 |
| 194 // Get the location of an (incoming) parameter to this function. | 199 // Get the location of an (incoming) parameter to this function. |
| 195 LinkageLocation GetParameterLocation(int index) { | 200 LinkageLocation GetParameterLocation(int index) const { |
| 196 return incoming_->GetInputLocation(index + 1); // + 1 to skip target. | 201 return incoming_->GetInputLocation(index + 1); // + 1 to skip target. |
| 197 } | 202 } |
| 198 | 203 |
| 199 // Get the machine type of an (incoming) parameter to this function. | 204 // Get the machine type of an (incoming) parameter to this function. |
| 200 MachineType GetParameterType(int index) { | 205 MachineType GetParameterType(int index) const { |
| 201 return incoming_->GetInputType(index + 1); // + 1 to skip target. | 206 return incoming_->GetInputType(index + 1); // + 1 to skip target. |
| 202 } | 207 } |
| 203 | 208 |
| 204 // Get the location where this function should place its return value. | 209 // Get the location where this function should place its return value. |
| 205 LinkageLocation GetReturnLocation() { | 210 LinkageLocation GetReturnLocation() const { |
| 206 return incoming_->GetReturnLocation(0); | 211 return incoming_->GetReturnLocation(0); |
| 207 } | 212 } |
| 208 | 213 |
| 209 // Get the machine type of this function's return value. | 214 // Get the machine type of this function's return value. |
| 210 MachineType GetReturnType() { return incoming_->GetReturnType(0); } | 215 MachineType GetReturnType() const { return incoming_->GetReturnType(0); } |
| 211 | 216 |
| 212 // Get the frame offset for a given spill slot. The location depends on the | 217 // Get the frame offset for a given spill slot. The location depends on the |
| 213 // calling convention and the specific frame layout, and may thus be | 218 // calling convention and the specific frame layout, and may thus be |
| 214 // architecture-specific. Negative spill slots indicate arguments on the | 219 // architecture-specific. Negative spill slots indicate arguments on the |
| 215 // caller's frame. The {extra} parameter indicates an additional offset from | 220 // caller's frame. The {extra} parameter indicates an additional offset from |
| 216 // the frame offset, e.g. to index into part of a double slot. | 221 // the frame offset, e.g. to index into part of a double slot. |
| 217 FrameOffset GetFrameOffset(int spill_slot, Frame* frame, int extra = 0); | 222 FrameOffset GetFrameOffset(int spill_slot, Frame* frame, int extra = 0) const; |
| 218 | |
| 219 CompilationInfo* info() const { return info_; } | |
| 220 | 223 |
| 221 static bool NeedsFrameState(Runtime::FunctionId function); | 224 static bool NeedsFrameState(Runtime::FunctionId function); |
| 222 | 225 |
| 223 private: | 226 private: |
| 224 CompilationInfo* info_; | 227 Zone* const zone_; |
| 225 CallDescriptor* incoming_; | 228 CallDescriptor* const incoming_; |
| 229 |
| 230 DISALLOW_COPY_AND_ASSIGN(Linkage); |
| 226 }; | 231 }; |
| 227 | 232 |
| 228 } // namespace compiler | 233 } // namespace compiler |
| 229 } // namespace internal | 234 } // namespace internal |
| 230 } // namespace v8 | 235 } // namespace v8 |
| 231 | 236 |
| 232 #endif // V8_COMPILER_LINKAGE_H_ | 237 #endif // V8_COMPILER_LINKAGE_H_ |
| OLD | NEW |