| 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 3946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3957 | 3957 |
| 3958 // New is a private method as RawInstruction and RawCode objects should | 3958 // New is a private method as RawInstruction and RawCode objects should |
| 3959 // only be created using the Code::FinalizeCode method. This method creates | 3959 // only be created using the Code::FinalizeCode method. This method creates |
| 3960 // the RawInstruction and RawCode objects, sets up the pointer offsets | 3960 // the RawInstruction and RawCode objects, sets up the pointer offsets |
| 3961 // and links the two in a GC safe manner. | 3961 // and links the two in a GC safe manner. |
| 3962 static RawInstructions* New(intptr_t size); | 3962 static RawInstructions* New(intptr_t size); |
| 3963 | 3963 |
| 3964 FINAL_HEAP_OBJECT_IMPLEMENTATION(Instructions, Object); | 3964 FINAL_HEAP_OBJECT_IMPLEMENTATION(Instructions, Object); |
| 3965 friend class Class; | 3965 friend class Class; |
| 3966 friend class Code; | 3966 friend class Code; |
| 3967 friend class InstructionsWriter; | 3967 friend class AssemblyInstructionsWriter; |
| 3968 friend class BlobInstructionsWriter; |
| 3968 }; | 3969 }; |
| 3969 | 3970 |
| 3970 | 3971 |
| 3971 class LocalVarDescriptors : public Object { | 3972 class LocalVarDescriptors : public Object { |
| 3972 public: | 3973 public: |
| 3973 intptr_t Length() const; | 3974 intptr_t Length() const; |
| 3974 | 3975 |
| 3975 RawString* GetName(intptr_t var_index) const; | 3976 RawString* GetName(intptr_t var_index) const; |
| 3976 | 3977 |
| 3977 void SetVar(intptr_t var_index, | 3978 void SetVar(intptr_t var_index, |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4370 private: | 4371 private: |
| 4371 static void UnpackInto(const Array& table, | 4372 static void UnpackInto(const Array& table, |
| 4372 const TypedData& packed, | 4373 const TypedData& packed, |
| 4373 GrowableArray<DeoptInstr*>* instructions, | 4374 GrowableArray<DeoptInstr*>* instructions, |
| 4374 intptr_t length); | 4375 intptr_t length); |
| 4375 }; | 4376 }; |
| 4376 | 4377 |
| 4377 | 4378 |
| 4378 class Code : public Object { | 4379 class Code : public Object { |
| 4379 public: | 4380 public: |
| 4380 uword active_entry_point() const { return raw_ptr()->entry_point_; } | 4381 RawInstructions* active_instructions() const { |
| 4382 return raw_ptr()->active_instructions_; |
| 4383 } |
| 4381 | 4384 |
| 4382 RawInstructions* instructions() const { return raw_ptr()->instructions_; } | 4385 RawInstructions* instructions() const { return raw_ptr()->instructions_; } |
| 4383 | 4386 |
| 4384 static intptr_t saved_instructions_offset() { | 4387 static intptr_t saved_instructions_offset() { |
| 4385 return OFFSET_OF(RawCode, instructions_); | 4388 return OFFSET_OF(RawCode, instructions_); |
| 4386 } | 4389 } |
| 4387 | 4390 |
| 4388 static intptr_t entry_point_offset() { | 4391 static intptr_t entry_point_offset() { |
| 4389 return OFFSET_OF(RawCode, entry_point_); | 4392 return OFFSET_OF(RawCode, entry_point_); |
| 4390 } | 4393 } |
| 4391 | 4394 |
| 4392 RawObjectPool* object_pool() const { return raw_ptr()->object_pool_; } | 4395 RawObjectPool* object_pool() const { return raw_ptr()->object_pool_; } |
| 4393 static intptr_t object_pool_offset() { | 4396 static intptr_t object_pool_offset() { |
| 4394 return OFFSET_OF(RawCode, object_pool_); | 4397 return OFFSET_OF(RawCode, object_pool_); |
| 4395 } | 4398 } |
| 4396 | 4399 |
| 4397 intptr_t pointer_offsets_length() const { | 4400 intptr_t pointer_offsets_length() const { |
| 4398 return PtrOffBits::decode(raw_ptr()->state_bits_); | 4401 return PtrOffBits::decode(raw_ptr()->state_bits_); |
| 4399 } | 4402 } |
| 4400 | 4403 |
| 4401 bool is_optimized() const { | 4404 bool is_optimized() const { |
| 4402 return OptimizedBit::decode(raw_ptr()->state_bits_); | 4405 return OptimizedBit::decode(raw_ptr()->state_bits_); |
| 4403 } | 4406 } |
| 4404 void set_is_optimized(bool value) const; | 4407 void set_is_optimized(bool value) const; |
| 4405 bool is_alive() const { | 4408 bool is_alive() const { |
| 4406 return AliveBit::decode(raw_ptr()->state_bits_); | 4409 return AliveBit::decode(raw_ptr()->state_bits_); |
| 4407 } | 4410 } |
| 4408 void set_is_alive(bool value) const; | 4411 void set_is_alive(bool value) const; |
| 4409 | 4412 |
| 4410 uword EntryPoint() const; | 4413 uword EntryPoint() const { |
| 4411 intptr_t Size() const; | 4414 return Instructions::Handle(instructions()).EntryPoint(); |
| 4412 | 4415 } |
| 4416 intptr_t Size() const { |
| 4417 const Instructions& instr = Instructions::Handle(instructions()); |
| 4418 return instr.size(); |
| 4419 } |
| 4413 RawObjectPool* GetObjectPool() const { | 4420 RawObjectPool* GetObjectPool() const { |
| 4414 return object_pool(); | 4421 return object_pool(); |
| 4415 } | 4422 } |
| 4416 bool ContainsInstructionAt(uword addr) const { | 4423 bool ContainsInstructionAt(uword addr) const { |
| 4417 const uword offset = addr - EntryPoint(); | 4424 const Instructions& instr = Instructions::Handle(instructions()); |
| 4418 return offset < static_cast<uword>(Size()); | 4425 const uword offset = addr - instr.EntryPoint(); |
| 4426 return offset < static_cast<uword>(instr.size()); |
| 4419 } | 4427 } |
| 4420 | 4428 |
| 4421 // Returns true if there is a debugger breakpoint set in this code object. | 4429 // Returns true if there is a debugger breakpoint set in this code object. |
| 4422 bool HasBreakpoint() const; | 4430 bool HasBreakpoint() const; |
| 4423 | 4431 |
| 4424 RawPcDescriptors* pc_descriptors() const { | 4432 RawPcDescriptors* pc_descriptors() const { |
| 4425 return raw_ptr()->pc_descriptors_; | 4433 return raw_ptr()->pc_descriptors_; |
| 4426 } | 4434 } |
| 4427 void set_pc_descriptors(const PcDescriptors& descriptors) const { | 4435 void set_pc_descriptors(const PcDescriptors& descriptors) const { |
| 4428 ASSERT(descriptors.IsOld()); | 4436 ASSERT(descriptors.IsOld()); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4647 bool IsStubCode() const; | 4655 bool IsStubCode() const; |
| 4648 bool IsFunctionCode() const; | 4656 bool IsFunctionCode() const; |
| 4649 | 4657 |
| 4650 void DisableDartCode() const; | 4658 void DisableDartCode() const; |
| 4651 | 4659 |
| 4652 void DisableStubCode() const; | 4660 void DisableStubCode() const; |
| 4653 | 4661 |
| 4654 void Enable() const { | 4662 void Enable() const { |
| 4655 if (!IsDisabled()) return; | 4663 if (!IsDisabled()) return; |
| 4656 ASSERT(Thread::Current()->IsMutatorThread()); | 4664 ASSERT(Thread::Current()->IsMutatorThread()); |
| 4665 ASSERT(instructions() != active_instructions()); |
| 4657 SetActiveInstructions(instructions()); | 4666 SetActiveInstructions(instructions()); |
| 4658 } | 4667 } |
| 4659 | 4668 |
| 4660 bool IsDisabled() const { | 4669 bool IsDisabled() const { |
| 4661 return active_entry_point() != EntryPoint(); | 4670 return instructions() != active_instructions(); |
| 4662 } | 4671 } |
| 4663 | 4672 |
| 4664 private: | 4673 private: |
| 4665 void set_state_bits(intptr_t bits) const; | 4674 void set_state_bits(intptr_t bits) const; |
| 4666 | 4675 |
| 4667 void set_object_pool(RawObjectPool* object_pool) const { | 4676 void set_object_pool(RawObjectPool* object_pool) const { |
| 4668 StorePointer(&raw_ptr()->object_pool_, object_pool); | 4677 StorePointer(&raw_ptr()->object_pool_, object_pool); |
| 4669 } | 4678 } |
| 4670 | 4679 |
| 4671 friend class RawObject; // For RawObject::SizeFromClass(). | 4680 friend class RawObject; // For RawObject::SizeFromClass(). |
| (...skipping 3845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8517 | 8526 |
| 8518 | 8527 |
| 8519 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8528 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 8520 intptr_t index) { | 8529 intptr_t index) { |
| 8521 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8530 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 8522 } | 8531 } |
| 8523 | 8532 |
| 8524 } // namespace dart | 8533 } // namespace dart |
| 8525 | 8534 |
| 8526 #endif // VM_OBJECT_H_ | 8535 #endif // VM_OBJECT_H_ |
| OLD | NEW |