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 "allocation.h" | 8 #include "allocation.h" |
9 #include "assembler.h" | 9 #include "assembler.h" |
10 #include "codegen.h" | 10 #include "codegen.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 struct CodeStubInterfaceDescriptor { | 270 struct CodeStubInterfaceDescriptor { |
271 CodeStubInterfaceDescriptor(); | 271 CodeStubInterfaceDescriptor(); |
272 int register_param_count_; | 272 int register_param_count_; |
273 | 273 |
274 Register stack_parameter_count_; | 274 Register stack_parameter_count_; |
275 // if hint_stack_parameter_count_ > 0, the code stub can optimize the | 275 // if hint_stack_parameter_count_ > 0, the code stub can optimize the |
276 // return sequence. Default value is -1, which means it is ignored. | 276 // return sequence. Default value is -1, which means it is ignored. |
277 int hint_stack_parameter_count_; | 277 int hint_stack_parameter_count_; |
278 StubFunctionMode function_mode_; | 278 StubFunctionMode function_mode_; |
279 Register* register_params_; | 279 Register* register_params_; |
| 280 // Specifies Representations for the stub's parameter. Points to an array of |
| 281 // Representations of the same length of the numbers of parameters to the |
| 282 // stub, or if NULL (the default value), Representation of each parameter |
| 283 // assumed to be Tagged() |
| 284 Representation* register_param_representations_; |
280 | 285 |
281 Address deoptimization_handler_; | 286 Address deoptimization_handler_; |
282 HandlerArgumentsMode handler_arguments_mode_; | 287 HandlerArgumentsMode handler_arguments_mode_; |
283 | 288 |
284 bool initialized() const { return register_param_count_ >= 0; } | 289 bool initialized() const { return register_param_count_ >= 0; } |
285 | 290 |
286 int environment_length() const { | 291 int environment_length() const { |
287 return register_param_count_; | 292 return register_param_count_; |
288 } | 293 } |
289 | 294 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 static const int kFunction = 0; | 579 static const int kFunction = 0; |
575 | 580 |
576 private: | 581 private: |
577 int slots_; | 582 int slots_; |
578 }; | 583 }; |
579 | 584 |
580 | 585 |
581 class FastCloneShallowArrayStub : public HydrogenCodeStub { | 586 class FastCloneShallowArrayStub : public HydrogenCodeStub { |
582 public: | 587 public: |
583 // Maximum length of copied elements array. | 588 // Maximum length of copied elements array. |
584 static const int kMaximumClonedLength = 8; | 589 static const int kMaximumInlinedCloneLength = 8; |
585 enum Mode { | |
586 CLONE_ELEMENTS, | |
587 CLONE_DOUBLE_ELEMENTS, | |
588 COPY_ON_WRITE_ELEMENTS, | |
589 CLONE_ANY_ELEMENTS, | |
590 LAST_CLONE_MODE = CLONE_ANY_ELEMENTS | |
591 }; | |
592 | |
593 static const int kFastCloneModeCount = LAST_CLONE_MODE + 1; | |
594 | 590 |
595 FastCloneShallowArrayStub(Isolate* isolate, | 591 FastCloneShallowArrayStub(Isolate* isolate, |
596 Mode mode, | 592 AllocationSiteMode allocation_site_mode) |
597 AllocationSiteMode allocation_site_mode, | |
598 int length) | |
599 : HydrogenCodeStub(isolate), | 593 : HydrogenCodeStub(isolate), |
600 mode_(mode), | 594 allocation_site_mode_(allocation_site_mode) {} |
601 allocation_site_mode_(allocation_site_mode), | |
602 length_((mode == COPY_ON_WRITE_ELEMENTS) ? 0 : length) { | |
603 ASSERT_GE(length_, 0); | |
604 ASSERT_LE(length_, kMaximumClonedLength); | |
605 } | |
606 | 595 |
607 Mode mode() const { return mode_; } | |
608 int length() const { return length_; } | |
609 AllocationSiteMode allocation_site_mode() const { | 596 AllocationSiteMode allocation_site_mode() const { |
610 return allocation_site_mode_; | 597 return allocation_site_mode_; |
611 } | 598 } |
612 | 599 |
613 ElementsKind ComputeElementsKind() const { | 600 virtual Handle<Code> GenerateCode(); |
614 switch (mode()) { | |
615 case CLONE_ELEMENTS: | |
616 case COPY_ON_WRITE_ELEMENTS: | |
617 return FAST_ELEMENTS; | |
618 case CLONE_DOUBLE_ELEMENTS: | |
619 return FAST_DOUBLE_ELEMENTS; | |
620 case CLONE_ANY_ELEMENTS: | |
621 /*fall-through*/; | |
622 } | |
623 UNREACHABLE(); | |
624 return LAST_ELEMENTS_KIND; | |
625 } | |
626 | |
627 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | |
628 | 601 |
629 virtual void InitializeInterfaceDescriptor( | 602 virtual void InitializeInterfaceDescriptor( |
630 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 603 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
631 | 604 |
632 static void InstallDescriptors(Isolate* isolate); | 605 static void InstallDescriptors(Isolate* isolate); |
633 | 606 |
634 private: | 607 private: |
635 Mode mode_; | |
636 AllocationSiteMode allocation_site_mode_; | 608 AllocationSiteMode allocation_site_mode_; |
637 int length_; | |
638 | 609 |
639 class AllocationSiteModeBits: public BitField<AllocationSiteMode, 0, 1> {}; | 610 class AllocationSiteModeBits: public BitField<AllocationSiteMode, 0, 1> {}; |
640 class ModeBits: public BitField<Mode, 1, 4> {}; | |
641 class LengthBits: public BitField<int, 5, 4> {}; | |
642 // Ensure data fits within available bits. | 611 // Ensure data fits within available bits. |
643 STATIC_ASSERT(LAST_ALLOCATION_SITE_MODE == 1); | |
644 STATIC_ASSERT(kFastCloneModeCount < 16); | |
645 STATIC_ASSERT(kMaximumClonedLength < 16); | |
646 Major MajorKey() { return FastCloneShallowArray; } | 612 Major MajorKey() { return FastCloneShallowArray; } |
647 int NotMissMinorKey() { | 613 int NotMissMinorKey() { |
648 return AllocationSiteModeBits::encode(allocation_site_mode_) | 614 return AllocationSiteModeBits::encode(allocation_site_mode_); |
649 | ModeBits::encode(mode_) | |
650 | LengthBits::encode(length_); | |
651 } | 615 } |
652 }; | 616 }; |
653 | 617 |
654 | 618 |
655 class FastCloneShallowObjectStub : public HydrogenCodeStub { | 619 class FastCloneShallowObjectStub : public HydrogenCodeStub { |
656 public: | 620 public: |
657 // Maximum number of properties in copied object. | 621 // Maximum number of properties in copied object. |
658 static const int kMaximumClonedProperties = 6; | 622 static const int kMaximumClonedProperties = 6; |
659 | 623 |
660 FastCloneShallowObjectStub(Isolate* isolate, int length) | 624 FastCloneShallowObjectStub(Isolate* isolate, int length) |
(...skipping 1882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2543 | 2507 |
2544 | 2508 |
2545 class CallDescriptors { | 2509 class CallDescriptors { |
2546 public: | 2510 public: |
2547 static void InitializeForIsolate(Isolate* isolate); | 2511 static void InitializeForIsolate(Isolate* isolate); |
2548 }; | 2512 }; |
2549 | 2513 |
2550 } } // namespace v8::internal | 2514 } } // namespace v8::internal |
2551 | 2515 |
2552 #endif // V8_CODE_STUBS_H_ | 2516 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |