OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 3162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3173 return &raw_ptr()->data_[data_index]; | 3173 return &raw_ptr()->data_[data_index]; |
3174 } | 3174 } |
3175 | 3175 |
3176 void SetLength(intptr_t value) const; | 3176 void SetLength(intptr_t value) const; |
3177 | 3177 |
3178 FINAL_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo, Object); | 3178 FINAL_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo, Object); |
3179 friend class Class; | 3179 friend class Class; |
3180 }; | 3180 }; |
3181 | 3181 |
3182 | 3182 |
| 3183 #define DEOPT_REASONS(V) \ |
| 3184 V(Unknown) \ |
| 3185 V(InstanceGetter) \ |
| 3186 V(PolymorphicInstanceCallTestFail) \ |
| 3187 V(InstanceCallNoICData) \ |
| 3188 V(IntegerToDouble) \ |
| 3189 V(BinarySmiOp) \ |
| 3190 V(BinaryMintOp) \ |
| 3191 V(UnaryMintOp) \ |
| 3192 V(ShiftMintOp) \ |
| 3193 V(BinaryDoubleOp) \ |
| 3194 V(InstanceSetter) \ |
| 3195 V(Equality) \ |
| 3196 V(RelationalOp) \ |
| 3197 V(EqualityClassCheck) \ |
| 3198 V(NoTypeFeedback) \ |
| 3199 V(UnaryOp) \ |
| 3200 V(UnboxInteger) \ |
| 3201 V(CheckClass) \ |
| 3202 V(HoistedCheckClass) \ |
| 3203 V(CheckSmi) \ |
| 3204 V(CheckArrayBound) \ |
| 3205 V(AtCall) \ |
| 3206 V(DoubleToSmi) \ |
| 3207 V(Int32Load) \ |
| 3208 V(Uint32Load) \ |
| 3209 V(GuardField) \ |
| 3210 V(NumReasons) \ |
| 3211 |
| 3212 enum DeoptReasonId { |
| 3213 #define DEFINE_ENUM_LIST(name) kDeopt##name, |
| 3214 DEOPT_REASONS(DEFINE_ENUM_LIST) |
| 3215 #undef DEFINE_ENUM_LIST |
| 3216 }; |
| 3217 |
| 3218 |
3183 class Code : public Object { | 3219 class Code : public Object { |
3184 public: | 3220 public: |
3185 RawInstructions* instructions() const { return raw_ptr()->instructions_; } | 3221 RawInstructions* instructions() const { return raw_ptr()->instructions_; } |
3186 static intptr_t instructions_offset() { | 3222 static intptr_t instructions_offset() { |
3187 return OFFSET_OF(RawCode, instructions_); | 3223 return OFFSET_OF(RawCode, instructions_); |
3188 } | 3224 } |
3189 intptr_t pointer_offsets_length() const { | 3225 intptr_t pointer_offsets_length() const { |
3190 return raw_ptr()->pointer_offsets_length_; | 3226 return raw_ptr()->pointer_offsets_length_; |
3191 } | 3227 } |
3192 | 3228 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3250 kSCallTableFunctionEntry = 1, | 3286 kSCallTableFunctionEntry = 1, |
3251 kSCallTableCodeEntry = 2, | 3287 kSCallTableCodeEntry = 2, |
3252 kSCallTableEntryLength = 3, | 3288 kSCallTableEntryLength = 3, |
3253 }; | 3289 }; |
3254 | 3290 |
3255 void set_static_calls_target_table(const Array& value) const; | 3291 void set_static_calls_target_table(const Array& value) const; |
3256 RawArray* static_calls_target_table() const { | 3292 RawArray* static_calls_target_table() const { |
3257 return raw_ptr()->static_calls_target_table_; | 3293 return raw_ptr()->static_calls_target_table_; |
3258 } | 3294 } |
3259 | 3295 |
3260 RawDeoptInfo* GetDeoptInfoAtPc(uword pc, intptr_t* deopt_reason) const; | 3296 RawDeoptInfo* GetDeoptInfoAtPc(uword pc, DeoptReasonId* deopt_reason) const; |
3261 | 3297 |
3262 // Returns null if there is no static call at 'pc'. | 3298 // Returns null if there is no static call at 'pc'. |
3263 RawFunction* GetStaticCallTargetFunctionAt(uword pc) const; | 3299 RawFunction* GetStaticCallTargetFunctionAt(uword pc) const; |
3264 // Returns null if there is no static call at 'pc'. | 3300 // Returns null if there is no static call at 'pc'. |
3265 RawCode* GetStaticCallTargetCodeAt(uword pc) const; | 3301 RawCode* GetStaticCallTargetCodeAt(uword pc) const; |
3266 // Aborts if there is no static call at 'pc'. | 3302 // Aborts if there is no static call at 'pc'. |
3267 void SetStaticCallTargetCodeAt(uword pc, const Code& code) const; | 3303 void SetStaticCallTargetCodeAt(uword pc, const Code& code) const; |
3268 | 3304 |
3269 void Disassemble(DisassemblyFormatter* formatter = NULL) const; | 3305 void Disassemble(DisassemblyFormatter* formatter = NULL) const; |
3270 | 3306 |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3601 | 3637 |
3602 FINAL_HEAP_OBJECT_IMPLEMENTATION(ContextScope, Object); | 3638 FINAL_HEAP_OBJECT_IMPLEMENTATION(ContextScope, Object); |
3603 friend class Class; | 3639 friend class Class; |
3604 }; | 3640 }; |
3605 | 3641 |
3606 | 3642 |
3607 // Object holding information about an IC: test classes and their | 3643 // Object holding information about an IC: test classes and their |
3608 // corresponding targets. | 3644 // corresponding targets. |
3609 class ICData : public Object { | 3645 class ICData : public Object { |
3610 public: | 3646 public: |
3611 RawFunction* function() const { | 3647 RawFunction* owner() const { |
3612 return raw_ptr()->function_; | 3648 return raw_ptr()->owner_; |
3613 } | 3649 } |
3614 | 3650 |
3615 RawString* target_name() const { | 3651 RawString* target_name() const { |
3616 return raw_ptr()->target_name_; | 3652 return raw_ptr()->target_name_; |
3617 } | 3653 } |
3618 | 3654 |
3619 RawArray* arguments_descriptor() const { | 3655 RawArray* arguments_descriptor() const { |
3620 return raw_ptr()->args_descriptor_; | 3656 return raw_ptr()->args_descriptor_; |
3621 } | 3657 } |
3622 | 3658 |
3623 intptr_t num_args_tested() const { | 3659 intptr_t NumArgsTested() const; |
3624 return raw_ptr()->num_args_tested_; | |
3625 } | |
3626 | 3660 |
3627 intptr_t deopt_id() const { | 3661 intptr_t deopt_id() const { |
3628 return raw_ptr()->deopt_id_; | 3662 return raw_ptr()->deopt_id_; |
3629 } | 3663 } |
3630 | 3664 |
3631 intptr_t deopt_reason() const { | 3665 bool HasDeoptReasons() const { return DeoptReasons() > 0; } |
3632 return raw_ptr()->deopt_reason_; | 3666 uint32_t DeoptReasons() const; |
3633 } | 3667 void SetDeoptReasons(uint32_t reasons) const; |
3634 | 3668 |
3635 void set_deopt_reason(intptr_t reason) const; | 3669 bool HasDeoptReason(DeoptReasonId reason) const; |
| 3670 void AddDeoptReason(DeoptReasonId reason) const; |
3636 | 3671 |
3637 bool is_closure_call() const { | 3672 bool IssuedJSWarning() const; |
3638 return raw_ptr()->is_closure_call_ == 1; | 3673 void SetIssuedJSWarning() const; |
3639 } | |
3640 | 3674 |
3641 void set_is_closure_call(bool value) const; | 3675 bool IsClosureCall() const; |
| 3676 void SetIsClosureCall() const; |
3642 | 3677 |
3643 intptr_t NumberOfChecks() const; | 3678 intptr_t NumberOfChecks() const; |
3644 | 3679 |
3645 static intptr_t InstanceSize() { | 3680 static intptr_t InstanceSize() { |
3646 return RoundedAllocationSize(sizeof(RawICData)); | 3681 return RoundedAllocationSize(sizeof(RawICData)); |
3647 } | 3682 } |
3648 | 3683 |
3649 static intptr_t target_name_offset() { | 3684 static intptr_t target_name_offset() { |
3650 return OFFSET_OF(RawICData, target_name_); | 3685 return OFFSET_OF(RawICData, target_name_); |
3651 } | 3686 } |
3652 | 3687 |
3653 static intptr_t num_args_tested_offset() { | 3688 static intptr_t state_bits_offset() { |
3654 return OFFSET_OF(RawICData, num_args_tested_); | 3689 return OFFSET_OF(RawICData, state_bits_); |
| 3690 } |
| 3691 |
| 3692 static intptr_t NumArgsTestedMask() { |
| 3693 return (1 << kNumArgsTestedSize) - 1; |
3655 } | 3694 } |
3656 | 3695 |
3657 static intptr_t arguments_descriptor_offset() { | 3696 static intptr_t arguments_descriptor_offset() { |
3658 return OFFSET_OF(RawICData, args_descriptor_); | 3697 return OFFSET_OF(RawICData, args_descriptor_); |
3659 } | 3698 } |
3660 | 3699 |
3661 static intptr_t ic_data_offset() { | 3700 static intptr_t ic_data_offset() { |
3662 return OFFSET_OF(RawICData, ic_data_); | 3701 return OFFSET_OF(RawICData, ic_data_); |
3663 } | 3702 } |
3664 | 3703 |
3665 static intptr_t function_offset() { | 3704 static intptr_t owner_offset() { |
3666 return OFFSET_OF(RawICData, function_); | 3705 return OFFSET_OF(RawICData, owner_); |
3667 } | |
3668 | |
3669 static intptr_t is_closure_call_offset() { | |
3670 return OFFSET_OF(RawICData, is_closure_call_); | |
3671 } | 3706 } |
3672 | 3707 |
3673 // Used for unoptimized static calls when no class-ids are checked. | 3708 // Used for unoptimized static calls when no class-ids are checked. |
3674 void AddTarget(const Function& target) const; | 3709 void AddTarget(const Function& target) const; |
3675 | 3710 |
3676 // Adding checks. | 3711 // Adding checks. |
3677 | 3712 |
3678 // Adds one more class test to ICData. Length of 'classes' must be equal to | 3713 // Adds one more class test to ICData. Length of 'classes' must be equal to |
3679 // the number of arguments tested. Use only for num_args_tested > 1. | 3714 // the number of arguments tested. Use only for num_args_tested > 1. |
3680 void AddCheck(const GrowableArray<intptr_t>& class_ids, | 3715 void AddCheck(const GrowableArray<intptr_t>& class_ids, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3713 RawICData* AsUnaryClassChecksForArgNr(intptr_t arg_nr) const; | 3748 RawICData* AsUnaryClassChecksForArgNr(intptr_t arg_nr) const; |
3714 RawICData* AsUnaryClassChecks() const { | 3749 RawICData* AsUnaryClassChecks() const { |
3715 return AsUnaryClassChecksForArgNr(0); | 3750 return AsUnaryClassChecksForArgNr(0); |
3716 } | 3751 } |
3717 | 3752 |
3718 bool AllTargetsHaveSameOwner(intptr_t owner_cid) const; | 3753 bool AllTargetsHaveSameOwner(intptr_t owner_cid) const; |
3719 bool AllReceiversAreNumbers() const; | 3754 bool AllReceiversAreNumbers() const; |
3720 bool HasOneTarget() const; | 3755 bool HasOneTarget() const; |
3721 bool HasReceiverClassId(intptr_t class_id) const; | 3756 bool HasReceiverClassId(intptr_t class_id) const; |
3722 | 3757 |
3723 static RawICData* New(const Function& caller_function, | 3758 static RawICData* New(const Function& owner, |
3724 const String& target_name, | 3759 const String& target_name, |
3725 const Array& arguments_descriptor, | 3760 const Array& arguments_descriptor, |
3726 intptr_t deopt_id, | 3761 intptr_t deopt_id, |
3727 intptr_t num_args_tested); | 3762 intptr_t num_args_tested); |
3728 | 3763 |
3729 static intptr_t TestEntryLengthFor(intptr_t num_args); | 3764 static intptr_t TestEntryLengthFor(intptr_t num_args); |
3730 | 3765 |
3731 static intptr_t TargetIndexFor(intptr_t num_args) { | 3766 static intptr_t TargetIndexFor(intptr_t num_args) { |
3732 return num_args; | 3767 return num_args; |
3733 } | 3768 } |
3734 | 3769 |
3735 static intptr_t CountIndexFor(intptr_t num_args) { | 3770 static intptr_t CountIndexFor(intptr_t num_args) { |
3736 return (num_args + 1); | 3771 return (num_args + 1); |
3737 } | 3772 } |
3738 | 3773 |
3739 private: | 3774 private: |
3740 RawArray* ic_data() const { | 3775 RawArray* ic_data() const { |
3741 return raw_ptr()->ic_data_; | 3776 return raw_ptr()->ic_data_; |
3742 } | 3777 } |
3743 | 3778 |
3744 void set_function(const Function& value) const; | 3779 void set_owner(const Function& value) const; |
3745 void set_target_name(const String& value) const; | 3780 void set_target_name(const String& value) const; |
3746 void set_arguments_descriptor(const Array& value) const; | 3781 void set_arguments_descriptor(const Array& value) const; |
3747 void set_deopt_id(intptr_t value) const; | 3782 void set_deopt_id(intptr_t value) const; |
3748 void set_num_args_tested(intptr_t value) const; | 3783 void SetNumArgsTested(intptr_t value) const; |
3749 void set_ic_data(const Array& value) const; | 3784 void set_ic_data(const Array& value) const; |
| 3785 void set_state_bits(uint32_t bits) const; |
| 3786 |
| 3787 enum { |
| 3788 kNumArgsTestedBits = 0, |
| 3789 kNumArgsTestedSize = 2, |
| 3790 kDeoptReasonBits = kNumArgsTestedBits + kNumArgsTestedSize, |
| 3791 kDeoptReasonSize = kDeoptNumReasons, |
| 3792 kIssuedJSWarningBit = kDeoptReasonBits + kDeoptReasonSize, |
| 3793 kIsClosureCallBit = kIssuedJSWarningBit + 1, |
| 3794 }; |
| 3795 |
| 3796 class NumArgsTestedBits : public BitField<uint32_t, |
| 3797 kNumArgsTestedBits, kNumArgsTestedSize> {}; // NOLINT |
| 3798 class DeoptReasonBits : public BitField<uint32_t, |
| 3799 kDeoptReasonBits, kDeoptReasonSize> {}; // NOLINT |
| 3800 class IssuedJSWarningBit : public BitField<bool, kIssuedJSWarningBit, 1> {}; |
| 3801 class IsClosureCallBit : public BitField<bool, kIsClosureCallBit, 1> {}; |
3750 | 3802 |
3751 #if defined(DEBUG) | 3803 #if defined(DEBUG) |
3752 // Used in asserts to verify that a check is not added twice. | 3804 // Used in asserts to verify that a check is not added twice. |
3753 bool HasCheck(const GrowableArray<intptr_t>& cids) const; | 3805 bool HasCheck(const GrowableArray<intptr_t>& cids) const; |
3754 #endif // DEBUG | 3806 #endif // DEBUG |
3755 | 3807 |
3756 intptr_t TestEntryLength() const; | 3808 intptr_t TestEntryLength() const; |
3757 void WriteSentinel(const Array& data) const; | 3809 void WriteSentinel(const Array& data) const; |
3758 | 3810 |
3759 FINAL_HEAP_OBJECT_IMPLEMENTATION(ICData, Object); | 3811 FINAL_HEAP_OBJECT_IMPLEMENTATION(ICData, Object); |
(...skipping 3153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6913 | 6965 |
6914 | 6966 |
6915 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6967 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
6916 intptr_t index) { | 6968 intptr_t index) { |
6917 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6969 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
6918 } | 6970 } |
6919 | 6971 |
6920 } // namespace dart | 6972 } // namespace dart |
6921 | 6973 |
6922 #endif // VM_OBJECT_H_ | 6974 #endif // VM_OBJECT_H_ |
OLD | NEW |