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 4333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4344 } | 4344 } |
4345 static intptr_t InstanceSize(intptr_t len) { | 4345 static intptr_t InstanceSize(intptr_t len) { |
4346 ASSERT(0 <= len && len <= kMaxElements); | 4346 ASSERT(0 <= len && len <= kMaxElements); |
4347 return RoundedAllocationSize(sizeof(RawCode) + (len * kBytesPerElement)); | 4347 return RoundedAllocationSize(sizeof(RawCode) + (len * kBytesPerElement)); |
4348 } | 4348 } |
4349 static RawCode* FinalizeCode(const Function& function, | 4349 static RawCode* FinalizeCode(const Function& function, |
4350 Assembler* assembler, | 4350 Assembler* assembler, |
4351 bool optimized = false); | 4351 bool optimized = false); |
4352 static RawCode* FinalizeCode(const char* name, | 4352 static RawCode* FinalizeCode(const char* name, |
4353 Assembler* assembler, | 4353 Assembler* assembler, |
4354 bool optimized = false); | 4354 bool optimized); |
4355 static RawCode* LookupCode(uword pc); | 4355 static RawCode* LookupCode(uword pc); |
4356 static RawCode* LookupCodeInVmIsolate(uword pc); | 4356 static RawCode* LookupCodeInVmIsolate(uword pc); |
4357 static RawCode* FindCode(uword pc, int64_t timestamp); | 4357 static RawCode* FindCode(uword pc, int64_t timestamp); |
4358 | 4358 |
4359 int32_t GetPointerOffsetAt(int index) const { | 4359 int32_t GetPointerOffsetAt(int index) const { |
4360 NoSafepointScope no_safepoint; | 4360 NoSafepointScope no_safepoint; |
4361 return *PointerOffsetAddrAt(index); | 4361 return *PointerOffsetAddrAt(index); |
4362 } | 4362 } |
4363 intptr_t GetTokenIndexOfPC(uword pc) const; | 4363 intptr_t GetTokenIndexOfPC(uword pc) const; |
4364 | 4364 |
(...skipping 26 matching lines...) Expand all Loading... |
4391 bool IsFunctionCode() const; | 4391 bool IsFunctionCode() const; |
4392 | 4392 |
4393 void DisableDartCode() const; | 4393 void DisableDartCode() const; |
4394 | 4394 |
4395 void DisableStubCode() const; | 4395 void DisableStubCode() const; |
4396 | 4396 |
4397 void Enable() const { | 4397 void Enable() const { |
4398 if (!IsDisabled()) return; | 4398 if (!IsDisabled()) return; |
4399 ASSERT(Thread::Current()->IsMutatorThread()); | 4399 ASSERT(Thread::Current()->IsMutatorThread()); |
4400 ASSERT(instructions() != active_instructions()); | 4400 ASSERT(instructions() != active_instructions()); |
4401 set_active_instructions(instructions()); | 4401 SetActiveInstructions(instructions()); |
4402 } | 4402 } |
4403 | 4403 |
4404 bool IsDisabled() const { | 4404 bool IsDisabled() const { |
4405 return instructions() != active_instructions(); | 4405 return instructions() != active_instructions(); |
4406 } | 4406 } |
4407 | 4407 |
4408 private: | 4408 private: |
4409 void set_state_bits(intptr_t bits) const; | 4409 void set_state_bits(intptr_t bits) const; |
4410 | 4410 |
4411 void set_object_pool(RawObjectPool* object_pool) const { | 4411 void set_object_pool(RawObjectPool* object_pool) const { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4443 static bool IsOptimized(RawCode* code) { | 4443 static bool IsOptimized(RawCode* code) { |
4444 return Code::OptimizedBit::decode(code->ptr()->state_bits_); | 4444 return Code::OptimizedBit::decode(code->ptr()->state_bits_); |
4445 } | 4445 } |
4446 | 4446 |
4447 static const intptr_t kEntrySize = sizeof(int32_t); // NOLINT | 4447 static const intptr_t kEntrySize = sizeof(int32_t); // NOLINT |
4448 | 4448 |
4449 void set_compile_timestamp(int64_t timestamp) const { | 4449 void set_compile_timestamp(int64_t timestamp) const { |
4450 StoreNonPointer(&raw_ptr()->compile_timestamp_, timestamp); | 4450 StoreNonPointer(&raw_ptr()->compile_timestamp_, timestamp); |
4451 } | 4451 } |
4452 | 4452 |
4453 void set_active_instructions(RawInstructions* instructions) const { | 4453 void SetActiveInstructions(RawInstructions* instructions) const; |
4454 ASSERT(Thread::Current()->IsMutatorThread() || !is_alive()); | |
4455 // RawInstructions are never allocated in New space and hence a | |
4456 // store buffer update is not needed here. | |
4457 StorePointer(&raw_ptr()->active_instructions_, instructions); | |
4458 StoreNonPointer(&raw_ptr()->entry_point_, | |
4459 reinterpret_cast<uword>(instructions->ptr()) + | |
4460 Instructions::HeaderSize()); | |
4461 } | |
4462 | 4454 |
4463 void set_instructions(RawInstructions* instructions) const { | 4455 void set_instructions(RawInstructions* instructions) const { |
4464 ASSERT(Thread::Current()->IsMutatorThread() || !is_alive()); | 4456 ASSERT(Thread::Current()->IsMutatorThread() || !is_alive()); |
4465 StorePointer(&raw_ptr()->instructions_, instructions); | 4457 StorePointer(&raw_ptr()->instructions_, instructions); |
4466 } | 4458 } |
4467 | 4459 |
4468 void set_pointer_offsets_length(intptr_t value) { | 4460 void set_pointer_offsets_length(intptr_t value) { |
4469 // The number of fixups is limited to 1-billion. | 4461 // The number of fixups is limited to 1-billion. |
4470 ASSERT(Utils::IsUint(30, value)); | 4462 ASSERT(Utils::IsUint(30, value)); |
4471 set_state_bits(PtrOffBits::update(value, raw_ptr()->state_bits_)); | 4463 set_state_bits(PtrOffBits::update(value, raw_ptr()->state_bits_)); |
(...skipping 3741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8213 | 8205 |
8214 | 8206 |
8215 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8207 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
8216 intptr_t index) { | 8208 intptr_t index) { |
8217 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8209 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
8218 } | 8210 } |
8219 | 8211 |
8220 } // namespace dart | 8212 } // namespace dart |
8221 | 8213 |
8222 #endif // VM_OBJECT_H_ | 8214 #endif // VM_OBJECT_H_ |
OLD | NEW |