Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: runtime/vm/object.h

Issue 2974233002: VM: Re-format to use at most one newline between functions (Closed)
Patch Set: Rebase and merge Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/native_symbol_win.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "vm/json_stream.h"
12 #include "vm/bitmap.h" 11 #include "vm/bitmap.h"
13 #include "vm/dart.h" 12 #include "vm/dart.h"
14 #include "vm/flags.h" 13 #include "vm/flags.h"
15 #include "vm/globals.h" 14 #include "vm/globals.h"
16 #include "vm/growable_array.h" 15 #include "vm/growable_array.h"
17 #include "vm/handles.h" 16 #include "vm/handles.h"
18 #include "vm/heap.h" 17 #include "vm/heap.h"
19 #include "vm/isolate.h" 18 #include "vm/isolate.h"
19 #include "vm/json_stream.h"
20 #include "vm/method_recognizer.h" 20 #include "vm/method_recognizer.h"
21 #include "vm/os.h" 21 #include "vm/os.h"
22 #include "vm/raw_object.h" 22 #include "vm/raw_object.h"
23 #include "vm/report.h" 23 #include "vm/report.h"
24 #include "vm/scanner.h" 24 #include "vm/scanner.h"
25 #include "vm/tags.h" 25 #include "vm/tags.h"
26 #include "vm/thread.h" 26 #include "vm/thread.h"
27 #include "vm/token_position.h" 27 #include "vm/token_position.h"
28 28
29 namespace dart { 29 namespace dart {
30 30
31 // Forward declarations. 31 // Forward declarations.
32 namespace kernel { 32 namespace kernel {
33 class Program; 33 class Program;
34 class TreeNode; 34 class TreeNode;
35 } 35 } // namespace kernel
36 36
37 #define DEFINE_FORWARD_DECLARATION(clazz) class clazz; 37 #define DEFINE_FORWARD_DECLARATION(clazz) class clazz;
38 CLASS_LIST(DEFINE_FORWARD_DECLARATION) 38 CLASS_LIST(DEFINE_FORWARD_DECLARATION)
39 #undef DEFINE_FORWARD_DECLARATION 39 #undef DEFINE_FORWARD_DECLARATION
40 class Api; 40 class Api;
41 class ArgumentsDescriptor; 41 class ArgumentsDescriptor;
42 class Assembler; 42 class Assembler;
43 class Closure; 43 class Closure;
44 class Code; 44 class Code;
45 class DisassemblyFormatter; 45 class DisassemblyFormatter;
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 841
842 #define REUSABLE_FRIEND_DECLARATION(name) \ 842 #define REUSABLE_FRIEND_DECLARATION(name) \
843 friend class Reusable##name##HandleScope; 843 friend class Reusable##name##HandleScope;
844 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION) 844 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION)
845 #undef REUSABLE_FRIEND_DECLARATION 845 #undef REUSABLE_FRIEND_DECLARATION
846 846
847 DISALLOW_ALLOCATION(); 847 DISALLOW_ALLOCATION();
848 DISALLOW_COPY_AND_ASSIGN(Object); 848 DISALLOW_COPY_AND_ASSIGN(Object);
849 }; 849 };
850 850
851
852 class PassiveObject : public Object { 851 class PassiveObject : public Object {
853 public: 852 public:
854 void operator=(RawObject* value) { raw_ = value; } 853 void operator=(RawObject* value) { raw_ = value; }
855 void operator^=(RawObject* value) { raw_ = value; } 854 void operator^=(RawObject* value) { raw_ = value; }
856 855
857 static PassiveObject& Handle(Zone* zone, RawObject* raw_ptr) { 856 static PassiveObject& Handle(Zone* zone, RawObject* raw_ptr) {
858 PassiveObject* obj = 857 PassiveObject* obj =
859 reinterpret_cast<PassiveObject*>(VMHandles::AllocateHandle(zone)); 858 reinterpret_cast<PassiveObject*>(VMHandles::AllocateHandle(zone));
860 obj->raw_ = raw_ptr; 859 obj->raw_ = raw_ptr;
861 obj->set_vtable(0); 860 obj->set_vtable(0);
(...skipping 24 matching lines...) Expand all
886 static PassiveObject& ZoneHandle(Zone* zone) { 885 static PassiveObject& ZoneHandle(Zone* zone) {
887 return ZoneHandle(zone, Object::null()); 886 return ZoneHandle(zone, Object::null());
888 } 887 }
889 888
890 private: 889 private:
891 PassiveObject() : Object() {} 890 PassiveObject() : Object() {}
892 DISALLOW_ALLOCATION(); 891 DISALLOW_ALLOCATION();
893 DISALLOW_COPY_AND_ASSIGN(PassiveObject); 892 DISALLOW_COPY_AND_ASSIGN(PassiveObject);
894 }; 893 };
895 894
896
897 typedef ZoneGrowableHandlePtrArray<const AbstractType> Trail; 895 typedef ZoneGrowableHandlePtrArray<const AbstractType> Trail;
898 typedef ZoneGrowableHandlePtrArray<const AbstractType>* TrailPtr; 896 typedef ZoneGrowableHandlePtrArray<const AbstractType>* TrailPtr;
899 897
900
901 class Class : public Object { 898 class Class : public Object {
902 public: 899 public:
903 intptr_t instance_size() const { 900 intptr_t instance_size() const {
904 ASSERT(is_finalized() || is_prefinalized()); 901 ASSERT(is_finalized() || is_prefinalized());
905 return (raw_ptr()->instance_size_in_words_ * kWordSize); 902 return (raw_ptr()->instance_size_in_words_ * kWordSize);
906 } 903 }
907 void set_instance_size(intptr_t value_in_bytes) const { 904 void set_instance_size(intptr_t value_in_bytes) const {
908 ASSERT(kWordSize != 0); 905 ASSERT(kWordSize != 0);
909 set_instance_size_in_words(value_in_bytes / kWordSize); 906 set_instance_size_in_words(value_in_bytes / kWordSize);
910 } 907 }
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 1526
1530 FINAL_HEAP_OBJECT_IMPLEMENTATION(Class, Object); 1527 FINAL_HEAP_OBJECT_IMPLEMENTATION(Class, Object);
1531 friend class AbstractType; 1528 friend class AbstractType;
1532 friend class Instance; 1529 friend class Instance;
1533 friend class Object; 1530 friend class Object;
1534 friend class Type; 1531 friend class Type;
1535 friend class Intrinsifier; 1532 friend class Intrinsifier;
1536 friend class ProgramVisitor; 1533 friend class ProgramVisitor;
1537 }; 1534 };
1538 1535
1539
1540 // Unresolved class is used for storing unresolved names which will be resolved 1536 // Unresolved class is used for storing unresolved names which will be resolved
1541 // to a class after all classes have been loaded and finalized. 1537 // to a class after all classes have been loaded and finalized.
1542 class UnresolvedClass : public Object { 1538 class UnresolvedClass : public Object {
1543 public: 1539 public:
1544 RawObject* library_or_library_prefix() const { 1540 RawObject* library_or_library_prefix() const {
1545 return raw_ptr()->library_or_library_prefix_; 1541 return raw_ptr()->library_or_library_prefix_;
1546 } 1542 }
1547 RawString* ident() const { return raw_ptr()->ident_; } 1543 RawString* ident() const { return raw_ptr()->ident_; }
1548 TokenPosition token_pos() const { return raw_ptr()->token_pos_; } 1544 TokenPosition token_pos() const { return raw_ptr()->token_pos_; }
1549 1545
(...skipping 11 matching lines...) Expand all
1561 void set_library_or_library_prefix(const Object& library_prefix) const; 1557 void set_library_or_library_prefix(const Object& library_prefix) const;
1562 void set_ident(const String& ident) const; 1558 void set_ident(const String& ident) const;
1563 void set_token_pos(TokenPosition token_pos) const; 1559 void set_token_pos(TokenPosition token_pos) const;
1564 1560
1565 static RawUnresolvedClass* New(); 1561 static RawUnresolvedClass* New();
1566 1562
1567 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object); 1563 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object);
1568 friend class Class; 1564 friend class Class;
1569 }; 1565 };
1570 1566
1571
1572 // Classification of type genericity according to type parameter owners. 1567 // Classification of type genericity according to type parameter owners.
1573 enum Genericity { 1568 enum Genericity {
1574 kAny, // Consider type params of current class and functions. 1569 kAny, // Consider type params of current class and functions.
1575 kCurrentClass, // Consider type params of current class only. 1570 kCurrentClass, // Consider type params of current class only.
1576 kFunctions, // Consider type params of current and parent functions. 1571 kFunctions, // Consider type params of current and parent functions.
1577 }; 1572 };
1578 1573
1579
1580 // A TypeArguments is an array of AbstractType. 1574 // A TypeArguments is an array of AbstractType.
1581 class TypeArguments : public Object { 1575 class TypeArguments : public Object {
1582 public: 1576 public:
1583 // We use 30 bits for the hash code so hashes in a snapshot taken on a 1577 // We use 30 bits for the hash code so hashes in a snapshot taken on a
1584 // 64-bit architecture stay in Smi range when loaded on a 32-bit 1578 // 64-bit architecture stay in Smi range when loaded on a 32-bit
1585 // architecture. 1579 // architecture.
1586 static const intptr_t kHashBits = 30; 1580 static const intptr_t kHashBits = 30;
1587 1581
1588 intptr_t Length() const; 1582 intptr_t Length() const;
1589 RawAbstractType* TypeAt(intptr_t index) const; 1583 RawAbstractType* TypeAt(intptr_t index) const;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 // Number of fields in the raw object=3 (instantiations_, length_ and hash_). 1778 // Number of fields in the raw object=3 (instantiations_, length_ and hash_).
1785 static const int kNumFields = 3; 1779 static const int kNumFields = 3;
1786 1780
1787 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeArguments, Object); 1781 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeArguments, Object);
1788 friend class AbstractType; 1782 friend class AbstractType;
1789 friend class Class; 1783 friend class Class;
1790 friend class ClearTypeHashVisitor; 1784 friend class ClearTypeHashVisitor;
1791 friend class Object; 1785 friend class Object;
1792 }; 1786 };
1793 1787
1794
1795 class PatchClass : public Object { 1788 class PatchClass : public Object {
1796 public: 1789 public:
1797 RawClass* patched_class() const { return raw_ptr()->patched_class_; } 1790 RawClass* patched_class() const { return raw_ptr()->patched_class_; }
1798 RawClass* origin_class() const { return raw_ptr()->origin_class_; } 1791 RawClass* origin_class() const { return raw_ptr()->origin_class_; }
1799 RawScript* script() const { return raw_ptr()->script_; } 1792 RawScript* script() const { return raw_ptr()->script_; }
1800 1793
1801 static intptr_t InstanceSize() { 1794 static intptr_t InstanceSize() {
1802 return RoundedAllocationSize(sizeof(RawPatchClass)); 1795 return RoundedAllocationSize(sizeof(RawPatchClass));
1803 } 1796 }
1804 static bool IsInFullSnapshot(RawPatchClass* cls) { 1797 static bool IsInFullSnapshot(RawPatchClass* cls) {
(...skipping 10 matching lines...) Expand all
1815 void set_patched_class(const Class& value) const; 1808 void set_patched_class(const Class& value) const;
1816 void set_origin_class(const Class& value) const; 1809 void set_origin_class(const Class& value) const;
1817 void set_script(const Script& value) const; 1810 void set_script(const Script& value) const;
1818 1811
1819 static RawPatchClass* New(); 1812 static RawPatchClass* New();
1820 1813
1821 FINAL_HEAP_OBJECT_IMPLEMENTATION(PatchClass, Object); 1814 FINAL_HEAP_OBJECT_IMPLEMENTATION(PatchClass, Object);
1822 friend class Class; 1815 friend class Class;
1823 }; 1816 };
1824 1817
1825
1826 class SingleTargetCache : public Object { 1818 class SingleTargetCache : public Object {
1827 public: 1819 public:
1828 RawCode* target() const { return raw_ptr()->target_; } 1820 RawCode* target() const { return raw_ptr()->target_; }
1829 void set_target(const Code& target) const; 1821 void set_target(const Code& target) const;
1830 static intptr_t target_offset() { 1822 static intptr_t target_offset() {
1831 return OFFSET_OF(RawSingleTargetCache, target_); 1823 return OFFSET_OF(RawSingleTargetCache, target_);
1832 } 1824 }
1833 1825
1834 #define DEFINE_NON_POINTER_FIELD_ACCESSORS(type, name) \ 1826 #define DEFINE_NON_POINTER_FIELD_ACCESSORS(type, name) \
1835 type name() const { return raw_ptr()->name##_; } \ 1827 type name() const { return raw_ptr()->name##_; } \
(...skipping 13 matching lines...) Expand all
1849 return RoundedAllocationSize(sizeof(RawSingleTargetCache)); 1841 return RoundedAllocationSize(sizeof(RawSingleTargetCache));
1850 } 1842 }
1851 1843
1852 static RawSingleTargetCache* New(); 1844 static RawSingleTargetCache* New();
1853 1845
1854 private: 1846 private:
1855 FINAL_HEAP_OBJECT_IMPLEMENTATION(SingleTargetCache, Object); 1847 FINAL_HEAP_OBJECT_IMPLEMENTATION(SingleTargetCache, Object);
1856 friend class Class; 1848 friend class Class;
1857 }; 1849 };
1858 1850
1859
1860 class UnlinkedCall : public Object { 1851 class UnlinkedCall : public Object {
1861 public: 1852 public:
1862 RawString* target_name() const { return raw_ptr()->target_name_; } 1853 RawString* target_name() const { return raw_ptr()->target_name_; }
1863 void set_target_name(const String& target_name) const; 1854 void set_target_name(const String& target_name) const;
1864 RawArray* args_descriptor() const { return raw_ptr()->args_descriptor_; } 1855 RawArray* args_descriptor() const { return raw_ptr()->args_descriptor_; }
1865 void set_args_descriptor(const Array& args_descriptor) const; 1856 void set_args_descriptor(const Array& args_descriptor) const;
1866 1857
1867 static intptr_t InstanceSize() { 1858 static intptr_t InstanceSize() {
1868 return RoundedAllocationSize(sizeof(RawUnlinkedCall)); 1859 return RoundedAllocationSize(sizeof(RawUnlinkedCall));
1869 } 1860 }
1870 1861
1871 static RawUnlinkedCall* New(); 1862 static RawUnlinkedCall* New();
1872 1863
1873 private: 1864 private:
1874 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnlinkedCall, Object); 1865 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnlinkedCall, Object);
1875 friend class Class; 1866 friend class Class;
1876 }; 1867 };
1877 1868
1878
1879 // Object holding information about an IC: test classes and their 1869 // Object holding information about an IC: test classes and their
1880 // corresponding targets. The owner of the ICData can be either the function 1870 // corresponding targets. The owner of the ICData can be either the function
1881 // or the original ICData object. In case of background compilation we 1871 // or the original ICData object. In case of background compilation we
1882 // copy the ICData in a child object, thus freezing it during background 1872 // copy the ICData in a child object, thus freezing it during background
1883 // compilation. Code may contain only original ICData objects. 1873 // compilation. Code may contain only original ICData objects.
1884 class ICData : public Object { 1874 class ICData : public Object {
1885 public: 1875 public:
1886 RawFunction* Owner() const; 1876 RawFunction* Owner() const;
1887 1877
1888 RawICData* Original() const; 1878 RawICData* Original() const;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2190 // A cache of VM heap allocated preinitialized empty ic data entry arrays. 2180 // A cache of VM heap allocated preinitialized empty ic data entry arrays.
2191 static RawArray* cached_icdata_arrays_[kCachedICDataArrayCount]; 2181 static RawArray* cached_icdata_arrays_[kCachedICDataArrayCount];
2192 2182
2193 FINAL_HEAP_OBJECT_IMPLEMENTATION(ICData, Object); 2183 FINAL_HEAP_OBJECT_IMPLEMENTATION(ICData, Object);
2194 friend class Class; 2184 friend class Class;
2195 friend class SnapshotWriter; 2185 friend class SnapshotWriter;
2196 friend class Serializer; 2186 friend class Serializer;
2197 friend class Deserializer; 2187 friend class Deserializer;
2198 }; 2188 };
2199 2189
2200
2201 class Function : public Object { 2190 class Function : public Object {
2202 public: 2191 public:
2203 RawString* name() const { return raw_ptr()->name_; } 2192 RawString* name() const { return raw_ptr()->name_; }
2204 RawString* UserVisibleName() const; // Same as scrubbed name. 2193 RawString* UserVisibleName() const; // Same as scrubbed name.
2205 RawString* QualifiedScrubbedName() const { 2194 RawString* QualifiedScrubbedName() const {
2206 return QualifiedName(kScrubbedName); 2195 return QualifiedName(kScrubbedName);
2207 } 2196 }
2208 RawString* QualifiedUserVisibleName() const { 2197 RawString* QualifiedUserVisibleName() const {
2209 return QualifiedName(kUserVisibleName); 2198 return QualifiedName(kUserVisibleName);
2210 } 2199 }
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
3055 FINAL_HEAP_OBJECT_IMPLEMENTATION(Function, Object); 3044 FINAL_HEAP_OBJECT_IMPLEMENTATION(Function, Object);
3056 friend class Class; 3045 friend class Class;
3057 friend class SnapshotWriter; 3046 friend class SnapshotWriter;
3058 friend class Parser; // For set_eval_script. 3047 friend class Parser; // For set_eval_script.
3059 // RawFunction::VisitFunctionPointers accesses the private constructor of 3048 // RawFunction::VisitFunctionPointers accesses the private constructor of
3060 // Function. 3049 // Function.
3061 friend class RawFunction; 3050 friend class RawFunction;
3062 friend class ClassFinalizer; // To reset parent_function. 3051 friend class ClassFinalizer; // To reset parent_function.
3063 }; 3052 };
3064 3053
3065
3066 class ClosureData : public Object { 3054 class ClosureData : public Object {
3067 public: 3055 public:
3068 static intptr_t InstanceSize() { 3056 static intptr_t InstanceSize() {
3069 return RoundedAllocationSize(sizeof(RawClosureData)); 3057 return RoundedAllocationSize(sizeof(RawClosureData));
3070 } 3058 }
3071 3059
3072 private: 3060 private:
3073 RawContextScope* context_scope() const { return raw_ptr()->context_scope_; } 3061 RawContextScope* context_scope() const { return raw_ptr()->context_scope_; }
3074 void set_context_scope(const ContextScope& value) const; 3062 void set_context_scope(const ContextScope& value) const;
3075 3063
(...skipping 12 matching lines...) Expand all
3088 void set_hash(intptr_t value) const; 3076 void set_hash(intptr_t value) const;
3089 3077
3090 static RawClosureData* New(); 3078 static RawClosureData* New();
3091 3079
3092 FINAL_HEAP_OBJECT_IMPLEMENTATION(ClosureData, Object); 3080 FINAL_HEAP_OBJECT_IMPLEMENTATION(ClosureData, Object);
3093 friend class Class; 3081 friend class Class;
3094 friend class Function; 3082 friend class Function;
3095 friend class HeapProfiler; 3083 friend class HeapProfiler;
3096 }; 3084 };
3097 3085
3098
3099 class SignatureData : public Object { 3086 class SignatureData : public Object {
3100 public: 3087 public:
3101 static intptr_t InstanceSize() { 3088 static intptr_t InstanceSize() {
3102 return RoundedAllocationSize(sizeof(RawSignatureData)); 3089 return RoundedAllocationSize(sizeof(RawSignatureData));
3103 } 3090 }
3104 3091
3105 private: 3092 private:
3106 // Enclosing function of this signature function. 3093 // Enclosing function of this signature function.
3107 RawFunction* parent_function() const { return raw_ptr()->parent_function_; } 3094 RawFunction* parent_function() const { return raw_ptr()->parent_function_; }
3108 void set_parent_function(const Function& value) const; 3095 void set_parent_function(const Function& value) const;
3109 3096
3110 // Signature type of this signature function. 3097 // Signature type of this signature function.
3111 RawType* signature_type() const { return raw_ptr()->signature_type_; } 3098 RawType* signature_type() const { return raw_ptr()->signature_type_; }
3112 void set_signature_type(const Type& value) const; 3099 void set_signature_type(const Type& value) const;
3113 3100
3114 static RawSignatureData* New(Heap::Space space = Heap::kOld); 3101 static RawSignatureData* New(Heap::Space space = Heap::kOld);
3115 3102
3116 FINAL_HEAP_OBJECT_IMPLEMENTATION(SignatureData, Object); 3103 FINAL_HEAP_OBJECT_IMPLEMENTATION(SignatureData, Object);
3117 friend class Class; 3104 friend class Class;
3118 friend class Function; 3105 friend class Function;
3119 friend class HeapProfiler; 3106 friend class HeapProfiler;
3120 }; 3107 };
3121 3108
3122
3123 class RedirectionData : public Object { 3109 class RedirectionData : public Object {
3124 public: 3110 public:
3125 static intptr_t InstanceSize() { 3111 static intptr_t InstanceSize() {
3126 return RoundedAllocationSize(sizeof(RawRedirectionData)); 3112 return RoundedAllocationSize(sizeof(RawRedirectionData));
3127 } 3113 }
3128 3114
3129 private: 3115 private:
3130 // The type specifies the class and type arguments of the target constructor. 3116 // The type specifies the class and type arguments of the target constructor.
3131 RawType* type() const { return raw_ptr()->type_; } 3117 RawType* type() const { return raw_ptr()->type_; }
3132 void set_type(const Type& value) const; 3118 void set_type(const Type& value) const;
3133 3119
3134 // The optional identifier specifies a named constructor. 3120 // The optional identifier specifies a named constructor.
3135 RawString* identifier() const { return raw_ptr()->identifier_; } 3121 RawString* identifier() const { return raw_ptr()->identifier_; }
3136 void set_identifier(const String& value) const; 3122 void set_identifier(const String& value) const;
3137 3123
3138 // The resolved constructor or factory target of the redirection. 3124 // The resolved constructor or factory target of the redirection.
3139 RawFunction* target() const { return raw_ptr()->target_; } 3125 RawFunction* target() const { return raw_ptr()->target_; }
3140 void set_target(const Function& value) const; 3126 void set_target(const Function& value) const;
3141 3127
3142 static RawRedirectionData* New(); 3128 static RawRedirectionData* New();
3143 3129
3144 FINAL_HEAP_OBJECT_IMPLEMENTATION(RedirectionData, Object); 3130 FINAL_HEAP_OBJECT_IMPLEMENTATION(RedirectionData, Object);
3145 friend class Class; 3131 friend class Class;
3146 friend class Function; 3132 friend class Function;
3147 friend class HeapProfiler; 3133 friend class HeapProfiler;
3148 }; 3134 };
3149 3135
3150
3151 class Field : public Object { 3136 class Field : public Object {
3152 public: 3137 public:
3153 RawField* Original() const; 3138 RawField* Original() const;
3154 void SetOriginal(const Field& value) const; 3139 void SetOriginal(const Field& value) const;
3155 bool IsOriginal() const { 3140 bool IsOriginal() const {
3156 if (IsNull()) { 3141 if (IsNull()) {
3157 return true; 3142 return true;
3158 } 3143 }
3159 NoSafepointScope no_safepoint; 3144 NoSafepointScope no_safepoint;
3160 return !raw_ptr()->owner_->IsField(); 3145 return !raw_ptr()->owner_->IsField();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3197 return raw_ptr()->kernel_offset_; 3182 return raw_ptr()->kernel_offset_;
3198 #endif 3183 #endif
3199 } 3184 }
3200 3185
3201 void set_kernel_offset(intptr_t kernel_offset) const { 3186 void set_kernel_offset(intptr_t kernel_offset) const {
3202 #if !defined(DART_PRECOMPILED_RUNTIME) 3187 #if !defined(DART_PRECOMPILED_RUNTIME)
3203 StoreNonPointer(&raw_ptr()->kernel_offset_, kernel_offset); 3188 StoreNonPointer(&raw_ptr()->kernel_offset_, kernel_offset);
3204 #endif 3189 #endif
3205 } 3190 }
3206 3191
3207
3208 inline intptr_t Offset() const; 3192 inline intptr_t Offset() const;
3209 // Called during class finalization. 3193 // Called during class finalization.
3210 inline void SetOffset(intptr_t offset_in_bytes) const; 3194 inline void SetOffset(intptr_t offset_in_bytes) const;
3211 3195
3212 inline RawInstance* StaticValue() const; 3196 inline RawInstance* StaticValue() const;
3213 inline void SetStaticValue(const Instance& value, 3197 inline void SetStaticValue(const Instance& value,
3214 bool save_initial_value = false) const; 3198 bool save_initial_value = false) const;
3215 3199
3216 RawClass* Owner() const; 3200 RawClass* Owner() const;
3217 RawClass* Origin() const; // Either mixin class, or same as owner(). 3201 RawClass* Origin() const; // Either mixin class, or same as owner().
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
3467 3451
3468 static RawField* New(); 3452 static RawField* New();
3469 3453
3470 FINAL_HEAP_OBJECT_IMPLEMENTATION(Field, Object); 3454 FINAL_HEAP_OBJECT_IMPLEMENTATION(Field, Object);
3471 friend class Class; 3455 friend class Class;
3472 friend class HeapProfiler; 3456 friend class HeapProfiler;
3473 friend class RawField; 3457 friend class RawField;
3474 friend class FieldSerializationCluster; 3458 friend class FieldSerializationCluster;
3475 }; 3459 };
3476 3460
3477
3478 class LiteralToken : public Object { 3461 class LiteralToken : public Object {
3479 public: 3462 public:
3480 Token::Kind kind() const { return raw_ptr()->kind_; } 3463 Token::Kind kind() const { return raw_ptr()->kind_; }
3481 RawString* literal() const { return raw_ptr()->literal_; } 3464 RawString* literal() const { return raw_ptr()->literal_; }
3482 RawObject* value() const { return raw_ptr()->value_; } 3465 RawObject* value() const { return raw_ptr()->value_; }
3483 3466
3484 static intptr_t InstanceSize() { 3467 static intptr_t InstanceSize() {
3485 return RoundedAllocationSize(sizeof(RawLiteralToken)); 3468 return RoundedAllocationSize(sizeof(RawLiteralToken));
3486 } 3469 }
3487 3470
3488 static RawLiteralToken* New(); 3471 static RawLiteralToken* New();
3489 static RawLiteralToken* New(Token::Kind kind, const String& literal); 3472 static RawLiteralToken* New(Token::Kind kind, const String& literal);
3490 3473
3491 private: 3474 private:
3492 void set_kind(Token::Kind kind) const { 3475 void set_kind(Token::Kind kind) const {
3493 StoreNonPointer(&raw_ptr()->kind_, kind); 3476 StoreNonPointer(&raw_ptr()->kind_, kind);
3494 } 3477 }
3495 void set_literal(const String& literal) const; 3478 void set_literal(const String& literal) const;
3496 void set_value(const Object& value) const; 3479 void set_value(const Object& value) const;
3497 3480
3498 FINAL_HEAP_OBJECT_IMPLEMENTATION(LiteralToken, Object); 3481 FINAL_HEAP_OBJECT_IMPLEMENTATION(LiteralToken, Object);
3499 friend class Class; 3482 friend class Class;
3500 }; 3483 };
3501 3484
3502
3503 class TokenStream : public Object { 3485 class TokenStream : public Object {
3504 public: 3486 public:
3505 RawGrowableObjectArray* TokenObjects() const; 3487 RawGrowableObjectArray* TokenObjects() const;
3506 void SetTokenObjects(const GrowableObjectArray& value) const; 3488 void SetTokenObjects(const GrowableObjectArray& value) const;
3507 3489
3508 RawExternalTypedData* GetStream() const; 3490 RawExternalTypedData* GetStream() const;
3509 void SetStream(const ExternalTypedData& stream) const; 3491 void SetStream(const ExternalTypedData& stream) const;
3510 3492
3511 RawString* GenerateSource() const; 3493 RawString* GenerateSource() const;
3512 RawString* GenerateSource(TokenPosition start, TokenPosition end) const; 3494 RawString* GenerateSource(TokenPosition start, TokenPosition end) const;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
3581 3563
3582 static RawTokenStream* New(); 3564 static RawTokenStream* New();
3583 static void DataFinalizer(void* isolate_callback_data, 3565 static void DataFinalizer(void* isolate_callback_data,
3584 Dart_WeakPersistentHandle handle, 3566 Dart_WeakPersistentHandle handle,
3585 void* peer); 3567 void* peer);
3586 3568
3587 FINAL_HEAP_OBJECT_IMPLEMENTATION(TokenStream, Object); 3569 FINAL_HEAP_OBJECT_IMPLEMENTATION(TokenStream, Object);
3588 friend class Class; 3570 friend class Class;
3589 }; 3571 };
3590 3572
3591
3592 class Script : public Object { 3573 class Script : public Object {
3593 public: 3574 public:
3594 RawString* url() const { return raw_ptr()->url_; } 3575 RawString* url() const { return raw_ptr()->url_; }
3595 3576
3596 // The actual url which was loaded from disk, if provided by the embedder. 3577 // The actual url which was loaded from disk, if provided by the embedder.
3597 RawString* resolved_url() const { return raw_ptr()->resolved_url_; } 3578 RawString* resolved_url() const { return raw_ptr()->resolved_url_; }
3598 bool HasSource() const; 3579 bool HasSource() const;
3599 RawString* Source() const; 3580 RawString* Source() const;
3600 RawString* GenerateSource() const; // Generates source code from Tokenstream. 3581 RawString* GenerateSource() const; // Generates source code from Tokenstream.
3601 RawGrowableObjectArray* GenerateLineNumberArray() const; 3582 RawGrowableObjectArray* GenerateLineNumberArray() const;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
3704 RawArray* line_starts() const; 3685 RawArray* line_starts() const;
3705 RawArray* debug_positions() const; 3686 RawArray* debug_positions() const;
3706 3687
3707 static RawScript* New(); 3688 static RawScript* New();
3708 3689
3709 FINAL_HEAP_OBJECT_IMPLEMENTATION(Script, Object); 3690 FINAL_HEAP_OBJECT_IMPLEMENTATION(Script, Object);
3710 friend class Class; 3691 friend class Class;
3711 friend class Precompiler; 3692 friend class Precompiler;
3712 }; 3693 };
3713 3694
3714
3715 class DictionaryIterator : public ValueObject { 3695 class DictionaryIterator : public ValueObject {
3716 public: 3696 public:
3717 explicit DictionaryIterator(const Library& library); 3697 explicit DictionaryIterator(const Library& library);
3718 3698
3719 bool HasNext() const { return next_ix_ < size_; } 3699 bool HasNext() const { return next_ix_ < size_; }
3720 3700
3721 // Returns next non-null raw object. 3701 // Returns next non-null raw object.
3722 RawObject* GetNext(); 3702 RawObject* GetNext();
3723 3703
3724 private: 3704 private:
3725 void MoveToNextObject(); 3705 void MoveToNextObject();
3726 3706
3727 const Array& array_; 3707 const Array& array_;
3728 const int size_; // Number of elements to iterate over. 3708 const int size_; // Number of elements to iterate over.
3729 int next_ix_; // Index of next element. 3709 int next_ix_; // Index of next element.
3730 3710
3731 friend class ClassDictionaryIterator; 3711 friend class ClassDictionaryIterator;
3732 friend class LibraryPrefixIterator; 3712 friend class LibraryPrefixIterator;
3733 DISALLOW_COPY_AND_ASSIGN(DictionaryIterator); 3713 DISALLOW_COPY_AND_ASSIGN(DictionaryIterator);
3734 }; 3714 };
3735 3715
3736
3737 class ClassDictionaryIterator : public DictionaryIterator { 3716 class ClassDictionaryIterator : public DictionaryIterator {
3738 public: 3717 public:
3739 enum IterationKind { 3718 enum IterationKind {
3740 // TODO(hausner): fix call sites that use kIteratePrivate. There is only 3719 // TODO(hausner): fix call sites that use kIteratePrivate. There is only
3741 // one top-level class per library left, not an array to iterate over. 3720 // one top-level class per library left, not an array to iterate over.
3742 kIteratePrivate, 3721 kIteratePrivate,
3743 kNoIteratePrivate 3722 kNoIteratePrivate
3744 }; 3723 };
3745 3724
3746 ClassDictionaryIterator(const Library& library, 3725 ClassDictionaryIterator(const Library& library,
3747 IterationKind kind = kNoIteratePrivate); 3726 IterationKind kind = kNoIteratePrivate);
3748 3727
3749 bool HasNext() const { 3728 bool HasNext() const {
3750 return (next_ix_ < size_) || !toplevel_class_.IsNull(); 3729 return (next_ix_ < size_) || !toplevel_class_.IsNull();
3751 } 3730 }
3752 3731
3753 // Returns a non-null raw class. 3732 // Returns a non-null raw class.
3754 RawClass* GetNextClass(); 3733 RawClass* GetNextClass();
3755 3734
3756 private: 3735 private:
3757 void MoveToNextClass(); 3736 void MoveToNextClass();
3758 3737
3759 Class& toplevel_class_; 3738 Class& toplevel_class_;
3760 3739
3761 DISALLOW_COPY_AND_ASSIGN(ClassDictionaryIterator); 3740 DISALLOW_COPY_AND_ASSIGN(ClassDictionaryIterator);
3762 }; 3741 };
3763 3742
3764
3765 class LibraryPrefixIterator : public DictionaryIterator { 3743 class LibraryPrefixIterator : public DictionaryIterator {
3766 public: 3744 public:
3767 explicit LibraryPrefixIterator(const Library& library); 3745 explicit LibraryPrefixIterator(const Library& library);
3768 RawLibraryPrefix* GetNext(); 3746 RawLibraryPrefix* GetNext();
3769 3747
3770 private: 3748 private:
3771 void Advance(); 3749 void Advance();
3772 DISALLOW_COPY_AND_ASSIGN(LibraryPrefixIterator); 3750 DISALLOW_COPY_AND_ASSIGN(LibraryPrefixIterator);
3773 }; 3751 };
3774 3752
3775
3776 class Library : public Object { 3753 class Library : public Object {
3777 public: 3754 public:
3778 RawString* name() const { return raw_ptr()->name_; } 3755 RawString* name() const { return raw_ptr()->name_; }
3779 void SetName(const String& name) const; 3756 void SetName(const String& name) const;
3780 3757
3781 RawString* url() const { return raw_ptr()->url_; } 3758 RawString* url() const { return raw_ptr()->url_; }
3782 RawString* private_key() const { return raw_ptr()->private_key_; } 3759 RawString* private_key() const { return raw_ptr()->private_key_; }
3783 bool LoadNotStarted() const { 3760 bool LoadNotStarted() const {
3784 return raw_ptr()->load_state_ == RawLibrary::kAllocated; 3761 return raw_ptr()->load_state_ == RawLibrary::kAllocated;
3785 } 3762 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
3972 static void CheckFunctionFingerprints(); 3949 static void CheckFunctionFingerprints();
3973 #endif // defined(DART_NO_SNAPSHOT). 3950 #endif // defined(DART_NO_SNAPSHOT).
3974 3951
3975 static bool IsPrivate(const String& name); 3952 static bool IsPrivate(const String& name);
3976 // Construct the full name of a corelib member. 3953 // Construct the full name of a corelib member.
3977 static const String& PrivateCoreLibName(const String& member); 3954 static const String& PrivateCoreLibName(const String& member);
3978 // Lookup class in the core lib which also contains various VM 3955 // Lookup class in the core lib which also contains various VM
3979 // helper methods and classes. Allow look up of private classes. 3956 // helper methods and classes. Allow look up of private classes.
3980 static RawClass* LookupCoreClass(const String& class_name); 3957 static RawClass* LookupCoreClass(const String& class_name);
3981 3958
3982
3983 // Return Function::null() if function does not exist in libs. 3959 // Return Function::null() if function does not exist in libs.
3984 static RawFunction* GetFunction(const GrowableArray<Library*>& libs, 3960 static RawFunction* GetFunction(const GrowableArray<Library*>& libs,
3985 const char* class_name, 3961 const char* class_name,
3986 const char* function_name); 3962 const char* function_name);
3987 3963
3988 // Character used to indicate a private identifier. 3964 // Character used to indicate a private identifier.
3989 static const char kPrivateIdentifierStart = '_'; 3965 static const char kPrivateIdentifierStart = '_';
3990 3966
3991 // Character used to separate private identifiers from 3967 // Character used to separate private identifiers from
3992 // the library-specific key. 3968 // the library-specific key.
(...skipping 28 matching lines...) Expand all
4021 void InvalidateResolvedName(const String& name) const; 3997 void InvalidateResolvedName(const String& name) const;
4022 void InvalidateResolvedNamesCache() const; 3998 void InvalidateResolvedNamesCache() const;
4023 3999
4024 RawArray* exported_names() const { return raw_ptr()->exported_names_; } 4000 RawArray* exported_names() const { return raw_ptr()->exported_names_; }
4025 bool LookupExportedNamesCache(const String& name, Object* obj) const; 4001 bool LookupExportedNamesCache(const String& name, Object* obj) const;
4026 void AddToExportedNamesCache(const String& name, const Object& obj) const; 4002 void AddToExportedNamesCache(const String& name, const Object& obj) const;
4027 void InitExportedNamesCache() const; 4003 void InitExportedNamesCache() const;
4028 void ClearExportedNamesCache() const; 4004 void ClearExportedNamesCache() const;
4029 static void InvalidateExportedNamesCaches(); 4005 static void InvalidateExportedNamesCaches();
4030 4006
4031
4032 void InitImportList() const; 4007 void InitImportList() const;
4033 void RehashDictionary(const Array& old_dict, intptr_t new_dict_size) const; 4008 void RehashDictionary(const Array& old_dict, intptr_t new_dict_size) const;
4034 static RawLibrary* NewLibraryHelper(const String& url, bool import_core_lib); 4009 static RawLibrary* NewLibraryHelper(const String& url, bool import_core_lib);
4035 RawObject* LookupEntry(const String& name, intptr_t* index) const; 4010 RawObject* LookupEntry(const String& name, intptr_t* index) const;
4036 4011
4037 void AllocatePrivateKey() const; 4012 void AllocatePrivateKey() const;
4038 4013
4039 RawString* MakeMetadataName(const Object& obj) const; 4014 RawString* MakeMetadataName(const Object& obj) const;
4040 RawField* GetMetadataField(const String& metaname) const; 4015 RawField* GetMetadataField(const String& metaname) const;
4041 void AddMetadata(const Object& owner, 4016 void AddMetadata(const Object& owner,
4042 const String& name, 4017 const String& name,
4043 TokenPosition token_pos, 4018 TokenPosition token_pos,
4044 intptr_t kernel_offset = 0) const; 4019 intptr_t kernel_offset = 0) const;
4045 4020
4046 FINAL_HEAP_OBJECT_IMPLEMENTATION(Library, Object); 4021 FINAL_HEAP_OBJECT_IMPLEMENTATION(Library, Object);
4047 4022
4048 friend class Bootstrap; 4023 friend class Bootstrap;
4049 friend class Class; 4024 friend class Class;
4050 friend class Debugger; 4025 friend class Debugger;
4051 friend class DictionaryIterator; 4026 friend class DictionaryIterator;
4052 friend class Isolate; 4027 friend class Isolate;
4053 friend class LibraryDeserializationCluster; 4028 friend class LibraryDeserializationCluster;
4054 friend class Namespace; 4029 friend class Namespace;
4055 friend class Object; 4030 friend class Object;
4056 friend class Precompiler; 4031 friend class Precompiler;
4057 }; 4032 };
4058 4033
4059
4060 // A Namespace contains the names in a library dictionary, filtered by 4034 // A Namespace contains the names in a library dictionary, filtered by
4061 // the show/hide combinators. 4035 // the show/hide combinators.
4062 class Namespace : public Object { 4036 class Namespace : public Object {
4063 public: 4037 public:
4064 RawLibrary* library() const { return raw_ptr()->library_; } 4038 RawLibrary* library() const { return raw_ptr()->library_; }
4065 RawArray* show_names() const { return raw_ptr()->show_names_; } 4039 RawArray* show_names() const { return raw_ptr()->show_names_; }
4066 RawArray* hide_names() const { return raw_ptr()->hide_names_; } 4040 RawArray* hide_names() const { return raw_ptr()->hide_names_; }
4067 4041
4068 void AddMetadata(const Object& owner, TokenPosition token_pos); 4042 void AddMetadata(const Object& owner, TokenPosition token_pos);
4069 RawObject* GetMetadata() const; 4043 RawObject* GetMetadata() const;
(...skipping 13 matching lines...) Expand all
4083 private: 4057 private:
4084 static RawNamespace* New(); 4058 static RawNamespace* New();
4085 4059
4086 RawField* metadata_field() const { return raw_ptr()->metadata_field_; } 4060 RawField* metadata_field() const { return raw_ptr()->metadata_field_; }
4087 void set_metadata_field(const Field& value) const; 4061 void set_metadata_field(const Field& value) const;
4088 4062
4089 FINAL_HEAP_OBJECT_IMPLEMENTATION(Namespace, Object); 4063 FINAL_HEAP_OBJECT_IMPLEMENTATION(Namespace, Object);
4090 friend class Class; 4064 friend class Class;
4091 }; 4065 };
4092 4066
4093
4094 // ObjectPool contains constants, immediates and addresses embedded in code 4067 // ObjectPool contains constants, immediates and addresses embedded in code
4095 // and deoptimization infos. Each entry has an type-info associated with it 4068 // and deoptimization infos. Each entry has an type-info associated with it
4096 // which is stored in a typed data array (info_array). 4069 // which is stored in a typed data array (info_array).
4097 class ObjectPool : public Object { 4070 class ObjectPool : public Object {
4098 public: 4071 public:
4099 enum EntryType { 4072 enum EntryType {
4100 kTaggedObject, 4073 kTaggedObject,
4101 kImmediate, 4074 kImmediate,
4102 kNativeEntry, 4075 kNativeEntry,
4103 }; 4076 };
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
4188 ASSERT((index >= 0) && (index < Length())); 4161 ASSERT((index >= 0) && (index < Length()));
4189 return &raw_ptr()->data()[index]; 4162 return &raw_ptr()->data()[index];
4190 } 4163 }
4191 4164
4192 FINAL_HEAP_OBJECT_IMPLEMENTATION(ObjectPool, Object); 4165 FINAL_HEAP_OBJECT_IMPLEMENTATION(ObjectPool, Object);
4193 friend class Class; 4166 friend class Class;
4194 friend class Object; 4167 friend class Object;
4195 friend class RawObjectPool; 4168 friend class RawObjectPool;
4196 }; 4169 };
4197 4170
4198
4199 class Instructions : public Object { 4171 class Instructions : public Object {
4200 public: 4172 public:
4201 enum { 4173 enum {
4202 kSizePos = 0, 4174 kSizePos = 0,
4203 kSizeSize = 31, 4175 kSizeSize = 31,
4204 kFlagsPos = kSizePos + kSizeSize, 4176 kFlagsPos = kSizePos + kSizeSize,
4205 kFlagsSize = 1, // Currently, only flag is single entry flag. 4177 kFlagsSize = 1, // Currently, only flag is single entry flag.
4206 }; 4178 };
4207 4179
4208 class SizeBits : public BitField<uint32_t, uint32_t, kSizePos, kSizeSize> {}; 4180 class SizeBits : public BitField<uint32_t, uint32_t, kSizePos, kSizeSize> {};
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
4316 // and links the two in a GC safe manner. 4288 // and links the two in a GC safe manner.
4317 static RawInstructions* New(intptr_t size, bool has_single_entry_point); 4289 static RawInstructions* New(intptr_t size, bool has_single_entry_point);
4318 4290
4319 FINAL_HEAP_OBJECT_IMPLEMENTATION(Instructions, Object); 4291 FINAL_HEAP_OBJECT_IMPLEMENTATION(Instructions, Object);
4320 friend class Class; 4292 friend class Class;
4321 friend class Code; 4293 friend class Code;
4322 friend class AssemblyImageWriter; 4294 friend class AssemblyImageWriter;
4323 friend class BlobImageWriter; 4295 friend class BlobImageWriter;
4324 }; 4296 };
4325 4297
4326
4327 class LocalVarDescriptors : public Object { 4298 class LocalVarDescriptors : public Object {
4328 public: 4299 public:
4329 intptr_t Length() const; 4300 intptr_t Length() const;
4330 4301
4331 RawString* GetName(intptr_t var_index) const; 4302 RawString* GetName(intptr_t var_index) const;
4332 4303
4333 void SetVar(intptr_t var_index, 4304 void SetVar(intptr_t var_index,
4334 const String& name, 4305 const String& name,
4335 RawLocalVarDescriptors::VarInfo* info) const; 4306 RawLocalVarDescriptors::VarInfo* info) const;
4336 4307
(...skipping 19 matching lines...) Expand all
4356 static RawLocalVarDescriptors* New(intptr_t num_variables); 4327 static RawLocalVarDescriptors* New(intptr_t num_variables);
4357 4328
4358 static const char* KindToCString(RawLocalVarDescriptors::VarInfoKind kind); 4329 static const char* KindToCString(RawLocalVarDescriptors::VarInfoKind kind);
4359 4330
4360 private: 4331 private:
4361 FINAL_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors, Object); 4332 FINAL_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors, Object);
4362 friend class Class; 4333 friend class Class;
4363 friend class Object; 4334 friend class Object;
4364 }; 4335 };
4365 4336
4366
4367 class PcDescriptors : public Object { 4337 class PcDescriptors : public Object {
4368 public: 4338 public:
4369 static const intptr_t kBytesPerElement = 1; 4339 static const intptr_t kBytesPerElement = 1;
4370 static const intptr_t kMaxElements = kMaxInt32 / kBytesPerElement; 4340 static const intptr_t kMaxElements = kMaxInt32 / kBytesPerElement;
4371 4341
4372 static intptr_t InstanceSize() { 4342 static intptr_t InstanceSize() {
4373 ASSERT(sizeof(RawPcDescriptors) == 4343 ASSERT(sizeof(RawPcDescriptors) ==
4374 OFFSET_OF_RETURNED_VALUE(RawPcDescriptors, data)); 4344 OFFSET_OF_RETURNED_VALUE(RawPcDescriptors, data));
4375 return 0; 4345 return 0;
4376 } 4346 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
4479 static RawPcDescriptors* New(intptr_t length); 4449 static RawPcDescriptors* New(intptr_t length);
4480 4450
4481 void SetLength(intptr_t value) const; 4451 void SetLength(intptr_t value) const;
4482 void CopyData(GrowableArray<uint8_t>* data); 4452 void CopyData(GrowableArray<uint8_t>* data);
4483 4453
4484 FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object); 4454 FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object);
4485 friend class Class; 4455 friend class Class;
4486 friend class Object; 4456 friend class Object;
4487 }; 4457 };
4488 4458
4489
4490 class CodeSourceMap : public Object { 4459 class CodeSourceMap : public Object {
4491 public: 4460 public:
4492 static const intptr_t kBytesPerElement = 1; 4461 static const intptr_t kBytesPerElement = 1;
4493 static const intptr_t kMaxElements = kMaxInt32 / kBytesPerElement; 4462 static const intptr_t kMaxElements = kMaxInt32 / kBytesPerElement;
4494 4463
4495 static intptr_t InstanceSize() { 4464 static intptr_t InstanceSize() {
4496 ASSERT(sizeof(RawCodeSourceMap) == 4465 ASSERT(sizeof(RawCodeSourceMap) ==
4497 OFFSET_OF_RETURNED_VALUE(RawCodeSourceMap, data)); 4466 OFFSET_OF_RETURNED_VALUE(RawCodeSourceMap, data));
4498 return 0; 4467 return 0;
4499 } 4468 }
(...skipping 20 matching lines...) Expand all
4520 void PrintToJSONObject(JSONObject* jsobj, bool ref) const; 4489 void PrintToJSONObject(JSONObject* jsobj, bool ref) const;
4521 4490
4522 private: 4491 private:
4523 void SetLength(intptr_t value) const; 4492 void SetLength(intptr_t value) const;
4524 4493
4525 FINAL_HEAP_OBJECT_IMPLEMENTATION(CodeSourceMap, Object); 4494 FINAL_HEAP_OBJECT_IMPLEMENTATION(CodeSourceMap, Object);
4526 friend class Class; 4495 friend class Class;
4527 friend class Object; 4496 friend class Object;
4528 }; 4497 };
4529 4498
4530
4531 class StackMap : public Object { 4499 class StackMap : public Object {
4532 public: 4500 public:
4533 static const intptr_t kNoMaximum = -1; 4501 static const intptr_t kNoMaximum = -1;
4534 static const intptr_t kNoMinimum = -1; 4502 static const intptr_t kNoMinimum = -1;
4535 4503
4536 bool IsObject(intptr_t index) const { 4504 bool IsObject(intptr_t index) const {
4537 ASSERT(InRange(index)); 4505 ASSERT(InRange(index));
4538 return GetBit(index); 4506 return GetBit(index);
4539 } 4507 }
4540 4508
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4588 bool InRange(intptr_t index) const { return index < Length(); } 4556 bool InRange(intptr_t index) const { return index < Length(); }
4589 4557
4590 bool GetBit(intptr_t bit_index) const; 4558 bool GetBit(intptr_t bit_index) const;
4591 void SetBit(intptr_t bit_index, bool value) const; 4559 void SetBit(intptr_t bit_index, bool value) const;
4592 4560
4593 FINAL_HEAP_OBJECT_IMPLEMENTATION(StackMap, Object); 4561 FINAL_HEAP_OBJECT_IMPLEMENTATION(StackMap, Object);
4594 friend class BitmapBuilder; 4562 friend class BitmapBuilder;
4595 friend class Class; 4563 friend class Class;
4596 }; 4564 };
4597 4565
4598
4599 class ExceptionHandlers : public Object { 4566 class ExceptionHandlers : public Object {
4600 public: 4567 public:
4601 static const intptr_t kInvalidPcOffset = 0; 4568 static const intptr_t kInvalidPcOffset = 0;
4602 4569
4603 intptr_t num_entries() const; 4570 intptr_t num_entries() const;
4604 4571
4605 void GetHandlerInfo(intptr_t try_index, ExceptionHandlerInfo* info) const; 4572 void GetHandlerInfo(intptr_t try_index, ExceptionHandlerInfo* info) const;
4606 4573
4607 uword HandlerPCOffset(intptr_t try_index) const; 4574 uword HandlerPCOffset(intptr_t try_index) const;
4608 intptr_t OuterTryIndex(intptr_t try_index) const; 4575 intptr_t OuterTryIndex(intptr_t try_index) const;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4643 // malicious code. 4610 // malicious code.
4644 static const intptr_t kMaxHandlers = 1024 * 1024; 4611 static const intptr_t kMaxHandlers = 1024 * 1024;
4645 4612
4646 void set_handled_types_data(const Array& value) const; 4613 void set_handled_types_data(const Array& value) const;
4647 4614
4648 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers, Object); 4615 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers, Object);
4649 friend class Class; 4616 friend class Class;
4650 friend class Object; 4617 friend class Object;
4651 }; 4618 };
4652 4619
4653
4654 class Code : public Object { 4620 class Code : public Object {
4655 public: 4621 public:
4656 RawInstructions* active_instructions() const { 4622 RawInstructions* active_instructions() const {
4657 #if defined(DART_PRECOMPILED_RUNTIME) 4623 #if defined(DART_PRECOMPILED_RUNTIME)
4658 UNREACHABLE(); 4624 UNREACHABLE();
4659 return NULL; 4625 return NULL;
4660 #else 4626 #else
4661 return raw_ptr()->active_instructions_; 4627 return raw_ptr()->active_instructions_;
4662 #endif 4628 #endif
4663 } 4629 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
4821 kNumberOfEntries 4787 kNumberOfEntries
4822 }; 4788 };
4823 4789
4824 const Array& comments_; 4790 const Array& comments_;
4825 4791
4826 friend class Code; 4792 friend class Code;
4827 4793
4828 DISALLOW_COPY_AND_ASSIGN(Comments); 4794 DISALLOW_COPY_AND_ASSIGN(Comments);
4829 }; 4795 };
4830 4796
4831
4832 const Comments& comments() const; 4797 const Comments& comments() const;
4833 void set_comments(const Comments& comments) const; 4798 void set_comments(const Comments& comments) const;
4834 4799
4835 RawObject* return_address_metadata() const { 4800 RawObject* return_address_metadata() const {
4836 #if defined(DART_PRECOMPILED_RUNTIME) 4801 #if defined(DART_PRECOMPILED_RUNTIME)
4837 UNREACHABLE(); 4802 UNREACHABLE();
4838 return NULL; 4803 return NULL;
4839 #else 4804 #else
4840 return raw_ptr()->return_address_metadata_; 4805 return raw_ptr()->return_address_metadata_;
4841 #endif 4806 #endif
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
5063 // only be created using the Code::FinalizeCode method. This method creates 5028 // only be created using the Code::FinalizeCode method. This method creates
5064 // the RawInstruction and RawCode objects, sets up the pointer offsets 5029 // the RawInstruction and RawCode objects, sets up the pointer offsets
5065 // and links the two in a GC safe manner. 5030 // and links the two in a GC safe manner.
5066 static RawCode* New(intptr_t pointer_offsets_length); 5031 static RawCode* New(intptr_t pointer_offsets_length);
5067 5032
5068 FINAL_HEAP_OBJECT_IMPLEMENTATION(Code, Object); 5033 FINAL_HEAP_OBJECT_IMPLEMENTATION(Code, Object);
5069 friend class Class; 5034 friend class Class;
5070 friend class SnapshotWriter; 5035 friend class SnapshotWriter;
5071 friend class FunctionSerializationCluster; 5036 friend class FunctionSerializationCluster;
5072 friend class CodeSerializationCluster; 5037 friend class CodeSerializationCluster;
5073 friend class CodePatcher; // for set_instructions 5038 friend class CodePatcher; // for set_instructions
5074 friend class ProgramVisitor; // for set_instructions 5039 friend class ProgramVisitor; // for set_instructions
5075 // So that the RawFunction pointer visitor can determine whether code the 5040 // So that the RawFunction pointer visitor can determine whether code the
5076 // function points to is optimized. 5041 // function points to is optimized.
5077 friend class RawFunction; 5042 friend class RawFunction;
5078 }; 5043 };
5079 5044
5080
5081 class Context : public Object { 5045 class Context : public Object {
5082 public: 5046 public:
5083 RawContext* parent() const { return raw_ptr()->parent_; } 5047 RawContext* parent() const { return raw_ptr()->parent_; }
5084 void set_parent(const Context& parent) const { 5048 void set_parent(const Context& parent) const {
5085 StorePointer(&raw_ptr()->parent_, parent.raw()); 5049 StorePointer(&raw_ptr()->parent_, parent.raw());
5086 } 5050 }
5087 static intptr_t parent_offset() { return OFFSET_OF(RawContext, parent_); } 5051 static intptr_t parent_offset() { return OFFSET_OF(RawContext, parent_); }
5088 5052
5089 intptr_t num_variables() const { return raw_ptr()->num_variables_; } 5053 intptr_t num_variables() const { return raw_ptr()->num_variables_; }
5090 static intptr_t num_variables_offset() { 5054 static intptr_t num_variables_offset() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
5127 5091
5128 void set_num_variables(intptr_t num_variables) const { 5092 void set_num_variables(intptr_t num_variables) const {
5129 StoreNonPointer(&raw_ptr()->num_variables_, num_variables); 5093 StoreNonPointer(&raw_ptr()->num_variables_, num_variables);
5130 } 5094 }
5131 5095
5132 FINAL_HEAP_OBJECT_IMPLEMENTATION(Context, Object); 5096 FINAL_HEAP_OBJECT_IMPLEMENTATION(Context, Object);
5133 friend class Class; 5097 friend class Class;
5134 friend class Object; 5098 friend class Object;
5135 }; 5099 };
5136 5100
5137
5138 // The ContextScope class makes it possible to delay the compilation of a local 5101 // The ContextScope class makes it possible to delay the compilation of a local
5139 // function until it is invoked. A ContextScope instance collects the local 5102 // function until it is invoked. A ContextScope instance collects the local
5140 // variables that are referenced by the local function to be compiled and that 5103 // variables that are referenced by the local function to be compiled and that
5141 // belong to the outer scopes, that is, to the local scopes of (possibly nested) 5104 // belong to the outer scopes, that is, to the local scopes of (possibly nested)
5142 // functions enclosing the local function. Each captured variable is represented 5105 // functions enclosing the local function. Each captured variable is represented
5143 // by its token position in the source, its name, its type, its allocation index 5106 // by its token position in the source, its name, its type, its allocation index
5144 // in the context, and its context level. The function nesting level and loop 5107 // in the context, and its context level. The function nesting level and loop
5145 // nesting level are not preserved, since they are only used until the context 5108 // nesting level are not preserved, since they are only used until the context
5146 // level is assigned. In addition the ContextScope has a field 'is_implicit' 5109 // level is assigned. In addition the ContextScope has a field 'is_implicit'
5147 // which is true if the ContextScope was created for an implicit closure. 5110 // which is true if the ContextScope was created for an implicit closure.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
5207 const RawContextScope::VariableDesc* VariableDescAddr(intptr_t index) const { 5170 const RawContextScope::VariableDesc* VariableDescAddr(intptr_t index) const {
5208 ASSERT((index >= 0) && (index < num_variables())); 5171 ASSERT((index >= 0) && (index < num_variables()));
5209 return raw_ptr()->VariableDescAddr(index); 5172 return raw_ptr()->VariableDescAddr(index);
5210 } 5173 }
5211 5174
5212 FINAL_HEAP_OBJECT_IMPLEMENTATION(ContextScope, Object); 5175 FINAL_HEAP_OBJECT_IMPLEMENTATION(ContextScope, Object);
5213 friend class Class; 5176 friend class Class;
5214 friend class Object; 5177 friend class Object;
5215 }; 5178 };
5216 5179
5217
5218 class MegamorphicCache : public Object { 5180 class MegamorphicCache : public Object {
5219 public: 5181 public:
5220 static const intptr_t kInitialCapacity = 16; 5182 static const intptr_t kInitialCapacity = 16;
5221 static const intptr_t kSpreadFactor = 7; 5183 static const intptr_t kSpreadFactor = 7;
5222 static const double kLoadFactor; 5184 static const double kLoadFactor;
5223 5185
5224 RawArray* buckets() const; 5186 RawArray* buckets() const;
5225 void set_buckets(const Array& buckets) const; 5187 void set_buckets(const Array& buckets) const;
5226 5188
5227 intptr_t mask() const; 5189 intptr_t mask() const;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
5276 const Smi& class_id, 5238 const Smi& class_id,
5277 const Function& target); 5239 const Function& target);
5278 5240
5279 static inline RawObject* GetClassId(const Array& array, intptr_t index); 5241 static inline RawObject* GetClassId(const Array& array, intptr_t index);
5280 static inline RawObject* GetTargetFunction(const Array& array, 5242 static inline RawObject* GetTargetFunction(const Array& array,
5281 intptr_t index); 5243 intptr_t index);
5282 5244
5283 FINAL_HEAP_OBJECT_IMPLEMENTATION(MegamorphicCache, Object); 5245 FINAL_HEAP_OBJECT_IMPLEMENTATION(MegamorphicCache, Object);
5284 }; 5246 };
5285 5247
5286
5287 class SubtypeTestCache : public Object { 5248 class SubtypeTestCache : public Object {
5288 public: 5249 public:
5289 enum Entries { 5250 enum Entries {
5290 kInstanceClassIdOrFunction = 0, 5251 kInstanceClassIdOrFunction = 0,
5291 kInstanceTypeArguments = 1, 5252 kInstanceTypeArguments = 1,
5292 kInstantiatorTypeArguments = 2, 5253 kInstantiatorTypeArguments = 2,
5293 kFunctionTypeArguments = 3, 5254 kFunctionTypeArguments = 3,
5294 kTestResult = 4, 5255 kTestResult = 4,
5295 kTestEntryLength = 5, 5256 kTestEntryLength = 5,
5296 }; 5257 };
(...skipping 25 matching lines...) Expand all
5322 RawArray* cache() const { return raw_ptr()->cache_; } 5283 RawArray* cache() const { return raw_ptr()->cache_; }
5323 5284
5324 void set_cache(const Array& value) const; 5285 void set_cache(const Array& value) const;
5325 5286
5326 intptr_t TestEntryLength() const; 5287 intptr_t TestEntryLength() const;
5327 5288
5328 FINAL_HEAP_OBJECT_IMPLEMENTATION(SubtypeTestCache, Object); 5289 FINAL_HEAP_OBJECT_IMPLEMENTATION(SubtypeTestCache, Object);
5329 friend class Class; 5290 friend class Class;
5330 }; 5291 };
5331 5292
5332
5333 class Error : public Object { 5293 class Error : public Object {
5334 public: 5294 public:
5335 virtual const char* ToErrorCString() const; 5295 virtual const char* ToErrorCString() const;
5336 5296
5337 private: 5297 private:
5338 HEAP_OBJECT_IMPLEMENTATION(Error, Object); 5298 HEAP_OBJECT_IMPLEMENTATION(Error, Object);
5339 }; 5299 };
5340 5300
5341
5342 class ApiError : public Error { 5301 class ApiError : public Error {
5343 public: 5302 public:
5344 RawString* message() const { return raw_ptr()->message_; } 5303 RawString* message() const { return raw_ptr()->message_; }
5345 5304
5346 static intptr_t InstanceSize() { 5305 static intptr_t InstanceSize() {
5347 return RoundedAllocationSize(sizeof(RawApiError)); 5306 return RoundedAllocationSize(sizeof(RawApiError));
5348 } 5307 }
5349 5308
5350 static RawApiError* New(const String& message, 5309 static RawApiError* New(const String& message,
5351 Heap::Space space = Heap::kNew); 5310 Heap::Space space = Heap::kNew);
5352 5311
5353 virtual const char* ToErrorCString() const; 5312 virtual const char* ToErrorCString() const;
5354 5313
5355 private: 5314 private:
5356 void set_message(const String& message) const; 5315 void set_message(const String& message) const;
5357 5316
5358 static RawApiError* New(); 5317 static RawApiError* New();
5359 5318
5360 FINAL_HEAP_OBJECT_IMPLEMENTATION(ApiError, Error); 5319 FINAL_HEAP_OBJECT_IMPLEMENTATION(ApiError, Error);
5361 friend class Class; 5320 friend class Class;
5362 }; 5321 };
5363 5322
5364
5365 class LanguageError : public Error { 5323 class LanguageError : public Error {
5366 public: 5324 public:
5367 Report::Kind kind() const { 5325 Report::Kind kind() const {
5368 return static_cast<Report::Kind>(raw_ptr()->kind_); 5326 return static_cast<Report::Kind>(raw_ptr()->kind_);
5369 } 5327 }
5370 5328
5371 // Build, cache, and return formatted message. 5329 // Build, cache, and return formatted message.
5372 RawString* FormatMessage() const; 5330 RawString* FormatMessage() const;
5373 5331
5374 static intptr_t InstanceSize() { 5332 static intptr_t InstanceSize() {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5421 5379
5422 RawString* formatted_message() const { return raw_ptr()->formatted_message_; } 5380 RawString* formatted_message() const { return raw_ptr()->formatted_message_; }
5423 void set_formatted_message(const String& value) const; 5381 void set_formatted_message(const String& value) const;
5424 5382
5425 static RawLanguageError* New(); 5383 static RawLanguageError* New();
5426 5384
5427 FINAL_HEAP_OBJECT_IMPLEMENTATION(LanguageError, Error); 5385 FINAL_HEAP_OBJECT_IMPLEMENTATION(LanguageError, Error);
5428 friend class Class; 5386 friend class Class;
5429 }; 5387 };
5430 5388
5431
5432 class UnhandledException : public Error { 5389 class UnhandledException : public Error {
5433 public: 5390 public:
5434 RawInstance* exception() const { return raw_ptr()->exception_; } 5391 RawInstance* exception() const { return raw_ptr()->exception_; }
5435 static intptr_t exception_offset() { 5392 static intptr_t exception_offset() {
5436 return OFFSET_OF(RawUnhandledException, exception_); 5393 return OFFSET_OF(RawUnhandledException, exception_);
5437 } 5394 }
5438 5395
5439 RawInstance* stacktrace() const { return raw_ptr()->stacktrace_; } 5396 RawInstance* stacktrace() const { return raw_ptr()->stacktrace_; }
5440 static intptr_t stacktrace_offset() { 5397 static intptr_t stacktrace_offset() {
5441 return OFFSET_OF(RawUnhandledException, stacktrace_); 5398 return OFFSET_OF(RawUnhandledException, stacktrace_);
(...skipping 13 matching lines...) Expand all
5455 static RawUnhandledException* New(Heap::Space space = Heap::kNew); 5412 static RawUnhandledException* New(Heap::Space space = Heap::kNew);
5456 5413
5457 void set_exception(const Instance& exception) const; 5414 void set_exception(const Instance& exception) const;
5458 void set_stacktrace(const Instance& stacktrace) const; 5415 void set_stacktrace(const Instance& stacktrace) const;
5459 5416
5460 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnhandledException, Error); 5417 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnhandledException, Error);
5461 friend class Class; 5418 friend class Class;
5462 friend class ObjectStore; 5419 friend class ObjectStore;
5463 }; 5420 };
5464 5421
5465
5466 class UnwindError : public Error { 5422 class UnwindError : public Error {
5467 public: 5423 public:
5468 bool is_user_initiated() const { return raw_ptr()->is_user_initiated_; } 5424 bool is_user_initiated() const { return raw_ptr()->is_user_initiated_; }
5469 void set_is_user_initiated(bool value) const; 5425 void set_is_user_initiated(bool value) const;
5470 5426
5471 RawString* message() const { return raw_ptr()->message_; } 5427 RawString* message() const { return raw_ptr()->message_; }
5472 5428
5473 static intptr_t InstanceSize() { 5429 static intptr_t InstanceSize() {
5474 return RoundedAllocationSize(sizeof(RawUnwindError)); 5430 return RoundedAllocationSize(sizeof(RawUnwindError));
5475 } 5431 }
5476 5432
5477 static RawUnwindError* New(const String& message, 5433 static RawUnwindError* New(const String& message,
5478 Heap::Space space = Heap::kNew); 5434 Heap::Space space = Heap::kNew);
5479 5435
5480 virtual const char* ToErrorCString() const; 5436 virtual const char* ToErrorCString() const;
5481 5437
5482 private: 5438 private:
5483 void set_message(const String& message) const; 5439 void set_message(const String& message) const;
5484 5440
5485 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnwindError, Error); 5441 FINAL_HEAP_OBJECT_IMPLEMENTATION(UnwindError, Error);
5486 friend class Class; 5442 friend class Class;
5487 }; 5443 };
5488 5444
5489
5490 // Instance is the base class for all instance objects (aka the Object class 5445 // Instance is the base class for all instance objects (aka the Object class
5491 // in Dart source code. 5446 // in Dart source code.
5492 class Instance : public Object { 5447 class Instance : public Object {
5493 public: 5448 public:
5494 // Equality and identity testing. 5449 // Equality and identity testing.
5495 // 1. OperatorEquals: true iff 'this == other' is true in Dart code. 5450 // 1. OperatorEquals: true iff 'this == other' is true in Dart code.
5496 // 2. IsIdenticalTo: true iff 'identical(this, other)' is true in Dart code. 5451 // 2. IsIdenticalTo: true iff 'identical(this, other)' is true in Dart code.
5497 // 3. CanonicalizeEquals: used to canonicalize compile-time constants, e.g., 5452 // 3. CanonicalizeEquals: used to canonicalize compile-time constants, e.g.,
5498 // using bitwise equality of fields and list elements. 5453 // using bitwise equality of fields and list elements.
5499 // Subclasses where 1 and 3 coincide may also define a plain Equals, e.g., 5454 // Subclasses where 1 and 3 coincide may also define a plain Equals, e.g.,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
5635 friend class RegExp; 5590 friend class RegExp;
5636 friend class SnapshotWriter; 5591 friend class SnapshotWriter;
5637 friend class StubCode; 5592 friend class StubCode;
5638 friend class TypedDataView; 5593 friend class TypedDataView;
5639 friend class InstanceSerializationCluster; 5594 friend class InstanceSerializationCluster;
5640 friend class InstanceDeserializationCluster; 5595 friend class InstanceDeserializationCluster;
5641 friend class ClassDeserializationCluster; // vtable 5596 friend class ClassDeserializationCluster; // vtable
5642 friend class InstanceMorpher; 5597 friend class InstanceMorpher;
5643 }; 5598 };
5644 5599
5645
5646 class LibraryPrefix : public Instance { 5600 class LibraryPrefix : public Instance {
5647 public: 5601 public:
5648 RawString* name() const { return raw_ptr()->name_; } 5602 RawString* name() const { return raw_ptr()->name_; }
5649 virtual RawString* DictionaryName() const { return name(); } 5603 virtual RawString* DictionaryName() const { return name(); }
5650 5604
5651 RawArray* imports() const { return raw_ptr()->imports_; } 5605 RawArray* imports() const { return raw_ptr()->imports_; }
5652 intptr_t num_imports() const { return raw_ptr()->num_imports_; } 5606 intptr_t num_imports() const { return raw_ptr()->num_imports_; }
5653 RawLibrary* importer() const { return raw_ptr()->importer_; } 5607 RawLibrary* importer() const { return raw_ptr()->importer_; }
5654 5608
5655 RawInstance* LoadError() const; 5609 RawInstance* LoadError() const;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
5692 void set_num_imports(intptr_t value) const; 5646 void set_num_imports(intptr_t value) const;
5693 void set_importer(const Library& value) const; 5647 void set_importer(const Library& value) const;
5694 void set_is_loaded() const; 5648 void set_is_loaded() const;
5695 5649
5696 static RawLibraryPrefix* New(); 5650 static RawLibraryPrefix* New();
5697 5651
5698 FINAL_HEAP_OBJECT_IMPLEMENTATION(LibraryPrefix, Instance); 5652 FINAL_HEAP_OBJECT_IMPLEMENTATION(LibraryPrefix, Instance);
5699 friend class Class; 5653 friend class Class;
5700 }; 5654 };
5701 5655
5702
5703 // AbstractType is an abstract superclass. 5656 // AbstractType is an abstract superclass.
5704 // Subclasses of AbstractType are Type and TypeParameter. 5657 // Subclasses of AbstractType are Type and TypeParameter.
5705 class AbstractType : public Instance { 5658 class AbstractType : public Instance {
5706 public: 5659 public:
5707 // We use 30 bits for the hash code so hashes in a snapshot taken on a 5660 // We use 30 bits for the hash code so hashes in a snapshot taken on a
5708 // 64-bit architecture stay in Smi range when loaded on a 32-bit 5661 // 64-bit architecture stay in Smi range when loaded on a 32-bit
5709 // architecture. 5662 // architecture.
5710 static const intptr_t kHashBits = 30; 5663 static const intptr_t kHashBits = 30;
5711 5664
5712 virtual bool IsFinalized() const; 5665 virtual bool IsFinalized() const;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
5901 // type arguments, if any. 5854 // type arguments, if any.
5902 RawString* BuildName(NameVisibility visibility) const; 5855 RawString* BuildName(NameVisibility visibility) const;
5903 5856
5904 protected: 5857 protected:
5905 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Instance); 5858 HEAP_OBJECT_IMPLEMENTATION(AbstractType, Instance);
5906 friend class Class; 5859 friend class Class;
5907 friend class Function; 5860 friend class Function;
5908 friend class TypeArguments; 5861 friend class TypeArguments;
5909 }; 5862 };
5910 5863
5911
5912 // A Type consists of a class, possibly parameterized with type 5864 // A Type consists of a class, possibly parameterized with type
5913 // arguments. Example: C<T1, T2>. 5865 // arguments. Example: C<T1, T2>.
5914 // An unresolved class is a String specifying the class name. 5866 // An unresolved class is a String specifying the class name.
5915 // 5867 //
5916 // Caution: 'RawType*' denotes a 'raw' pointer to a VM object of class Type, as 5868 // Caution: 'RawType*' denotes a 'raw' pointer to a VM object of class Type, as
5917 // opposed to 'Type' denoting a 'handle' to the same object. 'RawType' does not 5869 // opposed to 'Type' denoting a 'handle' to the same object. 'RawType' does not
5918 // relate to a 'raw type', as opposed to a 'cooked type' or 'rare type'. 5870 // relate to a 'raw type', as opposed to a 'cooked type' or 'rare type'.
5919 class Type : public AbstractType { 5871 class Type : public AbstractType {
5920 public: 5872 public:
5921 static intptr_t type_class_id_offset() { 5873 static intptr_t type_class_id_offset() {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
6053 void set_type_state(int8_t state) const; 6005 void set_type_state(int8_t state) const;
6054 6006
6055 static RawType* New(Heap::Space space = Heap::kOld); 6007 static RawType* New(Heap::Space space = Heap::kOld);
6056 6008
6057 FINAL_HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType); 6009 FINAL_HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType);
6058 friend class Class; 6010 friend class Class;
6059 friend class TypeArguments; 6011 friend class TypeArguments;
6060 friend class ClearTypeHashVisitor; 6012 friend class ClearTypeHashVisitor;
6061 }; 6013 };
6062 6014
6063
6064 // A TypeRef is used to break cycles in the representation of recursive types. 6015 // A TypeRef is used to break cycles in the representation of recursive types.
6065 // Its only field is the recursive AbstractType it refers to, which can 6016 // Its only field is the recursive AbstractType it refers to, which can
6066 // temporarily be null during finalization. 6017 // temporarily be null during finalization.
6067 // Note that the cycle always involves type arguments. 6018 // Note that the cycle always involves type arguments.
6068 class TypeRef : public AbstractType { 6019 class TypeRef : public AbstractType {
6069 public: 6020 public:
6070 virtual bool IsFinalized() const { 6021 virtual bool IsFinalized() const {
6071 const AbstractType& ref_type = AbstractType::Handle(type()); 6022 const AbstractType& ref_type = AbstractType::Handle(type());
6072 return !ref_type.IsNull() && ref_type.IsFinalized(); 6023 return !ref_type.IsNull() && ref_type.IsFinalized();
6073 } 6024 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
6128 6079
6129 static RawTypeRef* New(const AbstractType& type); 6080 static RawTypeRef* New(const AbstractType& type);
6130 6081
6131 private: 6082 private:
6132 static RawTypeRef* New(); 6083 static RawTypeRef* New();
6133 6084
6134 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeRef, AbstractType); 6085 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeRef, AbstractType);
6135 friend class Class; 6086 friend class Class;
6136 }; 6087 };
6137 6088
6138
6139 // A TypeParameter represents a type parameter of a parameterized class. 6089 // A TypeParameter represents a type parameter of a parameterized class.
6140 // It specifies its index (and its name for debugging purposes), as well as its 6090 // It specifies its index (and its name for debugging purposes), as well as its
6141 // upper bound. 6091 // upper bound.
6142 // For example, the type parameter 'V' is specified as index 1 in the context of 6092 // For example, the type parameter 'V' is specified as index 1 in the context of
6143 // the class HashMap<K, V>. At compile time, the TypeParameter is not 6093 // the class HashMap<K, V>. At compile time, the TypeParameter is not
6144 // instantiated yet, i.e. it is only a place holder. 6094 // instantiated yet, i.e. it is only a place holder.
6145 // Upon finalization, the TypeParameter index is changed to reflect its position 6095 // Upon finalization, the TypeParameter index is changed to reflect its position
6146 // as type argument (rather than type parameter) of the parameterized class. 6096 // as type argument (rather than type parameter) of the parameterized class.
6147 // If the type parameter is declared without an extends clause, its bound is set 6097 // If the type parameter is declared without an extends clause, its bound is set
6148 // to the ObjectType. 6098 // to the ObjectType.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
6233 void set_token_pos(TokenPosition token_pos) const; 6183 void set_token_pos(TokenPosition token_pos) const;
6234 void set_type_state(int8_t state) const; 6184 void set_type_state(int8_t state) const;
6235 6185
6236 static RawTypeParameter* New(); 6186 static RawTypeParameter* New();
6237 6187
6238 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType); 6188 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType);
6239 friend class Class; 6189 friend class Class;
6240 friend class ClearTypeHashVisitor; 6190 friend class ClearTypeHashVisitor;
6241 }; 6191 };
6242 6192
6243
6244 // A BoundedType represents a type instantiated at compile time from a type 6193 // A BoundedType represents a type instantiated at compile time from a type
6245 // parameter specifying a bound that either cannot be checked at compile time 6194 // parameter specifying a bound that either cannot be checked at compile time
6246 // because the type or the bound are still uninstantiated or can be checked and 6195 // because the type or the bound are still uninstantiated or can be checked and
6247 // would trigger a bound error in checked mode. The bound must be checked at 6196 // would trigger a bound error in checked mode. The bound must be checked at
6248 // runtime once the type and its bound are instantiated and when the execution 6197 // runtime once the type and its bound are instantiated and when the execution
6249 // mode is known to be checked mode. 6198 // mode is known to be checked mode.
6250 class BoundedType : public AbstractType { 6199 class BoundedType : public AbstractType {
6251 public: 6200 public:
6252 virtual bool IsFinalized() const { 6201 virtual bool IsFinalized() const {
6253 return AbstractType::Handle(type()).IsFinalized(); 6202 return AbstractType::Handle(type()).IsFinalized();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
6329 void set_bound(const AbstractType& value) const; 6278 void set_bound(const AbstractType& value) const;
6330 void set_type_parameter(const TypeParameter& value) const; 6279 void set_type_parameter(const TypeParameter& value) const;
6331 6280
6332 static RawBoundedType* New(); 6281 static RawBoundedType* New();
6333 6282
6334 FINAL_HEAP_OBJECT_IMPLEMENTATION(BoundedType, AbstractType); 6283 FINAL_HEAP_OBJECT_IMPLEMENTATION(BoundedType, AbstractType);
6335 friend class Class; 6284 friend class Class;
6336 friend class ClearTypeHashVisitor; 6285 friend class ClearTypeHashVisitor;
6337 }; 6286 };
6338 6287
6339
6340 // A MixinAppType represents a parsed mixin application clause, e.g. 6288 // A MixinAppType represents a parsed mixin application clause, e.g.
6341 // "S<T> with M<U>, N<V>". 6289 // "S<T> with M<U>, N<V>".
6342 // MixinAppType objects do not survive finalization, so they do not 6290 // MixinAppType objects do not survive finalization, so they do not
6343 // need to be written to and read from snapshots. 6291 // need to be written to and read from snapshots.
6344 // The class finalizer creates synthesized classes S&M and S&M&N if they do not 6292 // The class finalizer creates synthesized classes S&M and S&M&N if they do not
6345 // yet exist in the library declaring the mixin application clause. 6293 // yet exist in the library declaring the mixin application clause.
6346 class MixinAppType : public AbstractType { 6294 class MixinAppType : public AbstractType {
6347 public: 6295 public:
6348 // A MixinAppType object is unfinalized by definition, since it is replaced at 6296 // A MixinAppType object is unfinalized by definition, since it is replaced at
6349 // class finalization time with a finalized (and possibly malformed or 6297 // class finalization time with a finalized (and possibly malformed or
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
6381 6329
6382 RawArray* mixin_types() const { return raw_ptr()->mixin_types_; } 6330 RawArray* mixin_types() const { return raw_ptr()->mixin_types_; }
6383 void set_mixin_types(const Array& value) const; 6331 void set_mixin_types(const Array& value) const;
6384 6332
6385 static RawMixinAppType* New(); 6333 static RawMixinAppType* New();
6386 6334
6387 FINAL_HEAP_OBJECT_IMPLEMENTATION(MixinAppType, AbstractType); 6335 FINAL_HEAP_OBJECT_IMPLEMENTATION(MixinAppType, AbstractType);
6388 friend class Class; 6336 friend class Class;
6389 }; 6337 };
6390 6338
6391
6392 class Number : public Instance { 6339 class Number : public Instance {
6393 public: 6340 public:
6394 // TODO(iposva): Add more useful Number methods. 6341 // TODO(iposva): Add more useful Number methods.
6395 RawString* ToString(Heap::Space space) const; 6342 RawString* ToString(Heap::Space space) const;
6396 6343
6397 // Numbers are canonicalized differently from other instances/strings. 6344 // Numbers are canonicalized differently from other instances/strings.
6398 virtual RawInstance* CheckAndCanonicalize(Thread* thread, 6345 virtual RawInstance* CheckAndCanonicalize(Thread* thread,
6399 const char** error_str) const; 6346 const char** error_str) const;
6400 6347
6401 #if defined(DEBUG) 6348 #if defined(DEBUG)
6402 // Check if number is canonical. 6349 // Check if number is canonical.
6403 virtual bool CheckIsCanonical(Thread* thread) const; 6350 virtual bool CheckIsCanonical(Thread* thread) const;
6404 #endif // DEBUG 6351 #endif // DEBUG
6405 6352
6406 private: 6353 private:
6407 OBJECT_IMPLEMENTATION(Number, Instance); 6354 OBJECT_IMPLEMENTATION(Number, Instance);
6408 6355
6409 friend class Class; 6356 friend class Class;
6410 }; 6357 };
6411 6358
6412
6413 class Integer : public Number { 6359 class Integer : public Number {
6414 public: 6360 public:
6415 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew); 6361 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew);
6416 static RawInteger* NewFromUint64(uint64_t value, 6362 static RawInteger* NewFromUint64(uint64_t value,
6417 Heap::Space space = Heap::kNew); 6363 Heap::Space space = Heap::kNew);
6418 6364
6419 // Returns a canonical Integer object allocated in the old gen space. 6365 // Returns a canonical Integer object allocated in the old gen space.
6420 static RawInteger* NewCanonical(const String& str); 6366 static RawInteger* NewCanonical(const String& str);
6421 6367
6422 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew); 6368 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
6457 Heap::Space space = Heap::kNew) const; 6403 Heap::Space space = Heap::kNew) const;
6458 RawInteger* BitOp(Token::Kind operation, 6404 RawInteger* BitOp(Token::Kind operation,
6459 const Integer& other, 6405 const Integer& other,
6460 Heap::Space space = Heap::kNew) const; 6406 Heap::Space space = Heap::kNew) const;
6461 6407
6462 private: 6408 private:
6463 OBJECT_IMPLEMENTATION(Integer, Number); 6409 OBJECT_IMPLEMENTATION(Integer, Number);
6464 friend class Class; 6410 friend class Class;
6465 }; 6411 };
6466 6412
6467
6468 class Smi : public Integer { 6413 class Smi : public Integer {
6469 public: 6414 public:
6470 static const intptr_t kBits = kSmiBits; 6415 static const intptr_t kBits = kSmiBits;
6471 static const intptr_t kMaxValue = kSmiMax; 6416 static const intptr_t kMaxValue = kSmiMax;
6472 static const intptr_t kMinValue = kSmiMin; 6417 static const intptr_t kMinValue = kSmiMin;
6473 6418
6474 intptr_t Value() const { return ValueFromRaw(raw_value()); } 6419 intptr_t Value() const { return ValueFromRaw(raw_value()); }
6475 6420
6476 virtual bool Equals(const Instance& other) const; 6421 virtual bool Equals(const Instance& other) const;
6477 virtual bool IsZero() const { return Value() == 0; } 6422 virtual bool IsZero() const { return Value() == 0; }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
6542 Smi() : Integer() {} 6487 Smi() : Integer() {}
6543 BASE_OBJECT_IMPLEMENTATION(Smi, Integer); 6488 BASE_OBJECT_IMPLEMENTATION(Smi, Integer);
6544 OBJECT_SERVICE_SUPPORT(Smi); 6489 OBJECT_SERVICE_SUPPORT(Smi);
6545 friend class Api; // For ValueFromRaw 6490 friend class Api; // For ValueFromRaw
6546 friend class Class; 6491 friend class Class;
6547 friend class Object; 6492 friend class Object;
6548 friend class ReusableSmiHandleScope; 6493 friend class ReusableSmiHandleScope;
6549 friend class Thread; 6494 friend class Thread;
6550 }; 6495 };
6551 6496
6552
6553 class Mint : public Integer { 6497 class Mint : public Integer {
6554 public: 6498 public:
6555 static const intptr_t kBits = 63; // 64-th bit is sign. 6499 static const intptr_t kBits = 63; // 64-th bit is sign.
6556 static const int64_t kMaxValue = 6500 static const int64_t kMaxValue =
6557 static_cast<int64_t>(DART_2PART_UINT64_C(0x7FFFFFFF, FFFFFFFF)); 6501 static_cast<int64_t>(DART_2PART_UINT64_C(0x7FFFFFFF, FFFFFFFF));
6558 static const int64_t kMinValue = 6502 static const int64_t kMinValue =
6559 static_cast<int64_t>(DART_2PART_UINT64_C(0x80000000, 00000000)); 6503 static_cast<int64_t>(DART_2PART_UINT64_C(0x80000000, 00000000));
6560 6504
6561 int64_t value() const { return raw_ptr()->value_; } 6505 int64_t value() const { return raw_ptr()->value_; }
6562 static intptr_t value_offset() { return OFFSET_OF(RawMint, value_); } 6506 static intptr_t value_offset() { return OFFSET_OF(RawMint, value_); }
(...skipping 24 matching lines...) Expand all
6587 static RawMint* NewCanonical(int64_t value); 6531 static RawMint* NewCanonical(int64_t value);
6588 6532
6589 private: 6533 private:
6590 void set_value(int64_t value) const; 6534 void set_value(int64_t value) const;
6591 6535
6592 MINT_OBJECT_IMPLEMENTATION(Mint, Integer, Integer); 6536 MINT_OBJECT_IMPLEMENTATION(Mint, Integer, Integer);
6593 friend class Class; 6537 friend class Class;
6594 friend class Number; 6538 friend class Number;
6595 }; 6539 };
6596 6540
6597
6598 class Bigint : public Integer { 6541 class Bigint : public Integer {
6599 public: 6542 public:
6600 virtual bool IsZero() const { return Used() == 0; } 6543 virtual bool IsZero() const { return Used() == 0; }
6601 virtual bool IsNegative() const { return Neg(); } 6544 virtual bool IsNegative() const { return Neg(); }
6602 virtual bool Equals(const Instance& other) const; 6545 virtual bool Equals(const Instance& other) const;
6603 6546
6604 virtual double AsDoubleValue() const; 6547 virtual double AsDoubleValue() const;
6605 virtual int64_t AsInt64Value() const; 6548 virtual int64_t AsInt64Value() const;
6606 virtual int64_t AsTruncatedInt64Value() const; 6549 virtual int64_t AsTruncatedInt64Value() const;
6607 virtual uint32_t AsTruncatedUint32Value() const; 6550 virtual uint32_t AsTruncatedUint32Value() const;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
6685 static RawTypedData* NewDigitsFromDecCString(const char* str, 6628 static RawTypedData* NewDigitsFromDecCString(const char* str,
6686 intptr_t* used, 6629 intptr_t* used,
6687 Heap::Space space = Heap::kNew); 6630 Heap::Space space = Heap::kNew);
6688 6631
6689 static RawBigint* Allocate(intptr_t length, Heap::Space space = Heap::kNew); 6632 static RawBigint* Allocate(intptr_t length, Heap::Space space = Heap::kNew);
6690 6633
6691 FINAL_HEAP_OBJECT_IMPLEMENTATION(Bigint, Integer); 6634 FINAL_HEAP_OBJECT_IMPLEMENTATION(Bigint, Integer);
6692 friend class Class; 6635 friend class Class;
6693 }; 6636 };
6694 6637
6695
6696 // Class Double represents class Double in corelib_impl, which implements 6638 // Class Double represents class Double in corelib_impl, which implements
6697 // abstract class double in corelib. 6639 // abstract class double in corelib.
6698 class Double : public Number { 6640 class Double : public Number {
6699 public: 6641 public:
6700 double value() const { return raw_ptr()->value_; } 6642 double value() const { return raw_ptr()->value_; }
6701 6643
6702 bool BitwiseEqualsToDouble(double value) const; 6644 bool BitwiseEqualsToDouble(double value) const;
6703 virtual bool OperatorEquals(const Instance& other) const; 6645 virtual bool OperatorEquals(const Instance& other) const;
6704 virtual bool CanonicalizeEquals(const Instance& other) const; 6646 virtual bool CanonicalizeEquals(const Instance& other) const;
6705 virtual uword ComputeCanonicalTableHash() const { 6647 virtual uword ComputeCanonicalTableHash() const {
(...skipping 20 matching lines...) Expand all
6726 static intptr_t value_offset() { return OFFSET_OF(RawDouble, value_); } 6668 static intptr_t value_offset() { return OFFSET_OF(RawDouble, value_); }
6727 6669
6728 private: 6670 private:
6729 void set_value(double value) const; 6671 void set_value(double value) const;
6730 6672
6731 FINAL_HEAP_OBJECT_IMPLEMENTATION(Double, Number); 6673 FINAL_HEAP_OBJECT_IMPLEMENTATION(Double, Number);
6732 friend class Class; 6674 friend class Class;
6733 friend class Number; 6675 friend class Number;
6734 }; 6676 };
6735 6677
6736
6737 // String may not be '\0' terminated. 6678 // String may not be '\0' terminated.
6738 class String : public Instance { 6679 class String : public Instance {
6739 public: 6680 public:
6740 // We use 30 bits for the hash code so hashes in a snapshot taken on a 6681 // We use 30 bits for the hash code so hashes in a snapshot taken on a
6741 // 64-bit architecture stay in Smi range when loaded on a 32-bit 6682 // 64-bit architecture stay in Smi range when loaded on a 32-bit
6742 // architecture. 6683 // architecture.
6743 static const intptr_t kHashBits = 30; 6684 static const intptr_t kHashBits = 30;
6744 6685
6745 static const intptr_t kOneByteChar = 1; 6686 static const intptr_t kOneByteChar = 1;
6746 static const intptr_t kTwoByteChar = 2; 6687 static const intptr_t kTwoByteChar = 2;
6747 6688
6748 // All strings share the same maximum element count to keep things 6689 // All strings share the same maximum element count to keep things
6749 // simple. We choose a value that will prevent integer overflow for 6690 // simple. We choose a value that will prevent integer overflow for
6750 // 2 byte strings, since it is the worst case. 6691 // 2 byte strings, since it is the worst case.
6751 #if defined(HASH_IN_OBJECT_HEADER) 6692 #if defined(HASH_IN_OBJECT_HEADER)
6752 static const intptr_t kSizeofRawString = sizeof(RawInstance) + kWordSize; 6693 static const intptr_t kSizeofRawString = sizeof(RawInstance) + kWordSize;
6753 #else 6694 #else
6754 static const intptr_t kSizeofRawString = sizeof(RawInstance) + 2 * kWordSize; 6695 static const intptr_t kSizeofRawString = sizeof(RawInstance) + 2 * kWordSize;
6755 #endif 6696 #endif
6756 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar; 6697 static const intptr_t kMaxElements = kSmiMax / kTwoByteChar;
6757 6698
6758 class CodePointIterator : public ValueObject { 6699 class CodePointIterator : public ValueObject {
6759 public: 6700 public:
6760 explicit CodePointIterator(const String& str) 6701 explicit CodePointIterator(const String& str)
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
7074 friend class OneByteString; 7015 friend class OneByteString;
7075 friend class TwoByteString; 7016 friend class TwoByteString;
7076 friend class ExternalOneByteString; 7017 friend class ExternalOneByteString;
7077 friend class ExternalTwoByteString; 7018 friend class ExternalTwoByteString;
7078 // So that SkippedCodeFunctions can print a debug string from a NoHandleScope. 7019 // So that SkippedCodeFunctions can print a debug string from a NoHandleScope.
7079 friend class SkippedCodeFunctions; 7020 friend class SkippedCodeFunctions;
7080 friend class RawOneByteString; 7021 friend class RawOneByteString;
7081 friend class RODataSerializationCluster; // SetHash 7022 friend class RODataSerializationCluster; // SetHash
7082 }; 7023 };
7083 7024
7084
7085 class OneByteString : public AllStatic { 7025 class OneByteString : public AllStatic {
7086 public: 7026 public:
7087 static uint16_t CharAt(const String& str, intptr_t index) { 7027 static uint16_t CharAt(const String& str, intptr_t index) {
7088 ASSERT((index >= 0) && (index < str.Length())); 7028 ASSERT((index >= 0) && (index < str.Length()));
7089 ASSERT(str.IsOneByteString()); 7029 ASSERT(str.IsOneByteString());
7090 return raw_ptr(str)->data()[index]; 7030 return raw_ptr(str)->data()[index];
7091 } 7031 }
7092 7032
7093 static void SetCharAt(const String& str, intptr_t index, uint8_t code_unit) { 7033 static void SetCharAt(const String& str, intptr_t index, uint8_t code_unit) {
7094 NoSafepointScope no_safepoint; 7034 NoSafepointScope no_safepoint;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
7211 bool as_reference); 7151 bool as_reference);
7212 7152
7213 friend class Class; 7153 friend class Class;
7214 friend class String; 7154 friend class String;
7215 friend class Symbols; 7155 friend class Symbols;
7216 friend class ExternalOneByteString; 7156 friend class ExternalOneByteString;
7217 friend class SnapshotReader; 7157 friend class SnapshotReader;
7218 friend class StringHasher; 7158 friend class StringHasher;
7219 }; 7159 };
7220 7160
7221
7222 class TwoByteString : public AllStatic { 7161 class TwoByteString : public AllStatic {
7223 public: 7162 public:
7224 static uint16_t CharAt(const String& str, intptr_t index) { 7163 static uint16_t CharAt(const String& str, intptr_t index) {
7225 ASSERT((index >= 0) && (index < str.Length())); 7164 ASSERT((index >= 0) && (index < str.Length()));
7226 ASSERT(str.IsTwoByteString()); 7165 ASSERT(str.IsTwoByteString());
7227 return raw_ptr(str)->data()[index]; 7166 return raw_ptr(str)->data()[index];
7228 } 7167 }
7229 7168
7230 static void SetCharAt(const String& str, intptr_t index, uint16_t ch) { 7169 static void SetCharAt(const String& str, intptr_t index, uint16_t ch) {
7231 NoSafepointScope no_safepoint; 7170 NoSafepointScope no_safepoint;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
7298 Dart_PeerFinalizer cback); 7237 Dart_PeerFinalizer cback);
7299 7238
7300 static void Finalize(void* isolate_callback_data, 7239 static void Finalize(void* isolate_callback_data,
7301 Dart_WeakPersistentHandle handle, 7240 Dart_WeakPersistentHandle handle,
7302 void* peer); 7241 void* peer);
7303 7242
7304 static RawTwoByteString* null() { 7243 static RawTwoByteString* null() {
7305 return reinterpret_cast<RawTwoByteString*>(Object::null()); 7244 return reinterpret_cast<RawTwoByteString*>(Object::null());
7306 } 7245 }
7307 7246
7308
7309 static const ClassId kClassId = kTwoByteStringCid; 7247 static const ClassId kClassId = kTwoByteStringCid;
7310 7248
7311 private: 7249 private:
7312 static RawTwoByteString* raw(const String& str) { 7250 static RawTwoByteString* raw(const String& str) {
7313 return reinterpret_cast<RawTwoByteString*>(str.raw()); 7251 return reinterpret_cast<RawTwoByteString*>(str.raw());
7314 } 7252 }
7315 7253
7316 static const RawTwoByteString* raw_ptr(const String& str) { 7254 static const RawTwoByteString* raw_ptr(const String& str) {
7317 return reinterpret_cast<const RawTwoByteString*>(str.raw_ptr()); 7255 return reinterpret_cast<const RawTwoByteString*>(str.raw_ptr());
7318 } 7256 }
7319 7257
7320 static uint16_t* CharAddr(const String& str, intptr_t index) { 7258 static uint16_t* CharAddr(const String& str, intptr_t index) {
7321 ASSERT((index >= 0) && (index < str.Length())); 7259 ASSERT((index >= 0) && (index < str.Length()));
7322 ASSERT(str.IsTwoByteString()); 7260 ASSERT(str.IsTwoByteString());
7323 return &str.UnsafeMutableNonPointer(raw_ptr(str)->data())[index]; 7261 return &str.UnsafeMutableNonPointer(raw_ptr(str)->data())[index];
7324 } 7262 }
7325 7263
7326 static RawTwoByteString* ReadFrom(SnapshotReader* reader, 7264 static RawTwoByteString* ReadFrom(SnapshotReader* reader,
7327 intptr_t object_id, 7265 intptr_t object_id,
7328 intptr_t tags, 7266 intptr_t tags,
7329 Snapshot::Kind kind, 7267 Snapshot::Kind kind,
7330 bool as_reference); 7268 bool as_reference);
7331 7269
7332 friend class Class; 7270 friend class Class;
7333 friend class String; 7271 friend class String;
7334 friend class SnapshotReader; 7272 friend class SnapshotReader;
7335 friend class Symbols; 7273 friend class Symbols;
7336 }; 7274 };
7337 7275
7338
7339 class ExternalOneByteString : public AllStatic { 7276 class ExternalOneByteString : public AllStatic {
7340 public: 7277 public:
7341 static uint16_t CharAt(const String& str, intptr_t index) { 7278 static uint16_t CharAt(const String& str, intptr_t index) {
7342 NoSafepointScope no_safepoint; 7279 NoSafepointScope no_safepoint;
7343 return *CharAddr(str, index); 7280 return *CharAddr(str, index);
7344 } 7281 }
7345 7282
7346 static void* GetPeer(const String& str) { 7283 static void* GetPeer(const String& str) {
7347 return raw_ptr(str)->external_data_->peer(); 7284 return raw_ptr(str)->external_data_->peer();
7348 } 7285 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
7412 // Indicates this class cannot be extended by dart code. 7349 // Indicates this class cannot be extended by dart code.
7413 return -kWordSize; 7350 return -kWordSize;
7414 } 7351 }
7415 7352
7416 friend class Class; 7353 friend class Class;
7417 friend class String; 7354 friend class String;
7418 friend class SnapshotReader; 7355 friend class SnapshotReader;
7419 friend class Symbols; 7356 friend class Symbols;
7420 }; 7357 };
7421 7358
7422
7423 class ExternalTwoByteString : public AllStatic { 7359 class ExternalTwoByteString : public AllStatic {
7424 public: 7360 public:
7425 static uint16_t CharAt(const String& str, intptr_t index) { 7361 static uint16_t CharAt(const String& str, intptr_t index) {
7426 NoSafepointScope no_safepoint; 7362 NoSafepointScope no_safepoint;
7427 return *CharAddr(str, index); 7363 return *CharAddr(str, index);
7428 } 7364 }
7429 7365
7430 static void* GetPeer(const String& str) { 7366 static void* GetPeer(const String& str) {
7431 return raw_ptr(str)->external_data_->peer(); 7367 return raw_ptr(str)->external_data_->peer();
7432 } 7368 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
7492 // Indicates this class cannot be extended by dart code. 7428 // Indicates this class cannot be extended by dart code.
7493 return -kWordSize; 7429 return -kWordSize;
7494 } 7430 }
7495 7431
7496 friend class Class; 7432 friend class Class;
7497 friend class String; 7433 friend class String;
7498 friend class SnapshotReader; 7434 friend class SnapshotReader;
7499 friend class Symbols; 7435 friend class Symbols;
7500 }; 7436 };
7501 7437
7502
7503 // Class Bool implements Dart core class bool. 7438 // Class Bool implements Dart core class bool.
7504 class Bool : public Instance { 7439 class Bool : public Instance {
7505 public: 7440 public:
7506 bool value() const { return raw_ptr()->value_; } 7441 bool value() const { return raw_ptr()->value_; }
7507 7442
7508 static intptr_t InstanceSize() { 7443 static intptr_t InstanceSize() {
7509 return RoundedAllocationSize(sizeof(RawBool)); 7444 return RoundedAllocationSize(sizeof(RawBool));
7510 } 7445 }
7511 7446
7512 static const Bool& True() { return Object::bool_true(); } 7447 static const Bool& True() { return Object::bool_true(); }
(...skipping 10 matching lines...) Expand all
7523 } 7458 }
7524 7459
7525 // New should only be called to initialize the two legal bool values. 7460 // New should only be called to initialize the two legal bool values.
7526 static RawBool* New(bool value); 7461 static RawBool* New(bool value);
7527 7462
7528 FINAL_HEAP_OBJECT_IMPLEMENTATION(Bool, Instance); 7463 FINAL_HEAP_OBJECT_IMPLEMENTATION(Bool, Instance);
7529 friend class Class; 7464 friend class Class;
7530 friend class Object; // To initialize the true and false values. 7465 friend class Object; // To initialize the true and false values.
7531 }; 7466 };
7532 7467
7533
7534 class Array : public Instance { 7468 class Array : public Instance {
7535 public: 7469 public:
7536 // We use 30 bits for the hash code so hashes in a snapshot taken on a 7470 // We use 30 bits for the hash code so hashes in a snapshot taken on a
7537 // 64-bit architecture stay in Smi range when loaded on a 32-bit 7471 // 64-bit architecture stay in Smi range when loaded on a 32-bit
7538 // architecture. 7472 // architecture.
7539 static const intptr_t kHashBits = 30; 7473 static const intptr_t kHashBits = 30;
7540 7474
7541 intptr_t Length() const { 7475 intptr_t Length() const {
7542 ASSERT(!IsNull()); 7476 ASSERT(!IsNull());
7543 return Smi::Value(raw_ptr()->length_); 7477 return Smi::Value(raw_ptr()->length_);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
7647 StoreSmi(&raw_ptr()->length_, Smi::New(value)); 7581 StoreSmi(&raw_ptr()->length_, Smi::New(value));
7648 } 7582 }
7649 7583
7650 FINAL_HEAP_OBJECT_IMPLEMENTATION(Array, Instance); 7584 FINAL_HEAP_OBJECT_IMPLEMENTATION(Array, Instance);
7651 friend class Class; 7585 friend class Class;
7652 friend class ImmutableArray; 7586 friend class ImmutableArray;
7653 friend class Object; 7587 friend class Object;
7654 friend class String; 7588 friend class String;
7655 }; 7589 };
7656 7590
7657
7658 class ImmutableArray : public AllStatic { 7591 class ImmutableArray : public AllStatic {
7659 public: 7592 public:
7660 static RawImmutableArray* New(intptr_t len, Heap::Space space = Heap::kNew); 7593 static RawImmutableArray* New(intptr_t len, Heap::Space space = Heap::kNew);
7661 7594
7662 static RawImmutableArray* ReadFrom(SnapshotReader* reader, 7595 static RawImmutableArray* ReadFrom(SnapshotReader* reader,
7663 intptr_t object_id, 7596 intptr_t object_id,
7664 intptr_t tags, 7597 intptr_t tags,
7665 Snapshot::Kind kind, 7598 Snapshot::Kind kind,
7666 bool as_reference); 7599 bool as_reference);
7667 7600
(...skipping 11 matching lines...) Expand all
7679 return -kWordSize; 7612 return -kWordSize;
7680 } 7613 }
7681 7614
7682 static RawImmutableArray* raw(const Array& array) { 7615 static RawImmutableArray* raw(const Array& array) {
7683 return reinterpret_cast<RawImmutableArray*>(array.raw()); 7616 return reinterpret_cast<RawImmutableArray*>(array.raw());
7684 } 7617 }
7685 7618
7686 friend class Class; 7619 friend class Class;
7687 }; 7620 };
7688 7621
7689
7690 class GrowableObjectArray : public Instance { 7622 class GrowableObjectArray : public Instance {
7691 public: 7623 public:
7692 intptr_t Capacity() const { 7624 intptr_t Capacity() const {
7693 NoSafepointScope no_safepoint; 7625 NoSafepointScope no_safepoint;
7694 ASSERT(!IsNull()); 7626 ASSERT(!IsNull());
7695 return Smi::Value(DataArray()->length_); 7627 return Smi::Value(DataArray()->length_);
7696 } 7628 }
7697 intptr_t Length() const { 7629 intptr_t Length() const {
7698 ASSERT(!IsNull()); 7630 ASSERT(!IsNull());
7699 return Smi::Value(raw_ptr()->length_); 7631 return Smi::Value(raw_ptr()->length_);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
7787 return &(DataArray()->data()[index]); 7719 return &(DataArray()->data()[index]);
7788 } 7720 }
7789 7721
7790 static const int kDefaultInitialCapacity = 0; 7722 static const int kDefaultInitialCapacity = 0;
7791 7723
7792 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance); 7724 FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance);
7793 friend class Array; 7725 friend class Array;
7794 friend class Class; 7726 friend class Class;
7795 }; 7727 };
7796 7728
7797
7798 class Float32x4 : public Instance { 7729 class Float32x4 : public Instance {
7799 public: 7730 public:
7800 static RawFloat32x4* New(float value0, 7731 static RawFloat32x4* New(float value0,
7801 float value1, 7732 float value1,
7802 float value2, 7733 float value2,
7803 float value3, 7734 float value3,
7804 Heap::Space space = Heap::kNew); 7735 Heap::Space space = Heap::kNew);
7805 static RawFloat32x4* New(simd128_value_t value, 7736 static RawFloat32x4* New(simd128_value_t value,
7806 Heap::Space space = Heap::kNew); 7737 Heap::Space space = Heap::kNew);
7807 7738
(...skipping 14 matching lines...) Expand all
7822 return RoundedAllocationSize(sizeof(RawFloat32x4)); 7753 return RoundedAllocationSize(sizeof(RawFloat32x4));
7823 } 7754 }
7824 7755
7825 static intptr_t value_offset() { return OFFSET_OF(RawFloat32x4, value_); } 7756 static intptr_t value_offset() { return OFFSET_OF(RawFloat32x4, value_); }
7826 7757
7827 private: 7758 private:
7828 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4, Instance); 7759 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4, Instance);
7829 friend class Class; 7760 friend class Class;
7830 }; 7761 };
7831 7762
7832
7833 class Int32x4 : public Instance { 7763 class Int32x4 : public Instance {
7834 public: 7764 public:
7835 static RawInt32x4* New(int32_t value0, 7765 static RawInt32x4* New(int32_t value0,
7836 int32_t value1, 7766 int32_t value1,
7837 int32_t value2, 7767 int32_t value2,
7838 int32_t value3, 7768 int32_t value3,
7839 Heap::Space space = Heap::kNew); 7769 Heap::Space space = Heap::kNew);
7840 static RawInt32x4* New(simd128_value_t value, Heap::Space space = Heap::kNew); 7770 static RawInt32x4* New(simd128_value_t value, Heap::Space space = Heap::kNew);
7841 7771
7842 int32_t x() const; 7772 int32_t x() const;
(...skipping 13 matching lines...) Expand all
7856 return RoundedAllocationSize(sizeof(RawInt32x4)); 7786 return RoundedAllocationSize(sizeof(RawInt32x4));
7857 } 7787 }
7858 7788
7859 static intptr_t value_offset() { return OFFSET_OF(RawInt32x4, value_); } 7789 static intptr_t value_offset() { return OFFSET_OF(RawInt32x4, value_); }
7860 7790
7861 private: 7791 private:
7862 FINAL_HEAP_OBJECT_IMPLEMENTATION(Int32x4, Instance); 7792 FINAL_HEAP_OBJECT_IMPLEMENTATION(Int32x4, Instance);
7863 friend class Class; 7793 friend class Class;
7864 }; 7794 };
7865 7795
7866
7867 class Float64x2 : public Instance { 7796 class Float64x2 : public Instance {
7868 public: 7797 public:
7869 static RawFloat64x2* New(double value0, 7798 static RawFloat64x2* New(double value0,
7870 double value1, 7799 double value1,
7871 Heap::Space space = Heap::kNew); 7800 Heap::Space space = Heap::kNew);
7872 static RawFloat64x2* New(simd128_value_t value, 7801 static RawFloat64x2* New(simd128_value_t value,
7873 Heap::Space space = Heap::kNew); 7802 Heap::Space space = Heap::kNew);
7874 7803
7875 double x() const; 7804 double x() const;
7876 double y() const; 7805 double y() const;
7877 7806
7878 void set_x(double x) const; 7807 void set_x(double x) const;
7879 void set_y(double y) const; 7808 void set_y(double y) const;
7880 7809
7881 simd128_value_t value() const; 7810 simd128_value_t value() const;
7882 void set_value(simd128_value_t value) const; 7811 void set_value(simd128_value_t value) const;
7883 7812
7884 static intptr_t InstanceSize() { 7813 static intptr_t InstanceSize() {
7885 return RoundedAllocationSize(sizeof(RawFloat64x2)); 7814 return RoundedAllocationSize(sizeof(RawFloat64x2));
7886 } 7815 }
7887 7816
7888 static intptr_t value_offset() { return OFFSET_OF(RawFloat64x2, value_); } 7817 static intptr_t value_offset() { return OFFSET_OF(RawFloat64x2, value_); }
7889 7818
7890 private: 7819 private:
7891 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float64x2, Instance); 7820 FINAL_HEAP_OBJECT_IMPLEMENTATION(Float64x2, Instance);
7892 friend class Class; 7821 friend class Class;
7893 }; 7822 };
7894 7823
7895
7896 class TypedData : public Instance { 7824 class TypedData : public Instance {
7897 public: 7825 public:
7898 // We use 30 bits for the hash code so hashes in a snapshot taken on a 7826 // We use 30 bits for the hash code so hashes in a snapshot taken on a
7899 // 64-bit architecture stay in Smi range when loaded on a 32-bit 7827 // 64-bit architecture stay in Smi range when loaded on a 32-bit
7900 // architecture. 7828 // architecture.
7901 static const intptr_t kHashBits = 30; 7829 static const intptr_t kHashBits = 30;
7902 7830
7903 intptr_t Length() const { 7831 intptr_t Length() const {
7904 ASSERT(!IsNull()); 7832 ASSERT(!IsNull());
7905 return Smi::Value(raw_ptr()->length_); 7833 return Smi::Value(raw_ptr()->length_);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
8004 dst.LengthInBytes())); 7932 dst.LengthInBytes()));
8005 { 7933 {
8006 NoSafepointScope no_safepoint; 7934 NoSafepointScope no_safepoint;
8007 if (length_in_bytes > 0) { 7935 if (length_in_bytes > 0) {
8008 memmove(dst.DataAddr(dst_offset_in_bytes), 7936 memmove(dst.DataAddr(dst_offset_in_bytes),
8009 src.DataAddr(src_offset_in_bytes), length_in_bytes); 7937 src.DataAddr(src_offset_in_bytes), length_in_bytes);
8010 } 7938 }
8011 } 7939 }
8012 } 7940 }
8013 7941
8014
8015 template <typename DstType, typename SrcType> 7942 template <typename DstType, typename SrcType>
8016 static void ClampedCopy(const DstType& dst, 7943 static void ClampedCopy(const DstType& dst,
8017 intptr_t dst_offset_in_bytes, 7944 intptr_t dst_offset_in_bytes,
8018 const SrcType& src, 7945 const SrcType& src,
8019 intptr_t src_offset_in_bytes, 7946 intptr_t src_offset_in_bytes,
8020 intptr_t length_in_bytes) { 7947 intptr_t length_in_bytes) {
8021 ASSERT(Utils::RangeCheck(src_offset_in_bytes, length_in_bytes, 7948 ASSERT(Utils::RangeCheck(src_offset_in_bytes, length_in_bytes,
8022 src.LengthInBytes())); 7949 src.LengthInBytes()));
8023 ASSERT(Utils::RangeCheck(dst_offset_in_bytes, length_in_bytes, 7950 ASSERT(Utils::RangeCheck(dst_offset_in_bytes, length_in_bytes,
8024 dst.LengthInBytes())); 7951 dst.LengthInBytes()));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
8063 static const intptr_t kNumElementSizes = 7990 static const intptr_t kNumElementSizes =
8064 kTypedDataFloat64x2ArrayCid - kTypedDataInt8ArrayCid + 1; 7991 kTypedDataFloat64x2ArrayCid - kTypedDataInt8ArrayCid + 1;
8065 static const intptr_t element_size_table[kNumElementSizes]; 7992 static const intptr_t element_size_table[kNumElementSizes];
8066 7993
8067 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypedData, Instance); 7994 FINAL_HEAP_OBJECT_IMPLEMENTATION(TypedData, Instance);
8068 friend class Class; 7995 friend class Class;
8069 friend class ExternalTypedData; 7996 friend class ExternalTypedData;
8070 friend class TypedDataView; 7997 friend class TypedDataView;
8071 }; 7998 };
8072 7999
8073
8074 class ExternalTypedData : public Instance { 8000 class ExternalTypedData : public Instance {
8075 public: 8001 public:
8076 intptr_t Length() const { 8002 intptr_t Length() const {
8077 ASSERT(!IsNull()); 8003 ASSERT(!IsNull());
8078 return Smi::Value(raw_ptr()->length_); 8004 return Smi::Value(raw_ptr()->length_);
8079 } 8005 }
8080 8006
8081 intptr_t ElementSizeInBytes() const { 8007 intptr_t ElementSizeInBytes() const {
8082 intptr_t cid = raw()->GetClassId(); 8008 intptr_t cid = raw()->GetClassId();
8083 return ElementSizeInBytes(cid); 8009 return ElementSizeInBytes(cid);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
8175 ASSERT( 8101 ASSERT(
8176 !Isolate::Current()->heap()->Contains(reinterpret_cast<uword>(data))); 8102 !Isolate::Current()->heap()->Contains(reinterpret_cast<uword>(data)));
8177 StoreNonPointer(&raw_ptr()->data_, data); 8103 StoreNonPointer(&raw_ptr()->data_, data);
8178 } 8104 }
8179 8105
8180 private: 8106 private:
8181 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData, Instance); 8107 FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData, Instance);
8182 friend class Class; 8108 friend class Class;
8183 }; 8109 };
8184 8110
8185
8186 class TypedDataView : public AllStatic { 8111 class TypedDataView : public AllStatic {
8187 public: 8112 public:
8188 static intptr_t ElementSizeInBytes(const Instance& view_obj) { 8113 static intptr_t ElementSizeInBytes(const Instance& view_obj) {
8189 ASSERT(!view_obj.IsNull()); 8114 ASSERT(!view_obj.IsNull());
8190 intptr_t cid = view_obj.raw()->GetClassId(); 8115 intptr_t cid = view_obj.raw()->GetClassId();
8191 return ElementSizeInBytes(cid); 8116 return ElementSizeInBytes(cid);
8192 } 8117 }
8193 8118
8194 static RawInstance* Data(const Instance& view_obj) { 8119 static RawInstance* Data(const Instance& view_obj) {
8195 ASSERT(!view_obj.IsNull()); 8120 ASSERT(!view_obj.IsNull());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
8235 } 8160 }
8236 8161
8237 private: 8162 private:
8238 enum { 8163 enum {
8239 kDataOffset = 1, 8164 kDataOffset = 1,
8240 kOffsetInBytesOffset = 2, 8165 kOffsetInBytesOffset = 2,
8241 kLengthOffset = 3, 8166 kLengthOffset = 3,
8242 }; 8167 };
8243 }; 8168 };
8244 8169
8245
8246 class ByteBuffer : public AllStatic { 8170 class ByteBuffer : public AllStatic {
8247 public: 8171 public:
8248 static RawInstance* Data(const Instance& view_obj) { 8172 static RawInstance* Data(const Instance& view_obj) {
8249 ASSERT(!view_obj.IsNull()); 8173 ASSERT(!view_obj.IsNull());
8250 return *reinterpret_cast<RawInstance* const*>(view_obj.raw_ptr() + 8174 return *reinterpret_cast<RawInstance* const*>(view_obj.raw_ptr() +
8251 kDataOffset); 8175 kDataOffset);
8252 } 8176 }
8253 8177
8254 static intptr_t NumberOfFields() { return kDataOffset; } 8178 static intptr_t NumberOfFields() { return kDataOffset; }
8255 8179
8256 static intptr_t data_offset() { return kWordSize * kDataOffset; } 8180 static intptr_t data_offset() { return kWordSize * kDataOffset; }
8257 8181
8258 private: 8182 private:
8259 enum { 8183 enum {
8260 kDataOffset = 1, 8184 kDataOffset = 1,
8261 }; 8185 };
8262 }; 8186 };
8263 8187
8264
8265 // Corresponds to 8188 // Corresponds to
8266 // - "new Map()", 8189 // - "new Map()",
8267 // - non-const map literals, and 8190 // - non-const map literals, and
8268 // - the default constructor of LinkedHashMap in dart:collection. 8191 // - the default constructor of LinkedHashMap in dart:collection.
8269 class LinkedHashMap : public Instance { 8192 class LinkedHashMap : public Instance {
8270 public: 8193 public:
8271 static intptr_t InstanceSize() { 8194 static intptr_t InstanceSize() {
8272 return RoundedAllocationSize(sizeof(RawLinkedHashMap)); 8195 return RoundedAllocationSize(sizeof(RawLinkedHashMap));
8273 } 8196 }
8274 8197
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
8388 static const intptr_t kInitialIndexSize = 1 << (kInitialIndexBits + 1); 8311 static const intptr_t kInitialIndexSize = 1 << (kInitialIndexBits + 1);
8389 8312
8390 // Allocate a map, but leave all fields set to null. 8313 // Allocate a map, but leave all fields set to null.
8391 // Used during deserialization (since map might contain itself as key/value). 8314 // Used during deserialization (since map might contain itself as key/value).
8392 static RawLinkedHashMap* NewUninitialized(Heap::Space space = Heap::kNew); 8315 static RawLinkedHashMap* NewUninitialized(Heap::Space space = Heap::kNew);
8393 8316
8394 friend class Class; 8317 friend class Class;
8395 friend class LinkedHashMapDeserializationCluster; 8318 friend class LinkedHashMapDeserializationCluster;
8396 }; 8319 };
8397 8320
8398
8399 class Closure : public Instance { 8321 class Closure : public Instance {
8400 public: 8322 public:
8401 RawTypeArguments* instantiator_type_arguments() const { 8323 RawTypeArguments* instantiator_type_arguments() const {
8402 return raw_ptr()->instantiator_type_arguments_; 8324 return raw_ptr()->instantiator_type_arguments_;
8403 } 8325 }
8404 static intptr_t instantiator_type_arguments_offset() { 8326 static intptr_t instantiator_type_arguments_offset() {
8405 return OFFSET_OF(RawClosure, instantiator_type_arguments_); 8327 return OFFSET_OF(RawClosure, instantiator_type_arguments_);
8406 } 8328 }
8407 8329
8408 RawTypeArguments* function_type_arguments() const { 8330 RawTypeArguments* function_type_arguments() const {
(...skipping 26 matching lines...) Expand all
8435 const Context& context, 8357 const Context& context,
8436 Heap::Space space = Heap::kNew); 8358 Heap::Space space = Heap::kNew);
8437 8359
8438 private: 8360 private:
8439 static RawClosure* New(); 8361 static RawClosure* New();
8440 8362
8441 FINAL_HEAP_OBJECT_IMPLEMENTATION(Closure, Instance); 8363 FINAL_HEAP_OBJECT_IMPLEMENTATION(Closure, Instance);
8442 friend class Class; 8364 friend class Class;
8443 }; 8365 };
8444 8366
8445
8446 class Capability : public Instance { 8367 class Capability : public Instance {
8447 public: 8368 public:
8448 uint64_t Id() const { return raw_ptr()->id_; } 8369 uint64_t Id() const { return raw_ptr()->id_; }
8449 8370
8450 static intptr_t InstanceSize() { 8371 static intptr_t InstanceSize() {
8451 return RoundedAllocationSize(sizeof(RawCapability)); 8372 return RoundedAllocationSize(sizeof(RawCapability));
8452 } 8373 }
8453 static RawCapability* New(uint64_t id, Heap::Space space = Heap::kNew); 8374 static RawCapability* New(uint64_t id, Heap::Space space = Heap::kNew);
8454 8375
8455 private: 8376 private:
8456 FINAL_HEAP_OBJECT_IMPLEMENTATION(Capability, Instance); 8377 FINAL_HEAP_OBJECT_IMPLEMENTATION(Capability, Instance);
8457 friend class Class; 8378 friend class Class;
8458 }; 8379 };
8459 8380
8460
8461 class ReceivePort : public Instance { 8381 class ReceivePort : public Instance {
8462 public: 8382 public:
8463 RawSendPort* send_port() const { return raw_ptr()->send_port_; } 8383 RawSendPort* send_port() const { return raw_ptr()->send_port_; }
8464 Dart_Port Id() const { return send_port()->ptr()->id_; } 8384 Dart_Port Id() const { return send_port()->ptr()->id_; }
8465 8385
8466 RawInstance* handler() const { return raw_ptr()->handler_; } 8386 RawInstance* handler() const { return raw_ptr()->handler_; }
8467 void set_handler(const Instance& value) const; 8387 void set_handler(const Instance& value) const;
8468 8388
8469 static intptr_t InstanceSize() { 8389 static intptr_t InstanceSize() {
8470 return RoundedAllocationSize(sizeof(RawReceivePort)); 8390 return RoundedAllocationSize(sizeof(RawReceivePort));
8471 } 8391 }
8472 static RawReceivePort* New(Dart_Port id, 8392 static RawReceivePort* New(Dart_Port id,
8473 bool is_control_port, 8393 bool is_control_port,
8474 Heap::Space space = Heap::kNew); 8394 Heap::Space space = Heap::kNew);
8475 8395
8476 private: 8396 private:
8477 FINAL_HEAP_OBJECT_IMPLEMENTATION(ReceivePort, Instance); 8397 FINAL_HEAP_OBJECT_IMPLEMENTATION(ReceivePort, Instance);
8478 friend class Class; 8398 friend class Class;
8479 }; 8399 };
8480 8400
8481
8482 class SendPort : public Instance { 8401 class SendPort : public Instance {
8483 public: 8402 public:
8484 Dart_Port Id() const { return raw_ptr()->id_; } 8403 Dart_Port Id() const { return raw_ptr()->id_; }
8485 8404
8486 Dart_Port origin_id() const { return raw_ptr()->origin_id_; } 8405 Dart_Port origin_id() const { return raw_ptr()->origin_id_; }
8487 void set_origin_id(Dart_Port id) const { 8406 void set_origin_id(Dart_Port id) const {
8488 ASSERT(origin_id() == 0); 8407 ASSERT(origin_id() == 0);
8489 StoreNonPointer(&(raw_ptr()->origin_id_), id); 8408 StoreNonPointer(&(raw_ptr()->origin_id_), id);
8490 } 8409 }
8491 8410
8492 static intptr_t InstanceSize() { 8411 static intptr_t InstanceSize() {
8493 return RoundedAllocationSize(sizeof(RawSendPort)); 8412 return RoundedAllocationSize(sizeof(RawSendPort));
8494 } 8413 }
8495 static RawSendPort* New(Dart_Port id, Heap::Space space = Heap::kNew); 8414 static RawSendPort* New(Dart_Port id, Heap::Space space = Heap::kNew);
8496 static RawSendPort* New(Dart_Port id, 8415 static RawSendPort* New(Dart_Port id,
8497 Dart_Port origin_id, 8416 Dart_Port origin_id,
8498 Heap::Space space = Heap::kNew); 8417 Heap::Space space = Heap::kNew);
8499 8418
8500 private: 8419 private:
8501 FINAL_HEAP_OBJECT_IMPLEMENTATION(SendPort, Instance); 8420 FINAL_HEAP_OBJECT_IMPLEMENTATION(SendPort, Instance);
8502 friend class Class; 8421 friend class Class;
8503 }; 8422 };
8504 8423
8505
8506 // Internal stacktrace object used in exceptions for printing stack traces. 8424 // Internal stacktrace object used in exceptions for printing stack traces.
8507 class StackTrace : public Instance { 8425 class StackTrace : public Instance {
8508 public: 8426 public:
8509 static const int kPreallocatedStackdepth = 30; 8427 static const int kPreallocatedStackdepth = 30;
8510 8428
8511 intptr_t Length() const; 8429 intptr_t Length() const;
8512 8430
8513 RawStackTrace* async_link() const { return raw_ptr()->async_link_; } 8431 RawStackTrace* async_link() const { return raw_ptr()->async_link_; }
8514 void set_async_link(const StackTrace& async_link) const; 8432 void set_async_link(const StackTrace& async_link) const;
8515 void set_expand_inlined(bool value) const; 8433 void set_expand_inlined(bool value) const;
(...skipping 24 matching lines...) Expand all
8540 8458
8541 void set_code_array(const Array& code_array) const; 8459 void set_code_array(const Array& code_array) const;
8542 void set_pc_offset_array(const Array& pc_offset_array) const; 8460 void set_pc_offset_array(const Array& pc_offset_array) const;
8543 bool expand_inlined() const; 8461 bool expand_inlined() const;
8544 8462
8545 FINAL_HEAP_OBJECT_IMPLEMENTATION(StackTrace, Instance); 8463 FINAL_HEAP_OBJECT_IMPLEMENTATION(StackTrace, Instance);
8546 friend class Class; 8464 friend class Class;
8547 friend class Debugger; 8465 friend class Debugger;
8548 }; 8466 };
8549 8467
8550
8551 // Internal JavaScript regular expression object. 8468 // Internal JavaScript regular expression object.
8552 class RegExp : public Instance { 8469 class RegExp : public Instance {
8553 public: 8470 public:
8554 // Meaning of RegExType: 8471 // Meaning of RegExType:
8555 // kUninitialized: the type of th regexp has not been initialized yet. 8472 // kUninitialized: the type of th regexp has not been initialized yet.
8556 // kSimple: A simple pattern to match against, using string indexOf operation. 8473 // kSimple: A simple pattern to match against, using string indexOf operation.
8557 // kComplex: A complex pattern to match. 8474 // kComplex: A complex pattern to match.
8558 enum RegExType { 8475 enum RegExType {
8559 kUnitialized = 0, 8476 kUnitialized = 0,
8560 kSimple = 1, 8477 kSimple = 1,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
8681 FlagsBits::update(value, raw_ptr()->type_flags_)); 8598 FlagsBits::update(value, raw_ptr()->type_flags_));
8682 } 8599 }
8683 8600
8684 RegExType type() const { return TypeBits::decode(raw_ptr()->type_flags_); } 8601 RegExType type() const { return TypeBits::decode(raw_ptr()->type_flags_); }
8685 intptr_t flags() const { return FlagsBits::decode(raw_ptr()->type_flags_); } 8602 intptr_t flags() const { return FlagsBits::decode(raw_ptr()->type_flags_); }
8686 8603
8687 FINAL_HEAP_OBJECT_IMPLEMENTATION(RegExp, Instance); 8604 FINAL_HEAP_OBJECT_IMPLEMENTATION(RegExp, Instance);
8688 friend class Class; 8605 friend class Class;
8689 }; 8606 };
8690 8607
8691
8692 class WeakProperty : public Instance { 8608 class WeakProperty : public Instance {
8693 public: 8609 public:
8694 RawObject* key() const { return raw_ptr()->key_; } 8610 RawObject* key() const { return raw_ptr()->key_; }
8695 8611
8696 void set_key(const Object& key) const { 8612 void set_key(const Object& key) const {
8697 StorePointer(&raw_ptr()->key_, key.raw()); 8613 StorePointer(&raw_ptr()->key_, key.raw());
8698 } 8614 }
8699 8615
8700 RawObject* value() const { return raw_ptr()->value_; } 8616 RawObject* value() const { return raw_ptr()->value_; }
8701 8617
(...skipping 11 matching lines...) Expand all
8713 ASSERT(raw_weak->ptr()->next_ == 0); 8629 ASSERT(raw_weak->ptr()->next_ == 0);
8714 raw_weak->StorePointer(&(raw_weak->ptr()->key_), Object::null()); 8630 raw_weak->StorePointer(&(raw_weak->ptr()->key_), Object::null());
8715 raw_weak->StorePointer(&(raw_weak->ptr()->value_), Object::null()); 8631 raw_weak->StorePointer(&(raw_weak->ptr()->value_), Object::null());
8716 } 8632 }
8717 8633
8718 private: 8634 private:
8719 FINAL_HEAP_OBJECT_IMPLEMENTATION(WeakProperty, Instance); 8635 FINAL_HEAP_OBJECT_IMPLEMENTATION(WeakProperty, Instance);
8720 friend class Class; 8636 friend class Class;
8721 }; 8637 };
8722 8638
8723
8724 class MirrorReference : public Instance { 8639 class MirrorReference : public Instance {
8725 public: 8640 public:
8726 RawObject* referent() const { return raw_ptr()->referent_; } 8641 RawObject* referent() const { return raw_ptr()->referent_; }
8727 8642
8728 void set_referent(const Object& referent) const { 8643 void set_referent(const Object& referent) const {
8729 StorePointer(&raw_ptr()->referent_, referent.raw()); 8644 StorePointer(&raw_ptr()->referent_, referent.raw());
8730 } 8645 }
8731 8646
8732 RawAbstractType* GetAbstractTypeReferent() const; 8647 RawAbstractType* GetAbstractTypeReferent() const;
8733 8648
(...skipping 12 matching lines...) Expand all
8746 8661
8747 static intptr_t InstanceSize() { 8662 static intptr_t InstanceSize() {
8748 return RoundedAllocationSize(sizeof(RawMirrorReference)); 8663 return RoundedAllocationSize(sizeof(RawMirrorReference));
8749 } 8664 }
8750 8665
8751 private: 8666 private:
8752 FINAL_HEAP_OBJECT_IMPLEMENTATION(MirrorReference, Instance); 8667 FINAL_HEAP_OBJECT_IMPLEMENTATION(MirrorReference, Instance);
8753 friend class Class; 8668 friend class Class;
8754 }; 8669 };
8755 8670
8756
8757 class UserTag : public Instance { 8671 class UserTag : public Instance {
8758 public: 8672 public:
8759 uword tag() const { return raw_ptr()->tag(); } 8673 uword tag() const { return raw_ptr()->tag(); }
8760 void set_tag(uword t) const { 8674 void set_tag(uword t) const {
8761 ASSERT(t >= UserTags::kUserTagIdOffset); 8675 ASSERT(t >= UserTags::kUserTagIdOffset);
8762 ASSERT(t < UserTags::kUserTagIdOffset + UserTags::kMaxUserTags); 8676 ASSERT(t < UserTags::kUserTagIdOffset + UserTags::kMaxUserTags);
8763 StoreNonPointer(&raw_ptr()->tag_, t); 8677 StoreNonPointer(&raw_ptr()->tag_, t);
8764 } 8678 }
8765 static intptr_t tag_offset() { return OFFSET_OF(RawUserTag, tag_); } 8679 static intptr_t tag_offset() { return OFFSET_OF(RawUserTag, tag_); }
8766 8680
(...skipping 16 matching lines...) Expand all
8783 static void AddTagToIsolate(Thread* thread, const UserTag& tag); 8697 static void AddTagToIsolate(Thread* thread, const UserTag& tag);
8784 8698
8785 void set_label(const String& tag_label) const { 8699 void set_label(const String& tag_label) const {
8786 StorePointer(&raw_ptr()->label_, tag_label.raw()); 8700 StorePointer(&raw_ptr()->label_, tag_label.raw());
8787 } 8701 }
8788 8702
8789 FINAL_HEAP_OBJECT_IMPLEMENTATION(UserTag, Instance); 8703 FINAL_HEAP_OBJECT_IMPLEMENTATION(UserTag, Instance);
8790 friend class Class; 8704 friend class Class;
8791 }; 8705 };
8792 8706
8793
8794 class ObjectPoolInfo : public ValueObject { 8707 class ObjectPoolInfo : public ValueObject {
8795 public: 8708 public:
8796 explicit ObjectPoolInfo(const ObjectPool& pool) 8709 explicit ObjectPoolInfo(const ObjectPool& pool)
8797 : array_(TypedData::Handle(pool.info_array())) {} 8710 : array_(TypedData::Handle(pool.info_array())) {}
8798 8711
8799 explicit ObjectPoolInfo(const TypedData& info_array) : array_(info_array) {} 8712 explicit ObjectPoolInfo(const TypedData& info_array) : array_(info_array) {}
8800 8713
8801 ObjectPool::EntryType InfoAt(intptr_t i) { 8714 ObjectPool::EntryType InfoAt(intptr_t i) {
8802 return static_cast<ObjectPool::EntryType>(array_.GetInt8(i)); 8715 return static_cast<ObjectPool::EntryType>(array_.GetInt8(i));
8803 } 8716 }
8804 8717
8805 void SetInfoAt(intptr_t i, ObjectPool::EntryType info) { 8718 void SetInfoAt(intptr_t i, ObjectPool::EntryType info) {
8806 array_.SetInt8(i, static_cast<int8_t>(info)); 8719 array_.SetInt8(i, static_cast<int8_t>(info));
8807 } 8720 }
8808 8721
8809 private: 8722 private:
8810 const TypedData& array_; 8723 const TypedData& array_;
8811 }; 8724 };
8812 8725
8813
8814 // Breaking cycles and loops. 8726 // Breaking cycles and loops.
8815 RawClass* Object::clazz() const { 8727 RawClass* Object::clazz() const {
8816 uword raw_value = reinterpret_cast<uword>(raw_); 8728 uword raw_value = reinterpret_cast<uword>(raw_);
8817 if ((raw_value & kSmiTagMask) == kSmiTag) { 8729 if ((raw_value & kSmiTagMask) == kSmiTag) {
8818 return Smi::Class(); 8730 return Smi::Class();
8819 } 8731 }
8820 return Isolate::Current()->class_table()->At(raw()->GetClassId()); 8732 return Isolate::Current()->class_table()->At(raw()->GetClassId());
8821 } 8733 }
8822 8734
8823
8824 DART_FORCE_INLINE void Object::SetRaw(RawObject* value) { 8735 DART_FORCE_INLINE void Object::SetRaw(RawObject* value) {
8825 NoSafepointScope no_safepoint_scope; 8736 NoSafepointScope no_safepoint_scope;
8826 raw_ = value; 8737 raw_ = value;
8827 if ((reinterpret_cast<uword>(value) & kSmiTagMask) == kSmiTag) { 8738 if ((reinterpret_cast<uword>(value) & kSmiTagMask) == kSmiTag) {
8828 set_vtable(Smi::handle_vtable_); 8739 set_vtable(Smi::handle_vtable_);
8829 return; 8740 return;
8830 } 8741 }
8831 intptr_t cid = value->GetClassId(); 8742 intptr_t cid = value->GetClassId();
8832 // Free-list elements cannot be wrapped in a handle. 8743 // Free-list elements cannot be wrapped in a handle.
8833 ASSERT(cid != kFreeListElement); 8744 ASSERT(cid != kFreeListElement);
8834 ASSERT(cid != kForwardingCorpse); 8745 ASSERT(cid != kForwardingCorpse);
8835 if (cid >= kNumPredefinedCids) { 8746 if (cid >= kNumPredefinedCids) {
8836 cid = kInstanceCid; 8747 cid = kInstanceCid;
8837 } 8748 }
8838 set_vtable(builtin_vtables_[cid]); 8749 set_vtable(builtin_vtables_[cid]);
8839 #if defined(DEBUG) 8750 #if defined(DEBUG)
8840 if (FLAG_verify_handles) { 8751 if (FLAG_verify_handles) {
8841 Isolate* isolate = Isolate::Current(); 8752 Isolate* isolate = Isolate::Current();
8842 Heap* isolate_heap = isolate->heap(); 8753 Heap* isolate_heap = isolate->heap();
8843 Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); 8754 Heap* vm_isolate_heap = Dart::vm_isolate()->heap();
8844 ASSERT(isolate_heap->Contains(RawObject::ToAddr(raw_)) || 8755 ASSERT(isolate_heap->Contains(RawObject::ToAddr(raw_)) ||
8845 vm_isolate_heap->Contains(RawObject::ToAddr(raw_))); 8756 vm_isolate_heap->Contains(RawObject::ToAddr(raw_)));
8846 } 8757 }
8847 #endif 8758 #endif
8848 } 8759 }
8849 8760
8850
8851 intptr_t Field::Offset() const { 8761 intptr_t Field::Offset() const {
8852 ASSERT(is_instance()); // Valid only for dart instance fields. 8762 ASSERT(is_instance()); // Valid only for dart instance fields.
8853 intptr_t value = Smi::Value(raw_ptr()->value_.offset_); 8763 intptr_t value = Smi::Value(raw_ptr()->value_.offset_);
8854 return (value * kWordSize); 8764 return (value * kWordSize);
8855 } 8765 }
8856 8766
8857
8858 void Field::SetOffset(intptr_t offset_in_bytes) const { 8767 void Field::SetOffset(intptr_t offset_in_bytes) const {
8859 ASSERT(is_instance()); // Valid only for dart instance fields. 8768 ASSERT(is_instance()); // Valid only for dart instance fields.
8860 ASSERT(kWordSize != 0); 8769 ASSERT(kWordSize != 0);
8861 StorePointer(&raw_ptr()->value_.offset_, 8770 StorePointer(&raw_ptr()->value_.offset_,
8862 Smi::New(offset_in_bytes / kWordSize)); 8771 Smi::New(offset_in_bytes / kWordSize));
8863 } 8772 }
8864 8773
8865
8866 RawInstance* Field::StaticValue() const { 8774 RawInstance* Field::StaticValue() const {
8867 ASSERT(is_static()); // Valid only for static dart fields. 8775 ASSERT(is_static()); // Valid only for static dart fields.
8868 return raw_ptr()->value_.static_value_; 8776 return raw_ptr()->value_.static_value_;
8869 } 8777 }
8870 8778
8871
8872 void Field::SetStaticValue(const Instance& value, 8779 void Field::SetStaticValue(const Instance& value,
8873 bool save_initial_value) const { 8780 bool save_initial_value) const {
8874 ASSERT(Thread::Current()->IsMutatorThread()); 8781 ASSERT(Thread::Current()->IsMutatorThread());
8875 ASSERT(is_static()); // Valid only for static dart fields. 8782 ASSERT(is_static()); // Valid only for static dart fields.
8876 StorePointer(&raw_ptr()->value_.static_value_, value.raw()); 8783 StorePointer(&raw_ptr()->value_.static_value_, value.raw());
8877 if (save_initial_value) { 8784 if (save_initial_value) {
8878 ASSERT(!HasPrecompiledInitializer()); 8785 ASSERT(!HasPrecompiledInitializer());
8879 StorePointer(&raw_ptr()->initializer_.saved_value_, value.raw()); 8786 StorePointer(&raw_ptr()->initializer_.saved_value_, value.raw());
8880 } 8787 }
8881 } 8788 }
8882 8789
8883
8884 void Context::SetAt(intptr_t index, const Object& value) const { 8790 void Context::SetAt(intptr_t index, const Object& value) const {
8885 StorePointer(ObjectAddr(index), value.raw()); 8791 StorePointer(ObjectAddr(index), value.raw());
8886 } 8792 }
8887 8793
8888
8889 intptr_t Instance::GetNativeField(int index) const { 8794 intptr_t Instance::GetNativeField(int index) const {
8890 ASSERT(IsValidNativeIndex(index)); 8795 ASSERT(IsValidNativeIndex(index));
8891 NoSafepointScope no_safepoint; 8796 NoSafepointScope no_safepoint;
8892 RawTypedData* native_fields = 8797 RawTypedData* native_fields =
8893 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); 8798 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr());
8894 if (native_fields == TypedData::null()) { 8799 if (native_fields == TypedData::null()) {
8895 return 0; 8800 return 0;
8896 } 8801 }
8897 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data())[index]; 8802 return reinterpret_cast<intptr_t*>(native_fields->ptr()->data())[index];
8898 } 8803 }
8899 8804
8900
8901 void Instance::GetNativeFields(uint16_t num_fields, 8805 void Instance::GetNativeFields(uint16_t num_fields,
8902 intptr_t* field_values) const { 8806 intptr_t* field_values) const {
8903 NoSafepointScope no_safepoint; 8807 NoSafepointScope no_safepoint;
8904 ASSERT(num_fields == NumNativeFields()); 8808 ASSERT(num_fields == NumNativeFields());
8905 ASSERT(field_values != NULL); 8809 ASSERT(field_values != NULL);
8906 RawTypedData* native_fields = 8810 RawTypedData* native_fields =
8907 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr()); 8811 reinterpret_cast<RawTypedData*>(*NativeFieldsAddr());
8908 if (native_fields == TypedData::null()) { 8812 if (native_fields == TypedData::null()) {
8909 for (intptr_t i = 0; i < num_fields; i++) { 8813 for (intptr_t i = 0; i < num_fields; i++) {
8910 field_values[i] = 0; 8814 field_values[i] = 0;
8911 } 8815 }
8912 } 8816 }
8913 intptr_t* fields = reinterpret_cast<intptr_t*>(native_fields->ptr()->data()); 8817 intptr_t* fields = reinterpret_cast<intptr_t*>(native_fields->ptr()->data());
8914 for (intptr_t i = 0; i < num_fields; i++) { 8818 for (intptr_t i = 0; i < num_fields; i++) {
8915 field_values[i] = fields[i]; 8819 field_values[i] = fields[i];
8916 } 8820 }
8917 } 8821 }
8918 8822
8919
8920 bool String::Equals(const String& str) const { 8823 bool String::Equals(const String& str) const {
8921 if (raw() == str.raw()) { 8824 if (raw() == str.raw()) {
8922 return true; // Both handles point to the same raw instance. 8825 return true; // Both handles point to the same raw instance.
8923 } 8826 }
8924 if (str.IsNull()) { 8827 if (str.IsNull()) {
8925 return false; 8828 return false;
8926 } 8829 }
8927 if (IsCanonical() && str.IsCanonical()) { 8830 if (IsCanonical() && str.IsCanonical()) {
8928 return false; // Two symbols that aren't identical aren't equal. 8831 return false; // Two symbols that aren't identical aren't equal.
8929 } 8832 }
8930 if (HasHash() && str.HasHash() && (Hash() != str.Hash())) { 8833 if (HasHash() && str.HasHash() && (Hash() != str.Hash())) {
8931 return false; // Both sides have hash codes and they do not match. 8834 return false; // Both sides have hash codes and they do not match.
8932 } 8835 }
8933 return Equals(str, 0, str.Length()); 8836 return Equals(str, 0, str.Length());
8934 } 8837 }
8935 8838
8936
8937 intptr_t Library::UrlHash() const { 8839 intptr_t Library::UrlHash() const {
8938 intptr_t result = String::GetCachedHash(url()); 8840 intptr_t result = String::GetCachedHash(url());
8939 ASSERT(result != 0); 8841 ASSERT(result != 0);
8940 return result; 8842 return result;
8941 } 8843 }
8942 8844
8943
8944 void MegamorphicCache::SetEntry(const Array& array, 8845 void MegamorphicCache::SetEntry(const Array& array,
8945 intptr_t index, 8846 intptr_t index,
8946 const Smi& class_id, 8847 const Smi& class_id,
8947 const Function& target) { 8848 const Function& target) {
8948 array.SetAt((index * kEntryLength) + kClassIdIndex, class_id); 8849 array.SetAt((index * kEntryLength) + kClassIdIndex, class_id);
8949 array.SetAt((index * kEntryLength) + kTargetFunctionIndex, target); 8850 array.SetAt((index * kEntryLength) + kTargetFunctionIndex, target);
8950 } 8851 }
8951 8852
8952
8953 RawObject* MegamorphicCache::GetClassId(const Array& array, intptr_t index) { 8853 RawObject* MegamorphicCache::GetClassId(const Array& array, intptr_t index) {
8954 return array.At((index * kEntryLength) + kClassIdIndex); 8854 return array.At((index * kEntryLength) + kClassIdIndex);
8955 } 8855 }
8956 8856
8957
8958 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 8857 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
8959 intptr_t index) { 8858 intptr_t index) {
8960 return array.At((index * kEntryLength) + kTargetFunctionIndex); 8859 return array.At((index * kEntryLength) + kTargetFunctionIndex);
8961 } 8860 }
8962 8861
8963
8964 inline intptr_t Type::Hash() const { 8862 inline intptr_t Type::Hash() const {
8965 intptr_t result = Smi::Value(raw_ptr()->hash_); 8863 intptr_t result = Smi::Value(raw_ptr()->hash_);
8966 if (result != 0) { 8864 if (result != 0) {
8967 return result; 8865 return result;
8968 } 8866 }
8969 return ComputeHash(); 8867 return ComputeHash();
8970 } 8868 }
8971 8869
8972
8973 inline void Type::SetHash(intptr_t value) const { 8870 inline void Type::SetHash(intptr_t value) const {
8974 // This is only safe because we create a new Smi, which does not cause 8871 // This is only safe because we create a new Smi, which does not cause
8975 // heap allocation. 8872 // heap allocation.
8976 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); 8873 StoreSmi(&raw_ptr()->hash_, Smi::New(value));
8977 } 8874 }
8978 8875
8979
8980 inline intptr_t TypeParameter::Hash() const { 8876 inline intptr_t TypeParameter::Hash() const {
8981 ASSERT(IsFinalized()); 8877 ASSERT(IsFinalized());
8982 intptr_t result = Smi::Value(raw_ptr()->hash_); 8878 intptr_t result = Smi::Value(raw_ptr()->hash_);
8983 if (result != 0) { 8879 if (result != 0) {
8984 return result; 8880 return result;
8985 } 8881 }
8986 return ComputeHash(); 8882 return ComputeHash();
8987 } 8883 }
8988 8884
8989
8990 inline void TypeParameter::SetHash(intptr_t value) const { 8885 inline void TypeParameter::SetHash(intptr_t value) const {
8991 // This is only safe because we create a new Smi, which does not cause 8886 // This is only safe because we create a new Smi, which does not cause
8992 // heap allocation. 8887 // heap allocation.
8993 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); 8888 StoreSmi(&raw_ptr()->hash_, Smi::New(value));
8994 } 8889 }
8995 8890
8996
8997 inline intptr_t BoundedType::Hash() const { 8891 inline intptr_t BoundedType::Hash() const {
8998 intptr_t result = Smi::Value(raw_ptr()->hash_); 8892 intptr_t result = Smi::Value(raw_ptr()->hash_);
8999 if (result != 0) { 8893 if (result != 0) {
9000 return result; 8894 return result;
9001 } 8895 }
9002 return ComputeHash(); 8896 return ComputeHash();
9003 } 8897 }
9004 8898
9005
9006 inline void BoundedType::SetHash(intptr_t value) const { 8899 inline void BoundedType::SetHash(intptr_t value) const {
9007 // This is only safe because we create a new Smi, which does not cause 8900 // This is only safe because we create a new Smi, which does not cause
9008 // heap allocation. 8901 // heap allocation.
9009 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); 8902 StoreSmi(&raw_ptr()->hash_, Smi::New(value));
9010 } 8903 }
9011 8904
9012
9013 inline intptr_t TypeArguments::Hash() const { 8905 inline intptr_t TypeArguments::Hash() const {
9014 if (IsNull()) return 0; 8906 if (IsNull()) return 0;
9015 intptr_t result = Smi::Value(raw_ptr()->hash_); 8907 intptr_t result = Smi::Value(raw_ptr()->hash_);
9016 if (result != 0) { 8908 if (result != 0) {
9017 return result; 8909 return result;
9018 } 8910 }
9019 return ComputeHash(); 8911 return ComputeHash();
9020 } 8912 }
9021 8913
9022
9023 inline void TypeArguments::SetHash(intptr_t value) const { 8914 inline void TypeArguments::SetHash(intptr_t value) const {
9024 // This is only safe because we create a new Smi, which does not cause 8915 // This is only safe because we create a new Smi, which does not cause
9025 // heap allocation. 8916 // heap allocation.
9026 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); 8917 StoreSmi(&raw_ptr()->hash_, Smi::New(value));
9027 } 8918 }
9028 8919
9029 } // namespace dart 8920 } // namespace dart
9030 8921
9031 #endif // RUNTIME_VM_OBJECT_H_ 8922 #endif // RUNTIME_VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/native_symbol_win.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698