Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: runtime/vm/object.h

Issue 254723003: Remember all deopt reasons in ic_data, not just the last one. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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) \
Ivan Posva 2014/04/25 20:59:23 I would be more comfortable if this was within a c
regis 2014/04/25 23:38:28 Done. But I had to move class ICData before class
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
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
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; }
srdjan 2014/04/25 20:54:16 != 0, since it cannot be negative.
regis 2014/04/25 23:38:28 Done.
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 NumArgsTestedShift() {
3693 return kNumArgsTestedBits;
3694 }
3695
3696 static intptr_t NumArgsTestedMask() {
3697 return (1 << kNumArgsTestedSize) - 1;
3655 } 3698 }
3656 3699
3657 static intptr_t arguments_descriptor_offset() { 3700 static intptr_t arguments_descriptor_offset() {
3658 return OFFSET_OF(RawICData, args_descriptor_); 3701 return OFFSET_OF(RawICData, args_descriptor_);
3659 } 3702 }
3660 3703
3661 static intptr_t ic_data_offset() { 3704 static intptr_t ic_data_offset() {
3662 return OFFSET_OF(RawICData, ic_data_); 3705 return OFFSET_OF(RawICData, ic_data_);
3663 } 3706 }
3664 3707
3665 static intptr_t function_offset() { 3708 static intptr_t owner_offset() {
3666 return OFFSET_OF(RawICData, function_); 3709 return OFFSET_OF(RawICData, owner_);
3667 }
3668
3669 static intptr_t is_closure_call_offset() {
3670 return OFFSET_OF(RawICData, is_closure_call_);
3671 } 3710 }
3672 3711
3673 // Used for unoptimized static calls when no class-ids are checked. 3712 // Used for unoptimized static calls when no class-ids are checked.
3674 void AddTarget(const Function& target) const; 3713 void AddTarget(const Function& target) const;
3675 3714
3676 // Adding checks. 3715 // Adding checks.
3677 3716
3678 // Adds one more class test to ICData. Length of 'classes' must be equal to 3717 // 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. 3718 // the number of arguments tested. Use only for num_args_tested > 1.
3680 void AddCheck(const GrowableArray<intptr_t>& class_ids, 3719 void AddCheck(const GrowableArray<intptr_t>& class_ids,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3713 RawICData* AsUnaryClassChecksForArgNr(intptr_t arg_nr) const; 3752 RawICData* AsUnaryClassChecksForArgNr(intptr_t arg_nr) const;
3714 RawICData* AsUnaryClassChecks() const { 3753 RawICData* AsUnaryClassChecks() const {
3715 return AsUnaryClassChecksForArgNr(0); 3754 return AsUnaryClassChecksForArgNr(0);
3716 } 3755 }
3717 3756
3718 bool AllTargetsHaveSameOwner(intptr_t owner_cid) const; 3757 bool AllTargetsHaveSameOwner(intptr_t owner_cid) const;
3719 bool AllReceiversAreNumbers() const; 3758 bool AllReceiversAreNumbers() const;
3720 bool HasOneTarget() const; 3759 bool HasOneTarget() const;
3721 bool HasReceiverClassId(intptr_t class_id) const; 3760 bool HasReceiverClassId(intptr_t class_id) const;
3722 3761
3723 static RawICData* New(const Function& caller_function, 3762 static RawICData* New(const Function& owner,
3724 const String& target_name, 3763 const String& target_name,
3725 const Array& arguments_descriptor, 3764 const Array& arguments_descriptor,
3726 intptr_t deopt_id, 3765 intptr_t deopt_id,
3727 intptr_t num_args_tested); 3766 intptr_t num_args_tested);
3728 3767
3729 static intptr_t TestEntryLengthFor(intptr_t num_args); 3768 static intptr_t TestEntryLengthFor(intptr_t num_args);
3730 3769
3731 static intptr_t TargetIndexFor(intptr_t num_args) { 3770 static intptr_t TargetIndexFor(intptr_t num_args) {
3732 return num_args; 3771 return num_args;
3733 } 3772 }
3734 3773
3735 static intptr_t CountIndexFor(intptr_t num_args) { 3774 static intptr_t CountIndexFor(intptr_t num_args) {
3736 return (num_args + 1); 3775 return (num_args + 1);
3737 } 3776 }
3738 3777
3739 private: 3778 private:
3740 RawArray* ic_data() const { 3779 RawArray* ic_data() const {
3741 return raw_ptr()->ic_data_; 3780 return raw_ptr()->ic_data_;
3742 } 3781 }
3743 3782
3744 void set_function(const Function& value) const; 3783 void set_owner(const Function& value) const;
3745 void set_target_name(const String& value) const; 3784 void set_target_name(const String& value) const;
3746 void set_arguments_descriptor(const Array& value) const; 3785 void set_arguments_descriptor(const Array& value) const;
3747 void set_deopt_id(intptr_t value) const; 3786 void set_deopt_id(intptr_t value) const;
3748 void set_num_args_tested(intptr_t value) const; 3787 void SetNumArgsTested(intptr_t value) const;
3749 void set_ic_data(const Array& value) const; 3788 void set_ic_data(const Array& value) const;
3789 void set_state_bits(uint32_t bits) const;
3790
3791 enum {
3792 kNumArgsTestedBits = 0,
Ivan Posva 2014/04/25 20:59:23 Pos and Size?
regis 2014/04/25 23:38:28 Done.
3793 kNumArgsTestedSize = 2,
3794 kDeoptReasonBits = kNumArgsTestedBits + kNumArgsTestedSize,
3795 kDeoptReasonSize = kDeoptNumReasons,
3796 kIssuedJSWarningBit = kDeoptReasonBits + kDeoptReasonSize,
3797 kIsClosureCallBit = kIssuedJSWarningBit + 1,
3798 };
3799
3800 class NumArgsTestedBits : public BitField<uint32_t,
3801 kNumArgsTestedBits, kNumArgsTestedSize> {}; // NOLINT
3802 class DeoptReasonBits : public BitField<uint32_t,
3803 kDeoptReasonBits, kDeoptReasonSize> {}; // NOLINT
3804 class IssuedJSWarningBit : public BitField<bool, kIssuedJSWarningBit, 1> {};
3805 class IsClosureCallBit : public BitField<bool, kIsClosureCallBit, 1> {};
3750 3806
3751 #if defined(DEBUG) 3807 #if defined(DEBUG)
3752 // Used in asserts to verify that a check is not added twice. 3808 // Used in asserts to verify that a check is not added twice.
3753 bool HasCheck(const GrowableArray<intptr_t>& cids) const; 3809 bool HasCheck(const GrowableArray<intptr_t>& cids) const;
3754 #endif // DEBUG 3810 #endif // DEBUG
3755 3811
3756 intptr_t TestEntryLength() const; 3812 intptr_t TestEntryLength() const;
3757 void WriteSentinel(const Array& data) const; 3813 void WriteSentinel(const Array& data) const;
3758 3814
3759 FINAL_HEAP_OBJECT_IMPLEMENTATION(ICData, Object); 3815 FINAL_HEAP_OBJECT_IMPLEMENTATION(ICData, Object);
(...skipping 3153 matching lines...) Expand 10 before | Expand all | Expand 10 after
6913 6969
6914 6970
6915 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 6971 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
6916 intptr_t index) { 6972 intptr_t index) {
6917 return array.At((index * kEntryLength) + kTargetFunctionIndex); 6973 return array.At((index * kEntryLength) + kTargetFunctionIndex);
6918 } 6974 }
6919 6975
6920 } // namespace dart 6976 } // namespace dart
6921 6977
6922 #endif // VM_OBJECT_H_ 6978 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698