| 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 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 } | 1663 } |
| 1664 | 1664 |
| 1665 ClassFinalizer::VerifyBootstrapClasses(); | 1665 ClassFinalizer::VerifyBootstrapClasses(); |
| 1666 | 1666 |
| 1667 // Set up the intrinsic state of all functions (core, math and typed data). | 1667 // Set up the intrinsic state of all functions (core, math and typed data). |
| 1668 Intrinsifier::InitializeState(); | 1668 Intrinsifier::InitializeState(); |
| 1669 | 1669 |
| 1670 // Set up recognized state of all functions (core, math and typed data). | 1670 // Set up recognized state of all functions (core, math and typed data). |
| 1671 MethodRecognizer::InitializeState(); | 1671 MethodRecognizer::InitializeState(); |
| 1672 | 1672 |
| 1673 // Adds static const fields (class ids) to the class 'ClassID'); |
| 1674 lib = Library::LookupLibrary(thread, Symbols::DartInternal()); |
| 1675 ASSERT(!lib.IsNull()); |
| 1676 cls = lib.LookupClassAllowPrivate(Symbols::ClassID()); |
| 1677 ASSERT(!cls.IsNull()); |
| 1678 cls.InjectCIDFields(); |
| 1679 |
| 1673 isolate->object_store()->InitKnownObjects(); | 1680 isolate->object_store()->InitKnownObjects(); |
| 1674 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 1681 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| 1675 } else { | 1682 } else { |
| 1676 // Object::Init version when we are running in a version of dart that has a | 1683 // Object::Init version when we are running in a version of dart that has a |
| 1677 // full snapshot linked in and an isolate is initialized using the full | 1684 // full snapshot linked in and an isolate is initialized using the full |
| 1678 // snapshot. | 1685 // snapshot. |
| 1679 ObjectStore* object_store = isolate->object_store(); | 1686 ObjectStore* object_store = isolate->object_store(); |
| 1680 | 1687 |
| 1681 Class& cls = Class::Handle(zone); | 1688 Class& cls = Class::Handle(zone); |
| 1682 | 1689 |
| (...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3150 const intptr_t num_old_fields = arr.Length(); | 3157 const intptr_t num_old_fields = arr.Length(); |
| 3151 const Array& new_arr = Array::Handle( | 3158 const Array& new_arr = Array::Handle( |
| 3152 Array::Grow(arr, num_old_fields + num_new_fields, Heap::kOld)); | 3159 Array::Grow(arr, num_old_fields + num_new_fields, Heap::kOld)); |
| 3153 for (intptr_t i = 0; i < num_new_fields; i++) { | 3160 for (intptr_t i = 0; i < num_new_fields; i++) { |
| 3154 new_arr.SetAt(i + num_old_fields, *new_fields.At(i)); | 3161 new_arr.SetAt(i + num_old_fields, *new_fields.At(i)); |
| 3155 } | 3162 } |
| 3156 SetFields(new_arr); | 3163 SetFields(new_arr); |
| 3157 } | 3164 } |
| 3158 | 3165 |
| 3159 | 3166 |
| 3167 void Class::InjectCIDFields() const { |
| 3168 Thread* thread = Thread::Current(); |
| 3169 Zone* zone = thread->zone(); |
| 3170 Field& field = Field::Handle(zone); |
| 3171 Smi& value = Smi::Handle(zone); |
| 3172 String& field_name = String::Handle(zone); |
| 3173 |
| 3174 #define CLASS_LIST_WITH_NULL(V) \ |
| 3175 V(Null) \ |
| 3176 CLASS_LIST_NO_OBJECT(V) |
| 3177 |
| 3178 #define ADD_SET_FIELD(clazz) \ |
| 3179 field_name = Symbols::New(thread, "cid" #clazz); \ |
| 3180 field = \ |
| 3181 Field::New(field_name, true, false, true, false, *this, \ |
| 3182 Type::Handle(Type::IntType()), TokenPosition::kMinSource); \ |
| 3183 value = Smi::New(k##clazz##Cid); \ |
| 3184 field.SetStaticValue(value, true); \ |
| 3185 AddField(field); |
| 3186 |
| 3187 CLASS_LIST_WITH_NULL(ADD_SET_FIELD) |
| 3188 #undef ADD_SET_FIELD |
| 3189 #undef CLASS_LIST_WITH_NULL |
| 3190 } |
| 3191 |
| 3192 |
| 3160 template <class FakeInstance> | 3193 template <class FakeInstance> |
| 3161 RawClass* Class::NewCommon(intptr_t index) { | 3194 RawClass* Class::NewCommon(intptr_t index) { |
| 3162 ASSERT(Object::class_class() != Class::null()); | 3195 ASSERT(Object::class_class() != Class::null()); |
| 3163 Class& result = Class::Handle(); | 3196 Class& result = Class::Handle(); |
| 3164 { | 3197 { |
| 3165 RawObject* raw = | 3198 RawObject* raw = |
| 3166 Object::Allocate(Class::kClassId, Class::InstanceSize(), Heap::kOld); | 3199 Object::Allocate(Class::kClassId, Class::InstanceSize(), Heap::kOld); |
| 3167 NoSafepointScope no_safepoint; | 3200 NoSafepointScope no_safepoint; |
| 3168 result ^= raw; | 3201 result ^= raw; |
| 3169 } | 3202 } |
| (...skipping 19679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22849 return UserTag::null(); | 22882 return UserTag::null(); |
| 22850 } | 22883 } |
| 22851 | 22884 |
| 22852 | 22885 |
| 22853 const char* UserTag::ToCString() const { | 22886 const char* UserTag::ToCString() const { |
| 22854 const String& tag_label = String::Handle(label()); | 22887 const String& tag_label = String::Handle(label()); |
| 22855 return tag_label.ToCString(); | 22888 return tag_label.ToCString(); |
| 22856 } | 22889 } |
| 22857 | 22890 |
| 22858 } // namespace dart | 22891 } // namespace dart |
| OLD | NEW |