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" |
11 #include "vm/json_stream.h" | 11 #include "vm/json_stream.h" |
12 #include "vm/bitmap.h" | 12 #include "vm/bitmap.h" |
13 #include "vm/dart.h" | 13 #include "vm/dart.h" |
14 #include "vm/globals.h" | 14 #include "vm/globals.h" |
15 #include "vm/handles.h" | 15 #include "vm/handles.h" |
16 #include "vm/heap.h" | 16 #include "vm/heap.h" |
17 #include "vm/isolate.h" | 17 #include "vm/isolate.h" |
18 #include "vm/os.h" | 18 #include "vm/os.h" |
19 #include "vm/raw_object.h" | 19 #include "vm/raw_object.h" |
20 #include "vm/scanner.h" | 20 #include "vm/scanner.h" |
| 21 #include "vm/tags.h" |
21 | 22 |
22 namespace dart { | 23 namespace dart { |
23 | 24 |
24 // Forward declarations. | 25 // Forward declarations. |
25 #define DEFINE_FORWARD_DECLARATION(clazz) \ | 26 #define DEFINE_FORWARD_DECLARATION(clazz) \ |
26 class clazz; | 27 class clazz; |
27 CLASS_LIST(DEFINE_FORWARD_DECLARATION) | 28 CLASS_LIST(DEFINE_FORWARD_DECLARATION) |
28 #undef DEFINE_FORWARD_DECLARATION | 29 #undef DEFINE_FORWARD_DECLARATION |
29 class Api; | 30 class Api; |
30 class ArgumentsDescriptor; | 31 class ArgumentsDescriptor; |
(...skipping 2608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2639 | 2640 |
2640 static RawLibrary* AsyncLibrary(); | 2641 static RawLibrary* AsyncLibrary(); |
2641 static RawLibrary* CoreLibrary(); | 2642 static RawLibrary* CoreLibrary(); |
2642 static RawLibrary* CollectionLibrary(); | 2643 static RawLibrary* CollectionLibrary(); |
2643 static RawLibrary* InternalLibrary(); | 2644 static RawLibrary* InternalLibrary(); |
2644 static RawLibrary* IsolateLibrary(); | 2645 static RawLibrary* IsolateLibrary(); |
2645 static RawLibrary* MathLibrary(); | 2646 static RawLibrary* MathLibrary(); |
2646 static RawLibrary* MirrorsLibrary(); | 2647 static RawLibrary* MirrorsLibrary(); |
2647 static RawLibrary* NativeWrappersLibrary(); | 2648 static RawLibrary* NativeWrappersLibrary(); |
2648 static RawLibrary* TypedDataLibrary(); | 2649 static RawLibrary* TypedDataLibrary(); |
| 2650 static RawLibrary* ProfilerLibrary(); |
2649 | 2651 |
2650 // Eagerly compile all classes and functions in the library. | 2652 // Eagerly compile all classes and functions in the library. |
2651 static RawError* CompileAll(); | 2653 static RawError* CompileAll(); |
2652 | 2654 |
2653 // Checks function fingerprints. Prints mismatches and aborts if | 2655 // Checks function fingerprints. Prints mismatches and aborts if |
2654 // mismatch found. | 2656 // mismatch found. |
2655 static void CheckFunctionFingerprints(); | 2657 static void CheckFunctionFingerprints(); |
2656 | 2658 |
2657 static bool IsPrivate(const String& name); | 2659 static bool IsPrivate(const String& name); |
2658 // Construct the full name of a corelib member. | 2660 // Construct the full name of a corelib member. |
(...skipping 3976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6635 static intptr_t InstanceSize() { | 6637 static intptr_t InstanceSize() { |
6636 return RoundedAllocationSize(sizeof(RawMirrorReference)); | 6638 return RoundedAllocationSize(sizeof(RawMirrorReference)); |
6637 } | 6639 } |
6638 | 6640 |
6639 private: | 6641 private: |
6640 FINAL_HEAP_OBJECT_IMPLEMENTATION(MirrorReference, Instance); | 6642 FINAL_HEAP_OBJECT_IMPLEMENTATION(MirrorReference, Instance); |
6641 friend class Class; | 6643 friend class Class; |
6642 }; | 6644 }; |
6643 | 6645 |
6644 | 6646 |
| 6647 class UserTag : public Instance { |
| 6648 public: |
| 6649 uword tag() const { return raw_ptr()->tag(); } |
| 6650 void set_tag(uword t) const { |
| 6651 ASSERT(t >= UserTags::kUserTagIdOffset); |
| 6652 ASSERT(t < UserTags::kUserTagIdOffset + UserTags::kMaxUserTags); |
| 6653 raw_ptr()->tag_ = t; |
| 6654 }; |
| 6655 |
| 6656 RawString* label() const { |
| 6657 return raw_ptr()->label_; |
| 6658 } |
| 6659 |
| 6660 void MakeActive() const; |
| 6661 static void ClearActive(); |
| 6662 |
| 6663 static intptr_t InstanceSize() { |
| 6664 return RoundedAllocationSize(sizeof(RawUserTag)); |
| 6665 } |
| 6666 |
| 6667 static RawUserTag* New(const String& label, |
| 6668 Heap::Space space = Heap::kOld); |
| 6669 |
| 6670 static bool TagTableIsFull(Isolate* isolate); |
| 6671 static RawUserTag* FindTagById(uword tag_id); |
| 6672 |
| 6673 private: |
| 6674 static RawUserTag* FindTagInIsolate(Isolate* isolate, const String& label); |
| 6675 static void AddTagToIsolate(Isolate* isolate, const UserTag& tag); |
| 6676 static intptr_t FindAvailableTagId(Isolate* isolate); |
| 6677 |
| 6678 void set_label(const String& tag_label) const { |
| 6679 StorePointer(&raw_ptr()->label_, tag_label.raw()); |
| 6680 } |
| 6681 |
| 6682 FINAL_HEAP_OBJECT_IMPLEMENTATION(UserTag, Instance); |
| 6683 friend class Class; |
| 6684 }; |
| 6685 |
| 6686 |
6645 // Breaking cycles and loops. | 6687 // Breaking cycles and loops. |
6646 RawClass* Object::clazz() const { | 6688 RawClass* Object::clazz() const { |
6647 uword raw_value = reinterpret_cast<uword>(raw_); | 6689 uword raw_value = reinterpret_cast<uword>(raw_); |
6648 if ((raw_value & kSmiTagMask) == kSmiTag) { | 6690 if ((raw_value & kSmiTagMask) == kSmiTag) { |
6649 return Smi::Class(); | 6691 return Smi::Class(); |
6650 } | 6692 } |
6651 return Isolate::Current()->class_table()->At(raw()->GetClassId()); | 6693 return Isolate::Current()->class_table()->At(raw()->GetClassId()); |
6652 } | 6694 } |
6653 | 6695 |
6654 | 6696 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6775 | 6817 |
6776 | 6818 |
6777 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6819 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
6778 intptr_t index) { | 6820 intptr_t index) { |
6779 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6821 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
6780 } | 6822 } |
6781 | 6823 |
6782 } // namespace dart | 6824 } // namespace dart |
6783 | 6825 |
6784 #endif // VM_OBJECT_H_ | 6826 #endif // VM_OBJECT_H_ |
OLD | NEW |