| 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 3524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3535 // of two parts: | 3535 // of two parts: |
| 3536 // - first a prefix consiting of kMaterializeObject instructions describing | 3536 // - first a prefix consiting of kMaterializeObject instructions describing |
| 3537 // objects which had their allocation removed as part of AllocationSinking | 3537 // objects which had their allocation removed as part of AllocationSinking |
| 3538 // pass and have to be materialized; | 3538 // pass and have to be materialized; |
| 3539 // - followed by a list of DeoptInstr objects, specifying transformation | 3539 // - followed by a list of DeoptInstr objects, specifying transformation |
| 3540 // information for each slot in unoptimized frame(s). | 3540 // information for each slot in unoptimized frame(s). |
| 3541 // Arguments for object materialization (class of instance to be allocated and | 3541 // Arguments for object materialization (class of instance to be allocated and |
| 3542 // field-value pairs) are added as artificial slots to the expression stack | 3542 // field-value pairs) are added as artificial slots to the expression stack |
| 3543 // of the bottom-most frame. They are removed from the stack at the very end | 3543 // of the bottom-most frame. They are removed from the stack at the very end |
| 3544 // of deoptimization by the deoptimization stub. | 3544 // of deoptimization by the deoptimization stub. |
| 3545 class DeoptInfo : public Object { | 3545 class DeoptInfo : public AllStatic { |
| 3546 private: | 3546 public: |
| 3547 // Describes the layout of deopt info data. The index of a deopt-info entry | 3547 // Size of the frame part of the translation not counting kMaterializeObject |
| 3548 // is implicitly the target slot in which the value is written into. | 3548 // instructions in the prefix. |
| 3549 enum { | 3549 static intptr_t FrameSize(const TypedData& packed); |
| 3550 kInstruction = 0, | |
| 3551 kFromIndex, | |
| 3552 kNumberOfEntries, | |
| 3553 }; | |
| 3554 | 3550 |
| 3555 public: | 3551 // Returns the number of kMaterializeObject instructions in the prefix. |
| 3556 // The number of instructions. | 3552 static intptr_t NumMaterializations(const GrowableArray<DeoptInstr*>&); |
| 3557 intptr_t Length() const; | |
| 3558 | 3553 |
| 3559 // The number of real (non-suffix) instructions needed to execute the | 3554 // Unpack the entire translation into an array of deoptimization |
| 3560 // deoptimization translation. | 3555 // instructions. This copies any shared suffixes into the array. |
| 3561 intptr_t TranslationLength() const; | 3556 static void Unpack(const Array& table, |
| 3557 const TypedData& packed, |
| 3558 GrowableArray<DeoptInstr*>* instructions); |
| 3562 | 3559 |
| 3563 // Size of the frame part of the translation not counting kMaterializeObject | 3560 // Size of the frame part of the translation not counting kMaterializeObject |
| 3564 // instructions in the prefix. | 3561 // instructions in the prefix. |
| 3565 intptr_t FrameSize() const; | 3562 static const char* ToCString(const Array& table, |
| 3566 | 3563 const TypedData& packed); |
| 3567 // Returns the number of kMaterializeObject instructions in the prefix. | |
| 3568 intptr_t NumMaterializations() const; | |
| 3569 | |
| 3570 static RawDeoptInfo* New(intptr_t num_commands); | |
| 3571 | |
| 3572 static const intptr_t kBytesPerElement = (kNumberOfEntries * kWordSize); | |
| 3573 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | |
| 3574 | |
| 3575 static intptr_t InstanceSize() { | |
| 3576 ASSERT(sizeof(RawDeoptInfo) == | |
| 3577 OFFSET_OF_RETURNED_VALUE(RawDeoptInfo, data)); | |
| 3578 return 0; | |
| 3579 } | |
| 3580 | |
| 3581 static intptr_t InstanceSize(intptr_t len) { | |
| 3582 ASSERT(0 <= len && len <= kMaxElements); | |
| 3583 return RoundedAllocationSize(sizeof(RawDeoptInfo) + | |
| 3584 (len * kBytesPerElement)); | |
| 3585 } | |
| 3586 | |
| 3587 // 'index' corresponds to target, to-index. | |
| 3588 void SetAt(intptr_t index, | |
| 3589 intptr_t instr_kind, | |
| 3590 intptr_t from_index) const; | |
| 3591 | |
| 3592 intptr_t Instruction(intptr_t index) const; | |
| 3593 intptr_t FromIndex(intptr_t index) const; | |
| 3594 intptr_t ToIndex(intptr_t index) const { | |
| 3595 return index; | |
| 3596 } | |
| 3597 | |
| 3598 // Unpack the entire translation into an array of deoptimization | |
| 3599 // instructions. This copies any shared suffixes into the array. | |
| 3600 void ToInstructions(const Array& table, | |
| 3601 GrowableArray<DeoptInstr*>* instructions) const; | |
| 3602 | |
| 3603 | 3564 |
| 3604 // Returns true iff decompression yields the same instructions as the | 3565 // Returns true iff decompression yields the same instructions as the |
| 3605 // original. | 3566 // original. |
| 3606 bool VerifyDecompression(const GrowableArray<DeoptInstr*>& original, | 3567 static bool VerifyDecompression(const GrowableArray<DeoptInstr*>& original, |
| 3607 const Array& deopt_table) const; | 3568 const Array& deopt_table, |
| 3569 const TypedData& packed); |
| 3570 |
| 3608 | 3571 |
| 3609 private: | 3572 private: |
| 3610 intptr_t* EntryAddr(intptr_t index, intptr_t entry_offset) const { | 3573 static void UnpackInto(const Array& table, |
| 3611 ASSERT((index >=0) && (index < Length())); | 3574 const TypedData& packed, |
| 3612 intptr_t data_index = (index * kNumberOfEntries) + entry_offset; | 3575 GrowableArray<DeoptInstr*>* instructions, |
| 3613 return &UnsafeMutableNonPointer(raw_ptr()->data())[data_index]; | 3576 intptr_t length); |
| 3614 } | |
| 3615 | |
| 3616 void SetLength(intptr_t value) const; | |
| 3617 | |
| 3618 FINAL_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo, Object); | |
| 3619 friend class Class; | |
| 3620 }; | 3577 }; |
| 3621 | 3578 |
| 3622 | 3579 |
| 3623 // Object holding information about an IC: test classes and their | 3580 // Object holding information about an IC: test classes and their |
| 3624 // corresponding targets. | 3581 // corresponding targets. |
| 3625 class ICData : public Object { | 3582 class ICData : public Object { |
| 3626 public: | 3583 public: |
| 3627 RawFunction* owner() const { | 3584 RawFunction* owner() const { |
| 3628 return raw_ptr()->owner_; | 3585 return raw_ptr()->owner_; |
| 3629 } | 3586 } |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4005 kSCallTableFunctionEntry = 1, | 3962 kSCallTableFunctionEntry = 1, |
| 4006 kSCallTableCodeEntry = 2, | 3963 kSCallTableCodeEntry = 2, |
| 4007 kSCallTableEntryLength = 3, | 3964 kSCallTableEntryLength = 3, |
| 4008 }; | 3965 }; |
| 4009 | 3966 |
| 4010 void set_static_calls_target_table(const Array& value) const; | 3967 void set_static_calls_target_table(const Array& value) const; |
| 4011 RawArray* static_calls_target_table() const { | 3968 RawArray* static_calls_target_table() const { |
| 4012 return raw_ptr()->static_calls_target_table_; | 3969 return raw_ptr()->static_calls_target_table_; |
| 4013 } | 3970 } |
| 4014 | 3971 |
| 4015 RawDeoptInfo* GetDeoptInfoAtPc(uword pc, | 3972 RawTypedData* GetDeoptInfoAtPc(uword pc, |
| 4016 ICData::DeoptReasonId* deopt_reason, | 3973 ICData::DeoptReasonId* deopt_reason, |
| 4017 uint32_t* deopt_flags) const; | 3974 uint32_t* deopt_flags) const; |
| 4018 | 3975 |
| 4019 // Returns null if there is no static call at 'pc'. | 3976 // Returns null if there is no static call at 'pc'. |
| 4020 RawFunction* GetStaticCallTargetFunctionAt(uword pc) const; | 3977 RawFunction* GetStaticCallTargetFunctionAt(uword pc) const; |
| 4021 // Returns null if there is no static call at 'pc'. | 3978 // Returns null if there is no static call at 'pc'. |
| 4022 RawCode* GetStaticCallTargetCodeAt(uword pc) const; | 3979 RawCode* GetStaticCallTargetCodeAt(uword pc) const; |
| 4023 // Aborts if there is no static call at 'pc'. | 3980 // Aborts if there is no static call at 'pc'. |
| 4024 void SetStaticCallTargetCodeAt(uword pc, const Code& code) const; | 3981 void SetStaticCallTargetCodeAt(uword pc, const Code& code) const; |
| 4025 void SetStubCallTargetCodeAt(uword pc, const Code& code) const; | 3982 void SetStubCallTargetCodeAt(uword pc, const Code& code) const; |
| (...skipping 3811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7837 | 7794 |
| 7838 | 7795 |
| 7839 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7796 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 7840 intptr_t index) { | 7797 intptr_t index) { |
| 7841 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7798 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 7842 } | 7799 } |
| 7843 | 7800 |
| 7844 } // namespace dart | 7801 } // namespace dart |
| 7845 | 7802 |
| 7846 #endif // VM_OBJECT_H_ | 7803 #endif // VM_OBJECT_H_ |
| OLD | NEW |