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 3840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3851 friend class Object; | 3851 friend class Object; |
3852 friend class RawObjectPool; | 3852 friend class RawObjectPool; |
3853 }; | 3853 }; |
3854 | 3854 |
3855 | 3855 |
3856 class Instructions : public Object { | 3856 class Instructions : public Object { |
3857 public: | 3857 public: |
3858 intptr_t size() const { return raw_ptr()->size_; } // Excludes HeaderSize(). | 3858 intptr_t size() const { return raw_ptr()->size_; } // Excludes HeaderSize(). |
3859 | 3859 |
3860 uword EntryPoint() const { | 3860 uword EntryPoint() const { |
3861 return reinterpret_cast<uword>(raw_ptr()) + HeaderSize(); | 3861 return EntryPoint(raw()); |
| 3862 } |
| 3863 static uword EntryPoint(RawInstructions* instr) { |
| 3864 return reinterpret_cast<uword>(instr->ptr()) + HeaderSize(); |
3862 } | 3865 } |
3863 | 3866 |
3864 static const intptr_t kMaxElements = (kMaxInt32 - | 3867 static const intptr_t kMaxElements = (kMaxInt32 - |
3865 (sizeof(RawInstructions) + | 3868 (sizeof(RawInstructions) + |
3866 sizeof(RawObject) + | 3869 sizeof(RawObject) + |
3867 (2 * OS::kMaxPreferredCodeAlignment))); | 3870 (2 * OS::kMaxPreferredCodeAlignment))); |
3868 | 3871 |
3869 static intptr_t InstanceSize() { | 3872 static intptr_t InstanceSize() { |
3870 ASSERT(sizeof(RawInstructions) == | 3873 ASSERT(sizeof(RawInstructions) == |
3871 OFFSET_OF_RETURNED_VALUE(RawInstructions, data)); | 3874 OFFSET_OF_RETURNED_VALUE(RawInstructions, data)); |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4318 private: | 4321 private: |
4319 static void UnpackInto(const Array& table, | 4322 static void UnpackInto(const Array& table, |
4320 const TypedData& packed, | 4323 const TypedData& packed, |
4321 GrowableArray<DeoptInstr*>* instructions, | 4324 GrowableArray<DeoptInstr*>* instructions, |
4322 intptr_t length); | 4325 intptr_t length); |
4323 }; | 4326 }; |
4324 | 4327 |
4325 | 4328 |
4326 class Code : public Object { | 4329 class Code : public Object { |
4327 public: | 4330 public: |
4328 RawInstructions* active_instructions() const { | 4331 uword active_entry_point() const { return raw_ptr()->entry_point_; } |
4329 return raw_ptr()->active_instructions_; | |
4330 } | |
4331 | 4332 |
4332 RawInstructions* instructions() const { return raw_ptr()->instructions_; } | 4333 RawInstructions* instructions() const { return raw_ptr()->instructions_; } |
4333 | 4334 |
4334 static intptr_t saved_instructions_offset() { | 4335 static intptr_t saved_instructions_offset() { |
4335 return OFFSET_OF(RawCode, instructions_); | 4336 return OFFSET_OF(RawCode, instructions_); |
4336 } | 4337 } |
4337 | 4338 |
4338 static intptr_t entry_point_offset() { | 4339 static intptr_t entry_point_offset() { |
4339 return OFFSET_OF(RawCode, entry_point_); | 4340 return OFFSET_OF(RawCode, entry_point_); |
4340 } | 4341 } |
4341 | 4342 |
4342 RawObjectPool* object_pool() const { return raw_ptr()->object_pool_; } | 4343 RawObjectPool* object_pool() const { return raw_ptr()->object_pool_; } |
4343 static intptr_t object_pool_offset() { | 4344 static intptr_t object_pool_offset() { |
4344 return OFFSET_OF(RawCode, object_pool_); | 4345 return OFFSET_OF(RawCode, object_pool_); |
4345 } | 4346 } |
4346 | 4347 |
4347 intptr_t pointer_offsets_length() const { | 4348 intptr_t pointer_offsets_length() const { |
4348 return PtrOffBits::decode(raw_ptr()->state_bits_); | 4349 return PtrOffBits::decode(raw_ptr()->state_bits_); |
4349 } | 4350 } |
4350 | 4351 |
4351 bool is_optimized() const { | 4352 bool is_optimized() const { |
4352 return OptimizedBit::decode(raw_ptr()->state_bits_); | 4353 return OptimizedBit::decode(raw_ptr()->state_bits_); |
4353 } | 4354 } |
4354 void set_is_optimized(bool value) const; | 4355 void set_is_optimized(bool value) const; |
4355 bool is_alive() const { | 4356 bool is_alive() const { |
4356 return AliveBit::decode(raw_ptr()->state_bits_); | 4357 return AliveBit::decode(raw_ptr()->state_bits_); |
4357 } | 4358 } |
4358 void set_is_alive(bool value) const; | 4359 void set_is_alive(bool value) const; |
4359 | 4360 |
4360 uword EntryPoint() const { | 4361 uword EntryPoint() const; |
4361 return Instructions::Handle(instructions()).EntryPoint(); | 4362 intptr_t Size() const; |
4362 } | 4363 |
4363 intptr_t Size() const { | |
4364 const Instructions& instr = Instructions::Handle(instructions()); | |
4365 return instr.size(); | |
4366 } | |
4367 RawObjectPool* GetObjectPool() const { | 4364 RawObjectPool* GetObjectPool() const { |
4368 return object_pool(); | 4365 return object_pool(); |
4369 } | 4366 } |
4370 bool ContainsInstructionAt(uword addr) const { | 4367 bool ContainsInstructionAt(uword addr) const { |
4371 const Instructions& instr = Instructions::Handle(instructions()); | 4368 const uword offset = addr - EntryPoint(); |
4372 const uword offset = addr - instr.EntryPoint(); | 4369 return offset < static_cast<uword>(Size()); |
4373 return offset < static_cast<uword>(instr.size()); | |
4374 } | 4370 } |
4375 | 4371 |
4376 // Returns true if there is a debugger breakpoint set in this code object. | 4372 // Returns true if there is a debugger breakpoint set in this code object. |
4377 bool HasBreakpoint() const; | 4373 bool HasBreakpoint() const; |
4378 | 4374 |
4379 RawPcDescriptors* pc_descriptors() const { | 4375 RawPcDescriptors* pc_descriptors() const { |
4380 return raw_ptr()->pc_descriptors_; | 4376 return raw_ptr()->pc_descriptors_; |
4381 } | 4377 } |
4382 void set_pc_descriptors(const PcDescriptors& descriptors) const { | 4378 void set_pc_descriptors(const PcDescriptors& descriptors) const { |
4383 ASSERT(descriptors.IsOld()); | 4379 ASSERT(descriptors.IsOld()); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4602 bool IsStubCode() const; | 4598 bool IsStubCode() const; |
4603 bool IsFunctionCode() const; | 4599 bool IsFunctionCode() const; |
4604 | 4600 |
4605 void DisableDartCode() const; | 4601 void DisableDartCode() const; |
4606 | 4602 |
4607 void DisableStubCode() const; | 4603 void DisableStubCode() const; |
4608 | 4604 |
4609 void Enable() const { | 4605 void Enable() const { |
4610 if (!IsDisabled()) return; | 4606 if (!IsDisabled()) return; |
4611 ASSERT(Thread::Current()->IsMutatorThread()); | 4607 ASSERT(Thread::Current()->IsMutatorThread()); |
4612 ASSERT(instructions() != active_instructions()); | |
4613 SetActiveInstructions(instructions()); | 4608 SetActiveInstructions(instructions()); |
4614 } | 4609 } |
4615 | 4610 |
4616 bool IsDisabled() const { | 4611 bool IsDisabled() const { |
4617 return instructions() != active_instructions(); | 4612 return active_entry_point() != EntryPoint(); |
4618 } | 4613 } |
4619 | 4614 |
4620 private: | 4615 private: |
4621 void set_state_bits(intptr_t bits) const; | 4616 void set_state_bits(intptr_t bits) const; |
4622 | 4617 |
4623 void set_object_pool(RawObjectPool* object_pool) const { | 4618 void set_object_pool(RawObjectPool* object_pool) const { |
4624 StorePointer(&raw_ptr()->object_pool_, object_pool); | 4619 StorePointer(&raw_ptr()->object_pool_, object_pool); |
4625 } | 4620 } |
4626 | 4621 |
4627 friend class RawObject; // For RawObject::SizeFromClass(). | 4622 friend class RawObject; // For RawObject::SizeFromClass(). |
(...skipping 3792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8420 | 8415 |
8421 | 8416 |
8422 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8417 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
8423 intptr_t index) { | 8418 intptr_t index) { |
8424 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8419 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
8425 } | 8420 } |
8426 | 8421 |
8427 } // namespace dart | 8422 } // namespace dart |
8428 | 8423 |
8429 #endif // VM_OBJECT_H_ | 8424 #endif // VM_OBJECT_H_ |
OLD | NEW |