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 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 const Library& lib) { | 1112 const Library& lib) { |
1113 ASSERT(public_class_name.Length() > 0); | 1113 ASSERT(public_class_name.Length() > 0); |
1114 ASSERT(public_class_name.CharAt(0) == '_'); | 1114 ASSERT(public_class_name.CharAt(0) == '_'); |
1115 String& str = String::Handle(); | 1115 String& str = String::Handle(); |
1116 str = lib.PrivateName(public_class_name); | 1116 str = lib.PrivateName(public_class_name); |
1117 cls.set_name(str); | 1117 cls.set_name(str); |
1118 lib.AddClass(cls); | 1118 lib.AddClass(cls); |
1119 } | 1119 } |
1120 | 1120 |
1121 | 1121 |
1122 RawError* Object::Init(Isolate* isolate) { | 1122 // Initialize a new isolate from source or from a snapshot. |
| 1123 // |
| 1124 // There are three possibilities: |
| 1125 // 1. Running a Kernel binary. This function will bootstrap from the KERNEL |
| 1126 // file. |
| 1127 // 2. There is no snapshot. This function will bootstrap from source. |
| 1128 // 3. There is a snapshot. The caller should initialize from the snapshot. |
| 1129 // |
| 1130 // A non-NULL kernel argument indicates (1). A NULL kernel indicates (2) or |
| 1131 // (3), depending on whether the VM is compiled with DART_NO_SNAPSHOT defined or |
| 1132 // not. |
| 1133 RawError* Object::Init(Isolate* isolate, |
| 1134 const uint8_t* kernel_buffer, |
| 1135 intptr_t kernel_buffer_length) { |
1123 Thread* thread = Thread::Current(); | 1136 Thread* thread = Thread::Current(); |
1124 Zone* zone = thread->zone(); | 1137 Zone* zone = thread->zone(); |
1125 ASSERT(isolate == thread->isolate()); | 1138 ASSERT(isolate == thread->isolate()); |
| 1139 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 1140 const bool is_kernel = (kernel_buffer != NULL); |
| 1141 #endif |
1126 NOT_IN_PRODUCT(TimelineDurationScope tds(thread, Timeline::GetIsolateStream(), | 1142 NOT_IN_PRODUCT(TimelineDurationScope tds(thread, Timeline::GetIsolateStream(), |
1127 "Object::Init")); | 1143 "Object::Init");) |
1128 | 1144 |
1129 #if defined(DART_NO_SNAPSHOT) | 1145 #if defined(DART_NO_SNAPSHOT) |
1130 // Object::Init version when we are running in a version of dart that does | 1146 bool bootstrapping = true; |
1131 // not have a full snapshot linked in. | 1147 #elif defined(DART_PRECOMPILED_RUNTIME) |
1132 ObjectStore* object_store = isolate->object_store(); | 1148 bool bootstrapping = false; |
1133 | 1149 #else |
1134 Class& cls = Class::Handle(zone); | 1150 bool bootstrapping = is_kernel; |
1135 Type& type = Type::Handle(zone); | 1151 #endif |
1136 Array& array = Array::Handle(zone); | 1152 |
1137 Library& lib = Library::Handle(zone); | 1153 if (bootstrapping) { |
1138 | 1154 #if !defined(DART_PRECOMPILED_RUNTIME) |
1139 // All RawArray fields will be initialized to an empty array, therefore | 1155 // Object::Init version when we are bootstrapping from source or from a |
1140 // initialize array class first. | 1156 // Kernel binary. |
1141 cls = Class::New<Array>(); | 1157 ObjectStore* object_store = isolate->object_store(); |
1142 object_store->set_array_class(cls); | 1158 |
1143 | 1159 Class& cls = Class::Handle(zone); |
1144 // VM classes that are parameterized (Array, ImmutableArray, | 1160 Type& type = Type::Handle(zone); |
1145 // GrowableObjectArray, and LinkedHashMap) are also pre-finalized, | 1161 Array& array = Array::Handle(zone); |
1146 // so CalculateFieldOffsets() is not called, so we need to set the | 1162 Library& lib = Library::Handle(zone); |
1147 // offset of their type_arguments_ field, which is explicitly | 1163 |
1148 // declared in their respective Raw* classes. | 1164 // All RawArray fields will be initialized to an empty array, therefore |
1149 cls.set_type_arguments_field_offset(Array::type_arguments_offset()); | 1165 // initialize array class first. |
1150 cls.set_num_type_arguments(1); | 1166 cls = Class::New<Array>(); |
1151 | 1167 object_store->set_array_class(cls); |
1152 // Set up the growable object array class (Has to be done after the array | 1168 |
1153 // class is setup as one of its field is an array object). | 1169 // VM classes that are parameterized (Array, ImmutableArray, |
1154 cls = Class::New<GrowableObjectArray>(); | 1170 // GrowableObjectArray, and LinkedHashMap) are also pre-finalized, so |
1155 object_store->set_growable_object_array_class(cls); | 1171 // CalculateFieldOffsets() is not called, so we need to set the offset of |
1156 cls.set_type_arguments_field_offset( | 1172 // their type_arguments_ field, which is explicitly declared in their |
1157 GrowableObjectArray::type_arguments_offset()); | 1173 // respective Raw* classes. |
1158 cls.set_num_type_arguments(1); | 1174 cls.set_type_arguments_field_offset(Array::type_arguments_offset()); |
1159 | 1175 cls.set_num_type_arguments(1); |
1160 // Initialize hash set for canonical_type_. | 1176 |
1161 const intptr_t kInitialCanonicalTypeSize = 16; | 1177 // Set up the growable object array class (Has to be done after the array |
1162 array = | 1178 // class is setup as one of its field is an array object). |
1163 HashTables::New<CanonicalTypeSet>(kInitialCanonicalTypeSize, Heap::kOld); | 1179 cls = Class::New<GrowableObjectArray>(); |
1164 object_store->set_canonical_types(array); | 1180 object_store->set_growable_object_array_class(cls); |
1165 | 1181 cls.set_type_arguments_field_offset( |
1166 // Initialize hash set for canonical_type_arguments_. | 1182 GrowableObjectArray::type_arguments_offset()); |
1167 const intptr_t kInitialCanonicalTypeArgumentsSize = 4; | 1183 cls.set_num_type_arguments(1); |
1168 array = HashTables::New<CanonicalTypeArgumentsSet>( | 1184 |
1169 kInitialCanonicalTypeArgumentsSize, Heap::kOld); | 1185 // Initialize hash set for canonical_type_. |
1170 object_store->set_canonical_type_arguments(array); | 1186 const intptr_t kInitialCanonicalTypeSize = 16; |
1171 | 1187 array = HashTables::New<CanonicalTypeSet>(kInitialCanonicalTypeSize, |
1172 // Setup type class early in the process. | 1188 Heap::kOld); |
1173 const Class& type_cls = Class::Handle(zone, Class::New<Type>()); | 1189 object_store->set_canonical_types(array); |
1174 const Class& type_ref_cls = Class::Handle(zone, Class::New<TypeRef>()); | 1190 |
1175 const Class& type_parameter_cls = | 1191 // Initialize hash set for canonical_type_arguments_. |
1176 Class::Handle(zone, Class::New<TypeParameter>()); | 1192 const intptr_t kInitialCanonicalTypeArgumentsSize = 4; |
1177 const Class& bounded_type_cls = | 1193 array = HashTables::New<CanonicalTypeArgumentsSet>( |
1178 Class::Handle(zone, Class::New<BoundedType>()); | 1194 kInitialCanonicalTypeArgumentsSize, Heap::kOld); |
1179 const Class& mixin_app_type_cls = | 1195 object_store->set_canonical_type_arguments(array); |
1180 Class::Handle(zone, Class::New<MixinAppType>()); | 1196 |
1181 const Class& library_prefix_cls = | 1197 // Setup type class early in the process. |
1182 Class::Handle(zone, Class::New<LibraryPrefix>()); | 1198 const Class& type_cls = Class::Handle(zone, Class::New<Type>()); |
1183 | 1199 const Class& type_ref_cls = Class::Handle(zone, Class::New<TypeRef>()); |
1184 // Pre-allocate the OneByteString class needed by the symbol table. | 1200 const Class& type_parameter_cls = |
1185 cls = Class::NewStringClass(kOneByteStringCid); | 1201 Class::Handle(zone, Class::New<TypeParameter>()); |
1186 object_store->set_one_byte_string_class(cls); | 1202 const Class& bounded_type_cls = |
1187 | 1203 Class::Handle(zone, Class::New<BoundedType>()); |
1188 // Pre-allocate the TwoByteString class needed by the symbol table. | 1204 const Class& mixin_app_type_cls = |
1189 cls = Class::NewStringClass(kTwoByteStringCid); | 1205 Class::Handle(zone, Class::New<MixinAppType>()); |
1190 object_store->set_two_byte_string_class(cls); | 1206 const Class& library_prefix_cls = |
1191 | 1207 Class::Handle(zone, Class::New<LibraryPrefix>()); |
1192 // Setup the symbol table for the symbols created in the isolate. | 1208 |
1193 Symbols::SetupSymbolTable(isolate); | 1209 // Pre-allocate the OneByteString class needed by the symbol table. |
1194 | 1210 cls = Class::NewStringClass(kOneByteStringCid); |
1195 // Set up the libraries array before initializing the core library. | 1211 object_store->set_one_byte_string_class(cls); |
1196 const GrowableObjectArray& libraries = | 1212 |
1197 GrowableObjectArray::Handle(zone, GrowableObjectArray::New(Heap::kOld)); | 1213 // Pre-allocate the TwoByteString class needed by the symbol table. |
1198 object_store->set_libraries(libraries); | 1214 cls = Class::NewStringClass(kTwoByteStringCid); |
1199 | 1215 object_store->set_two_byte_string_class(cls); |
1200 // Pre-register the core library. | 1216 |
1201 Library::InitCoreLibrary(isolate); | 1217 // Setup the symbol table for the symbols created in the isolate. |
1202 | 1218 Symbols::SetupSymbolTable(isolate); |
1203 // Basic infrastructure has been setup, initialize the class dictionary. | 1219 |
1204 const Library& core_lib = Library::Handle(zone, Library::CoreLibrary()); | 1220 // Set up the libraries array before initializing the core library. |
1205 ASSERT(!core_lib.IsNull()); | 1221 const GrowableObjectArray& libraries = |
1206 | 1222 GrowableObjectArray::Handle(zone, GrowableObjectArray::New(Heap::kOld)); |
1207 const GrowableObjectArray& pending_classes = | 1223 object_store->set_libraries(libraries); |
1208 GrowableObjectArray::Handle(zone, GrowableObjectArray::New()); | 1224 |
1209 object_store->set_pending_classes(pending_classes); | 1225 // Pre-register the core library. |
1210 | 1226 Library::InitCoreLibrary(isolate); |
1211 Context& context = Context::Handle(zone, Context::New(0, Heap::kOld)); | 1227 |
1212 object_store->set_empty_context(context); | 1228 // Basic infrastructure has been setup, initialize the class dictionary. |
1213 | 1229 const Library& core_lib = Library::Handle(zone, Library::CoreLibrary()); |
1214 // Now that the symbol table is initialized and that the core dictionary as | 1230 ASSERT(!core_lib.IsNull()); |
1215 // well as the core implementation dictionary have been setup, preallocate | 1231 |
1216 // remaining classes and register them by name in the dictionaries. | 1232 const GrowableObjectArray& pending_classes = |
1217 String& name = String::Handle(zone); | 1233 GrowableObjectArray::Handle(zone, GrowableObjectArray::New()); |
1218 cls = object_store->array_class(); // Was allocated above. | 1234 object_store->set_pending_classes(pending_classes); |
1219 RegisterPrivateClass(cls, Symbols::_List(), core_lib); | 1235 |
1220 pending_classes.Add(cls); | 1236 Context& context = Context::Handle(zone, Context::New(0, Heap::kOld)); |
1221 // We cannot use NewNonParameterizedType(cls), because Array is parameterized. | 1237 object_store->set_empty_context(context); |
1222 // Warning: class _List has not been patched yet. Its declared number of type | 1238 |
1223 // parameters is still 0. It will become 1 after patching. The array type | 1239 // Now that the symbol table is initialized and that the core dictionary as |
1224 // allocated below represents the raw type _List and not _List<E> as we | 1240 // well as the core implementation dictionary have been setup, preallocate |
1225 // could expect. Use with caution. | 1241 // remaining classes and register them by name in the dictionaries. |
1226 type ^= Type::New(Object::Handle(zone, cls.raw()), | 1242 String& name = String::Handle(zone); |
1227 TypeArguments::Handle(zone), TokenPosition::kNoSource); | 1243 cls = object_store->array_class(); // Was allocated above. |
1228 type.SetIsFinalized(); | 1244 RegisterPrivateClass(cls, Symbols::_List(), core_lib); |
1229 type ^= type.Canonicalize(); | 1245 pending_classes.Add(cls); |
1230 object_store->set_array_type(type); | 1246 // We cannot use NewNonParameterizedType(cls), because Array is |
1231 | 1247 // parameterized. Warning: class _List has not been patched yet. Its |
1232 cls = object_store->growable_object_array_class(); // Was allocated above. | 1248 // declared number of type parameters is still 0. It will become 1 after |
1233 RegisterPrivateClass(cls, Symbols::_GrowableList(), core_lib); | 1249 // patching. The array type allocated below represents the raw type _List |
1234 pending_classes.Add(cls); | 1250 // and not _List<E> as we could expect. Use with caution. |
1235 | 1251 type ^= Type::New(Object::Handle(zone, cls.raw()), |
1236 cls = Class::New<Array>(kImmutableArrayCid); | 1252 TypeArguments::Handle(zone), TokenPosition::kNoSource); |
1237 object_store->set_immutable_array_class(cls); | 1253 type.SetIsFinalized(); |
1238 cls.set_type_arguments_field_offset(Array::type_arguments_offset()); | 1254 type ^= type.Canonicalize(); |
1239 cls.set_num_type_arguments(1); | 1255 object_store->set_array_type(type); |
1240 ASSERT(object_store->immutable_array_class() != object_store->array_class()); | 1256 |
1241 cls.set_is_prefinalized(); | 1257 cls = object_store->growable_object_array_class(); // Was allocated above. |
1242 RegisterPrivateClass(cls, Symbols::_ImmutableList(), core_lib); | 1258 RegisterPrivateClass(cls, Symbols::_GrowableList(), core_lib); |
1243 pending_classes.Add(cls); | 1259 pending_classes.Add(cls); |
1244 | 1260 |
1245 cls = object_store->one_byte_string_class(); // Was allocated above. | 1261 cls = Class::New<Array>(kImmutableArrayCid); |
1246 RegisterPrivateClass(cls, Symbols::OneByteString(), core_lib); | 1262 object_store->set_immutable_array_class(cls); |
1247 pending_classes.Add(cls); | 1263 cls.set_type_arguments_field_offset(Array::type_arguments_offset()); |
1248 | 1264 cls.set_num_type_arguments(1); |
1249 cls = object_store->two_byte_string_class(); // Was allocated above. | 1265 ASSERT(object_store->immutable_array_class() != |
1250 RegisterPrivateClass(cls, Symbols::TwoByteString(), core_lib); | 1266 object_store->array_class()); |
1251 pending_classes.Add(cls); | 1267 cls.set_is_prefinalized(); |
1252 | 1268 RegisterPrivateClass(cls, Symbols::_ImmutableList(), core_lib); |
1253 cls = Class::NewStringClass(kExternalOneByteStringCid); | 1269 pending_classes.Add(cls); |
1254 object_store->set_external_one_byte_string_class(cls); | 1270 |
1255 RegisterPrivateClass(cls, Symbols::ExternalOneByteString(), core_lib); | 1271 cls = object_store->one_byte_string_class(); // Was allocated above. |
1256 pending_classes.Add(cls); | 1272 RegisterPrivateClass(cls, Symbols::OneByteString(), core_lib); |
1257 | 1273 pending_classes.Add(cls); |
1258 cls = Class::NewStringClass(kExternalTwoByteStringCid); | 1274 |
1259 object_store->set_external_two_byte_string_class(cls); | 1275 cls = object_store->two_byte_string_class(); // Was allocated above. |
1260 RegisterPrivateClass(cls, Symbols::ExternalTwoByteString(), core_lib); | 1276 RegisterPrivateClass(cls, Symbols::TwoByteString(), core_lib); |
1261 pending_classes.Add(cls); | 1277 pending_classes.Add(cls); |
1262 | 1278 |
1263 // Pre-register the isolate library so the native class implementations | 1279 cls = Class::NewStringClass(kExternalOneByteStringCid); |
1264 // can be hooked up before compiling it. | 1280 object_store->set_external_one_byte_string_class(cls); |
1265 Library& isolate_lib = Library::Handle( | 1281 RegisterPrivateClass(cls, Symbols::ExternalOneByteString(), core_lib); |
1266 zone, Library::LookupLibrary(thread, Symbols::DartIsolate())); | 1282 pending_classes.Add(cls); |
1267 if (isolate_lib.IsNull()) { | 1283 |
1268 isolate_lib = Library::NewLibraryHelper(Symbols::DartIsolate(), true); | 1284 cls = Class::NewStringClass(kExternalTwoByteStringCid); |
1269 isolate_lib.SetLoadRequested(); | 1285 object_store->set_external_two_byte_string_class(cls); |
1270 isolate_lib.Register(thread); | 1286 RegisterPrivateClass(cls, Symbols::ExternalTwoByteString(), core_lib); |
| 1287 pending_classes.Add(cls); |
| 1288 |
| 1289 // Pre-register the isolate library so the native class implementations can |
| 1290 // be hooked up before compiling it. |
| 1291 Library& isolate_lib = Library::Handle( |
| 1292 zone, Library::LookupLibrary(thread, Symbols::DartIsolate())); |
| 1293 if (isolate_lib.IsNull()) { |
| 1294 isolate_lib = Library::NewLibraryHelper(Symbols::DartIsolate(), true); |
| 1295 isolate_lib.SetLoadRequested(); |
| 1296 isolate_lib.Register(thread); |
| 1297 } |
1271 object_store->set_bootstrap_library(ObjectStore::kIsolate, isolate_lib); | 1298 object_store->set_bootstrap_library(ObjectStore::kIsolate, isolate_lib); |
1272 } | 1299 ASSERT(!isolate_lib.IsNull()); |
1273 ASSERT(!isolate_lib.IsNull()); | 1300 ASSERT(isolate_lib.raw() == Library::IsolateLibrary()); |
1274 ASSERT(isolate_lib.raw() == Library::IsolateLibrary()); | 1301 |
1275 | 1302 cls = Class::New<Capability>(); |
1276 cls = Class::New<Capability>(); | 1303 RegisterPrivateClass(cls, Symbols::_CapabilityImpl(), isolate_lib); |
1277 RegisterPrivateClass(cls, Symbols::_CapabilityImpl(), isolate_lib); | 1304 pending_classes.Add(cls); |
1278 pending_classes.Add(cls); | 1305 |
1279 | 1306 cls = Class::New<ReceivePort>(); |
1280 cls = Class::New<ReceivePort>(); | 1307 RegisterPrivateClass(cls, Symbols::_RawReceivePortImpl(), isolate_lib); |
1281 RegisterPrivateClass(cls, Symbols::_RawReceivePortImpl(), isolate_lib); | 1308 pending_classes.Add(cls); |
1282 pending_classes.Add(cls); | 1309 |
1283 | 1310 cls = Class::New<SendPort>(); |
1284 cls = Class::New<SendPort>(); | 1311 RegisterPrivateClass(cls, Symbols::_SendPortImpl(), isolate_lib); |
1285 RegisterPrivateClass(cls, Symbols::_SendPortImpl(), isolate_lib); | 1312 pending_classes.Add(cls); |
1286 pending_classes.Add(cls); | 1313 |
1287 | 1314 const Class& stacktrace_cls = Class::Handle(zone, Class::New<Stacktrace>()); |
1288 const Class& stacktrace_cls = Class::Handle(zone, Class::New<Stacktrace>()); | 1315 RegisterPrivateClass(stacktrace_cls, Symbols::_StackTrace(), core_lib); |
1289 RegisterPrivateClass(stacktrace_cls, Symbols::_StackTrace(), core_lib); | 1316 pending_classes.Add(stacktrace_cls); |
1290 pending_classes.Add(stacktrace_cls); | 1317 // Super type set below, after Object is allocated. |
1291 // Super type set below, after Object is allocated. | 1318 |
1292 | 1319 cls = Class::New<RegExp>(); |
1293 cls = Class::New<RegExp>(); | 1320 RegisterPrivateClass(cls, Symbols::_RegExp(), core_lib); |
1294 RegisterPrivateClass(cls, Symbols::_RegExp(), core_lib); | 1321 pending_classes.Add(cls); |
1295 pending_classes.Add(cls); | 1322 |
1296 | 1323 // Initialize the base interfaces used by the core VM classes. |
1297 // Initialize the base interfaces used by the core VM classes. | 1324 |
1298 | 1325 // Allocate and initialize the pre-allocated classes in the core library. |
1299 // Allocate and initialize the pre-allocated classes in the core library. | 1326 // The script and token index of these pre-allocated classes is set up in |
1300 // The script and token index of these pre-allocated classes is set up in | 1327 // the parser when the corelib script is compiled (see |
1301 // the parser when the corelib script is compiled (see | 1328 // Parser::ParseClassDefinition). |
1302 // Parser::ParseClassDefinition). | 1329 cls = Class::New<Instance>(kInstanceCid); |
1303 cls = Class::New<Instance>(kInstanceCid); | 1330 object_store->set_object_class(cls); |
1304 object_store->set_object_class(cls); | 1331 cls.set_name(Symbols::Object()); |
1305 cls.set_name(Symbols::Object()); | 1332 cls.set_num_type_arguments(0); |
1306 cls.set_num_type_arguments(0); | 1333 cls.set_num_own_type_arguments(0); |
1307 cls.set_num_own_type_arguments(0); | 1334 cls.set_is_prefinalized(); |
1308 cls.set_is_prefinalized(); | 1335 core_lib.AddClass(cls); |
1309 core_lib.AddClass(cls); | 1336 pending_classes.Add(cls); |
1310 pending_classes.Add(cls); | 1337 type = Type::NewNonParameterizedType(cls); |
1311 type = Type::NewNonParameterizedType(cls); | 1338 object_store->set_object_type(type); |
1312 object_store->set_object_type(type); | 1339 |
1313 | 1340 cls = Class::New<Bool>(); |
1314 cls = Class::New<Bool>(); | 1341 object_store->set_bool_class(cls); |
1315 object_store->set_bool_class(cls); | 1342 RegisterClass(cls, Symbols::Bool(), core_lib); |
1316 RegisterClass(cls, Symbols::Bool(), core_lib); | 1343 pending_classes.Add(cls); |
1317 pending_classes.Add(cls); | 1344 |
1318 | 1345 cls = Class::New<Instance>(kNullCid); |
1319 cls = Class::New<Instance>(kNullCid); | 1346 object_store->set_null_class(cls); |
1320 object_store->set_null_class(cls); | 1347 cls.set_num_type_arguments(0); |
1321 cls.set_num_type_arguments(0); | 1348 cls.set_num_own_type_arguments(0); |
1322 cls.set_num_own_type_arguments(0); | 1349 cls.set_is_prefinalized(); |
1323 cls.set_is_prefinalized(); | 1350 RegisterClass(cls, Symbols::Null(), core_lib); |
1324 RegisterClass(cls, Symbols::Null(), core_lib); | 1351 pending_classes.Add(cls); |
1325 pending_classes.Add(cls); | 1352 |
1326 | 1353 ASSERT(!library_prefix_cls.IsNull()); |
1327 ASSERT(!library_prefix_cls.IsNull()); | 1354 RegisterPrivateClass(library_prefix_cls, Symbols::_LibraryPrefix(), |
1328 RegisterPrivateClass(library_prefix_cls, Symbols::_LibraryPrefix(), core_lib); | 1355 core_lib); |
1329 pending_classes.Add(library_prefix_cls); | 1356 pending_classes.Add(library_prefix_cls); |
1330 | 1357 |
1331 RegisterPrivateClass(type_cls, Symbols::Type(), core_lib); | 1358 RegisterPrivateClass(type_cls, Symbols::Type(), core_lib); |
1332 pending_classes.Add(type_cls); | 1359 pending_classes.Add(type_cls); |
1333 | 1360 |
1334 RegisterPrivateClass(type_ref_cls, Symbols::TypeRef(), core_lib); | 1361 RegisterPrivateClass(type_ref_cls, Symbols::TypeRef(), core_lib); |
1335 pending_classes.Add(type_ref_cls); | 1362 pending_classes.Add(type_ref_cls); |
1336 | 1363 |
1337 RegisterPrivateClass(type_parameter_cls, Symbols::TypeParameter(), core_lib); | 1364 RegisterPrivateClass(type_parameter_cls, Symbols::TypeParameter(), |
1338 pending_classes.Add(type_parameter_cls); | 1365 core_lib); |
1339 | 1366 pending_classes.Add(type_parameter_cls); |
1340 RegisterPrivateClass(bounded_type_cls, Symbols::BoundedType(), core_lib); | 1367 |
1341 pending_classes.Add(bounded_type_cls); | 1368 RegisterPrivateClass(bounded_type_cls, Symbols::BoundedType(), core_lib); |
1342 | 1369 pending_classes.Add(bounded_type_cls); |
1343 RegisterPrivateClass(mixin_app_type_cls, Symbols::MixinAppType(), core_lib); | 1370 |
1344 pending_classes.Add(mixin_app_type_cls); | 1371 RegisterPrivateClass(mixin_app_type_cls, Symbols::MixinAppType(), core_lib); |
1345 | 1372 pending_classes.Add(mixin_app_type_cls); |
1346 cls = Class::New<Integer>(); | 1373 |
1347 object_store->set_integer_implementation_class(cls); | 1374 cls = Class::New<Integer>(); |
1348 RegisterPrivateClass(cls, Symbols::IntegerImplementation(), core_lib); | 1375 object_store->set_integer_implementation_class(cls); |
1349 pending_classes.Add(cls); | 1376 RegisterPrivateClass(cls, Symbols::IntegerImplementation(), core_lib); |
1350 | 1377 pending_classes.Add(cls); |
1351 cls = Class::New<Smi>(); | 1378 |
1352 object_store->set_smi_class(cls); | 1379 cls = Class::New<Smi>(); |
1353 RegisterPrivateClass(cls, Symbols::_Smi(), core_lib); | 1380 object_store->set_smi_class(cls); |
1354 pending_classes.Add(cls); | 1381 RegisterPrivateClass(cls, Symbols::_Smi(), core_lib); |
1355 | 1382 pending_classes.Add(cls); |
1356 cls = Class::New<Mint>(); | 1383 |
1357 object_store->set_mint_class(cls); | 1384 cls = Class::New<Mint>(); |
1358 RegisterPrivateClass(cls, Symbols::_Mint(), core_lib); | 1385 object_store->set_mint_class(cls); |
1359 pending_classes.Add(cls); | 1386 RegisterPrivateClass(cls, Symbols::_Mint(), core_lib); |
1360 | 1387 pending_classes.Add(cls); |
1361 cls = Class::New<Bigint>(); | 1388 |
1362 object_store->set_bigint_class(cls); | 1389 cls = Class::New<Bigint>(); |
1363 RegisterPrivateClass(cls, Symbols::_Bigint(), core_lib); | 1390 object_store->set_bigint_class(cls); |
1364 pending_classes.Add(cls); | 1391 RegisterPrivateClass(cls, Symbols::_Bigint(), core_lib); |
1365 | 1392 pending_classes.Add(cls); |
1366 cls = Class::New<Double>(); | 1393 |
1367 object_store->set_double_class(cls); | 1394 cls = Class::New<Double>(); |
1368 RegisterPrivateClass(cls, Symbols::_Double(), core_lib); | 1395 object_store->set_double_class(cls); |
1369 pending_classes.Add(cls); | 1396 RegisterPrivateClass(cls, Symbols::_Double(), core_lib); |
1370 | 1397 pending_classes.Add(cls); |
1371 // Class that represents the Dart class _Closure and C++ class Closure. | 1398 |
1372 cls = Class::New<Closure>(); | 1399 // Class that represents the Dart class _Closure and C++ class Closure. |
1373 cls.set_type_arguments_field_offset(Closure::type_arguments_offset()); | 1400 cls = Class::New<Closure>(); |
1374 cls.set_num_type_arguments(0); // Although a closure has type_arguments_. | 1401 cls.set_type_arguments_field_offset(Closure::type_arguments_offset()); |
1375 cls.set_num_own_type_arguments(0); | 1402 cls.set_num_type_arguments(0); // Although a closure has type_arguments_. |
1376 RegisterPrivateClass(cls, Symbols::_Closure(), core_lib); | 1403 cls.set_num_own_type_arguments(0); |
1377 pending_classes.Add(cls); | 1404 RegisterPrivateClass(cls, Symbols::_Closure(), core_lib); |
1378 object_store->set_closure_class(cls); | 1405 pending_classes.Add(cls); |
1379 | 1406 object_store->set_closure_class(cls); |
1380 cls = Class::New<WeakProperty>(); | 1407 |
1381 object_store->set_weak_property_class(cls); | 1408 cls = Class::New<WeakProperty>(); |
1382 RegisterPrivateClass(cls, Symbols::_WeakProperty(), core_lib); | 1409 object_store->set_weak_property_class(cls); |
1383 | 1410 RegisterPrivateClass(cls, Symbols::_WeakProperty(), core_lib); |
1384 // Pre-register the mirrors library so we can place the vm class | 1411 |
1385 // MirrorReference there rather than the core library. | 1412 // Pre-register the mirrors library so we can place the vm class |
| 1413 // MirrorReference there rather than the core library. |
1386 #if !defined(PRODUCT) | 1414 #if !defined(PRODUCT) |
1387 lib = Library::LookupLibrary(thread, Symbols::DartMirrors()); | 1415 lib = Library::LookupLibrary(thread, Symbols::DartMirrors()); |
1388 if (lib.IsNull()) { | 1416 if (lib.IsNull()) { |
1389 lib = Library::NewLibraryHelper(Symbols::DartMirrors(), true); | 1417 lib = Library::NewLibraryHelper(Symbols::DartMirrors(), true); |
1390 lib.SetLoadRequested(); | 1418 lib.SetLoadRequested(); |
1391 lib.Register(thread); | 1419 lib.Register(thread); |
| 1420 } |
1392 object_store->set_bootstrap_library(ObjectStore::kMirrors, lib); | 1421 object_store->set_bootstrap_library(ObjectStore::kMirrors, lib); |
1393 } | 1422 ASSERT(!lib.IsNull()); |
1394 ASSERT(!lib.IsNull()); | 1423 ASSERT(lib.raw() == Library::MirrorsLibrary()); |
1395 ASSERT(lib.raw() == Library::MirrorsLibrary()); | 1424 |
1396 | 1425 cls = Class::New<MirrorReference>(); |
1397 cls = Class::New<MirrorReference>(); | 1426 RegisterPrivateClass(cls, Symbols::_MirrorReference(), lib); |
1398 RegisterPrivateClass(cls, Symbols::_MirrorReference(), lib); | 1427 #endif |
1399 #endif // !defined(PRODUCT) | 1428 |
1400 | 1429 // Pre-register the collection library so we can place the vm class |
1401 // Pre-register the collection library so we can place the vm class | 1430 // LinkedHashMap there rather than the core library. |
1402 // LinkedHashMap there rather than the core library. | 1431 lib = Library::LookupLibrary(thread, Symbols::DartCollection()); |
1403 lib = Library::LookupLibrary(thread, Symbols::DartCollection()); | 1432 if (lib.IsNull()) { |
1404 if (lib.IsNull()) { | 1433 lib = Library::NewLibraryHelper(Symbols::DartCollection(), true); |
1405 lib = Library::NewLibraryHelper(Symbols::DartCollection(), true); | 1434 lib.SetLoadRequested(); |
1406 lib.SetLoadRequested(); | 1435 lib.Register(thread); |
1407 lib.Register(thread); | 1436 } |
| 1437 |
1408 object_store->set_bootstrap_library(ObjectStore::kCollection, lib); | 1438 object_store->set_bootstrap_library(ObjectStore::kCollection, lib); |
1409 } | 1439 ASSERT(!lib.IsNull()); |
1410 ASSERT(!lib.IsNull()); | 1440 ASSERT(lib.raw() == Library::CollectionLibrary()); |
1411 ASSERT(lib.raw() == Library::CollectionLibrary()); | 1441 cls = Class::New<LinkedHashMap>(); |
1412 cls = Class::New<LinkedHashMap>(); | 1442 object_store->set_linked_hash_map_class(cls); |
1413 object_store->set_linked_hash_map_class(cls); | 1443 cls.set_type_arguments_field_offset(LinkedHashMap::type_arguments_offset()); |
1414 cls.set_type_arguments_field_offset(LinkedHashMap::type_arguments_offset()); | 1444 cls.set_num_type_arguments(2); |
1415 cls.set_num_type_arguments(2); | 1445 cls.set_num_own_type_arguments(0); |
1416 cls.set_num_own_type_arguments(2); | 1446 RegisterPrivateClass(cls, Symbols::_LinkedHashMap(), lib); |
1417 RegisterPrivateClass(cls, Symbols::_LinkedHashMap(), lib); | 1447 pending_classes.Add(cls); |
1418 pending_classes.Add(cls); | 1448 |
1419 | 1449 // Pre-register the developer library so we can place the vm class |
1420 // Pre-register the developer library so we can place the vm class | 1450 // UserTag there rather than the core library. |
1421 // UserTag there rather than the core library. | 1451 lib = Library::LookupLibrary(thread, Symbols::DartDeveloper()); |
1422 lib = Library::LookupLibrary(thread, Symbols::DartDeveloper()); | 1452 if (lib.IsNull()) { |
1423 if (lib.IsNull()) { | 1453 lib = Library::NewLibraryHelper(Symbols::DartDeveloper(), true); |
1424 lib = Library::NewLibraryHelper(Symbols::DartDeveloper(), true); | 1454 lib.SetLoadRequested(); |
1425 lib.SetLoadRequested(); | 1455 lib.Register(thread); |
1426 lib.Register(thread); | 1456 } |
1427 object_store->set_bootstrap_library(ObjectStore::kDeveloper, lib); | 1457 object_store->set_bootstrap_library(ObjectStore::kDeveloper, lib); |
1428 } | 1458 ASSERT(!lib.IsNull()); |
1429 ASSERT(!lib.IsNull()); | 1459 ASSERT(lib.raw() == Library::DeveloperLibrary()); |
1430 ASSERT(lib.raw() == Library::DeveloperLibrary()); | 1460 cls = Class::New<UserTag>(); |
1431 | 1461 RegisterPrivateClass(cls, Symbols::_UserTag(), lib); |
1432 lib = Library::LookupLibrary(thread, Symbols::DartDeveloper()); | 1462 pending_classes.Add(cls); |
1433 ASSERT(!lib.IsNull()); | 1463 |
1434 cls = Class::New<UserTag>(); | 1464 // Setup some default native field classes which can be extended for |
1435 RegisterPrivateClass(cls, Symbols::_UserTag(), lib); | 1465 // specifying native fields in dart classes. |
1436 pending_classes.Add(cls); | 1466 Library::InitNativeWrappersLibrary(isolate, is_kernel); |
1437 | 1467 ASSERT(object_store->native_wrappers_library() != Library::null()); |
1438 // Setup some default native field classes which can be extended for | 1468 |
1439 // specifying native fields in dart classes. | 1469 // Pre-register the typed_data library so the native class implementations |
1440 Library::InitNativeWrappersLibrary(isolate); | 1470 // can be hooked up before compiling it. |
1441 ASSERT(object_store->native_wrappers_library() != Library::null()); | 1471 lib = Library::LookupLibrary(thread, Symbols::DartTypedData()); |
1442 | 1472 if (lib.IsNull()) { |
1443 // Pre-register the typed_data library so the native class implementations | 1473 lib = Library::NewLibraryHelper(Symbols::DartTypedData(), true); |
1444 // can be hooked up before compiling it. | 1474 lib.SetLoadRequested(); |
1445 lib = Library::LookupLibrary(thread, Symbols::DartTypedData()); | 1475 lib.Register(thread); |
1446 if (lib.IsNull()) { | 1476 } |
1447 lib = Library::NewLibraryHelper(Symbols::DartTypedData(), true); | |
1448 lib.SetLoadRequested(); | |
1449 lib.Register(thread); | |
1450 object_store->set_bootstrap_library(ObjectStore::kTypedData, lib); | 1477 object_store->set_bootstrap_library(ObjectStore::kTypedData, lib); |
1451 } | 1478 ASSERT(!lib.IsNull()); |
1452 ASSERT(!lib.IsNull()); | 1479 ASSERT(lib.raw() == Library::TypedDataLibrary()); |
1453 ASSERT(lib.raw() == Library::TypedDataLibrary()); | |
1454 #define REGISTER_TYPED_DATA_CLASS(clazz) \ | 1480 #define REGISTER_TYPED_DATA_CLASS(clazz) \ |
1455 cls = Class::NewTypedDataClass(kTypedData##clazz##ArrayCid); \ | 1481 cls = Class::NewTypedDataClass(kTypedData##clazz##ArrayCid); \ |
1456 RegisterClass(cls, Symbols::clazz##List(), lib); | 1482 RegisterClass(cls, Symbols::clazz##List(), lib); |
1457 | 1483 |
1458 DART_CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); | 1484 DART_CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); |
1459 #undef REGISTER_TYPED_DATA_CLASS | 1485 #undef REGISTER_TYPED_DATA_CLASS |
1460 #define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \ | 1486 #define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \ |
1461 cls = Class::NewTypedDataViewClass(kTypedData##clazz##ViewCid); \ | 1487 cls = Class::NewTypedDataViewClass(kTypedData##clazz##ViewCid); \ |
1462 RegisterPrivateClass(cls, Symbols::_##clazz##View(), lib); \ | 1488 RegisterPrivateClass(cls, Symbols::_##clazz##View(), lib); \ |
1463 pending_classes.Add(cls); | 1489 pending_classes.Add(cls); |
1464 | 1490 |
1465 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_VIEW_CLASS); | 1491 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_VIEW_CLASS); |
1466 cls = Class::NewTypedDataViewClass(kByteDataViewCid); | 1492 cls = Class::NewTypedDataViewClass(kByteDataViewCid); |
1467 RegisterPrivateClass(cls, Symbols::_ByteDataView(), lib); | 1493 RegisterPrivateClass(cls, Symbols::_ByteDataView(), lib); |
1468 pending_classes.Add(cls); | 1494 pending_classes.Add(cls); |
1469 #undef REGISTER_TYPED_DATA_VIEW_CLASS | 1495 #undef REGISTER_TYPED_DATA_VIEW_CLASS |
1470 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ | 1496 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ |
1471 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); \ | 1497 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); \ |
1472 RegisterPrivateClass(cls, Symbols::_External##clazz(), lib); | 1498 RegisterPrivateClass(cls, Symbols::_External##clazz(), lib); |
1473 | 1499 |
1474 cls = Class::New<Instance>(kByteBufferCid); | 1500 cls = Class::New<Instance>(kByteBufferCid); |
1475 cls.set_instance_size(0); | 1501 cls.set_instance_size(0); |
1476 cls.set_next_field_offset(-kWordSize); | 1502 cls.set_next_field_offset(-kWordSize); |
1477 RegisterClass(cls, Symbols::ByteBuffer(), lib); | 1503 RegisterClass(cls, Symbols::ByteBuffer(), lib); |
1478 pending_classes.Add(cls); | 1504 pending_classes.Add(cls); |
1479 | 1505 |
1480 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); | 1506 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); |
1481 #undef REGISTER_EXT_TYPED_DATA_CLASS | 1507 #undef REGISTER_EXT_TYPED_DATA_CLASS |
1482 // Register Float32x4 and Int32x4 in the object store. | 1508 // Register Float32x4 and Int32x4 in the object store. |
1483 cls = Class::New<Float32x4>(); | 1509 cls = Class::New<Float32x4>(); |
1484 RegisterClass(cls, Symbols::Float32x4(), lib); | 1510 RegisterClass(cls, Symbols::Float32x4(), lib); |
1485 cls.set_num_type_arguments(0); | 1511 cls.set_num_type_arguments(0); |
1486 cls.set_num_own_type_arguments(0); | 1512 cls.set_num_own_type_arguments(0); |
1487 cls.set_is_prefinalized(); | 1513 cls.set_is_prefinalized(); |
1488 pending_classes.Add(cls); | 1514 pending_classes.Add(cls); |
1489 object_store->set_float32x4_class(cls); | 1515 object_store->set_float32x4_class(cls); |
1490 type = Type::NewNonParameterizedType(cls); | 1516 type = Type::NewNonParameterizedType(cls); |
1491 object_store->set_float32x4_type(type); | 1517 object_store->set_float32x4_type(type); |
1492 | 1518 |
1493 cls = Class::New<Int32x4>(); | 1519 cls = Class::New<Int32x4>(); |
1494 RegisterClass(cls, Symbols::Int32x4(), lib); | 1520 RegisterClass(cls, Symbols::Int32x4(), lib); |
1495 cls.set_num_type_arguments(0); | 1521 cls.set_num_type_arguments(0); |
1496 cls.set_num_own_type_arguments(0); | 1522 cls.set_num_own_type_arguments(0); |
1497 cls.set_is_prefinalized(); | 1523 cls.set_is_prefinalized(); |
1498 pending_classes.Add(cls); | 1524 pending_classes.Add(cls); |
1499 object_store->set_int32x4_class(cls); | 1525 object_store->set_int32x4_class(cls); |
1500 type = Type::NewNonParameterizedType(cls); | 1526 type = Type::NewNonParameterizedType(cls); |
1501 object_store->set_int32x4_type(type); | 1527 object_store->set_int32x4_type(type); |
1502 | 1528 |
1503 cls = Class::New<Float64x2>(); | 1529 cls = Class::New<Float64x2>(); |
1504 RegisterClass(cls, Symbols::Float64x2(), lib); | 1530 RegisterClass(cls, Symbols::Float64x2(), lib); |
1505 cls.set_num_type_arguments(0); | 1531 cls.set_num_type_arguments(0); |
1506 cls.set_num_own_type_arguments(0); | 1532 cls.set_num_own_type_arguments(0); |
1507 cls.set_is_prefinalized(); | 1533 cls.set_is_prefinalized(); |
1508 pending_classes.Add(cls); | 1534 pending_classes.Add(cls); |
1509 object_store->set_float64x2_class(cls); | 1535 object_store->set_float64x2_class(cls); |
1510 type = Type::NewNonParameterizedType(cls); | 1536 type = Type::NewNonParameterizedType(cls); |
1511 object_store->set_float64x2_type(type); | 1537 object_store->set_float64x2_type(type); |
1512 | 1538 |
1513 // Set the super type of class Stacktrace to Object type so that the | 1539 // Set the super type of class Stacktrace to Object type so that the |
1514 // 'toString' method is implemented. | 1540 // 'toString' method is implemented. |
1515 type = object_store->object_type(); | 1541 type = object_store->object_type(); |
1516 stacktrace_cls.set_super_type(type); | 1542 stacktrace_cls.set_super_type(type); |
1517 | 1543 |
1518 // Abstract class that represents the Dart class Function. | 1544 // Abstract class that represents the Dart class Function. |
1519 cls = Class::New<Instance>(kIllegalCid); | 1545 cls = Class::New<Instance>(kIllegalCid); |
1520 cls.set_num_type_arguments(0); | 1546 cls.set_num_type_arguments(0); |
1521 cls.set_num_own_type_arguments(0); | 1547 cls.set_num_own_type_arguments(0); |
1522 cls.set_is_prefinalized(); | 1548 cls.set_is_prefinalized(); |
1523 RegisterClass(cls, Symbols::Function(), core_lib); | 1549 RegisterClass(cls, Symbols::Function(), core_lib); |
1524 pending_classes.Add(cls); | 1550 pending_classes.Add(cls); |
1525 type = Type::NewNonParameterizedType(cls); | 1551 type = Type::NewNonParameterizedType(cls); |
1526 object_store->set_function_type(type); | 1552 object_store->set_function_type(type); |
1527 | 1553 |
1528 cls = Class::New<Number>(); | 1554 cls = Class::New<Number>(); |
1529 RegisterClass(cls, Symbols::Number(), core_lib); | 1555 RegisterClass(cls, Symbols::Number(), core_lib); |
1530 pending_classes.Add(cls); | 1556 pending_classes.Add(cls); |
1531 type = Type::NewNonParameterizedType(cls); | 1557 type = Type::NewNonParameterizedType(cls); |
1532 object_store->set_number_type(type); | 1558 object_store->set_number_type(type); |
1533 | 1559 |
1534 cls = Class::New<Instance>(kIllegalCid); | 1560 cls = Class::New<Instance>(kIllegalCid); |
1535 RegisterClass(cls, Symbols::Int(), core_lib); | 1561 RegisterClass(cls, Symbols::Int(), core_lib); |
1536 cls.set_num_type_arguments(0); | 1562 cls.set_num_type_arguments(0); |
1537 cls.set_num_own_type_arguments(0); | 1563 cls.set_num_own_type_arguments(0); |
1538 cls.set_is_prefinalized(); | 1564 cls.set_is_prefinalized(); |
1539 pending_classes.Add(cls); | 1565 pending_classes.Add(cls); |
1540 type = Type::NewNonParameterizedType(cls); | 1566 type = Type::NewNonParameterizedType(cls); |
1541 object_store->set_int_type(type); | 1567 object_store->set_int_type(type); |
1542 | 1568 |
1543 cls = Class::New<Instance>(kIllegalCid); | 1569 cls = Class::New<Instance>(kIllegalCid); |
1544 RegisterClass(cls, Symbols::Double(), core_lib); | 1570 RegisterClass(cls, Symbols::Double(), core_lib); |
1545 cls.set_num_type_arguments(0); | 1571 cls.set_num_type_arguments(0); |
1546 cls.set_num_own_type_arguments(0); | 1572 cls.set_num_own_type_arguments(0); |
1547 cls.set_is_prefinalized(); | 1573 cls.set_is_prefinalized(); |
1548 pending_classes.Add(cls); | 1574 pending_classes.Add(cls); |
1549 type = Type::NewNonParameterizedType(cls); | 1575 type = Type::NewNonParameterizedType(cls); |
1550 object_store->set_double_type(type); | 1576 object_store->set_double_type(type); |
1551 | 1577 |
1552 name = Symbols::_String().raw(); | 1578 name = Symbols::_String().raw(); |
1553 cls = Class::New<Instance>(kIllegalCid); | 1579 cls = Class::New<Instance>(kIllegalCid); |
1554 RegisterClass(cls, name, core_lib); | 1580 RegisterClass(cls, name, core_lib); |
1555 cls.set_num_type_arguments(0); | 1581 cls.set_num_type_arguments(0); |
1556 cls.set_num_own_type_arguments(0); | 1582 cls.set_num_own_type_arguments(0); |
1557 cls.set_is_prefinalized(); | 1583 cls.set_is_prefinalized(); |
1558 pending_classes.Add(cls); | 1584 pending_classes.Add(cls); |
1559 type = Type::NewNonParameterizedType(cls); | 1585 type = Type::NewNonParameterizedType(cls); |
1560 object_store->set_string_type(type); | 1586 object_store->set_string_type(type); |
1561 | 1587 |
1562 cls = object_store->bool_class(); | 1588 cls = object_store->bool_class(); |
1563 type = Type::NewNonParameterizedType(cls); | 1589 type = Type::NewNonParameterizedType(cls); |
1564 object_store->set_bool_type(type); | 1590 object_store->set_bool_type(type); |
1565 | 1591 |
1566 cls = object_store->smi_class(); | 1592 cls = object_store->smi_class(); |
1567 type = Type::NewNonParameterizedType(cls); | 1593 type = Type::NewNonParameterizedType(cls); |
1568 object_store->set_smi_type(type); | 1594 object_store->set_smi_type(type); |
1569 | 1595 |
1570 cls = object_store->mint_class(); | 1596 cls = object_store->mint_class(); |
1571 type = Type::NewNonParameterizedType(cls); | 1597 type = Type::NewNonParameterizedType(cls); |
1572 object_store->set_mint_type(type); | 1598 object_store->set_mint_type(type); |
1573 | 1599 |
1574 // The classes 'void' and 'dynamic' are phoney classes to make type checking | 1600 // The classes 'void' and 'dynamic' are phony classes to make type checking |
1575 // more regular; they live in the VM isolate. The class 'void' is not | 1601 // more regular; they live in the VM isolate. The class 'void' is not |
1576 // registered in the class dictionary because its name is a reserved word. | 1602 // registered in the class dictionary because its name is a reserved word. |
1577 // The class 'dynamic' is registered in the class dictionary because its name | 1603 // The class 'dynamic' is registered in the class dictionary because its |
1578 // is a built-in identifier (this is wrong). | 1604 // name is a built-in identifier (this is wrong). The corresponding types |
1579 // The corresponding types are stored in the object store. | 1605 // are stored in the object store. |
1580 cls = object_store->null_class(); | 1606 cls = object_store->null_class(); |
1581 type = Type::NewNonParameterizedType(cls); | 1607 type = Type::NewNonParameterizedType(cls); |
1582 object_store->set_null_type(type); | 1608 object_store->set_null_type(type); |
1583 | 1609 |
1584 // Consider removing when/if Null becomes an ordinary class. | 1610 // Consider removing when/if Null becomes an ordinary class. |
1585 type = object_store->object_type(); | 1611 type = object_store->object_type(); |
1586 cls.set_super_type(type); | 1612 cls.set_super_type(type); |
1587 | 1613 |
1588 // Finish the initialization by compiling the bootstrap scripts containing the | 1614 // Finish the initialization by compiling the bootstrap scripts containing |
1589 // base interfaces and the implementation of the internal classes. | 1615 // the base interfaces and the implementation of the internal classes. |
1590 const Error& error = Error::Handle(Bootstrap::DoBootstrapping()); | 1616 const Error& error = Error::Handle( |
1591 if (!error.IsNull()) { | 1617 zone, Bootstrap::DoBootstrapping(kernel_buffer, kernel_buffer_length)); |
1592 return error.raw(); | 1618 if (!error.IsNull()) { |
1593 } | 1619 return error.raw(); |
1594 | 1620 } |
1595 ClassFinalizer::VerifyBootstrapClasses(); | 1621 |
1596 | 1622 ClassFinalizer::VerifyBootstrapClasses(); |
1597 // Set up the intrinsic state of all functions (core, math and typed data). | 1623 |
1598 Intrinsifier::InitializeState(); | 1624 // Set up the intrinsic state of all functions (core, math and typed data). |
1599 | 1625 Intrinsifier::InitializeState(); |
1600 // Set up recognized state of all functions (core, math and typed data). | 1626 |
1601 MethodRecognizer::InitializeState(); | 1627 // Set up recognized state of all functions (core, math and typed data). |
1602 | 1628 MethodRecognizer::InitializeState(); |
1603 // Adds static const fields (class ids) to the class 'ClassID'); | 1629 |
1604 lib = Library::LookupLibrary(thread, Symbols::DartInternal()); | 1630 isolate->object_store()->InitKnownObjects(); |
1605 ASSERT(!lib.IsNull()); | 1631 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
1606 cls = lib.LookupClassAllowPrivate(Symbols::ClassID()); | 1632 } else { |
1607 ASSERT(!cls.IsNull()); | 1633 // Object::Init version when we are running in a version of dart that has a |
1608 Field& field = Field::Handle(zone); | 1634 // full snapshot linked in and an isolate is initialized using the full |
1609 Smi& value = Smi::Handle(zone); | 1635 // snapshot. |
1610 String& field_name = String::Handle(zone); | 1636 ObjectStore* object_store = isolate->object_store(); |
1611 | 1637 |
1612 #define CLASS_LIST_WITH_NULL(V) \ | 1638 Class& cls = Class::Handle(zone); |
1613 V(Null) \ | 1639 |
1614 CLASS_LIST_NO_OBJECT(V) | 1640 // Set up empty classes in the object store, these will get initialized |
1615 | 1641 // correctly when we read from the snapshot. This is done to allow |
1616 #define ADD_SET_FIELD(clazz) \ | 1642 // bootstrapping of reading classes from the snapshot. Some classes are not |
1617 field_name = Symbols::New(thread, "cid" #clazz); \ | 1643 // stored in the object store. Yet we still need to create their Class |
1618 field = \ | 1644 // object so that they get put into the class_table (as a side effect of |
1619 Field::New(field_name, true, false, true, false, cls, \ | 1645 // Class::New()). |
1620 Type::Handle(Type::IntType()), TokenPosition::kMinSource); \ | 1646 cls = Class::New<Instance>(kInstanceCid); |
1621 value = Smi::New(k##clazz##Cid); \ | 1647 object_store->set_object_class(cls); |
1622 field.SetStaticValue(value, true); \ | 1648 |
1623 cls.AddField(field); | 1649 cls = Class::New<LibraryPrefix>(); |
1624 | 1650 cls = Class::New<Type>(); |
1625 CLASS_LIST_WITH_NULL(ADD_SET_FIELD) | 1651 cls = Class::New<TypeRef>(); |
1626 #undef ADD_SET_FIELD | 1652 cls = Class::New<TypeParameter>(); |
1627 | 1653 cls = Class::New<BoundedType>(); |
1628 isolate->object_store()->InitKnownObjects(); | 1654 cls = Class::New<MixinAppType>(); |
1629 | 1655 |
1630 return Error::null(); | 1656 cls = Class::New<Array>(); |
1631 #else // defined(DART_NO_SNAPSHOT). | 1657 object_store->set_array_class(cls); |
1632 // Object::Init version when we are running in a version of dart that has | 1658 |
1633 // a full snapshot linked in and an isolate is initialized using the full | 1659 cls = Class::New<Array>(kImmutableArrayCid); |
1634 // snapshot. | 1660 object_store->set_immutable_array_class(cls); |
1635 ObjectStore* object_store = isolate->object_store(); | 1661 |
1636 | 1662 cls = Class::New<GrowableObjectArray>(); |
1637 Class& cls = Class::Handle(); | 1663 object_store->set_growable_object_array_class(cls); |
1638 | 1664 |
1639 // Set up empty classes in the object store, these will get | 1665 cls = Class::New<LinkedHashMap>(); |
1640 // initialized correctly when we read from the snapshot. | 1666 object_store->set_linked_hash_map_class(cls); |
1641 // This is done to allow bootstrapping of reading classes from the snapshot. | 1667 |
1642 // Some classes are not stored in the object store. Yet we still need to | 1668 cls = Class::New<Float32x4>(); |
1643 // create their Class object so that they get put into the class_table | 1669 object_store->set_float32x4_class(cls); |
1644 // (as a side effect of Class::New()). | 1670 |
1645 | 1671 cls = Class::New<Int32x4>(); |
1646 cls = Class::New<Instance>(kInstanceCid); | 1672 object_store->set_int32x4_class(cls); |
1647 object_store->set_object_class(cls); | 1673 |
1648 | 1674 cls = Class::New<Float64x2>(); |
1649 cls = Class::New<LibraryPrefix>(); | 1675 object_store->set_float64x2_class(cls); |
1650 cls = Class::New<Type>(); | |
1651 cls = Class::New<TypeRef>(); | |
1652 cls = Class::New<TypeParameter>(); | |
1653 cls = Class::New<BoundedType>(); | |
1654 cls = Class::New<MixinAppType>(); | |
1655 | |
1656 cls = Class::New<Array>(); | |
1657 object_store->set_array_class(cls); | |
1658 | |
1659 cls = Class::New<Array>(kImmutableArrayCid); | |
1660 object_store->set_immutable_array_class(cls); | |
1661 | |
1662 cls = Class::New<GrowableObjectArray>(); | |
1663 object_store->set_growable_object_array_class(cls); | |
1664 | |
1665 cls = Class::New<LinkedHashMap>(); | |
1666 object_store->set_linked_hash_map_class(cls); | |
1667 | |
1668 cls = Class::New<Float32x4>(); | |
1669 object_store->set_float32x4_class(cls); | |
1670 | |
1671 cls = Class::New<Int32x4>(); | |
1672 object_store->set_int32x4_class(cls); | |
1673 | |
1674 cls = Class::New<Float64x2>(); | |
1675 object_store->set_float64x2_class(cls); | |
1676 | 1676 |
1677 #define REGISTER_TYPED_DATA_CLASS(clazz) \ | 1677 #define REGISTER_TYPED_DATA_CLASS(clazz) \ |
1678 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid); | 1678 cls = Class::NewTypedDataClass(kTypedData##clazz##Cid); |
1679 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); | 1679 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_CLASS); |
1680 #undef REGISTER_TYPED_DATA_CLASS | 1680 #undef REGISTER_TYPED_DATA_CLASS |
1681 #define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \ | 1681 #define REGISTER_TYPED_DATA_VIEW_CLASS(clazz) \ |
1682 cls = Class::NewTypedDataViewClass(kTypedData##clazz##ViewCid); | 1682 cls = Class::NewTypedDataViewClass(kTypedData##clazz##ViewCid); |
1683 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_VIEW_CLASS); | 1683 CLASS_LIST_TYPED_DATA(REGISTER_TYPED_DATA_VIEW_CLASS); |
1684 #undef REGISTER_TYPED_DATA_VIEW_CLASS | 1684 #undef REGISTER_TYPED_DATA_VIEW_CLASS |
1685 cls = Class::NewTypedDataViewClass(kByteDataViewCid); | 1685 cls = Class::NewTypedDataViewClass(kByteDataViewCid); |
1686 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ | 1686 #define REGISTER_EXT_TYPED_DATA_CLASS(clazz) \ |
1687 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); | 1687 cls = Class::NewExternalTypedDataClass(kExternalTypedData##clazz##Cid); |
1688 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); | 1688 CLASS_LIST_TYPED_DATA(REGISTER_EXT_TYPED_DATA_CLASS); |
1689 #undef REGISTER_EXT_TYPED_DATA_CLASS | 1689 #undef REGISTER_EXT_TYPED_DATA_CLASS |
1690 | 1690 |
1691 cls = Class::New<Instance>(kByteBufferCid); | 1691 cls = Class::New<Instance>(kByteBufferCid); |
1692 | 1692 |
1693 cls = Class::New<Integer>(); | 1693 cls = Class::New<Integer>(); |
1694 object_store->set_integer_implementation_class(cls); | 1694 object_store->set_integer_implementation_class(cls); |
1695 | 1695 |
1696 cls = Class::New<Smi>(); | 1696 cls = Class::New<Smi>(); |
1697 object_store->set_smi_class(cls); | 1697 object_store->set_smi_class(cls); |
1698 | 1698 |
1699 cls = Class::New<Mint>(); | 1699 cls = Class::New<Mint>(); |
1700 object_store->set_mint_class(cls); | 1700 object_store->set_mint_class(cls); |
1701 | 1701 |
1702 cls = Class::New<Double>(); | 1702 cls = Class::New<Double>(); |
1703 object_store->set_double_class(cls); | 1703 object_store->set_double_class(cls); |
1704 | 1704 |
1705 cls = Class::New<Closure>(); | 1705 cls = Class::New<Closure>(); |
1706 object_store->set_closure_class(cls); | 1706 object_store->set_closure_class(cls); |
1707 | 1707 |
1708 cls = Class::New<Bigint>(); | 1708 cls = Class::New<Bigint>(); |
1709 object_store->set_bigint_class(cls); | 1709 object_store->set_bigint_class(cls); |
1710 | 1710 |
1711 cls = Class::NewStringClass(kOneByteStringCid); | 1711 cls = Class::NewStringClass(kOneByteStringCid); |
1712 object_store->set_one_byte_string_class(cls); | 1712 object_store->set_one_byte_string_class(cls); |
1713 | 1713 |
1714 cls = Class::NewStringClass(kTwoByteStringCid); | 1714 cls = Class::NewStringClass(kTwoByteStringCid); |
1715 object_store->set_two_byte_string_class(cls); | 1715 object_store->set_two_byte_string_class(cls); |
1716 | 1716 |
1717 cls = Class::NewStringClass(kExternalOneByteStringCid); | 1717 cls = Class::NewStringClass(kExternalOneByteStringCid); |
1718 object_store->set_external_one_byte_string_class(cls); | 1718 object_store->set_external_one_byte_string_class(cls); |
1719 | 1719 |
1720 cls = Class::NewStringClass(kExternalTwoByteStringCid); | 1720 cls = Class::NewStringClass(kExternalTwoByteStringCid); |
1721 object_store->set_external_two_byte_string_class(cls); | 1721 object_store->set_external_two_byte_string_class(cls); |
1722 | 1722 |
1723 cls = Class::New<Bool>(); | 1723 cls = Class::New<Bool>(); |
1724 object_store->set_bool_class(cls); | 1724 object_store->set_bool_class(cls); |
1725 | 1725 |
1726 cls = Class::New<Instance>(kNullCid); | 1726 cls = Class::New<Instance>(kNullCid); |
1727 object_store->set_null_class(cls); | 1727 object_store->set_null_class(cls); |
1728 | 1728 |
1729 cls = Class::New<Capability>(); | 1729 cls = Class::New<Capability>(); |
1730 cls = Class::New<ReceivePort>(); | 1730 cls = Class::New<ReceivePort>(); |
1731 cls = Class::New<SendPort>(); | 1731 cls = Class::New<SendPort>(); |
1732 cls = Class::New<Stacktrace>(); | 1732 cls = Class::New<Stacktrace>(); |
1733 cls = Class::New<RegExp>(); | 1733 cls = Class::New<RegExp>(); |
1734 cls = Class::New<Number>(); | 1734 cls = Class::New<Number>(); |
1735 | 1735 |
1736 cls = Class::New<WeakProperty>(); | 1736 cls = Class::New<WeakProperty>(); |
1737 object_store->set_weak_property_class(cls); | 1737 object_store->set_weak_property_class(cls); |
1738 | 1738 |
1739 cls = Class::New<MirrorReference>(); | 1739 cls = Class::New<MirrorReference>(); |
1740 cls = Class::New<UserTag>(); | 1740 cls = Class::New<UserTag>(); |
1741 | 1741 |
1742 const Context& context = Context::Handle(zone, Context::New(0, Heap::kOld)); | 1742 const Context& context = Context::Handle(zone, Context::New(0, Heap::kOld)); |
1743 object_store->set_empty_context(context); | 1743 object_store->set_empty_context(context); |
1744 | 1744 } |
1745 #endif // defined(DART_NO_SNAPSHOT). | |
1746 | |
1747 return Error::null(); | 1745 return Error::null(); |
1748 } | 1746 } |
1749 | 1747 |
1750 | 1748 |
1751 #if defined(DEBUG) | 1749 #if defined(DEBUG) |
1752 bool Object::InVMHeap() const { | 1750 bool Object::InVMHeap() const { |
1753 if (FLAG_verify_handles && raw()->IsVMHeapObject()) { | 1751 if (FLAG_verify_handles && raw()->IsVMHeapObject()) { |
1754 Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); | 1752 Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); |
1755 ASSERT(vm_isolate_heap->Contains(RawObject::ToAddr(raw()))); | 1753 ASSERT(vm_isolate_heap->Contains(RawObject::ToAddr(raw()))); |
1756 } | 1754 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1916 // Old original doesn't need to be remembered, so neither does the clone. | 1914 // Old original doesn't need to be remembered, so neither does the clone. |
1917 return raw_clone; | 1915 return raw_clone; |
1918 } | 1916 } |
1919 StoreBufferUpdateVisitor visitor(Thread::Current(), raw_clone); | 1917 StoreBufferUpdateVisitor visitor(Thread::Current(), raw_clone); |
1920 raw_clone->VisitPointers(&visitor); | 1918 raw_clone->VisitPointers(&visitor); |
1921 return raw_clone; | 1919 return raw_clone; |
1922 } | 1920 } |
1923 | 1921 |
1924 | 1922 |
1925 RawString* Class::Name() const { | 1923 RawString* Class::Name() const { |
1926 ASSERT(raw_ptr()->name_ != String::null()); | |
1927 return raw_ptr()->name_; | 1924 return raw_ptr()->name_; |
1928 } | 1925 } |
1929 | 1926 |
1930 | 1927 |
1931 RawString* Class::ScrubbedName() const { | 1928 RawString* Class::ScrubbedName() const { |
1932 return String::ScrubName(String::Handle(Name())); | 1929 return String::ScrubName(String::Handle(Name())); |
1933 } | 1930 } |
1934 | 1931 |
1935 | 1932 |
1936 RawString* Class::UserVisibleName() const { | 1933 RawString* Class::UserVisibleName() const { |
(...skipping 2453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4390 while (it.MoveNext()) { | 4387 while (it.MoveNext()) { |
4391 constant ^= set.GetKey(it.Current()); | 4388 constant ^= set.GetKey(it.Current()); |
4392 ASSERT(!constant.IsNull()); | 4389 ASSERT(!constant.IsNull()); |
4393 ASSERT(constant.IsCanonical()); | 4390 ASSERT(constant.IsCanonical()); |
4394 InsertCanonicalConstant(zone, constant); | 4391 InsertCanonicalConstant(zone, constant); |
4395 } | 4392 } |
4396 set.Release(); | 4393 set.Release(); |
4397 } | 4394 } |
4398 | 4395 |
4399 | 4396 |
4400 RawUnresolvedClass* UnresolvedClass::New(const LibraryPrefix& library_prefix, | 4397 RawUnresolvedClass* UnresolvedClass::New(const Object& library_prefix, |
4401 const String& ident, | 4398 const String& ident, |
4402 TokenPosition token_pos) { | 4399 TokenPosition token_pos) { |
4403 const UnresolvedClass& type = UnresolvedClass::Handle(UnresolvedClass::New()); | 4400 const UnresolvedClass& type = UnresolvedClass::Handle(UnresolvedClass::New()); |
4404 type.set_library_prefix(library_prefix); | 4401 type.set_library_or_library_prefix(library_prefix); |
4405 type.set_ident(ident); | 4402 type.set_ident(ident); |
4406 type.set_token_pos(token_pos); | 4403 type.set_token_pos(token_pos); |
4407 return type.raw(); | 4404 return type.raw(); |
4408 } | 4405 } |
4409 | 4406 |
4410 | 4407 |
4411 RawUnresolvedClass* UnresolvedClass::New() { | 4408 RawUnresolvedClass* UnresolvedClass::New() { |
4412 ASSERT(Object::unresolved_class_class() != Class::null()); | 4409 ASSERT(Object::unresolved_class_class() != Class::null()); |
4413 RawObject* raw = Object::Allocate( | 4410 RawObject* raw = Object::Allocate( |
4414 UnresolvedClass::kClassId, UnresolvedClass::InstanceSize(), Heap::kOld); | 4411 UnresolvedClass::kClassId, UnresolvedClass::InstanceSize(), Heap::kOld); |
4415 return reinterpret_cast<RawUnresolvedClass*>(raw); | 4412 return reinterpret_cast<RawUnresolvedClass*>(raw); |
4416 } | 4413 } |
4417 | 4414 |
4418 | 4415 |
4419 void UnresolvedClass::set_token_pos(TokenPosition token_pos) const { | 4416 void UnresolvedClass::set_token_pos(TokenPosition token_pos) const { |
4420 ASSERT(!token_pos.IsClassifying()); | 4417 ASSERT(!token_pos.IsClassifying()); |
4421 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); | 4418 StoreNonPointer(&raw_ptr()->token_pos_, token_pos); |
4422 } | 4419 } |
4423 | 4420 |
4424 | 4421 |
4425 void UnresolvedClass::set_ident(const String& ident) const { | 4422 void UnresolvedClass::set_ident(const String& ident) const { |
4426 StorePointer(&raw_ptr()->ident_, ident.raw()); | 4423 StorePointer(&raw_ptr()->ident_, ident.raw()); |
4427 } | 4424 } |
4428 | 4425 |
4429 | 4426 |
4430 void UnresolvedClass::set_library_prefix( | 4427 void UnresolvedClass::set_library_or_library_prefix( |
4431 const LibraryPrefix& library_prefix) const { | 4428 const Object& library_prefix) const { |
4432 StorePointer(&raw_ptr()->library_prefix_, library_prefix.raw()); | 4429 StorePointer(&raw_ptr()->library_or_library_prefix_, library_prefix.raw()); |
4433 } | 4430 } |
4434 | 4431 |
4435 | 4432 |
4436 RawString* UnresolvedClass::Name() const { | 4433 RawString* UnresolvedClass::Name() const { |
4437 if (library_prefix() != LibraryPrefix::null()) { | 4434 if (library_or_library_prefix() != Object::null()) { |
4438 Thread* thread = Thread::Current(); | 4435 Thread* thread = Thread::Current(); |
4439 Zone* zone = thread->zone(); | 4436 Zone* zone = thread->zone(); |
4440 const LibraryPrefix& lib_prefix = | 4437 const Object& lib_prefix = |
4441 LibraryPrefix::Handle(zone, library_prefix()); | 4438 Object::Handle(zone, library_or_library_prefix()); |
4442 const String& name = String::Handle(zone, lib_prefix.name()); // Qualifier. | 4439 String& name = String::Handle(zone); // Qualifier. |
| 4440 if (lib_prefix.IsLibraryPrefix()) { |
| 4441 name = LibraryPrefix::Cast(lib_prefix).name(); |
| 4442 } else { |
| 4443 name = Library::Cast(lib_prefix).name(); |
| 4444 } |
4443 GrowableHandlePtrArray<const String> strs(zone, 3); | 4445 GrowableHandlePtrArray<const String> strs(zone, 3); |
4444 strs.Add(name); | 4446 strs.Add(name); |
4445 strs.Add(Symbols::Dot()); | 4447 strs.Add(Symbols::Dot()); |
4446 strs.Add(String::Handle(zone, ident())); | 4448 strs.Add(String::Handle(zone, ident())); |
4447 return Symbols::FromConcatAll(thread, strs); | 4449 return Symbols::FromConcatAll(thread, strs); |
4448 } else { | 4450 } else { |
4449 return ident(); | 4451 return ident(); |
4450 } | 4452 } |
4451 } | 4453 } |
4452 | 4454 |
(...skipping 2643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7096 for (intptr_t i = 1; i < array.Length(); i++) { | 7098 for (intptr_t i = 1; i < array.Length(); i++) { |
7097 ic_data ^= array.At(i); | 7099 ic_data ^= array.At(i); |
7098 if (ic_data.deopt_id() == deopt_id) { | 7100 if (ic_data.deopt_id() == deopt_id) { |
7099 ic_data.AddDeoptReason(reason); | 7101 ic_data.AddDeoptReason(reason); |
7100 } | 7102 } |
7101 } | 7103 } |
7102 } | 7104 } |
7103 | 7105 |
7104 | 7106 |
7105 bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const { | 7107 bool Function::CheckSourceFingerprint(const char* prefix, int32_t fp) const { |
7106 if (SourceFingerprint() != fp) { | 7108 if ((kernel_function() == NULL) && (SourceFingerprint() != fp)) { |
7107 const bool recalculatingFingerprints = false; | 7109 const bool recalculatingFingerprints = false; |
7108 if (recalculatingFingerprints) { | 7110 if (recalculatingFingerprints) { |
7109 // This output can be copied into a file, then used with sed | 7111 // This output can be copied into a file, then used with sed |
7110 // to replace the old values. | 7112 // to replace the old values. |
7111 // sed -i .bak -f /tmp/newkeys runtime/vm/method_recognizer.h | 7113 // sed -i .bak -f /tmp/newkeys runtime/vm/method_recognizer.h |
7112 THR_Print("s/0x%08x/0x%08x/\n", fp, SourceFingerprint()); | 7114 THR_Print("s/0x%08x/0x%08x/\n", fp, SourceFingerprint()); |
7113 } else { | 7115 } else { |
7114 THR_Print( | 7116 THR_Print( |
7115 "FP mismatch while recognizing method %s:" | 7117 "FP mismatch while recognizing method %s:" |
7116 " expecting 0x%08x found 0x%08x\n", | 7118 " expecting 0x%08x found 0x%08x\n", |
(...skipping 3249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10366 RawObject* Library::Evaluate(const String& expr, | 10368 RawObject* Library::Evaluate(const String& expr, |
10367 const Array& param_names, | 10369 const Array& param_names, |
10368 const Array& param_values) const { | 10370 const Array& param_values) const { |
10369 // Evaluate the expression as a static function of the toplevel class. | 10371 // Evaluate the expression as a static function of the toplevel class. |
10370 Class& top_level_class = Class::Handle(toplevel_class()); | 10372 Class& top_level_class = Class::Handle(toplevel_class()); |
10371 ASSERT(top_level_class.is_finalized()); | 10373 ASSERT(top_level_class.is_finalized()); |
10372 return top_level_class.Evaluate(expr, param_names, param_values); | 10374 return top_level_class.Evaluate(expr, param_names, param_values); |
10373 } | 10375 } |
10374 | 10376 |
10375 | 10377 |
10376 void Library::InitNativeWrappersLibrary(Isolate* isolate) { | 10378 void Library::InitNativeWrappersLibrary(Isolate* isolate, bool is_kernel) { |
10377 static const int kNumNativeWrappersClasses = 4; | 10379 static const int kNumNativeWrappersClasses = 4; |
10378 COMPILE_ASSERT((kNumNativeWrappersClasses > 0) && | 10380 COMPILE_ASSERT((kNumNativeWrappersClasses > 0) && |
10379 (kNumNativeWrappersClasses < 10)); | 10381 (kNumNativeWrappersClasses < 10)); |
10380 Thread* thread = Thread::Current(); | 10382 Thread* thread = Thread::Current(); |
10381 Zone* zone = thread->zone(); | 10383 Zone* zone = thread->zone(); |
10382 const String& native_flds_lib_url = Symbols::DartNativeWrappers(); | 10384 const String& native_flds_lib_url = Symbols::DartNativeWrappers(); |
10383 const Library& native_flds_lib = Library::Handle( | 10385 const Library& native_flds_lib = Library::Handle( |
10384 zone, Library::NewLibraryHelper(native_flds_lib_url, false)); | 10386 zone, Library::NewLibraryHelper(native_flds_lib_url, false)); |
10385 const String& native_flds_lib_name = Symbols::DartNativeWrappersLibName(); | 10387 const String& native_flds_lib_name = Symbols::DartNativeWrappersLibName(); |
10386 native_flds_lib.SetName(native_flds_lib_name); | 10388 native_flds_lib.SetName(native_flds_lib_name); |
10387 native_flds_lib.SetLoadRequested(); | 10389 native_flds_lib.SetLoadRequested(); |
10388 native_flds_lib.Register(thread); | 10390 native_flds_lib.Register(thread); |
10389 native_flds_lib.SetLoadInProgress(); | 10391 native_flds_lib.SetLoadInProgress(); |
10390 isolate->object_store()->set_native_wrappers_library(native_flds_lib); | 10392 isolate->object_store()->set_native_wrappers_library(native_flds_lib); |
10391 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass"; | 10393 static const char* const kNativeWrappersClass = "NativeFieldWrapperClass"; |
10392 static const int kNameLength = 25; | 10394 static const int kNameLength = 25; |
10393 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1)); | 10395 ASSERT(kNameLength == (strlen(kNativeWrappersClass) + 1 + 1)); |
10394 char name_buffer[kNameLength]; | 10396 char name_buffer[kNameLength]; |
10395 String& cls_name = String::Handle(zone); | 10397 String& cls_name = String::Handle(zone); |
10396 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) { | 10398 for (int fld_cnt = 1; fld_cnt <= kNumNativeWrappersClasses; fld_cnt++) { |
10397 OS::SNPrint(name_buffer, kNameLength, "%s%d", kNativeWrappersClass, | 10399 OS::SNPrint(name_buffer, kNameLength, "%s%d", kNativeWrappersClass, |
10398 fld_cnt); | 10400 fld_cnt); |
10399 cls_name = Symbols::New(thread, name_buffer); | 10401 cls_name = Symbols::New(thread, name_buffer); |
10400 Class::NewNativeWrapper(native_flds_lib, cls_name, fld_cnt); | 10402 Class::NewNativeWrapper(native_flds_lib, cls_name, fld_cnt); |
10401 } | 10403 } |
10402 native_flds_lib.SetLoaded(); | 10404 // NOTE: If we bootstrap from a Kernel IR file we want to generate the |
| 10405 // synthetic constructors for the native wrapper classes. We leave this up to |
| 10406 // the [KernelReader] who will take care of it later. |
| 10407 if (!is_kernel) { |
| 10408 native_flds_lib.SetLoaded(); |
| 10409 } |
10403 } | 10410 } |
10404 | 10411 |
10405 | 10412 |
10406 // LibraryLookupSet maps URIs to libraries. | 10413 // LibraryLookupSet maps URIs to libraries. |
10407 class LibraryLookupTraits { | 10414 class LibraryLookupTraits { |
10408 public: | 10415 public: |
10409 static const char* Name() { return "LibraryLookupTraits"; } | 10416 static const char* Name() { return "LibraryLookupTraits"; } |
10410 static bool ReportStats() { return false; } | 10417 static bool ReportStats() { return false; } |
10411 | 10418 |
10412 static bool IsMatch(const Object& a, const Object& b) { | 10419 static bool IsMatch(const Object& a, const Object& b) { |
(...skipping 7016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17429 | 17436 |
17430 | 17437 |
17431 RawTypeRef* TypeRef::New(const AbstractType& type) { | 17438 RawTypeRef* TypeRef::New(const AbstractType& type) { |
17432 const TypeRef& result = TypeRef::Handle(TypeRef::New()); | 17439 const TypeRef& result = TypeRef::Handle(TypeRef::New()); |
17433 result.set_type(type); | 17440 result.set_type(type); |
17434 return result.raw(); | 17441 return result.raw(); |
17435 } | 17442 } |
17436 | 17443 |
17437 | 17444 |
17438 const char* TypeRef::ToCString() const { | 17445 const char* TypeRef::ToCString() const { |
| 17446 AbstractType& ref_type = AbstractType::Handle(type()); |
| 17447 if (ref_type.IsNull()) { |
| 17448 return "TypeRef: null"; |
| 17449 } |
17439 const char* type_cstr = | 17450 const char* type_cstr = |
17440 String::Handle(Class::Handle(type_class()).Name()).ToCString(); | 17451 String::Handle(Class::Handle(type_class()).Name()).ToCString(); |
17441 AbstractType& ref_type = AbstractType::Handle(type()); | |
17442 if (ref_type.IsFinalized()) { | 17452 if (ref_type.IsFinalized()) { |
17443 const intptr_t hash = ref_type.Hash(); | 17453 const intptr_t hash = ref_type.Hash(); |
17444 return OS::SCreate(Thread::Current()->zone(), | 17454 return OS::SCreate(Thread::Current()->zone(), |
17445 "TypeRef: %s<...> (@%p H%" Px ")", type_cstr, | 17455 "TypeRef: %s<...> (@%p H%" Px ")", type_cstr, |
17446 ref_type.raw(), hash); | 17456 ref_type.raw(), hash); |
17447 } else { | 17457 } else { |
17448 return OS::SCreate(Thread::Current()->zone(), "TypeRef: %s<...>", | 17458 return OS::SCreate(Thread::Current()->zone(), "TypeRef: %s<...>", |
17449 type_cstr); | 17459 type_cstr); |
17450 } | 17460 } |
17451 } | 17461 } |
(...skipping 5176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
22628 return UserTag::null(); | 22638 return UserTag::null(); |
22629 } | 22639 } |
22630 | 22640 |
22631 | 22641 |
22632 const char* UserTag::ToCString() const { | 22642 const char* UserTag::ToCString() const { |
22633 const String& tag_label = String::Handle(label()); | 22643 const String& tag_label = String::Handle(label()); |
22634 return tag_label.ToCString(); | 22644 return tag_label.ToCString(); |
22635 } | 22645 } |
22636 | 22646 |
22637 } // namespace dart | 22647 } // namespace dart |
OLD | NEW |