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