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_IMPL_H_ | 5 #ifndef V8_COMPILER_LINKAGE_IMPL_H_ |
6 #define V8_COMPILER_LINKAGE_IMPL_H_ | 6 #define V8_COMPILER_LINKAGE_IMPL_H_ |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 namespace compiler { | 10 namespace compiler { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 Operator::kNoProperties, // properties | 64 Operator::kNoProperties, // properties |
65 kNoCalleeSaved, // callee-saved registers | 65 kNoCalleeSaved, // callee-saved registers |
66 CallDescriptor::kNeedsFrameState); // flags | 66 CallDescriptor::kNeedsFrameState); // flags |
67 } | 67 } |
68 | 68 |
69 | 69 |
70 // TODO(turbofan): cache call descriptors for runtime calls. | 70 // TODO(turbofan): cache call descriptors for runtime calls. |
71 template <typename LinkageTraits> | 71 template <typename LinkageTraits> |
72 static CallDescriptor* GetRuntimeCallDescriptor( | 72 static CallDescriptor* GetRuntimeCallDescriptor( |
73 Zone* zone, Runtime::FunctionId function_id, int parameter_count, | 73 Zone* zone, Runtime::FunctionId function_id, int parameter_count, |
74 Operator::Property properties, CallDescriptor::Flags flags) { | 74 Operator::Property properties) { |
75 const int code_count = 1; | 75 const int code_count = 1; |
76 const int function_count = 1; | 76 const int function_count = 1; |
77 const int num_args_count = 1; | 77 const int num_args_count = 1; |
78 const int context_count = 1; | 78 const int context_count = 1; |
79 const int input_count = code_count + parameter_count + function_count + | 79 const int input_count = code_count + parameter_count + function_count + |
80 num_args_count + context_count; | 80 num_args_count + context_count; |
81 | 81 |
82 const Runtime::Function* function = Runtime::FunctionForId(function_id); | 82 const Runtime::Function* function = Runtime::FunctionForId(function_id); |
83 const int return_count = function->result_size; | 83 const int return_count = function->result_size; |
84 LinkageLocation* locations = | 84 LinkageLocation* locations = |
(...skipping 17 matching lines...) Expand all Loading... |
102 // All parameters to runtime calls go on the stack. | 102 // All parameters to runtime calls go on the stack. |
103 int spill_slot_index = i - parameter_count; | 103 int spill_slot_index = i - parameter_count; |
104 locations[index++] = TaggedStackSlot(spill_slot_index); | 104 locations[index++] = TaggedStackSlot(spill_slot_index); |
105 } | 105 } |
106 locations[index++] = | 106 locations[index++] = |
107 TaggedRegisterLocation(LinkageTraits::RuntimeCallFunctionReg()); | 107 TaggedRegisterLocation(LinkageTraits::RuntimeCallFunctionReg()); |
108 locations[index++] = | 108 locations[index++] = |
109 WordRegisterLocation(LinkageTraits::RuntimeCallArgCountReg()); | 109 WordRegisterLocation(LinkageTraits::RuntimeCallArgCountReg()); |
110 locations[index++] = TaggedRegisterLocation(LinkageTraits::ContextReg()); | 110 locations[index++] = TaggedRegisterLocation(LinkageTraits::ContextReg()); |
111 | 111 |
| 112 CallDescriptor::Flags flags = Linkage::NeedsFrameState(function_id) |
| 113 ? CallDescriptor::kNeedsFrameState |
| 114 : CallDescriptor::kNoFlags; |
| 115 |
112 // TODO(titzer): refactor TurboFan graph to consider context a value input. | 116 // TODO(titzer): refactor TurboFan graph to consider context a value input. |
113 return new (zone) CallDescriptor(CallDescriptor::kCallCodeObject, // kind | 117 return new (zone) CallDescriptor(CallDescriptor::kCallCodeObject, // kind |
114 return_count, // return_count | 118 return_count, // return_count |
115 parameter_count, // parameter_count | 119 parameter_count, // parameter_count |
116 input_count, // input_count | 120 input_count, // input_count |
117 locations, // locations | 121 locations, // locations |
118 properties, // properties | 122 properties, // properties |
119 kNoCalleeSaved, // callee-saved registers | 123 kNoCalleeSaved, // callee-saved registers |
120 flags, // flags | 124 flags, // flags |
121 function->name); | 125 function->name); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 for (; i < num_params; i++) { | 193 for (; i < num_params; i++) { |
190 locations[index++] = LinkageLocation(param_types[i], -1 - i); | 194 locations[index++] = LinkageLocation(param_types[i], -1 - i); |
191 } | 195 } |
192 return new (zone) CallDescriptor( | 196 return new (zone) CallDescriptor( |
193 CallDescriptor::kCallAddress, 1, num_params, num_params + 1, locations, | 197 CallDescriptor::kCallAddress, 1, num_params, num_params + 1, locations, |
194 Operator::kNoProperties, LinkageTraits::CCalleeSaveRegisters(), | 198 Operator::kNoProperties, LinkageTraits::CCalleeSaveRegisters(), |
195 CallDescriptor::kNoFlags); // TODO(jarin) should deoptimize! | 199 CallDescriptor::kNoFlags); // TODO(jarin) should deoptimize! |
196 } | 200 } |
197 }; | 201 }; |
198 | 202 |
| 203 |
| 204 bool Linkage::NeedsFrameState(Runtime::FunctionId function) { |
| 205 if (!FLAG_turbo_deoptimization) { |
| 206 return false; |
| 207 } |
| 208 // TODO(jarin) At the moment, we only add frame state for |
| 209 // few chosen runtime functions. |
| 210 switch (function) { |
| 211 case Runtime::kDebugBreak: |
| 212 case Runtime::kDeoptimizeFunction: |
| 213 case Runtime::kSetScriptBreakPoint: |
| 214 case Runtime::kDebugGetLoadedScripts: |
| 215 case Runtime::kStackGuard: |
| 216 return true; |
| 217 default: |
| 218 return false; |
| 219 } |
| 220 } |
| 221 |
199 } // namespace compiler | 222 } // namespace compiler |
200 } // namespace internal | 223 } // namespace internal |
201 } // namespace v8 | 224 } // namespace v8 |
202 | 225 |
203 #endif // V8_COMPILER_LINKAGE_IMPL_H_ | 226 #endif // V8_COMPILER_LINKAGE_IMPL_H_ |
OLD | NEW |