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/class_finalizer.h" | 5 #include "vm/class_finalizer.h" |
6 | 6 |
7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
8 #include "vm/heap.h" | 8 #include "vm/heap.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 cls = object_store->mint_class(); | 215 cls = object_store->mint_class(); |
216 ASSERT(Mint::InstanceSize() == cls.instance_size()); | 216 ASSERT(Mint::InstanceSize() == cls.instance_size()); |
217 cls = object_store->bigint_class(); | 217 cls = object_store->bigint_class(); |
218 ASSERT(Bigint::InstanceSize() == cls.instance_size()); | 218 ASSERT(Bigint::InstanceSize() == cls.instance_size()); |
219 cls = object_store->bool_class(); | 219 cls = object_store->bool_class(); |
220 ASSERT(Bool::InstanceSize() == cls.instance_size()); | 220 ASSERT(Bool::InstanceSize() == cls.instance_size()); |
221 cls = object_store->array_class(); | 221 cls = object_store->array_class(); |
222 ASSERT(Array::InstanceSize() == cls.instance_size()); | 222 ASSERT(Array::InstanceSize() == cls.instance_size()); |
223 cls = object_store->immutable_array_class(); | 223 cls = object_store->immutable_array_class(); |
224 ASSERT(ImmutableArray::InstanceSize() == cls.instance_size()); | 224 ASSERT(ImmutableArray::InstanceSize() == cls.instance_size()); |
225 cls = object_store->internal_byte_array_class(); | 225 cls = object_store->uint8_array_class(); |
226 ASSERT(InternalByteArray::InstanceSize() == cls.instance_size()); | 226 ASSERT(Uint8Array::InstanceSize() == cls.instance_size()); |
227 cls = object_store->external_byte_array_class(); | 227 cls = object_store->int16_array_class(); |
228 ASSERT(ExternalByteArray::InstanceSize() == cls.instance_size()); | 228 ASSERT(Int16Array::InstanceSize() == cls.instance_size()); |
| 229 cls = object_store->uint16_array_class(); |
| 230 ASSERT(Uint16Array::InstanceSize() == cls.instance_size()); |
| 231 cls = object_store->int32_array_class(); |
| 232 ASSERT(Int32Array::InstanceSize() == cls.instance_size()); |
| 233 cls = object_store->uint32_array_class(); |
| 234 ASSERT(Uint32Array::InstanceSize() == cls.instance_size()); |
| 235 cls = object_store->int64_array_class(); |
| 236 ASSERT(Int64Array::InstanceSize() == cls.instance_size()); |
| 237 cls = object_store->uint64_array_class(); |
| 238 ASSERT(Uint64Array::InstanceSize() == cls.instance_size()); |
| 239 cls = object_store->float32_array_class(); |
| 240 ASSERT(Float32Array::InstanceSize() == cls.instance_size()); |
| 241 cls = object_store->float64_array_class(); |
| 242 ASSERT(Float64Array::InstanceSize() == cls.instance_size()); |
| 243 cls = object_store->external_int8_array_class(); |
| 244 ASSERT(ExternalInt8Array::InstanceSize() == cls.instance_size()); |
| 245 cls = object_store->external_uint8_array_class(); |
| 246 ASSERT(ExternalUint8Array::InstanceSize() == cls.instance_size()); |
| 247 cls = object_store->external_int16_array_class(); |
| 248 ASSERT(ExternalInt16Array::InstanceSize() == cls.instance_size()); |
| 249 cls = object_store->external_uint16_array_class(); |
| 250 ASSERT(ExternalUint16Array::InstanceSize() == cls.instance_size()); |
| 251 cls = object_store->external_int32_array_class(); |
| 252 ASSERT(ExternalInt32Array::InstanceSize() == cls.instance_size()); |
| 253 cls = object_store->external_uint32_array_class(); |
| 254 ASSERT(ExternalUint32Array::InstanceSize() == cls.instance_size()); |
| 255 cls = object_store->external_int64_array_class(); |
| 256 ASSERT(ExternalInt64Array::InstanceSize() == cls.instance_size()); |
| 257 cls = object_store->external_uint64_array_class(); |
| 258 ASSERT(ExternalUint64Array::InstanceSize() == cls.instance_size()); |
| 259 cls = object_store->external_float32_array_class(); |
| 260 ASSERT(ExternalFloat32Array::InstanceSize() == cls.instance_size()); |
| 261 cls = object_store->external_float64_array_class(); |
| 262 ASSERT(ExternalFloat64Array::InstanceSize() == cls.instance_size()); |
229 #endif // defined(DEBUG) | 263 #endif // defined(DEBUG) |
230 | 264 |
231 // Remember the currently pending classes. | 265 // Remember the currently pending classes. |
232 const GrowableObjectArray& class_array = | 266 const GrowableObjectArray& class_array = |
233 GrowableObjectArray::Handle(object_store->pending_classes()); | 267 GrowableObjectArray::Handle(object_store->pending_classes()); |
234 for (intptr_t i = 0; i < class_array.Length(); i++) { | 268 for (intptr_t i = 0; i < class_array.Length(); i++) { |
235 // TODO(iposva): Add real checks. | 269 // TODO(iposva): Add real checks. |
236 cls ^= class_array.At(i); | 270 cls ^= class_array.At(i); |
237 if (cls.is_finalized() || cls.is_prefinalized()) { | 271 if (cls.is_finalized() || cls.is_prefinalized()) { |
238 // Pre-finalized bootstrap classes must not define any fields. | 272 // Pre-finalized bootstrap classes must not define any fields. |
239 ASSERT(Array::Handle(cls.fields()).Length() == 0); | 273 ASSERT(!cls.HasInstanceFields()); |
240 } | 274 } |
241 } | 275 } |
242 | 276 |
243 // Finalize classes that aren't pre-finalized by Object::Init(). | 277 // Finalize classes that aren't pre-finalized by Object::Init(). |
244 if (!FinalizePendingClasses()) { | 278 if (!FinalizePendingClasses()) { |
245 // TODO(srdjan): Exit like a real VM instead. | 279 // TODO(srdjan): Exit like a real VM instead. |
246 const Error& err = Error::Handle(object_store->sticky_error()); | 280 const Error& err = Error::Handle(object_store->sticky_error()); |
247 OS::PrintErr("Could not verify bootstrap classes : %s\n", | 281 OS::PrintErr("Could not verify bootstrap classes : %s\n", |
248 err.ToErrorCString()); | 282 err.ToErrorCString()); |
249 OS::Exit(255); | 283 OS::Exit(255); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 Class::Handle(core_impl_lib.LookupClass(integer_implementation_name)); | 346 Class::Handle(core_impl_lib.LookupClass(integer_implementation_name)); |
313 const String& growable_object_array_name = | 347 const String& growable_object_array_name = |
314 String::Handle(String::NewSymbol("GrowableObjectArray")); | 348 String::Handle(String::NewSymbol("GrowableObjectArray")); |
315 const Class& growable_object_array_class = | 349 const Class& growable_object_array_class = |
316 Class::Handle(core_impl_lib.LookupClass(growable_object_array_name)); | 350 Class::Handle(core_impl_lib.LookupClass(growable_object_array_name)); |
317 if ((super_class.raw() == object_store->bool_class()) || | 351 if ((super_class.raw() == object_store->bool_class()) || |
318 (super_class.raw() == object_store->double_class()) || | 352 (super_class.raw() == object_store->double_class()) || |
319 (super_class.raw() == object_store->array_class()) || | 353 (super_class.raw() == object_store->array_class()) || |
320 (super_class.raw() == object_store->immutable_array_class()) || | 354 (super_class.raw() == object_store->immutable_array_class()) || |
321 (super_class.raw() == growable_object_array_class.raw()) || | 355 (super_class.raw() == growable_object_array_class.raw()) || |
322 (super_class.raw() == object_store->internal_byte_array_class()) || | 356 (super_class.raw() == object_store->int8_array_class()) || |
323 (super_class.raw() == object_store->external_byte_array_class()) || | 357 (super_class.raw() == object_store->uint8_array_class()) || |
| 358 (super_class.raw() == object_store->int16_array_class()) || |
| 359 (super_class.raw() == object_store->uint16_array_class()) || |
| 360 (super_class.raw() == object_store->int32_array_class()) || |
| 361 (super_class.raw() == object_store->uint32_array_class()) || |
| 362 (super_class.raw() == object_store->int64_array_class()) || |
| 363 (super_class.raw() == object_store->uint64_array_class()) || |
| 364 (super_class.raw() == object_store->float32_array_class()) || |
| 365 (super_class.raw() == object_store->float64_array_class()) || |
| 366 (super_class.raw() == object_store->external_int8_array_class()) || |
| 367 (super_class.raw() == object_store->external_uint8_array_class()) || |
| 368 (super_class.raw() == object_store->external_int16_array_class()) || |
| 369 (super_class.raw() == object_store->external_uint16_array_class()) || |
| 370 (super_class.raw() == object_store->external_int32_array_class()) || |
| 371 (super_class.raw() == object_store->external_uint32_array_class()) || |
| 372 (super_class.raw() == object_store->external_int64_array_class()) || |
| 373 (super_class.raw() == object_store->external_uint64_array_class()) || |
| 374 (super_class.raw() == object_store->external_float32_array_class()) || |
| 375 (super_class.raw() == object_store->external_float64_array_class()) || |
324 (super_class.raw() == integer_implementation_class.raw()) || | 376 (super_class.raw() == integer_implementation_class.raw()) || |
325 (super_class.raw() == object_store->smi_class()) || | 377 (super_class.raw() == object_store->smi_class()) || |
326 (super_class.raw() == object_store->mint_class()) || | 378 (super_class.raw() == object_store->mint_class()) || |
327 (super_class.raw() == object_store->bigint_class()) || | 379 (super_class.raw() == object_store->bigint_class()) || |
328 (super_class.raw() == object_store->one_byte_string_class()) || | 380 (super_class.raw() == object_store->one_byte_string_class()) || |
329 (super_class.raw() == object_store->two_byte_string_class()) || | 381 (super_class.raw() == object_store->two_byte_string_class()) || |
330 (super_class.raw() == object_store->four_byte_string_class())) { | 382 (super_class.raw() == object_store->four_byte_string_class())) { |
331 const Script& script = Script::Handle(cls.script()); | 383 const Script& script = Script::Handle(cls.script()); |
332 ReportError(script, cls.token_index(), | 384 ReportError(script, cls.token_index(), |
333 "'%s' is not allowed to extend '%s'", | 385 "'%s' is not allowed to extend '%s'", |
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 void ClassFinalizer::ReportError(const char* format, ...) { | 1414 void ClassFinalizer::ReportError(const char* format, ...) { |
1363 va_list args; | 1415 va_list args; |
1364 va_start(args, format); | 1416 va_start(args, format); |
1365 const Error& error = Error::Handle( | 1417 const Error& error = Error::Handle( |
1366 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); | 1418 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); |
1367 va_end(args); | 1419 va_end(args); |
1368 ReportError(error); | 1420 ReportError(error); |
1369 } | 1421 } |
1370 | 1422 |
1371 } // namespace dart | 1423 } // namespace dart |
OLD | NEW |