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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 class IsGeneratorBits : public BitField<bool, 1, 1> {}; | 637 class IsGeneratorBits : public BitField<bool, 1, 1> {}; |
638 | 638 |
639 DISALLOW_COPY_AND_ASSIGN(FastNewClosureStub); | 639 DISALLOW_COPY_AND_ASSIGN(FastNewClosureStub); |
640 }; | 640 }; |
641 | 641 |
642 | 642 |
643 class FastNewContextStub V8_FINAL : public HydrogenCodeStub { | 643 class FastNewContextStub V8_FINAL : public HydrogenCodeStub { |
644 public: | 644 public: |
645 static const int kMaximumSlots = 64; | 645 static const int kMaximumSlots = 64; |
646 | 646 |
647 FastNewContextStub(Isolate* isolate, int slots) | 647 FastNewContextStub(Isolate* isolate, int slots) : HydrogenCodeStub(isolate) { |
648 : HydrogenCodeStub(isolate), slots_(slots) { | 648 DCHECK(slots > 0 && slots <= kMaximumSlots); |
649 DCHECK(slots_ > 0 && slots_ <= kMaximumSlots); | 649 set_sub_minor_key(SlotsBits::encode(slots)); |
650 } | 650 } |
651 | 651 |
652 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 652 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
653 | 653 |
654 virtual void InitializeInterfaceDescriptor( | 654 virtual void InitializeInterfaceDescriptor( |
655 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 655 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
656 | 656 |
657 static void InstallDescriptors(Isolate* isolate); | 657 static void InstallDescriptors(Isolate* isolate); |
658 | 658 |
659 int slots() const { return slots_; } | 659 int slots() const { return SlotsBits::decode(sub_minor_key()); } |
660 | |
661 virtual Major MajorKey() const V8_OVERRIDE { return FastNewContext; } | |
662 virtual int NotMissMinorKey() const V8_OVERRIDE { return slots_; } | |
663 | 660 |
664 // Parameters accessed via CodeStubGraphBuilder::GetParameter() | 661 // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
665 static const int kFunction = 0; | 662 static const int kFunction = 0; |
666 | 663 |
667 private: | 664 private: |
668 int slots_; | 665 virtual Major MajorKey() const V8_OVERRIDE { return FastNewContext; } |
| 666 |
| 667 class SlotsBits : public BitField<int, 0, 8> {}; |
| 668 |
| 669 DISALLOW_COPY_AND_ASSIGN(FastNewContextStub); |
669 }; | 670 }; |
670 | 671 |
671 | 672 |
672 class FastCloneShallowArrayStub : public HydrogenCodeStub { | 673 class FastCloneShallowArrayStub : public HydrogenCodeStub { |
673 public: | 674 public: |
674 FastCloneShallowArrayStub(Isolate* isolate, | 675 FastCloneShallowArrayStub(Isolate* isolate, |
675 AllocationSiteMode allocation_site_mode) | 676 AllocationSiteMode allocation_site_mode) |
676 : HydrogenCodeStub(isolate), | 677 : HydrogenCodeStub(isolate) { |
677 allocation_site_mode_(allocation_site_mode) {} | 678 set_sub_minor_key(AllocationSiteModeBits::encode(allocation_site_mode)); |
| 679 } |
678 | 680 |
679 AllocationSiteMode allocation_site_mode() const { | 681 AllocationSiteMode allocation_site_mode() const { |
680 return allocation_site_mode_; | 682 return AllocationSiteModeBits::decode(sub_minor_key()); |
681 } | 683 } |
682 | 684 |
683 virtual Handle<Code> GenerateCode(); | 685 virtual Handle<Code> GenerateCode(); |
684 | 686 |
685 virtual void InitializeInterfaceDescriptor( | 687 virtual void InitializeInterfaceDescriptor( |
686 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 688 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
687 | 689 |
688 static void InstallDescriptors(Isolate* isolate); | 690 static void InstallDescriptors(Isolate* isolate); |
689 | 691 |
690 private: | 692 private: |
691 AllocationSiteMode allocation_site_mode_; | 693 virtual Major MajorKey() const V8_OVERRIDE { return FastCloneShallowArray; } |
692 | 694 |
693 class AllocationSiteModeBits: public BitField<AllocationSiteMode, 0, 1> {}; | 695 class AllocationSiteModeBits: public BitField<AllocationSiteMode, 0, 1> {}; |
694 // Ensure data fits within available bits. | 696 |
695 virtual Major MajorKey() const V8_OVERRIDE { return FastCloneShallowArray; } | 697 DISALLOW_COPY_AND_ASSIGN(FastCloneShallowArrayStub); |
696 int NotMissMinorKey() const { | |
697 return AllocationSiteModeBits::encode(allocation_site_mode_); | |
698 } | |
699 }; | 698 }; |
700 | 699 |
701 | 700 |
702 class FastCloneShallowObjectStub : public HydrogenCodeStub { | 701 class FastCloneShallowObjectStub : public HydrogenCodeStub { |
703 public: | 702 public: |
704 // Maximum number of properties in copied object. | 703 // Maximum number of properties in copied object. |
705 static const int kMaximumClonedProperties = 6; | 704 static const int kMaximumClonedProperties = 6; |
706 | 705 |
707 FastCloneShallowObjectStub(Isolate* isolate, int length) | 706 FastCloneShallowObjectStub(Isolate* isolate, int length) |
708 : HydrogenCodeStub(isolate), length_(length) { | 707 : HydrogenCodeStub(isolate), length_(length) { |
(...skipping 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2491 byte ToByte() const { return ToIntegral(); } | 2490 byte ToByte() const { return ToIntegral(); } |
2492 bool UpdateStatus(Handle<Object> object); | 2491 bool UpdateStatus(Handle<Object> object); |
2493 bool NeedsMap() const; | 2492 bool NeedsMap() const; |
2494 bool CanBeUndetectable() const; | 2493 bool CanBeUndetectable() const; |
2495 bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); } | 2494 bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); } |
2496 | 2495 |
2497 static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); } | 2496 static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); } |
2498 }; | 2497 }; |
2499 | 2498 |
2500 ToBooleanStub(Isolate* isolate, ResultMode mode, Types types = Types()) | 2499 ToBooleanStub(Isolate* isolate, ResultMode mode, Types types = Types()) |
2501 : HydrogenCodeStub(isolate), types_(types), mode_(mode) {} | 2500 : HydrogenCodeStub(isolate) { |
| 2501 set_sub_minor_key(TypesBits::encode(types.ToByte()) | |
| 2502 ResultModeBits::encode(mode)); |
| 2503 } |
| 2504 |
2502 ToBooleanStub(Isolate* isolate, ExtraICState state) | 2505 ToBooleanStub(Isolate* isolate, ExtraICState state) |
2503 : HydrogenCodeStub(isolate), | 2506 : HydrogenCodeStub(isolate) { |
2504 types_(static_cast<byte>(state)), | 2507 set_sub_minor_key(TypesBits::encode(static_cast<byte>(state)) | |
2505 mode_(RESULT_AS_SMI) {} | 2508 ResultModeBits::encode(RESULT_AS_SMI)); |
| 2509 } |
2506 | 2510 |
2507 bool UpdateStatus(Handle<Object> object); | 2511 bool UpdateStatus(Handle<Object> object); |
2508 Types GetTypes() { return types_; } | 2512 Types types() const { return Types(TypesBits::decode(sub_minor_key())); } |
2509 ResultMode GetMode() { return mode_; } | 2513 ResultMode mode() const { return ResultModeBits::decode(sub_minor_key()); } |
2510 | 2514 |
2511 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 2515 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
2512 virtual void InitializeInterfaceDescriptor( | 2516 virtual void InitializeInterfaceDescriptor( |
2513 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 2517 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
2514 | 2518 |
2515 virtual Code::Kind GetCodeKind() const { return Code::TO_BOOLEAN_IC; } | 2519 virtual Code::Kind GetCodeKind() const { return Code::TO_BOOLEAN_IC; } |
2516 virtual void PrintState(OStream& os) const V8_OVERRIDE; // NOLINT | 2520 virtual void PrintState(OStream& os) const V8_OVERRIDE; // NOLINT |
2517 | 2521 |
2518 virtual bool SometimesSetsUpAFrame() { return false; } | 2522 virtual bool SometimesSetsUpAFrame() { return false; } |
2519 | 2523 |
2520 static void InstallDescriptors(Isolate* isolate) { | 2524 static void InstallDescriptors(Isolate* isolate) { |
2521 ToBooleanStub stub(isolate, RESULT_AS_SMI); | 2525 ToBooleanStub stub(isolate, RESULT_AS_SMI); |
2522 stub.InitializeInterfaceDescriptor( | 2526 stub.InitializeInterfaceDescriptor( |
2523 isolate->code_stub_interface_descriptor(CodeStub::ToBoolean)); | 2527 isolate->code_stub_interface_descriptor(CodeStub::ToBoolean)); |
2524 } | 2528 } |
2525 | 2529 |
2526 static Handle<Code> GetUninitialized(Isolate* isolate) { | 2530 static Handle<Code> GetUninitialized(Isolate* isolate) { |
2527 return ToBooleanStub(isolate, UNINITIALIZED).GetCode(); | 2531 return ToBooleanStub(isolate, UNINITIALIZED).GetCode(); |
2528 } | 2532 } |
2529 | 2533 |
2530 virtual ExtraICState GetExtraICState() const { return types_.ToIntegral(); } | 2534 virtual ExtraICState GetExtraICState() const { return types().ToIntegral(); } |
2531 | 2535 |
2532 virtual InlineCacheState GetICState() const { | 2536 virtual InlineCacheState GetICState() const { |
2533 if (types_.IsEmpty()) { | 2537 if (types().IsEmpty()) { |
2534 return ::v8::internal::UNINITIALIZED; | 2538 return ::v8::internal::UNINITIALIZED; |
2535 } else { | 2539 } else { |
2536 return MONOMORPHIC; | 2540 return MONOMORPHIC; |
2537 } | 2541 } |
2538 } | 2542 } |
2539 | 2543 |
2540 private: | 2544 private: |
| 2545 virtual Major MajorKey() const V8_OVERRIDE { return ToBoolean; } |
| 2546 |
| 2547 ToBooleanStub(Isolate* isolate, InitializationState init_state) |
| 2548 : HydrogenCodeStub(isolate, init_state) { |
| 2549 set_sub_minor_key(ResultModeBits::encode(RESULT_AS_SMI)); |
| 2550 } |
| 2551 |
2541 class TypesBits : public BitField<byte, 0, NUMBER_OF_TYPES> {}; | 2552 class TypesBits : public BitField<byte, 0, NUMBER_OF_TYPES> {}; |
2542 class ResultModeBits : public BitField<ResultMode, NUMBER_OF_TYPES, 2> {}; | 2553 class ResultModeBits : public BitField<ResultMode, NUMBER_OF_TYPES, 2> {}; |
2543 | 2554 |
2544 virtual Major MajorKey() const V8_OVERRIDE { return ToBoolean; } | 2555 DISALLOW_COPY_AND_ASSIGN(ToBooleanStub); |
2545 int NotMissMinorKey() const { | |
2546 return TypesBits::encode(types_.ToByte()) | ResultModeBits::encode(mode_); | |
2547 } | |
2548 | |
2549 ToBooleanStub(Isolate* isolate, InitializationState init_state) | |
2550 : HydrogenCodeStub(isolate, init_state), mode_(RESULT_AS_SMI) {} | |
2551 | |
2552 Types types_; | |
2553 ResultMode mode_; | |
2554 }; | 2556 }; |
2555 | 2557 |
2556 | 2558 |
2557 OStream& operator<<(OStream& os, const ToBooleanStub::Types& t); | 2559 OStream& operator<<(OStream& os, const ToBooleanStub::Types& t); |
2558 | 2560 |
2559 | 2561 |
2560 class ElementsTransitionAndStoreStub : public HydrogenCodeStub { | 2562 class ElementsTransitionAndStoreStub : public HydrogenCodeStub { |
2561 public: | 2563 public: |
2562 ElementsTransitionAndStoreStub(Isolate* isolate, | 2564 ElementsTransitionAndStoreStub(Isolate* isolate, ElementsKind from_kind, |
2563 ElementsKind from_kind, | 2565 ElementsKind to_kind, bool is_jsarray, |
2564 ElementsKind to_kind, | |
2565 bool is_jsarray, | |
2566 KeyedAccessStoreMode store_mode) | 2566 KeyedAccessStoreMode store_mode) |
2567 : HydrogenCodeStub(isolate), | 2567 : HydrogenCodeStub(isolate) { |
2568 from_kind_(from_kind), | 2568 set_sub_minor_key(FromBits::encode(from_kind) | ToBits::encode(to_kind) | |
2569 to_kind_(to_kind), | 2569 IsJSArrayBits::encode(is_jsarray) | |
2570 is_jsarray_(is_jsarray), | 2570 StoreModeBits::encode(store_mode)); |
2571 store_mode_(store_mode) {} | 2571 } |
2572 | 2572 |
2573 ElementsKind from_kind() const { return from_kind_; } | 2573 ElementsKind from_kind() const { return FromBits::decode(sub_minor_key()); } |
2574 ElementsKind to_kind() const { return to_kind_; } | 2574 ElementsKind to_kind() const { return ToBits::decode(sub_minor_key()); } |
2575 bool is_jsarray() const { return is_jsarray_; } | 2575 bool is_jsarray() const { return IsJSArrayBits::decode(sub_minor_key()); } |
2576 KeyedAccessStoreMode store_mode() const { return store_mode_; } | 2576 KeyedAccessStoreMode store_mode() const { |
| 2577 return StoreModeBits::decode(sub_minor_key()); |
| 2578 } |
2577 | 2579 |
2578 virtual Handle<Code> GenerateCode() V8_OVERRIDE; | 2580 virtual Handle<Code> GenerateCode() V8_OVERRIDE; |
2579 | 2581 |
2580 virtual void InitializeInterfaceDescriptor( | 2582 virtual void InitializeInterfaceDescriptor( |
2581 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; | 2583 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; |
2582 | 2584 |
2583 // Parameters accessed via CodeStubGraphBuilder::GetParameter() | 2585 // Parameters accessed via CodeStubGraphBuilder::GetParameter() |
2584 enum ParameterIndices { | 2586 enum ParameterIndices { |
2585 kValueIndex, | 2587 kValueIndex, |
2586 kMapIndex, | 2588 kMapIndex, |
2587 kKeyIndex, | 2589 kKeyIndex, |
2588 kObjectIndex, | 2590 kObjectIndex, |
2589 kParameterCount | 2591 kParameterCount |
2590 }; | 2592 }; |
2591 | 2593 |
2592 static const Register ValueRegister() { | 2594 static const Register ValueRegister() { |
2593 return StoreConvention::ValueRegister(); | 2595 return StoreConvention::ValueRegister(); |
2594 } | 2596 } |
2595 static const Register MapRegister() { return StoreConvention::MapRegister(); } | 2597 static const Register MapRegister() { return StoreConvention::MapRegister(); } |
2596 static const Register KeyRegister() { | 2598 static const Register KeyRegister() { |
2597 return StoreConvention::NameRegister(); | 2599 return StoreConvention::NameRegister(); |
2598 } | 2600 } |
2599 static const Register ObjectRegister() { | 2601 static const Register ObjectRegister() { |
2600 return StoreConvention::ReceiverRegister(); | 2602 return StoreConvention::ReceiverRegister(); |
2601 } | 2603 } |
2602 | 2604 |
2603 private: | 2605 private: |
2604 class FromBits: public BitField<ElementsKind, 0, 8> {}; | |
2605 class ToBits: public BitField<ElementsKind, 8, 8> {}; | |
2606 class IsJSArrayBits: public BitField<bool, 16, 1> {}; | |
2607 class StoreModeBits: public BitField<KeyedAccessStoreMode, 17, 4> {}; | |
2608 | |
2609 virtual Major MajorKey() const V8_OVERRIDE { | 2606 virtual Major MajorKey() const V8_OVERRIDE { |
2610 return ElementsTransitionAndStore; | 2607 return ElementsTransitionAndStore; |
2611 } | 2608 } |
2612 int NotMissMinorKey() const { | |
2613 return FromBits::encode(from_kind_) | | |
2614 ToBits::encode(to_kind_) | | |
2615 IsJSArrayBits::encode(is_jsarray_) | | |
2616 StoreModeBits::encode(store_mode_); | |
2617 } | |
2618 | 2609 |
2619 ElementsKind from_kind_; | 2610 class FromBits : public BitField<ElementsKind, 0, 8> {}; |
2620 ElementsKind to_kind_; | 2611 class ToBits : public BitField<ElementsKind, 8, 8> {}; |
2621 bool is_jsarray_; | 2612 class IsJSArrayBits : public BitField<bool, 16, 1> {}; |
2622 KeyedAccessStoreMode store_mode_; | 2613 class StoreModeBits : public BitField<KeyedAccessStoreMode, 17, 4> {}; |
2623 | 2614 |
2624 DISALLOW_COPY_AND_ASSIGN(ElementsTransitionAndStoreStub); | 2615 DISALLOW_COPY_AND_ASSIGN(ElementsTransitionAndStoreStub); |
2625 }; | 2616 }; |
2626 | 2617 |
2627 | 2618 |
2628 class StoreArrayLiteralElementStub : public PlatformCodeStub { | 2619 class StoreArrayLiteralElementStub : public PlatformCodeStub { |
2629 public: | 2620 public: |
2630 explicit StoreArrayLiteralElementStub(Isolate* isolate) | 2621 explicit StoreArrayLiteralElementStub(Isolate* isolate) |
2631 : PlatformCodeStub(isolate) { } | 2622 : PlatformCodeStub(isolate) { } |
2632 | 2623 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2689 | 2680 |
2690 | 2681 |
2691 class CallDescriptors { | 2682 class CallDescriptors { |
2692 public: | 2683 public: |
2693 static void InitializeForIsolate(Isolate* isolate); | 2684 static void InitializeForIsolate(Isolate* isolate); |
2694 }; | 2685 }; |
2695 | 2686 |
2696 } } // namespace v8::internal | 2687 } } // namespace v8::internal |
2697 | 2688 |
2698 #endif // V8_CODE_STUBS_H_ | 2689 #endif // V8_CODE_STUBS_H_ |
OLD | NEW |