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

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

Issue 1209033003: Work in progres, please take a look and give early feedback if this is the way we want to structure… (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: indentation Created 5 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
OLDNEW
1 // Copyright (c) 2014, the Fletch project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Fletch 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 #ifndef SRC_VM_OBJECT_H_ 5 #ifndef SRC_VM_OBJECT_H_
6 #define SRC_VM_OBJECT_H_ 6 #define SRC_VM_OBJECT_H_
7 7
8 #include <math.h> 8 #include <math.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 inline bool IsString(); 63 inline bool IsString();
64 inline bool IsFunction(); 64 inline bool IsFunction();
65 inline bool IsLargeInteger(); 65 inline bool IsLargeInteger();
66 inline bool IsByteArray(); 66 inline bool IsByteArray();
67 inline bool IsDouble(); 67 inline bool IsDouble();
68 inline bool IsBoxed(); 68 inline bool IsBoxed();
69 inline bool IsInitializer(); 69 inline bool IsInitializer();
70 inline bool IsStack(); 70 inline bool IsStack();
71 inline bool IsCoroutine(); 71 inline bool IsCoroutine();
72 inline bool IsPort(); 72 inline bool IsPort();
73 inline bool IsForeign(); 73 inline bool IsForeignFunction();
74 inline bool IsForeignMemory();
74 75
75 // - based on marker field in class. 76 // - based on marker field in class.
76 inline bool IsNull(); 77 inline bool IsNull();
77 inline bool IsTrue(); 78 inline bool IsTrue();
78 inline bool IsFalse(); 79 inline bool IsFalse();
79 80
80 // - based on complex heap object field in class. 81 // - based on complex heap object field in class.
81 inline bool IsComplexHeapObject(); 82 inline bool IsComplexHeapObject();
82 83
83 // - based on the flags field in class ComplexHeapObject. 84 // - based on the flags field in class ComplexHeapObject.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // [MSB...11] Contains the non variable size of the instance. 149 // [MSB...11] Contains the non variable size of the instance.
149 // [10] Whether the object is a ComplexHeapObject. 150 // [10] Whether the object is a ComplexHeapObject.
150 // [9-7] The marker of the instance. 151 // [9-7] The marker of the instance.
151 // [6] Tells whether all pointers are in the non variable part. 152 // [6] Tells whether all pointers are in the non variable part.
152 // [5] Tells whether the object has a variable part. 153 // [5] Tells whether the object has a variable part.
153 // [4-1] The type of the instance. 154 // [4-1] The type of the instance.
154 // [LSB] Smi tag. 155 // [LSB] Smi tag.
155 class InstanceFormat { 156 class InstanceFormat {
156 public: 157 public:
157 enum Type { 158 enum Type {
158 CLASS_TYPE = 0, 159 CLASS_TYPE = 0,
159 INSTANCE_TYPE = 1, 160 INSTANCE_TYPE = 1,
160 STRING_TYPE = 2, 161 STRING_TYPE = 2,
161 ARRAY_TYPE = 3, 162 ARRAY_TYPE = 3,
162 FUNCTION_TYPE = 4, 163 FUNCTION_TYPE = 4,
163 LARGE_INTEGER_TYPE = 5, 164 LARGE_INTEGER_TYPE = 5,
164 BYTE_ARRAY_TYPE = 6, 165 BYTE_ARRAY_TYPE = 6,
165 DOUBLE_TYPE = 7, 166 DOUBLE_TYPE = 7,
166 BOXED_TYPE = 8, 167 BOXED_TYPE = 8,
167 STACK_TYPE = 9, 168 STACK_TYPE = 9,
168 INITIALIZER_TYPE = 10, 169 INITIALIZER_TYPE = 10,
169 IMMEDIATE_TYPE = 15 // No instances. 170 IMMEDIATE_TYPE = 15 // No instances.
170 }; 171 };
171 172
172 enum Marker { 173 enum Marker {
173 NULL_MARKER = 0, 174 NULL_MARKER = 0,
174 TRUE_MARKER = 1, 175 TRUE_MARKER = 1,
175 FALSE_MARKER = 2, 176 FALSE_MARKER = 2,
176 COROUTINE_MARKER = 3, 177 COROUTINE_MARKER = 3,
177 PORT_MARKER = 4, 178 PORT_MARKER = 4,
178 FOREIGN_MARKER = 5, 179 FOREIGNFUNCTION_MARKER = 5,
kasperl 2015/07/03 07:49:54 FOREIGN_FUNCTION_MARKER FOREIGN_MEMORY_MARKER
ricow1 2015/07/03 08:57:25 Done.
179 NO_MARKER = 7 // Else marker. 180 FOREIGNMEMORY_MARKER = 6,
181 NO_MARKER = 7 // Else marker.
180 }; 182 };
181 183
182 // Factory functions. 184 // Factory functions.
183 inline static const InstanceFormat instance_format(int number_of_fields, 185 inline static const InstanceFormat instance_format(int number_of_fields,
184 Marker marker = NO_MARKER); 186 Marker marker = NO_MARKER);
185 inline static const InstanceFormat class_format(); 187 inline static const InstanceFormat class_format();
186 inline static const InstanceFormat num_format(); 188 inline static const InstanceFormat num_format();
187 inline static const InstanceFormat smi_format(); 189 inline static const InstanceFormat smi_format();
188 inline static const InstanceFormat string_format(); 190 inline static const InstanceFormat string_format();
189 inline static const InstanceFormat array_format(); 191 inline static const InstanceFormat array_format();
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 HeapObject* h = HeapObject::cast(this); 1182 HeapObject* h = HeapObject::cast(this);
1181 return h->format().marker() == InstanceFormat::COROUTINE_MARKER; 1183 return h->format().marker() == InstanceFormat::COROUTINE_MARKER;
1182 } 1184 }
1183 1185
1184 bool Object::IsPort() { 1186 bool Object::IsPort() {
1185 if (IsSmi()) return false; 1187 if (IsSmi()) return false;
1186 HeapObject* h = HeapObject::cast(this); 1188 HeapObject* h = HeapObject::cast(this);
1187 return h->format().marker() == InstanceFormat::PORT_MARKER; 1189 return h->format().marker() == InstanceFormat::PORT_MARKER;
1188 } 1190 }
1189 1191
1190 bool Object::IsForeign() { 1192 bool Object::IsForeignFunction() {
1191 if (IsSmi()) return false; 1193 if (IsSmi()) return false;
1192 HeapObject* h = HeapObject::cast(this); 1194 HeapObject* h = HeapObject::cast(this);
1193 return h->format().marker() == InstanceFormat::FOREIGN_MARKER; 1195 return h->format().marker() == InstanceFormat::FOREIGNFUNCTION_MARKER;
1194 } 1196 }
1195 1197
1198 bool Object::IsForeignMemory() {
1199 if (IsSmi()) return false;
1200 HeapObject* h = HeapObject::cast(this);
1201 return h->format().marker() == InstanceFormat::FOREIGNMEMORY_MARKER;
1202 }
1203
kasperl 2015/07/03 07:49:54 Only one newline between functions.
ricow1 2015/07/03 08:57:25 Done.
1204
1196 bool Object::IsNull() { 1205 bool Object::IsNull() {
1197 if (IsSmi()) return false; 1206 if (IsSmi()) return false;
1198 HeapObject* h = HeapObject::cast(this); 1207 HeapObject* h = HeapObject::cast(this);
1199 return h->format().marker() == InstanceFormat::NULL_MARKER; 1208 return h->format().marker() == InstanceFormat::NULL_MARKER;
1200 } 1209 }
1201 1210
1202 bool Object::IsTrue() { 1211 bool Object::IsTrue() {
1203 if (IsSmi()) return false; 1212 if (IsSmi()) return false;
1204 HeapObject* h = HeapObject::cast(this); 1213 HeapObject* h = HeapObject::cast(this);
1205 return h->format().marker() == InstanceFormat::TRUE_MARKER; 1214 return h->format().marker() == InstanceFormat::TRUE_MARKER;
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 } 1829 }
1821 1830
1822 inline void Coroutine::set_caller(Coroutine* value) { 1831 inline void Coroutine::set_caller(Coroutine* value) {
1823 at_put(kCallerOffset, value); 1832 at_put(kCallerOffset, value);
1824 } 1833 }
1825 1834
1826 } // namespace fletch 1835 } // namespace fletch
1827 1836
1828 1837
1829 #endif // SRC_VM_OBJECT_H_ 1838 #endif // SRC_VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698