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/bootstrap.h" | 5 #include "vm/bootstrap.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 | 8 |
9 #include "vm/bootstrap_natives.h" | 9 #include "vm/bootstrap_natives.h" |
10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 static void Finish(Thread* thread, bool from_kernel) { | 260 static void Finish(Thread* thread, bool from_kernel) { |
261 Bootstrap::SetupNativeResolver(); | 261 Bootstrap::SetupNativeResolver(); |
262 if (!ClassFinalizer::ProcessPendingClasses(from_kernel)) { | 262 if (!ClassFinalizer::ProcessPendingClasses(from_kernel)) { |
263 FATAL("Error in class finalization during bootstrapping."); | 263 FATAL("Error in class finalization during bootstrapping."); |
264 } | 264 } |
265 | 265 |
266 // Eagerly compile the _Closure class as it is the class of all closure | 266 // Eagerly compile the _Closure class as it is the class of all closure |
267 // instances. This allows us to just finalize function types without going | 267 // instances. This allows us to just finalize function types without going |
268 // through the hoops of trying to compile their scope class. | 268 // through the hoops of trying to compile their scope class. |
269 ObjectStore* object_store = thread->isolate()->object_store(); | 269 ObjectStore* object_store = thread->isolate()->object_store(); |
270 Class& cls = Class::Handle(thread->zone(), object_store->closure_class()); | 270 Zone* zone = thread->zone(); |
| 271 Class& cls = Class::Handle(zone, object_store->closure_class()); |
271 Compiler::CompileClass(cls); | 272 Compiler::CompileClass(cls); |
| 273 |
| 274 #if defined(DEBUG) |
| 275 // Verify that closure field offsets are identical in Dart and C++. |
| 276 const Array& fields = Array::Handle(zone, cls.fields()); |
| 277 ASSERT(fields.Length() == 3); |
| 278 Field& field = Field::Handle(zone); |
| 279 field ^= fields.At(0); |
| 280 ASSERT(field.Offset() == Closure::instantiator_offset()); |
| 281 field ^= fields.At(1); |
| 282 ASSERT(field.Offset() == Closure::function_offset()); |
| 283 field ^= fields.At(2); |
| 284 ASSERT(field.Offset() == Closure::context_offset()); |
| 285 #endif // defined(DEBUG) |
| 286 |
272 // Eagerly compile Bool class, bool constants are used from within compiler. | 287 // Eagerly compile Bool class, bool constants are used from within compiler. |
273 cls = object_store->bool_class(); | 288 cls = object_store->bool_class(); |
274 Compiler::CompileClass(cls); | 289 Compiler::CompileClass(cls); |
275 } | 290 } |
276 | 291 |
277 | 292 |
278 static RawError* BootstrapFromSource(Thread* thread) { | 293 static RawError* BootstrapFromSource(Thread* thread) { |
279 Isolate* isolate = thread->isolate(); | 294 Isolate* isolate = thread->isolate(); |
280 Zone* zone = thread->zone(); | 295 Zone* zone = thread->zone(); |
281 String& uri = String::Handle(zone); | 296 String& uri = String::Handle(zone); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 lib.Register(thread); | 407 lib.Register(thread); |
393 isolate->object_store()->set_bootstrap_library(id, lib); | 408 isolate->object_store()->set_bootstrap_library(id, lib); |
394 } | 409 } |
395 } | 410 } |
396 | 411 |
397 return (kernel_program == NULL) ? BootstrapFromSource(thread) | 412 return (kernel_program == NULL) ? BootstrapFromSource(thread) |
398 : BootstrapFromKernel(thread, kernel_program); | 413 : BootstrapFromKernel(thread, kernel_program); |
399 } | 414 } |
400 | 415 |
401 } // namespace dart | 416 } // namespace dart |
OLD | NEW |