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 #if !defined(DART_PRECOMPILED_RUNTIME) | 9 #if !defined(DART_PRECOMPILED_RUNTIME) |
10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 | 41 |
42 void Finish(Thread* thread, bool from_kernel) { | 42 void Finish(Thread* thread, bool from_kernel) { |
43 Bootstrap::SetupNativeResolver(); | 43 Bootstrap::SetupNativeResolver(); |
44 ClassFinalizer::ProcessPendingClasses(from_kernel); | 44 ClassFinalizer::ProcessPendingClasses(from_kernel); |
45 | 45 |
46 // Eagerly compile the _Closure class as it is the class of all closure | 46 // Eagerly compile the _Closure class as it is the class of all closure |
47 // instances. This allows us to just finalize function types without going | 47 // instances. This allows us to just finalize function types without going |
48 // through the hoops of trying to compile their scope class. | 48 // through the hoops of trying to compile their scope class. |
49 ObjectStore* object_store = thread->isolate()->object_store(); | 49 ObjectStore* object_store = thread->isolate()->object_store(); |
50 Class& cls = Class::Handle(thread->zone(), object_store->closure_class()); | 50 Zone* zone = thread->zone(); |
| 51 Class& cls = Class::Handle(zone, object_store->closure_class()); |
51 Compiler::CompileClass(cls); | 52 Compiler::CompileClass(cls); |
| 53 |
| 54 #if defined(DEBUG) |
| 55 // Verify that closure field offsets are identical in Dart and C++. |
| 56 const Array& fields = Array::Handle(zone, cls.fields()); |
| 57 ASSERT(fields.Length() == 3); |
| 58 Field& field = Field::Handle(zone); |
| 59 field ^= fields.At(0); |
| 60 ASSERT(field.Offset() == Closure::instantiator_offset()); |
| 61 field ^= fields.At(1); |
| 62 ASSERT(field.Offset() == Closure::function_offset()); |
| 63 field ^= fields.At(2); |
| 64 ASSERT(field.Offset() == Closure::context_offset()); |
| 65 #endif // defined(DEBUG) |
| 66 |
52 // Eagerly compile Bool class, bool constants are used from within compiler. | 67 // Eagerly compile Bool class, bool constants are used from within compiler. |
53 cls = object_store->bool_class(); | 68 cls = object_store->bool_class(); |
54 Compiler::CompileClass(cls); | 69 Compiler::CompileClass(cls); |
55 } | 70 } |
56 | 71 |
57 | 72 |
58 RawError* BootstrapFromKernel(Thread* thread, kernel::Program* program) { | 73 RawError* BootstrapFromKernel(Thread* thread, kernel::Program* program) { |
59 Zone* zone = thread->zone(); | 74 Zone* zone = thread->zone(); |
60 kernel::KernelReader reader(program); | 75 kernel::KernelReader reader(program); |
61 Isolate* isolate = thread->isolate(); | 76 Isolate* isolate = thread->isolate(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 return BootstrapFromKernel(thread, program); | 134 return BootstrapFromKernel(thread, program); |
120 } | 135 } |
121 #else | 136 #else |
122 RawError* Bootstrap::DoBootstrapping(kernel::Program* program) { | 137 RawError* Bootstrap::DoBootstrapping(kernel::Program* program) { |
123 UNREACHABLE(); | 138 UNREACHABLE(); |
124 return Error::null(); | 139 return Error::null(); |
125 } | 140 } |
126 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 141 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
127 | 142 |
128 } // namespace dart | 143 } // namespace dart |
OLD | NEW |