| 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 RUNTIME_VM_OBJECT_H_ | 5 #ifndef RUNTIME_VM_OBJECT_H_ |
| 6 #define RUNTIME_VM_OBJECT_H_ | 6 #define RUNTIME_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 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 static RawClass* literal_token_class_; // Class of LiteralToken vm object. | 750 static RawClass* literal_token_class_; // Class of LiteralToken vm object. |
| 751 static RawClass* token_stream_class_; // Class of the TokenStream vm object. | 751 static RawClass* token_stream_class_; // Class of the TokenStream vm object. |
| 752 static RawClass* script_class_; // Class of the Script vm object. | 752 static RawClass* script_class_; // Class of the Script vm object. |
| 753 static RawClass* library_class_; // Class of the Library vm object. | 753 static RawClass* library_class_; // Class of the Library vm object. |
| 754 static RawClass* namespace_class_; // Class of Namespace vm object. | 754 static RawClass* namespace_class_; // Class of Namespace vm object. |
| 755 static RawClass* code_class_; // Class of the Code vm object. | 755 static RawClass* code_class_; // Class of the Code vm object. |
| 756 static RawClass* instructions_class_; // Class of the Instructions vm object. | 756 static RawClass* instructions_class_; // Class of the Instructions vm object. |
| 757 static RawClass* object_pool_class_; // Class of the ObjectPool vm object. | 757 static RawClass* object_pool_class_; // Class of the ObjectPool vm object. |
| 758 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. | 758 static RawClass* pc_descriptors_class_; // Class of PcDescriptors vm object. |
| 759 static RawClass* code_source_map_class_; // Class of CodeSourceMap vm object. | 759 static RawClass* code_source_map_class_; // Class of CodeSourceMap vm object. |
| 760 static RawClass* stackmap_class_; // Class of Stackmap vm object. | 760 static RawClass* stackmap_class_; // Class of StackMap vm object. |
| 761 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors. | 761 static RawClass* var_descriptors_class_; // Class of LocalVarDescriptors. |
| 762 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. | 762 static RawClass* exception_handlers_class_; // Class of ExceptionHandlers. |
| 763 static RawClass* deopt_info_class_; // Class of DeoptInfo. | 763 static RawClass* deopt_info_class_; // Class of DeoptInfo. |
| 764 static RawClass* context_class_; // Class of the Context vm object. | 764 static RawClass* context_class_; // Class of the Context vm object. |
| 765 static RawClass* context_scope_class_; // Class of ContextScope vm object. | 765 static RawClass* context_scope_class_; // Class of ContextScope vm object. |
| 766 static RawClass* singletargetcache_class_; // Class of SingleTargetCache. | 766 static RawClass* singletargetcache_class_; // Class of SingleTargetCache. |
| 767 static RawClass* unlinkedcall_class_; // Class of UnlinkedCall. | 767 static RawClass* unlinkedcall_class_; // Class of UnlinkedCall. |
| 768 static RawClass* icdata_class_; // Class of ICData. | 768 static RawClass* icdata_class_; // Class of ICData. |
| 769 static RawClass* megamorphic_cache_class_; // Class of MegamorphiCache. | 769 static RawClass* megamorphic_cache_class_; // Class of MegamorphiCache. |
| 770 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache. | 770 static RawClass* subtypetestcache_class_; // Class of SubtypeTestCache. |
| (...skipping 3625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4396 intptr_t Length() const; | 4396 intptr_t Length() const; |
| 4397 void SetLength(intptr_t value) const; | 4397 void SetLength(intptr_t value) const; |
| 4398 void CopyData(GrowableArray<uint8_t>* data); | 4398 void CopyData(GrowableArray<uint8_t>* data); |
| 4399 | 4399 |
| 4400 FINAL_HEAP_OBJECT_IMPLEMENTATION(CodeSourceMap, Object); | 4400 FINAL_HEAP_OBJECT_IMPLEMENTATION(CodeSourceMap, Object); |
| 4401 friend class Class; | 4401 friend class Class; |
| 4402 friend class Object; | 4402 friend class Object; |
| 4403 }; | 4403 }; |
| 4404 | 4404 |
| 4405 | 4405 |
| 4406 class Stackmap : public Object { | 4406 class StackMap : public Object { |
| 4407 public: | 4407 public: |
| 4408 static const intptr_t kNoMaximum = -1; | 4408 static const intptr_t kNoMaximum = -1; |
| 4409 static const intptr_t kNoMinimum = -1; | 4409 static const intptr_t kNoMinimum = -1; |
| 4410 | 4410 |
| 4411 bool IsObject(intptr_t index) const { | 4411 bool IsObject(intptr_t index) const { |
| 4412 ASSERT(InRange(index)); | 4412 ASSERT(InRange(index)); |
| 4413 return GetBit(index); | 4413 return GetBit(index); |
| 4414 } | 4414 } |
| 4415 | 4415 |
| 4416 intptr_t Length() const { return raw_ptr()->length_; } | 4416 intptr_t Length() const { return raw_ptr()->length_; } |
| 4417 | 4417 |
| 4418 uint32_t PcOffset() const { return raw_ptr()->pc_offset_; } | 4418 uint32_t PcOffset() const { return raw_ptr()->pc_offset_; } |
| 4419 void SetPcOffset(uint32_t value) const { | 4419 void SetPcOffset(uint32_t value) const { |
| 4420 ASSERT(value <= kMaxUint32); | 4420 ASSERT(value <= kMaxUint32); |
| 4421 StoreNonPointer(&raw_ptr()->pc_offset_, value); | 4421 StoreNonPointer(&raw_ptr()->pc_offset_, value); |
| 4422 } | 4422 } |
| 4423 | 4423 |
| 4424 intptr_t SlowPathBitCount() const { return raw_ptr()->slow_path_bit_count_; } | 4424 intptr_t SlowPathBitCount() const { return raw_ptr()->slow_path_bit_count_; } |
| 4425 void SetSlowPathBitCount(intptr_t bit_count) const { | 4425 void SetSlowPathBitCount(intptr_t bit_count) const { |
| 4426 ASSERT(bit_count < kMaxInt32); | 4426 ASSERT(bit_count < kMaxInt32); |
| 4427 StoreNonPointer(&raw_ptr()->slow_path_bit_count_, bit_count); | 4427 StoreNonPointer(&raw_ptr()->slow_path_bit_count_, bit_count); |
| 4428 } | 4428 } |
| 4429 | 4429 |
| 4430 bool Equals(const Stackmap& other) const { | 4430 bool Equals(const StackMap& other) const { |
| 4431 if (Length() != other.Length()) { | 4431 if (Length() != other.Length()) { |
| 4432 return false; | 4432 return false; |
| 4433 } | 4433 } |
| 4434 NoSafepointScope no_safepoint; | 4434 NoSafepointScope no_safepoint; |
| 4435 return memcmp(raw_ptr(), other.raw_ptr(), InstanceSize(Length())) == 0; | 4435 return memcmp(raw_ptr(), other.raw_ptr(), InstanceSize(Length())) == 0; |
| 4436 } | 4436 } |
| 4437 | 4437 |
| 4438 static const intptr_t kMaxLengthInBytes = kSmiMax; | 4438 static const intptr_t kMaxLengthInBytes = kSmiMax; |
| 4439 | 4439 |
| 4440 static intptr_t InstanceSize() { | 4440 static intptr_t InstanceSize() { |
| 4441 ASSERT(sizeof(RawStackmap) == OFFSET_OF_RETURNED_VALUE(RawStackmap, data)); | 4441 ASSERT(sizeof(RawStackMap) == OFFSET_OF_RETURNED_VALUE(RawStackMap, data)); |
| 4442 return 0; | 4442 return 0; |
| 4443 } | 4443 } |
| 4444 static intptr_t InstanceSize(intptr_t length) { | 4444 static intptr_t InstanceSize(intptr_t length) { |
| 4445 ASSERT(length >= 0); | 4445 ASSERT(length >= 0); |
| 4446 // The stackmap payload is in an array of bytes. | 4446 // The stackmap payload is in an array of bytes. |
| 4447 intptr_t payload_size = Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte; | 4447 intptr_t payload_size = Utils::RoundUp(length, kBitsPerByte) / kBitsPerByte; |
| 4448 return RoundedAllocationSize(sizeof(RawStackmap) + payload_size); | 4448 return RoundedAllocationSize(sizeof(RawStackMap) + payload_size); |
| 4449 } | 4449 } |
| 4450 static RawStackmap* New(intptr_t pc_offset, | 4450 static RawStackMap* New(intptr_t pc_offset, |
| 4451 BitmapBuilder* bmap, | 4451 BitmapBuilder* bmap, |
| 4452 intptr_t register_bit_count); | 4452 intptr_t register_bit_count); |
| 4453 | 4453 |
| 4454 static RawStackmap* New(intptr_t length, | 4454 static RawStackMap* New(intptr_t length, |
| 4455 intptr_t register_bit_count, | 4455 intptr_t register_bit_count, |
| 4456 intptr_t pc_offset); | 4456 intptr_t pc_offset); |
| 4457 | 4457 |
| 4458 private: | 4458 private: |
| 4459 void SetLength(intptr_t length) const { | 4459 void SetLength(intptr_t length) const { |
| 4460 StoreNonPointer(&raw_ptr()->length_, length); | 4460 StoreNonPointer(&raw_ptr()->length_, length); |
| 4461 } | 4461 } |
| 4462 | 4462 |
| 4463 bool InRange(intptr_t index) const { return index < Length(); } | 4463 bool InRange(intptr_t index) const { return index < Length(); } |
| 4464 | 4464 |
| 4465 bool GetBit(intptr_t bit_index) const; | 4465 bool GetBit(intptr_t bit_index) const; |
| 4466 void SetBit(intptr_t bit_index, bool value) const; | 4466 void SetBit(intptr_t bit_index, bool value) const; |
| 4467 | 4467 |
| 4468 FINAL_HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object); | 4468 FINAL_HEAP_OBJECT_IMPLEMENTATION(StackMap, Object); |
| 4469 friend class BitmapBuilder; | 4469 friend class BitmapBuilder; |
| 4470 friend class Class; | 4470 friend class Class; |
| 4471 }; | 4471 }; |
| 4472 | 4472 |
| 4473 | 4473 |
| 4474 class ExceptionHandlers : public Object { | 4474 class ExceptionHandlers : public Object { |
| 4475 public: | 4475 public: |
| 4476 static const intptr_t kInvalidPcOffset = 0; | 4476 static const intptr_t kInvalidPcOffset = 0; |
| 4477 | 4477 |
| 4478 intptr_t num_entries() const; | 4478 intptr_t num_entries() const; |
| 4479 | 4479 |
| 4480 void GetHandlerInfo(intptr_t try_index, | 4480 void GetHandlerInfo(intptr_t try_index, |
| 4481 RawExceptionHandlers::HandlerInfo* info) const; | 4481 RawExceptionHandlers::HandlerInfo* info) const; |
| 4482 | 4482 |
| 4483 uword HandlerPCOffset(intptr_t try_index) const; | 4483 uword HandlerPCOffset(intptr_t try_index) const; |
| 4484 intptr_t OuterTryIndex(intptr_t try_index) const; | 4484 intptr_t OuterTryIndex(intptr_t try_index) const; |
| 4485 bool NeedsStacktrace(intptr_t try_index) const; | 4485 bool NeedsStackTrace(intptr_t try_index) const; |
| 4486 | 4486 |
| 4487 void SetHandlerInfo(intptr_t try_index, | 4487 void SetHandlerInfo(intptr_t try_index, |
| 4488 intptr_t outer_try_index, | 4488 intptr_t outer_try_index, |
| 4489 uword handler_pc_offset, | 4489 uword handler_pc_offset, |
| 4490 bool needs_stacktrace, | 4490 bool needs_stacktrace, |
| 4491 bool has_catch_all) const; | 4491 bool has_catch_all) const; |
| 4492 | 4492 |
| 4493 RawArray* GetHandledTypes(intptr_t try_index) const; | 4493 RawArray* GetHandledTypes(intptr_t try_index) const; |
| 4494 void SetHandledTypes(intptr_t try_index, const Array& handled_types) const; | 4494 void SetHandledTypes(intptr_t try_index, const Array& handled_types) const; |
| 4495 bool HasCatchAll(intptr_t try_index) const; | 4495 bool HasCatchAll(intptr_t try_index) const; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4673 UNREACHABLE(); | 4673 UNREACHABLE(); |
| 4674 return NULL; | 4674 return NULL; |
| 4675 #else | 4675 #else |
| 4676 return raw_ptr()->deopt_info_array_; | 4676 return raw_ptr()->deopt_info_array_; |
| 4677 #endif | 4677 #endif |
| 4678 } | 4678 } |
| 4679 void set_deopt_info_array(const Array& array) const; | 4679 void set_deopt_info_array(const Array& array) const; |
| 4680 | 4680 |
| 4681 RawArray* stackmaps() const { return raw_ptr()->stackmaps_; } | 4681 RawArray* stackmaps() const { return raw_ptr()->stackmaps_; } |
| 4682 void set_stackmaps(const Array& maps) const; | 4682 void set_stackmaps(const Array& maps) const; |
| 4683 RawStackmap* GetStackmap(uint32_t pc_offset, | 4683 RawStackMap* GetStackMap(uint32_t pc_offset, |
| 4684 Array* stackmaps, | 4684 Array* stackmaps, |
| 4685 Stackmap* map) const; | 4685 StackMap* map) const; |
| 4686 | 4686 |
| 4687 enum { | 4687 enum { |
| 4688 kSCallTableOffsetEntry = 0, | 4688 kSCallTableOffsetEntry = 0, |
| 4689 kSCallTableFunctionEntry = 1, | 4689 kSCallTableFunctionEntry = 1, |
| 4690 kSCallTableCodeEntry = 2, | 4690 kSCallTableCodeEntry = 2, |
| 4691 kSCallTableEntryLength = 3, | 4691 kSCallTableEntryLength = 3, |
| 4692 }; | 4692 }; |
| 4693 | 4693 |
| 4694 void set_static_calls_target_table(const Array& value) const; | 4694 void set_static_calls_target_table(const Array& value) const; |
| 4695 RawArray* static_calls_target_table() const { | 4695 RawArray* static_calls_target_table() const { |
| (...skipping 3672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8368 Dart_Port origin_id, | 8368 Dart_Port origin_id, |
| 8369 Heap::Space space = Heap::kNew); | 8369 Heap::Space space = Heap::kNew); |
| 8370 | 8370 |
| 8371 private: | 8371 private: |
| 8372 FINAL_HEAP_OBJECT_IMPLEMENTATION(SendPort, Instance); | 8372 FINAL_HEAP_OBJECT_IMPLEMENTATION(SendPort, Instance); |
| 8373 friend class Class; | 8373 friend class Class; |
| 8374 }; | 8374 }; |
| 8375 | 8375 |
| 8376 | 8376 |
| 8377 // Internal stacktrace object used in exceptions for printing stack traces. | 8377 // Internal stacktrace object used in exceptions for printing stack traces. |
| 8378 class Stacktrace : public Instance { | 8378 class StackTrace : public Instance { |
| 8379 public: | 8379 public: |
| 8380 static const int kPreallocatedStackdepth = 30; | 8380 static const int kPreallocatedStackdepth = 30; |
| 8381 | 8381 |
| 8382 intptr_t Length() const; | 8382 intptr_t Length() const; |
| 8383 | 8383 |
| 8384 RawFunction* FunctionAtFrame(intptr_t frame_index) const; | 8384 RawFunction* FunctionAtFrame(intptr_t frame_index) const; |
| 8385 | 8385 |
| 8386 RawCode* CodeAtFrame(intptr_t frame_index) const; | 8386 RawCode* CodeAtFrame(intptr_t frame_index) const; |
| 8387 void SetCodeAtFrame(intptr_t frame_index, const Code& code) const; | 8387 void SetCodeAtFrame(intptr_t frame_index, const Code& code) const; |
| 8388 | 8388 |
| 8389 RawSmi* PcOffsetAtFrame(intptr_t frame_index) const; | 8389 RawSmi* PcOffsetAtFrame(intptr_t frame_index) const; |
| 8390 void SetPcOffsetAtFrame(intptr_t frame_index, const Smi& pc_offset) const; | 8390 void SetPcOffsetAtFrame(intptr_t frame_index, const Smi& pc_offset) const; |
| 8391 void set_expand_inlined(bool value) const; | 8391 void set_expand_inlined(bool value) const; |
| 8392 | 8392 |
| 8393 static intptr_t InstanceSize() { | 8393 static intptr_t InstanceSize() { |
| 8394 return RoundedAllocationSize(sizeof(RawStacktrace)); | 8394 return RoundedAllocationSize(sizeof(RawStackTrace)); |
| 8395 } | 8395 } |
| 8396 static RawStacktrace* New(const Array& code_array, | 8396 static RawStackTrace* New(const Array& code_array, |
| 8397 const Array& pc_offset_array, | 8397 const Array& pc_offset_array, |
| 8398 Heap::Space space = Heap::kNew); | 8398 Heap::Space space = Heap::kNew); |
| 8399 | 8399 |
| 8400 // The argument 'max_frames' limits the number of printed frames. | 8400 // The argument 'max_frames' limits the number of printed frames. |
| 8401 const char* ToCStringInternal(intptr_t* frame_index, | 8401 const char* ToCStringInternal(intptr_t* frame_index, |
| 8402 intptr_t max_frames = kMaxInt32) const; | 8402 intptr_t max_frames = kMaxInt32) const; |
| 8403 | 8403 |
| 8404 private: | 8404 private: |
| 8405 void set_code_array(const Array& code_array) const; | 8405 void set_code_array(const Array& code_array) const; |
| 8406 void set_pc_offset_array(const Array& pc_offset_array) const; | 8406 void set_pc_offset_array(const Array& pc_offset_array) const; |
| 8407 bool expand_inlined() const; | 8407 bool expand_inlined() const; |
| 8408 | 8408 |
| 8409 FINAL_HEAP_OBJECT_IMPLEMENTATION(Stacktrace, Instance); | 8409 FINAL_HEAP_OBJECT_IMPLEMENTATION(StackTrace, Instance); |
| 8410 friend class Class; | 8410 friend class Class; |
| 8411 friend class Debugger; | 8411 friend class Debugger; |
| 8412 }; | 8412 }; |
| 8413 | 8413 |
| 8414 | 8414 |
| 8415 // Internal JavaScript regular expression object. | 8415 // Internal JavaScript regular expression object. |
| 8416 class RegExp : public Instance { | 8416 class RegExp : public Instance { |
| 8417 public: | 8417 public: |
| 8418 // Meaning of RegExType: | 8418 // Meaning of RegExType: |
| 8419 // kUninitialized: the type of th regexp has not been initialized yet. | 8419 // kUninitialized: the type of th regexp has not been initialized yet. |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8886 | 8886 |
| 8887 inline void TypeArguments::SetHash(intptr_t value) const { | 8887 inline void TypeArguments::SetHash(intptr_t value) const { |
| 8888 // This is only safe because we create a new Smi, which does not cause | 8888 // This is only safe because we create a new Smi, which does not cause |
| 8889 // heap allocation. | 8889 // heap allocation. |
| 8890 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 8890 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
| 8891 } | 8891 } |
| 8892 | 8892 |
| 8893 } // namespace dart | 8893 } // namespace dart |
| 8894 | 8894 |
| 8895 #endif // RUNTIME_VM_OBJECT_H_ | 8895 #endif // RUNTIME_VM_OBJECT_H_ |
| OLD | NEW |