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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 protected: | 274 protected: |
275 // Generates the assembler code for the stub. | 275 // Generates the assembler code for the stub. |
276 virtual void Generate(MacroAssembler* masm) = 0; | 276 virtual void Generate(MacroAssembler* masm) = 0; |
277 }; | 277 }; |
278 | 278 |
279 | 279 |
280 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; | 280 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; |
281 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; | 281 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS }; |
282 | 282 |
283 | 283 |
284 class CodeStubInterfaceDescriptor: public InterfaceDescriptor { | 284 class CodeStubInterfaceDescriptor { |
285 public: | 285 public: |
286 CodeStubInterfaceDescriptor(); | 286 CodeStubInterfaceDescriptor(); |
287 | 287 |
288 void Initialize(CodeStub::Major major, int register_parameter_count, | 288 void Initialize(CodeStub::Major major, |
289 Register* registers, Address deoptimization_handler = NULL, | 289 CallInterfaceDescriptor* call_descriptor, |
290 Representation* register_param_representations = NULL, | 290 Address deoptimization_handler = NULL, |
291 int hint_stack_parameter_count = -1, | 291 int hint_stack_parameter_count = -1, |
292 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); | 292 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE); |
293 void Initialize(CodeStub::Major major, int register_parameter_count, | 293 void Initialize(CodeStub::Major major, |
294 Register* registers, Register stack_parameter_count, | 294 CallInterfaceDescriptor* call_descriptor, |
| 295 Register stack_parameter_count, |
295 Address deoptimization_handler = NULL, | 296 Address deoptimization_handler = NULL, |
296 Representation* register_param_representations = NULL, | |
297 int hint_stack_parameter_count = -1, | 297 int hint_stack_parameter_count = -1, |
298 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, | 298 StubFunctionMode function_mode = NOT_JS_FUNCTION_STUB_MODE, |
299 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); | 299 HandlerArgumentsMode handler_mode = DONT_PASS_ARGUMENTS); |
300 | 300 |
301 void SetMissHandler(ExternalReference handler) { | 301 void SetMissHandler(ExternalReference handler) { |
302 miss_handler_ = handler; | 302 miss_handler_ = handler; |
303 has_miss_handler_ = true; | 303 has_miss_handler_ = true; |
304 // Our miss handler infrastructure doesn't currently support | 304 // Our miss handler infrastructure doesn't currently support |
305 // variable stack parameter counts. | 305 // variable stack parameter counts. |
306 DCHECK(!stack_parameter_count_.is_valid()); | 306 DCHECK(!stack_parameter_count_.is_valid()); |
307 } | 307 } |
308 | 308 |
| 309 bool IsInitialized() const { return call_descriptor_ != NULL; } |
| 310 |
| 311 CallInterfaceDescriptor* call_descriptor() const { return call_descriptor_; } |
| 312 |
| 313 int GetEnvironmentLength() const { |
| 314 return call_descriptor()->GetEnvironmentLength(); |
| 315 } |
| 316 |
| 317 int GetRegisterParameterCount() const { |
| 318 return call_descriptor()->GetRegisterParameterCount(); |
| 319 } |
| 320 |
| 321 Register GetParameterRegister(int index) const { |
| 322 return call_descriptor()->GetParameterRegister(index); |
| 323 } |
| 324 |
| 325 Representation GetParameterRepresentation(int index) const { |
| 326 return call_descriptor()->GetParameterRepresentation(index); |
| 327 } |
| 328 |
| 329 int GetEnvironmentParameterCount() const { |
| 330 return call_descriptor()->GetEnvironmentParameterCount(); |
| 331 } |
| 332 |
| 333 Register GetEnvironmentParameterRegister(int index) const { |
| 334 return call_descriptor()->GetEnvironmentParameterRegister(index); |
| 335 } |
| 336 |
| 337 Representation GetEnvironmentParameterRepresentation(int index) const { |
| 338 return call_descriptor()->GetEnvironmentParameterRepresentation(index); |
| 339 } |
| 340 |
309 ExternalReference miss_handler() const { | 341 ExternalReference miss_handler() const { |
310 DCHECK(has_miss_handler_); | 342 DCHECK(has_miss_handler_); |
311 return miss_handler_; | 343 return miss_handler_; |
312 } | 344 } |
313 | 345 |
314 bool has_miss_handler() const { | 346 bool has_miss_handler() const { |
315 return has_miss_handler_; | 347 return has_miss_handler_; |
316 } | 348 } |
317 | 349 |
318 bool IsEnvironmentParameterCountRegister(int index) const { | 350 bool IsEnvironmentParameterCountRegister(int index) const { |
319 return GetEnvironmentParameterRegister(index).is(stack_parameter_count_); | 351 return call_descriptor()->GetEnvironmentParameterRegister(index).is( |
| 352 stack_parameter_count_); |
320 } | 353 } |
321 | 354 |
322 int GetHandlerParameterCount() const { | 355 int GetHandlerParameterCount() const { |
323 int params = GetEnvironmentParameterCount(); | 356 int params = call_descriptor()->GetEnvironmentParameterCount(); |
324 if (handler_arguments_mode_ == PASS_ARGUMENTS) { | 357 if (handler_arguments_mode_ == PASS_ARGUMENTS) { |
325 params += 1; | 358 params += 1; |
326 } | 359 } |
327 return params; | 360 return params; |
328 } | 361 } |
329 | 362 |
330 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } | 363 int hint_stack_parameter_count() const { return hint_stack_parameter_count_; } |
331 Register stack_parameter_count() const { return stack_parameter_count_; } | 364 Register stack_parameter_count() const { return stack_parameter_count_; } |
332 StubFunctionMode function_mode() const { return function_mode_; } | 365 StubFunctionMode function_mode() const { return function_mode_; } |
333 Address deoptimization_handler() const { return deoptimization_handler_; } | 366 Address deoptimization_handler() const { return deoptimization_handler_; } |
334 CodeStub::Major MajorKey() const { return major_; } | 367 CodeStub::Major MajorKey() const { return major_; } |
335 | 368 |
336 private: | 369 private: |
| 370 CallInterfaceDescriptor* call_descriptor_; |
337 Register stack_parameter_count_; | 371 Register stack_parameter_count_; |
338 // If hint_stack_parameter_count_ > 0, the code stub can optimize the | 372 // If hint_stack_parameter_count_ > 0, the code stub can optimize the |
339 // return sequence. Default value is -1, which means it is ignored. | 373 // return sequence. Default value is -1, which means it is ignored. |
340 int hint_stack_parameter_count_; | 374 int hint_stack_parameter_count_; |
341 StubFunctionMode function_mode_; | 375 StubFunctionMode function_mode_; |
342 | 376 |
343 Address deoptimization_handler_; | 377 Address deoptimization_handler_; |
344 HandlerArgumentsMode handler_arguments_mode_; | 378 HandlerArgumentsMode handler_arguments_mode_; |
345 | 379 |
346 ExternalReference miss_handler_; | 380 ExternalReference miss_handler_; |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 kCallSiteInlineCheck = 1 << 1, | 698 kCallSiteInlineCheck = 1 << 1, |
665 kReturnTrueFalseObject = 1 << 2 | 699 kReturnTrueFalseObject = 1 << 2 |
666 }; | 700 }; |
667 | 701 |
668 InstanceofStub(Isolate* isolate, Flags flags) : PlatformCodeStub(isolate) { | 702 InstanceofStub(Isolate* isolate, Flags flags) : PlatformCodeStub(isolate) { |
669 minor_key_ = FlagBits::encode(flags); | 703 minor_key_ = FlagBits::encode(flags); |
670 } | 704 } |
671 | 705 |
672 void Generate(MacroAssembler* masm); | 706 void Generate(MacroAssembler* masm); |
673 | 707 |
674 static Register left(); | 708 static Register left() { return InstanceofConvention::left(); } |
675 static Register right(); | 709 static Register right() { return InstanceofConvention::right(); } |
676 | 710 |
677 virtual void InitializeInterfaceDescriptor( | 711 virtual void InitializeInterfaceDescriptor( |
678 CodeStubInterfaceDescriptor* descriptor); | 712 CodeStubInterfaceDescriptor* descriptor); |
679 | 713 |
680 private: | 714 private: |
681 virtual Major MajorKey() const V8_OVERRIDE { return Instanceof; } | 715 virtual Major MajorKey() const V8_OVERRIDE { return Instanceof; } |
682 | 716 |
683 Flags flags() const { return FlagBits::decode(minor_key_); } | 717 Flags flags() const { return FlagBits::decode(minor_key_); } |
684 | 718 |
685 bool HasArgsInRegisters() const { return (flags() & kArgsInRegisters) != 0; } | 719 bool HasArgsInRegisters() const { return (flags() & kArgsInRegisters) != 0; } |
(...skipping 1881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2567 | 2601 |
2568 void Generate(MacroAssembler* masm); | 2602 void Generate(MacroAssembler* masm); |
2569 | 2603 |
2570 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); | 2604 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); |
2571 }; | 2605 }; |
2572 | 2606 |
2573 | 2607 |
2574 } } // namespace v8::internal | 2608 } } // namespace v8::internal |
2575 | 2609 |
2576 #endif // V8_CODE_STUBS_H_ | 2610 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |