| 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 3433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3444 | 3444 |
| 3445 // Return true if the target function of this IC data may check for (and | 3445 // Return true if the target function of this IC data may check for (and |
| 3446 // possibly issue) a Javascript compatibility warning. | 3446 // possibly issue) a Javascript compatibility warning. |
| 3447 bool MayCheckForJSWarning() const; | 3447 bool MayCheckForJSWarning() const; |
| 3448 | 3448 |
| 3449 bool IsClosureCall() const; | 3449 bool IsClosureCall() const; |
| 3450 void SetIsClosureCall() const; | 3450 void SetIsClosureCall() const; |
| 3451 | 3451 |
| 3452 intptr_t NumberOfChecks() const; | 3452 intptr_t NumberOfChecks() const; |
| 3453 | 3453 |
| 3454 // Discounts any checks with usage of zero. |
| 3455 intptr_t NumberOfUsedChecks() const; |
| 3456 |
| 3454 static intptr_t InstanceSize() { | 3457 static intptr_t InstanceSize() { |
| 3455 return RoundedAllocationSize(sizeof(RawICData)); | 3458 return RoundedAllocationSize(sizeof(RawICData)); |
| 3456 } | 3459 } |
| 3457 | 3460 |
| 3458 static intptr_t target_name_offset() { | 3461 static intptr_t target_name_offset() { |
| 3459 return OFFSET_OF(RawICData, target_name_); | 3462 return OFFSET_OF(RawICData, target_name_); |
| 3460 } | 3463 } |
| 3461 | 3464 |
| 3462 static intptr_t state_bits_offset() { | 3465 static intptr_t state_bits_offset() { |
| 3463 return OFFSET_OF(RawICData, state_bits_); | 3466 return OFFSET_OF(RawICData, state_bits_); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3493 void AddCheck(const GrowableArray<intptr_t>& class_ids, | 3496 void AddCheck(const GrowableArray<intptr_t>& class_ids, |
| 3494 const Function& target) const; | 3497 const Function& target) const; |
| 3495 // Adds sorted so that Smi is the first class-id. Use only for | 3498 // Adds sorted so that Smi is the first class-id. Use only for |
| 3496 // num_args_tested == 1. | 3499 // num_args_tested == 1. |
| 3497 void AddReceiverCheck(intptr_t receiver_class_id, | 3500 void AddReceiverCheck(intptr_t receiver_class_id, |
| 3498 const Function& target, | 3501 const Function& target, |
| 3499 intptr_t count = 1) const; | 3502 intptr_t count = 1) const; |
| 3500 | 3503 |
| 3501 // Retrieving checks. | 3504 // Retrieving checks. |
| 3502 | 3505 |
| 3506 // TODO(srdjan): GetCheckAt without target. |
| 3503 void GetCheckAt(intptr_t index, | 3507 void GetCheckAt(intptr_t index, |
| 3504 GrowableArray<intptr_t>* class_ids, | 3508 GrowableArray<intptr_t>* class_ids, |
| 3505 Function* target) const; | 3509 Function* target) const; |
| 3506 // Only for 'num_args_checked == 1'. | 3510 // Only for 'num_args_checked == 1'. |
| 3507 void GetOneClassCheckAt(intptr_t index, | 3511 void GetOneClassCheckAt(intptr_t index, |
| 3508 intptr_t* class_id, | 3512 intptr_t* class_id, |
| 3509 Function* target) const; | 3513 Function* target) const; |
| 3510 // Only for 'num_args_checked == 1'. | 3514 // Only for 'num_args_checked == 1'. |
| 3511 intptr_t GetCidAt(intptr_t index) const; | 3515 intptr_t GetCidAt(intptr_t index) const; |
| 3512 | 3516 |
| 3513 intptr_t GetReceiverClassIdAt(intptr_t index) const; | 3517 intptr_t GetReceiverClassIdAt(intptr_t index) const; |
| 3514 intptr_t GetClassIdAt(intptr_t index, intptr_t arg_nr) const; | 3518 intptr_t GetClassIdAt(intptr_t index, intptr_t arg_nr) const; |
| 3515 | 3519 |
| 3516 RawFunction* GetTargetAt(intptr_t index) const; | 3520 RawFunction* GetTargetAt(intptr_t index) const; |
| 3517 RawFunction* GetTargetForReceiverClassId(intptr_t class_id) const; | 3521 RawFunction* GetTargetForReceiverClassId(intptr_t class_id) const; |
| 3518 | 3522 |
| 3519 void IncrementCountAt(intptr_t index, intptr_t value) const; | 3523 void IncrementCountAt(intptr_t index, intptr_t value) const; |
| 3520 void SetCountAt(intptr_t index, intptr_t value) const; | 3524 void SetCountAt(intptr_t index, intptr_t value) const; |
| 3521 intptr_t GetCountAt(intptr_t index) const; | 3525 intptr_t GetCountAt(intptr_t index) const; |
| 3522 intptr_t AggregateCount() const; | 3526 intptr_t AggregateCount() const; |
| 3523 | 3527 |
| 3524 // Returns this->raw() if num_args_tested == 1 and arg_nr == 1, otherwise | 3528 // Returns this->raw() if num_args_tested == 1 and arg_nr == 1, otherwise |
| 3525 // returns a new ICData object containing only unique arg_nr checks. | 3529 // returns a new ICData object containing only unique arg_nr checks. |
| 3530 // Returns only used entries. |
| 3526 RawICData* AsUnaryClassChecksForArgNr(intptr_t arg_nr) const; | 3531 RawICData* AsUnaryClassChecksForArgNr(intptr_t arg_nr) const; |
| 3527 RawICData* AsUnaryClassChecks() const { | 3532 RawICData* AsUnaryClassChecks() const { |
| 3528 return AsUnaryClassChecksForArgNr(0); | 3533 return AsUnaryClassChecksForArgNr(0); |
| 3529 } | 3534 } |
| 3530 | 3535 |
| 3536 // Consider only used entries. |
| 3531 bool AllTargetsHaveSameOwner(intptr_t owner_cid) const; | 3537 bool AllTargetsHaveSameOwner(intptr_t owner_cid) const; |
| 3532 bool AllReceiversAreNumbers() const; | 3538 bool AllReceiversAreNumbers() const; |
| 3533 bool HasOneTarget() const; | 3539 bool HasOneTarget() const; |
| 3534 bool HasReceiverClassId(intptr_t class_id) const; | 3540 bool HasReceiverClassId(intptr_t class_id) const; |
| 3535 | 3541 |
| 3536 static RawICData* New(const Function& owner, | 3542 static RawICData* New(const Function& owner, |
| 3537 const String& target_name, | 3543 const String& target_name, |
| 3538 const Array& arguments_descriptor, | 3544 const Array& arguments_descriptor, |
| 3539 intptr_t deopt_id, | 3545 intptr_t deopt_id, |
| 3540 intptr_t num_args_tested); | 3546 intptr_t num_args_tested); |
| 3541 | 3547 |
| 3542 static intptr_t TestEntryLengthFor(intptr_t num_args); | 3548 static intptr_t TestEntryLengthFor(intptr_t num_args); |
| 3543 | 3549 |
| 3544 static intptr_t TargetIndexFor(intptr_t num_args) { | 3550 static intptr_t TargetIndexFor(intptr_t num_args) { |
| 3545 return num_args; | 3551 return num_args; |
| 3546 } | 3552 } |
| 3547 | 3553 |
| 3548 static intptr_t CountIndexFor(intptr_t num_args) { | 3554 static intptr_t CountIndexFor(intptr_t num_args) { |
| 3549 return (num_args + 1); | 3555 return (num_args + 1); |
| 3550 } | 3556 } |
| 3551 | 3557 |
| 3558 bool IsUsedAt(intptr_t i) const; |
| 3559 |
| 3560 void GetUsedCidsForTwoArgs(GrowableArray<intptr_t>* first, |
| 3561 GrowableArray<intptr_t>* second) const; |
| 3562 |
| 3552 private: | 3563 private: |
| 3553 RawArray* ic_data() const { | 3564 RawArray* ic_data() const { |
| 3554 return raw_ptr()->ic_data_; | 3565 return raw_ptr()->ic_data_; |
| 3555 } | 3566 } |
| 3556 | 3567 |
| 3557 void set_owner(const Function& value) const; | 3568 void set_owner(const Function& value) const; |
| 3558 void set_target_name(const String& value) const; | 3569 void set_target_name(const String& value) const; |
| 3559 void set_arguments_descriptor(const Array& value) const; | 3570 void set_arguments_descriptor(const Array& value) const; |
| 3560 void set_deopt_id(intptr_t value) const; | 3571 void set_deopt_id(intptr_t value) const; |
| 3561 void SetNumArgsTested(intptr_t value) const; | 3572 void SetNumArgsTested(intptr_t value) const; |
| (...skipping 3788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7350 | 7361 |
| 7351 | 7362 |
| 7352 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7363 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 7353 intptr_t index) { | 7364 intptr_t index) { |
| 7354 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7365 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 7355 } | 7366 } |
| 7356 | 7367 |
| 7357 } // namespace dart | 7368 } // namespace dart |
| 7358 | 7369 |
| 7359 #endif // VM_OBJECT_H_ | 7370 #endif // VM_OBJECT_H_ |
| OLD | NEW |