OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 ASSERT(sentinel_ != NULL); | 262 ASSERT(sentinel_ != NULL); |
263 return *sentinel_; | 263 return *sentinel_; |
264 } | 264 } |
265 // Value marking that we are transitioning from sentinel, e.g., computing | 265 // Value marking that we are transitioning from sentinel, e.g., computing |
266 // a field value. Used to detect circular initialization. | 266 // a field value. Used to detect circular initialization. |
267 static const Instance& transition_sentinel() { | 267 static const Instance& transition_sentinel() { |
268 ASSERT(transition_sentinel_ != NULL); | 268 ASSERT(transition_sentinel_ != NULL); |
269 return *transition_sentinel_; | 269 return *transition_sentinel_; |
270 } | 270 } |
271 | 271 |
| 272 static const Bool& bool_true() { |
| 273 ASSERT(bool_true_ != NULL); |
| 274 return *bool_true_; |
| 275 } |
| 276 static const Bool& bool_false() { |
| 277 ASSERT(bool_false_ != NULL); |
| 278 return *bool_false_; |
| 279 } |
| 280 |
272 static RawClass* class_class() { return class_class_; } | 281 static RawClass* class_class() { return class_class_; } |
273 static RawClass* null_class() { return null_class_; } | 282 static RawClass* null_class() { return null_class_; } |
274 static RawClass* dynamic_class() { return dynamic_class_; } | 283 static RawClass* dynamic_class() { return dynamic_class_; } |
275 static RawClass* void_class() { return void_class_; } | 284 static RawClass* void_class() { return void_class_; } |
276 static RawClass* unresolved_class_class() { return unresolved_class_class_; } | 285 static RawClass* unresolved_class_class() { return unresolved_class_class_; } |
277 static RawClass* type_arguments_class() { return type_arguments_class_; } | 286 static RawClass* type_arguments_class() { return type_arguments_class_; } |
278 static RawClass* instantiated_type_arguments_class() { | 287 static RawClass* instantiated_type_arguments_class() { |
279 return instantiated_type_arguments_class_; | 288 return instantiated_type_arguments_class_; |
280 } | 289 } |
281 static RawClass* patch_class_class() { return patch_class_class_; } | 290 static RawClass* patch_class_class() { return patch_class_class_; } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 static RawClass* api_error_class_; // Class of ApiError. | 455 static RawClass* api_error_class_; // Class of ApiError. |
447 static RawClass* language_error_class_; // Class of LanguageError. | 456 static RawClass* language_error_class_; // Class of LanguageError. |
448 static RawClass* unhandled_exception_class_; // Class of UnhandledException. | 457 static RawClass* unhandled_exception_class_; // Class of UnhandledException. |
449 static RawClass* unwind_error_class_; // Class of UnwindError. | 458 static RawClass* unwind_error_class_; // Class of UnwindError. |
450 | 459 |
451 // The static values below are read-only handle pointers for singleton | 460 // The static values below are read-only handle pointers for singleton |
452 // objects that are shared between the different isolates. | 461 // objects that are shared between the different isolates. |
453 static Array* empty_array_; | 462 static Array* empty_array_; |
454 static Instance* sentinel_; | 463 static Instance* sentinel_; |
455 static Instance* transition_sentinel_; | 464 static Instance* transition_sentinel_; |
| 465 static Bool* bool_true_; |
| 466 static Bool* bool_false_; |
456 | 467 |
457 friend void ClassTable::Register(const Class& cls); | 468 friend void ClassTable::Register(const Class& cls); |
458 friend void RawObject::Validate(Isolate* isolate) const; | 469 friend void RawObject::Validate(Isolate* isolate) const; |
459 friend class Closure; | 470 friend class Closure; |
460 friend class SnapshotReader; | 471 friend class SnapshotReader; |
461 friend class OneByteString; | 472 friend class OneByteString; |
462 friend class TwoByteString; | 473 friend class TwoByteString; |
463 friend class ExternalOneByteString; | 474 friend class ExternalOneByteString; |
464 friend class ExternalTwoByteString; | 475 friend class ExternalTwoByteString; |
465 | 476 |
(...skipping 3921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4387 class Bool : public Instance { | 4398 class Bool : public Instance { |
4388 public: | 4399 public: |
4389 bool value() const { | 4400 bool value() const { |
4390 return raw_ptr()->value_; | 4401 return raw_ptr()->value_; |
4391 } | 4402 } |
4392 | 4403 |
4393 static intptr_t InstanceSize() { | 4404 static intptr_t InstanceSize() { |
4394 return RoundedAllocationSize(sizeof(RawBool)); | 4405 return RoundedAllocationSize(sizeof(RawBool)); |
4395 } | 4406 } |
4396 | 4407 |
4397 static RawBool* True(); | 4408 static const Bool& True() { |
4398 static RawBool* False(); | 4409 return Object::bool_true(); |
| 4410 } |
| 4411 |
| 4412 static const Bool& False() { |
| 4413 return Object::bool_false(); |
| 4414 } |
4399 | 4415 |
4400 static RawBool* Get(bool value) { | 4416 static RawBool* Get(bool value) { |
4401 return value ? Bool::True() : Bool::False(); | 4417 return value ? Bool::True().raw() : Bool::False().raw(); |
4402 } | 4418 } |
4403 | 4419 |
4404 private: | 4420 private: |
4405 void set_value(bool value) const { raw_ptr()->value_ = value; } | 4421 void set_value(bool value) const { raw_ptr()->value_ = value; } |
4406 | 4422 |
4407 // New should only be called to initialize the two legal bool values. | 4423 // New should only be called to initialize the two legal bool values. |
4408 static RawBool* New(bool value); | 4424 static RawBool* New(bool value); |
4409 | 4425 |
4410 HEAP_OBJECT_IMPLEMENTATION(Bool, Instance); | 4426 HEAP_OBJECT_IMPLEMENTATION(Bool, Instance); |
4411 friend class Class; | 4427 friend class Class; |
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6212 | 6228 |
6213 | 6229 |
6214 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6230 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
6215 intptr_t index) { | 6231 intptr_t index) { |
6216 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6232 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
6217 } | 6233 } |
6218 | 6234 |
6219 } // namespace dart | 6235 } // namespace dart |
6220 | 6236 |
6221 #endif // VM_OBJECT_H_ | 6237 #endif // VM_OBJECT_H_ |
OLD | NEW |