| 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 3696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3707 friend class Class; | 3707 friend class Class; |
| 3708 friend class Object; | 3708 friend class Object; |
| 3709 friend class RawObjectPool; | 3709 friend class RawObjectPool; |
| 3710 }; | 3710 }; |
| 3711 | 3711 |
| 3712 | 3712 |
| 3713 class Instructions : public Object { | 3713 class Instructions : public Object { |
| 3714 public: | 3714 public: |
| 3715 intptr_t size() const { return raw_ptr()->size_; } // Excludes HeaderSize(). | 3715 intptr_t size() const { return raw_ptr()->size_; } // Excludes HeaderSize(). |
| 3716 | 3716 |
| 3717 RawCode* code() const { |
| 3718 // This should only be accessed when jitting. |
| 3719 // TODO(johnmccutchan): Remove code back pointer. |
| 3720 ASSERT(!Dart::IsRunningPrecompiledCode()); |
| 3721 return raw_ptr()->code_; |
| 3722 } |
| 3723 |
| 3717 uword EntryPoint() const { | 3724 uword EntryPoint() const { |
| 3718 return reinterpret_cast<uword>(raw_ptr()) + HeaderSize(); | 3725 return reinterpret_cast<uword>(raw_ptr()) + HeaderSize(); |
| 3719 } | 3726 } |
| 3720 | 3727 |
| 3721 static const intptr_t kMaxElements = (kMaxInt32 - | 3728 static const intptr_t kMaxElements = (kMaxInt32 - |
| 3722 (sizeof(RawInstructions) + | 3729 (sizeof(RawInstructions) + |
| 3723 sizeof(RawObject) + | 3730 sizeof(RawObject) + |
| 3724 (2 * OS::kMaxPreferredCodeAlignment))); | 3731 (2 * OS::kMaxPreferredCodeAlignment))); |
| 3725 | 3732 |
| 3726 static intptr_t InstanceSize() { | 3733 static intptr_t InstanceSize() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3745 static RawInstructions* FromEntryPoint(uword entry_point) { | 3752 static RawInstructions* FromEntryPoint(uword entry_point) { |
| 3746 return reinterpret_cast<RawInstructions*>( | 3753 return reinterpret_cast<RawInstructions*>( |
| 3747 entry_point - HeaderSize() + kHeapObjectTag); | 3754 entry_point - HeaderSize() + kHeapObjectTag); |
| 3748 } | 3755 } |
| 3749 | 3756 |
| 3750 private: | 3757 private: |
| 3751 void set_size(intptr_t size) const { | 3758 void set_size(intptr_t size) const { |
| 3752 StoreNonPointer(&raw_ptr()->size_, size); | 3759 StoreNonPointer(&raw_ptr()->size_, size); |
| 3753 } | 3760 } |
| 3754 | 3761 |
| 3762 void set_code(RawCode* code) const { |
| 3763 StorePointer(&raw_ptr()->code_, code); |
| 3764 } |
| 3765 |
| 3755 // New is a private method as RawInstruction and RawCode objects should | 3766 // New is a private method as RawInstruction and RawCode objects should |
| 3756 // only be created using the Code::FinalizeCode method. This method creates | 3767 // only be created using the Code::FinalizeCode method. This method creates |
| 3757 // the RawInstruction and RawCode objects, sets up the pointer offsets | 3768 // the RawInstruction and RawCode objects, sets up the pointer offsets |
| 3758 // and links the two in a GC safe manner. | 3769 // and links the two in a GC safe manner. |
| 3759 static RawInstructions* New(intptr_t size); | 3770 static RawInstructions* New(intptr_t size); |
| 3760 | 3771 |
| 3761 FINAL_HEAP_OBJECT_IMPLEMENTATION(Instructions, Object); | 3772 FINAL_HEAP_OBJECT_IMPLEMENTATION(Instructions, Object); |
| 3762 friend class Class; | 3773 friend class Class; |
| 3763 friend class Code; | 3774 friend class Code; |
| 3764 friend class InstructionsWriter; | 3775 friend class InstructionsWriter; |
| (...skipping 4358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8123 | 8134 |
| 8124 | 8135 |
| 8125 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8136 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 8126 intptr_t index) { | 8137 intptr_t index) { |
| 8127 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8138 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 8128 } | 8139 } |
| 8129 | 8140 |
| 8130 } // namespace dart | 8141 } // namespace dart |
| 8131 | 8142 |
| 8132 #endif // VM_OBJECT_H_ | 8143 #endif // VM_OBJECT_H_ |
| OLD | NEW |