| 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 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/become.h" | 10 #include "vm/become.h" |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 | 906 |
| 907 cls = dynamic_class_; | 907 cls = dynamic_class_; |
| 908 *dynamic_type_ = Type::NewNonParameterizedType(cls); | 908 *dynamic_type_ = Type::NewNonParameterizedType(cls); |
| 909 | 909 |
| 910 cls = void_class_; | 910 cls = void_class_; |
| 911 *void_type_ = Type::NewNonParameterizedType(cls); | 911 *void_type_ = Type::NewNonParameterizedType(cls); |
| 912 | 912 |
| 913 cls = vector_class_; | 913 cls = vector_class_; |
| 914 *vector_type_ = Type::NewNonParameterizedType(cls); | 914 *vector_type_ = Type::NewNonParameterizedType(cls); |
| 915 | 915 |
| 916 // Since TypeArguments objects are passed as function arguments, make them |
| 917 // behave as Dart instances, although they are just VM objects. |
| 918 // Note that we cannot set the super type to ObjectType, which does not live |
| 919 // in the vm isolate. See special handling in Class::SuperClass(). |
| 920 cls = type_arguments_class_; |
| 921 cls.set_interfaces(Object::empty_array()); |
| 922 cls.SetFields(Object::empty_array()); |
| 923 cls.SetFunctions(Object::empty_array()); |
| 924 |
| 916 // Allocate and initialize singleton true and false boolean objects. | 925 // Allocate and initialize singleton true and false boolean objects. |
| 917 cls = Class::New<Bool>(); | 926 cls = Class::New<Bool>(); |
| 918 isolate->object_store()->set_bool_class(cls); | 927 isolate->object_store()->set_bool_class(cls); |
| 919 *bool_true_ = Bool::New(true); | 928 *bool_true_ = Bool::New(true); |
| 920 *bool_false_ = Bool::New(false); | 929 *bool_false_ = Bool::New(false); |
| 921 | 930 |
| 922 *smi_illegal_cid_ = Smi::New(kIllegalCid); | 931 *smi_illegal_cid_ = Smi::New(kIllegalCid); |
| 923 | 932 |
| 924 String& error_str = String::Handle(); | 933 String& error_str = String::Handle(); |
| 925 error_str = String::New("SnapshotWriter Error", Heap::kOld); | 934 error_str = String::New("SnapshotWriter Error", Heap::kOld); |
| (...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2075 NoSafepointScope no_safepoint; | 2084 NoSafepointScope no_safepoint; |
| 2076 result ^= raw; | 2085 result ^= raw; |
| 2077 } | 2086 } |
| 2078 FakeObject fake; | 2087 FakeObject fake; |
| 2079 result.set_handle_vtable(fake.vtable()); | 2088 result.set_handle_vtable(fake.vtable()); |
| 2080 result.set_instance_size(FakeObject::InstanceSize()); | 2089 result.set_instance_size(FakeObject::InstanceSize()); |
| 2081 result.set_next_field_offset(FakeObject::NextFieldOffset()); | 2090 result.set_next_field_offset(FakeObject::NextFieldOffset()); |
| 2082 COMPILE_ASSERT((FakeObject::kClassId != kInstanceCid)); | 2091 COMPILE_ASSERT((FakeObject::kClassId != kInstanceCid)); |
| 2083 result.set_id(FakeObject::kClassId); | 2092 result.set_id(FakeObject::kClassId); |
| 2084 result.set_state_bits(0); | 2093 result.set_state_bits(0); |
| 2085 if (FakeObject::kClassId < kInstanceCid) { | 2094 if ((FakeObject::kClassId < kInstanceCid) || |
| 2095 (FakeObject::kClassId == kTypeArgumentsCid)) { |
| 2086 // VM internal classes are done. There is no finalization needed or | 2096 // VM internal classes are done. There is no finalization needed or |
| 2087 // possible in this case. | 2097 // possible in this case. |
| 2088 result.set_is_finalized(); | 2098 result.set_is_finalized(); |
| 2089 } else { | 2099 } else { |
| 2090 // VM backed classes are almost ready: run checks and resolve class | 2100 // VM backed classes are almost ready: run checks and resolve class |
| 2091 // references, but do not recompute size. | 2101 // references, but do not recompute size. |
| 2092 result.set_is_prefinalized(); | 2102 result.set_is_prefinalized(); |
| 2093 } | 2103 } |
| 2094 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); | 2104 result.set_type_arguments_field_offset_in_words(kNoTypeArguments); |
| 2095 result.set_num_type_arguments(0); | 2105 result.set_num_type_arguments(0); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2507 } while (true); | 2517 } while (true); |
| 2508 set_num_type_arguments(num_type_args); | 2518 set_num_type_arguments(num_type_args); |
| 2509 return num_type_args; | 2519 return num_type_args; |
| 2510 } | 2520 } |
| 2511 | 2521 |
| 2512 RawClass* Class::SuperClass(bool original_classes) const { | 2522 RawClass* Class::SuperClass(bool original_classes) const { |
| 2513 Thread* thread = Thread::Current(); | 2523 Thread* thread = Thread::Current(); |
| 2514 Zone* zone = thread->zone(); | 2524 Zone* zone = thread->zone(); |
| 2515 Isolate* isolate = thread->isolate(); | 2525 Isolate* isolate = thread->isolate(); |
| 2516 if (super_type() == AbstractType::null()) { | 2526 if (super_type() == AbstractType::null()) { |
| 2527 if (id() == kTypeArgumentsCid) { |
| 2528 // Pretend TypeArguments objects are Dart instances. |
| 2529 return isolate->class_table()->At(kInstanceCid); |
| 2530 } |
| 2517 return Class::null(); | 2531 return Class::null(); |
| 2518 } | 2532 } |
| 2519 const AbstractType& sup_type = AbstractType::Handle(zone, super_type()); | 2533 const AbstractType& sup_type = AbstractType::Handle(zone, super_type()); |
| 2520 const intptr_t type_class_id = sup_type.type_class_id(); | 2534 const intptr_t type_class_id = sup_type.type_class_id(); |
| 2521 if (original_classes) { | 2535 if (original_classes) { |
| 2522 return isolate->GetClassForHeapWalkAt(type_class_id); | 2536 return isolate->GetClassForHeapWalkAt(type_class_id); |
| 2523 } else { | 2537 } else { |
| 2524 return isolate->class_table()->At(type_class_id); | 2538 return isolate->class_table()->At(type_class_id); |
| 2525 } | 2539 } |
| 2526 } | 2540 } |
| (...skipping 19943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22470 } | 22484 } |
| 22471 return UserTag::null(); | 22485 return UserTag::null(); |
| 22472 } | 22486 } |
| 22473 | 22487 |
| 22474 const char* UserTag::ToCString() const { | 22488 const char* UserTag::ToCString() const { |
| 22475 const String& tag_label = String::Handle(label()); | 22489 const String& tag_label = String::Handle(label()); |
| 22476 return tag_label.ToCString(); | 22490 return tag_label.ToCString(); |
| 22477 } | 22491 } |
| 22478 | 22492 |
| 22479 } // namespace dart | 22493 } // namespace dart |
| OLD | NEW |