| 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 3723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3734 friend class Class; | 3734 friend class Class; |
| 3735 friend class Object; | 3735 friend class Object; |
| 3736 friend class RawObjectPool; | 3736 friend class RawObjectPool; |
| 3737 }; | 3737 }; |
| 3738 | 3738 |
| 3739 | 3739 |
| 3740 class Instructions : public Object { | 3740 class Instructions : public Object { |
| 3741 public: | 3741 public: |
| 3742 intptr_t size() const { return raw_ptr()->size_; } // Excludes HeaderSize(). | 3742 intptr_t size() const { return raw_ptr()->size_; } // Excludes HeaderSize(). |
| 3743 | 3743 |
| 3744 RawCode* code() const { | |
| 3745 // This should only be accessed when jitting. | |
| 3746 // TODO(johnmccutchan): Remove code back pointer. | |
| 3747 ASSERT(!Dart::IsRunningPrecompiledCode()); | |
| 3748 return raw_ptr()->code_; | |
| 3749 } | |
| 3750 | |
| 3751 uword EntryPoint() const { | 3744 uword EntryPoint() const { |
| 3752 return reinterpret_cast<uword>(raw_ptr()) + HeaderSize(); | 3745 return reinterpret_cast<uword>(raw_ptr()) + HeaderSize(); |
| 3753 } | 3746 } |
| 3754 | 3747 |
| 3755 static const intptr_t kMaxElements = (kMaxInt32 - | 3748 static const intptr_t kMaxElements = (kMaxInt32 - |
| 3756 (sizeof(RawInstructions) + | 3749 (sizeof(RawInstructions) + |
| 3757 sizeof(RawObject) + | 3750 sizeof(RawObject) + |
| 3758 (2 * OS::kMaxPreferredCodeAlignment))); | 3751 (2 * OS::kMaxPreferredCodeAlignment))); |
| 3759 | 3752 |
| 3760 static intptr_t InstanceSize() { | 3753 static intptr_t InstanceSize() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3779 static RawInstructions* FromEntryPoint(uword entry_point) { | 3772 static RawInstructions* FromEntryPoint(uword entry_point) { |
| 3780 return reinterpret_cast<RawInstructions*>( | 3773 return reinterpret_cast<RawInstructions*>( |
| 3781 entry_point - HeaderSize() + kHeapObjectTag); | 3774 entry_point - HeaderSize() + kHeapObjectTag); |
| 3782 } | 3775 } |
| 3783 | 3776 |
| 3784 private: | 3777 private: |
| 3785 void set_size(intptr_t size) const { | 3778 void set_size(intptr_t size) const { |
| 3786 StoreNonPointer(&raw_ptr()->size_, size); | 3779 StoreNonPointer(&raw_ptr()->size_, size); |
| 3787 } | 3780 } |
| 3788 | 3781 |
| 3789 void set_code(RawCode* code) const { | |
| 3790 StorePointer(&raw_ptr()->code_, code); | |
| 3791 } | |
| 3792 | |
| 3793 // New is a private method as RawInstruction and RawCode objects should | 3782 // New is a private method as RawInstruction and RawCode objects should |
| 3794 // only be created using the Code::FinalizeCode method. This method creates | 3783 // only be created using the Code::FinalizeCode method. This method creates |
| 3795 // the RawInstruction and RawCode objects, sets up the pointer offsets | 3784 // the RawInstruction and RawCode objects, sets up the pointer offsets |
| 3796 // and links the two in a GC safe manner. | 3785 // and links the two in a GC safe manner. |
| 3797 static RawInstructions* New(intptr_t size); | 3786 static RawInstructions* New(intptr_t size); |
| 3798 | 3787 |
| 3799 FINAL_HEAP_OBJECT_IMPLEMENTATION(Instructions, Object); | 3788 FINAL_HEAP_OBJECT_IMPLEMENTATION(Instructions, Object); |
| 3800 friend class Class; | 3789 friend class Class; |
| 3801 friend class Code; | 3790 friend class Code; |
| 3802 friend class InstructionsWriter; | 3791 friend class InstructionsWriter; |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4415 kOptimizedBit = 0, | 4404 kOptimizedBit = 0, |
| 4416 kAliveBit = 1, | 4405 kAliveBit = 1, |
| 4417 kPtrOffBit = 2, | 4406 kPtrOffBit = 2, |
| 4418 kPtrOffSize = 30, | 4407 kPtrOffSize = 30, |
| 4419 }; | 4408 }; |
| 4420 | 4409 |
| 4421 class OptimizedBit : public BitField<bool, kOptimizedBit, 1> {}; | 4410 class OptimizedBit : public BitField<bool, kOptimizedBit, 1> {}; |
| 4422 class AliveBit : public BitField<bool, kAliveBit, 1> {}; | 4411 class AliveBit : public BitField<bool, kAliveBit, 1> {}; |
| 4423 class PtrOffBits : public BitField<intptr_t, kPtrOffBit, kPtrOffSize> {}; | 4412 class PtrOffBits : public BitField<intptr_t, kPtrOffBit, kPtrOffSize> {}; |
| 4424 | 4413 |
| 4425 // An object finder visitor interface. | |
| 4426 class FindRawCodeVisitor : public FindObjectVisitor { | |
| 4427 public: | |
| 4428 explicit FindRawCodeVisitor(uword pc) | |
| 4429 : FindObjectVisitor(Isolate::Current()), pc_(pc) { } | |
| 4430 virtual ~FindRawCodeVisitor() { } | |
| 4431 | |
| 4432 // Check if object matches find condition. | |
| 4433 virtual bool FindObject(RawObject* obj) const; | |
| 4434 | |
| 4435 private: | |
| 4436 const uword pc_; | |
| 4437 | |
| 4438 DISALLOW_COPY_AND_ASSIGN(FindRawCodeVisitor); | |
| 4439 }; | |
| 4440 | |
| 4441 class SlowFindRawCodeVisitor : public FindObjectVisitor { | 4414 class SlowFindRawCodeVisitor : public FindObjectVisitor { |
| 4442 public: | 4415 public: |
| 4443 explicit SlowFindRawCodeVisitor(uword pc) | 4416 explicit SlowFindRawCodeVisitor(uword pc) |
| 4444 : FindObjectVisitor(Isolate::Current()), pc_(pc) { } | 4417 : FindObjectVisitor(Isolate::Current()), pc_(pc) { } |
| 4445 virtual ~SlowFindRawCodeVisitor() { } | 4418 virtual ~SlowFindRawCodeVisitor() { } |
| 4446 | 4419 |
| 4447 // Check if object matches find condition. | 4420 // Check if object matches find condition. |
| 4448 virtual bool FindObject(RawObject* obj) const; | 4421 virtual bool FindObject(RawObject* obj) const; |
| 4449 | 4422 |
| 4450 private: | 4423 private: |
| (...skipping 3772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8223 | 8196 |
| 8224 | 8197 |
| 8225 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8198 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 8226 intptr_t index) { | 8199 intptr_t index) { |
| 8227 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8200 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 8228 } | 8201 } |
| 8229 | 8202 |
| 8230 } // namespace dart | 8203 } // namespace dart |
| 8231 | 8204 |
| 8232 #endif // VM_OBJECT_H_ | 8205 #endif // VM_OBJECT_H_ |
| OLD | NEW |