OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_CODE_STUBS_H_ | 5 #ifndef V8_CODE_STUBS_H_ |
6 #define V8_CODE_STUBS_H_ | 6 #define V8_CODE_STUBS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assembler.h" | 9 #include "src/assembler.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 259 |
260 protected: | 260 protected: |
261 // Generates the assembler code for the stub. | 261 // Generates the assembler code for the stub. |
262 virtual void Generate(MacroAssembler* masm) = 0; | 262 virtual void Generate(MacroAssembler* masm) = 0; |
263 }; | 263 }; |
264 | 264 |
265 | 265 |
266 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; | 266 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; |
267 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; | 267 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; |
268 | 268 |
269 struct CodeStubInterfaceDescriptor { | 269 class CodeStubInterfaceDescriptor { |
| 270 public: |
270 CodeStubInterfaceDescriptor(); | 271 CodeStubInterfaceDescriptor(); |
271 int register_param_count_; | |
272 | 272 |
273 Register stack_parameter_count_; | 273 void Initialize(int register_parameter_count, Register* registers, |
274 // if hint_stack_parameter_count_ > 0, the code stub can optimize the | 274 Address deoptimization_handler = NULL, |
275 // return sequence. Default value is -1, which means it is ignored. | 275 Representation* register_param_representations = NULL, |
276 int hint_stack_parameter_count_; | 276 int hint_stack_parameter_count = -1, |
277 StubFunctionMode function_mode_; | 277 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); |
278 Register* register_params_; | 278 void Initialize(int register_parameter_count, Register* registers, |
279 // Specifies Representations for the stub's parameter. Points to an array of | 279 Register stack_parameter_count, |
280 // Representations of the same length of the numbers of parameters to the | 280 Address deoptimization_handler = NULL, |
281 // stub, or if NULL (the default value), Representation of each parameter | 281 Representation* register_param_representations = NULL, |
282 // assumed to be Tagged() | 282 int hint_stack_parameter_count = -1, |
283 Representation* register_param_representations_; | 283 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, |
284 | 284 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); |
285 Address deoptimization_handler_; | |
286 HandlerArgumentsMode handler_arguments_mode_; | |
287 | |
288 bool initialized() const { return register_param_count_ >= 0; } | 285 bool initialized() const { return register_param_count_ >= 0; } |
289 | 286 |
290 int environment_length() const { | 287 int environment_length() const { |
291 return register_param_count_; | 288 return register_param_count_; |
292 } | 289 } |
293 | 290 |
294 void SetMissHandler(ExternalReference handler) { | 291 void SetMissHandler(ExternalReference handler) { |
295 miss_handler_ = handler; | 292 miss_handler_ = handler; |
296 has_miss_handler_ = true; | 293 has_miss_handler_ = true; |
297 // Our miss handler infrastructure doesn't currently support | 294 // Our miss handler infrastructure doesn't currently support |
298 // variable stack parameter counts. | 295 // variable stack parameter counts. |
299 ASSERT(!stack_parameter_count_.is_valid()); | 296 ASSERT(!stack_parameter_count_.is_valid()); |
300 } | 297 } |
301 | 298 |
302 ExternalReference miss_handler() { | 299 ExternalReference miss_handler() const { |
303 ASSERT(has_miss_handler_); | 300 ASSERT(has_miss_handler_); |
304 return miss_handler_; | 301 return miss_handler_; |
305 } | 302 } |
306 | 303 |
307 bool has_miss_handler() { | 304 bool has_miss_handler() const { |
308 return has_miss_handler_; | 305 return has_miss_handler_; |
309 } | 306 } |
310 | 307 |
311 Register GetParameterRegister(int index) const { | 308 Register GetParameterRegister(int index) const { |
312 return register_params_[index]; | 309 return register_params_[index]; |
313 } | 310 } |
314 | 311 |
315 bool IsParameterCountRegister(int index) { | 312 Representation GetRegisterParameterRepresentation(int index) const { |
| 313 ASSERT(index < register_param_count_); |
| 314 if (register_param_representations_.get() == NULL) { |
| 315 return Representation::Tagged(); |
| 316 } |
| 317 |
| 318 return register_param_representations_[index]; |
| 319 } |
| 320 |
| 321 bool IsParameterCountRegister(int index) const { |
316 return GetParameterRegister(index).is(stack_parameter_count_); | 322 return GetParameterRegister(index).is(stack_parameter_count_); |
317 } | 323 } |
318 | 324 |
319 int GetHandlerParameterCount() { | 325 int GetHandlerParameterCount() const { |
320 int params = environment_length(); | 326 int params = environment_length(); |
321 if (handler_arguments_mode_ == PASS_ARGUMENTS) { | 327 if (handler_arguments_mode_ == PASS_ARGUMENTS) { |
322 params += 1; | 328 params += 1; |
323 } | 329 } |
324 return params; | 330 return params; |
325 } | 331 } |
326 | 332 |
| 333 int register_param_count() const { return register_param_count_; } |
| 334 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } |
| 335 Register stack_parameter_count() const { return stack_parameter_count_; } |
| 336 StubFunctionMode function_mode() const { return function_mode_; } |
| 337 Address deoptimization_handler() const { return deoptimization_handler_; } |
| 338 Representation* register_param_representations() const { |
| 339 return register_param_representations_.get(); |
| 340 } |
| 341 |
327 private: | 342 private: |
| 343 int register_param_count_; |
| 344 |
| 345 Register stack_parameter_count_; |
| 346 // If hint_stack_parameter_count_ > 0, the code stub can optimize the |
| 347 // return sequence. Default value is -1, which means it is ignored. |
| 348 int hint_stack_parameter_count_; |
| 349 StubFunctionMode function_mode_; |
| 350 // The Register params are allocated dynamically by the |
| 351 // CodeStubInterfaceDescriptor, and freed on destruction. This is because |
| 352 // static arrays of Registers cause creation of runtime static initializers |
| 353 // which we don't want. |
| 354 SmartArrayPointer<Register> register_params_; |
| 355 // Specifies Representations for the stub's parameter. Points to an array of |
| 356 // Representations of the same length of the numbers of parameters to the |
| 357 // stub, or if NULL (the default value), Representation of each parameter |
| 358 // assumed to be Tagged(). |
| 359 SmartArrayPointer<Representation> register_param_representations_; |
| 360 |
| 361 Address deoptimization_handler_; |
| 362 HandlerArgumentsMode handler_arguments_mode_; |
| 363 |
328 ExternalReference miss_handler_; | 364 ExternalReference miss_handler_; |
329 bool has_miss_handler_; | 365 bool has_miss_handler_; |
| 366 DISALLOW_COPY_AND_ASSIGN(CodeStubInterfaceDescriptor); |
330 }; | 367 }; |
331 | 368 |
332 | 369 |
333 struct PlatformCallInterfaceDescriptor; | 370 struct PlatformCallInterfaceDescriptor; |
334 | 371 |
335 | 372 |
336 struct CallInterfaceDescriptor { | 373 struct CallInterfaceDescriptor { |
337 CallInterfaceDescriptor() | 374 CallInterfaceDescriptor() |
338 : register_param_count_(-1), | 375 : register_param_count_(-1), |
339 register_params_(NULL), | 376 register_params_(NULL), |
(...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2483 | 2520 |
2484 | 2521 |
2485 class CallDescriptors { | 2522 class CallDescriptors { |
2486 public: | 2523 public: |
2487 static void InitializeForIsolate(Isolate* isolate); | 2524 static void InitializeForIsolate(Isolate* isolate); |
2488 }; | 2525 }; |
2489 | 2526 |
2490 } } // namespace v8::internal | 2527 } } // namespace v8::internal |
2491 | 2528 |
2492 #endif // V8_CODE_STUBS_H_ | 2529 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |