OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/code_generator.h" | 7 #include "vm/code_generator.h" |
8 #include "vm/flags.h" | 8 #include "vm/flags.h" |
9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 cids->Add(ifc.id()); | 110 cids->Add(ifc.id()); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 | 114 |
115 // Processing ObjectStore::pending_classes_ occurs: | 115 // Processing ObjectStore::pending_classes_ occurs: |
116 // a) when bootstrap process completes (VerifyBootstrapClasses). | 116 // a) when bootstrap process completes (VerifyBootstrapClasses). |
117 // b) after the user classes are loaded (dart_api). | 117 // b) after the user classes are loaded (dart_api). |
118 bool ClassFinalizer::ProcessPendingClasses() { | 118 bool ClassFinalizer::ProcessPendingClasses() { |
119 Isolate* isolate = Isolate::Current(); | 119 Thread* thread = Thread::Current(); |
| 120 Isolate* isolate = thread->isolate(); |
120 ASSERT(isolate != NULL); | 121 ASSERT(isolate != NULL); |
121 HANDLESCOPE(isolate); | 122 HANDLESCOPE(thread); |
122 ObjectStore* object_store = isolate->object_store(); | 123 ObjectStore* object_store = isolate->object_store(); |
123 const Error& error = Error::Handle(isolate, object_store->sticky_error()); | 124 const Error& error = Error::Handle(isolate, object_store->sticky_error()); |
124 if (!error.IsNull()) { | 125 if (!error.IsNull()) { |
125 return false; | 126 return false; |
126 } | 127 } |
127 if (AllClassesFinalized()) { | 128 if (AllClassesFinalized()) { |
128 return true; | 129 return true; |
129 } | 130 } |
130 | 131 |
131 LongJumpScope jump; | 132 LongJumpScope jump; |
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2220 | 2221 |
2221 if (FLAG_trace_class_finalization) { | 2222 if (FLAG_trace_class_finalization) { |
2222 ISL_Print("Done applying mixin members of %s to %s\n", | 2223 ISL_Print("Done applying mixin members of %s to %s\n", |
2223 mixin_cls.ToCString(), | 2224 mixin_cls.ToCString(), |
2224 cls.ToCString()); | 2225 cls.ToCString()); |
2225 } | 2226 } |
2226 } | 2227 } |
2227 | 2228 |
2228 | 2229 |
2229 void ClassFinalizer::FinalizeTypesInClass(const Class& cls) { | 2230 void ClassFinalizer::FinalizeTypesInClass(const Class& cls) { |
2230 HANDLESCOPE(Isolate::Current()); | 2231 Thread* thread = Thread::Current(); |
| 2232 HANDLESCOPE(thread); |
2231 if (cls.is_type_finalized()) { | 2233 if (cls.is_type_finalized()) { |
2232 return; | 2234 return; |
2233 } | 2235 } |
2234 if (FLAG_trace_class_finalization) { | 2236 if (FLAG_trace_class_finalization) { |
2235 ISL_Print("Finalize types in %s\n", cls.ToCString()); | 2237 ISL_Print("Finalize types in %s\n", cls.ToCString()); |
2236 } | 2238 } |
2237 if (!IsSuperCycleFree(cls)) { | 2239 if (!IsSuperCycleFree(cls)) { |
2238 const String& name = String::Handle(cls.Name()); | 2240 const String& name = String::Handle(cls.Name()); |
2239 ReportError(cls, cls.token_pos(), | 2241 ReportError(cls, cls.token_pos(), |
2240 "class '%s' has a cycle in its superclass relationship", | 2242 "class '%s' has a cycle in its superclass relationship", |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2353 // because it has not been compiled yet. There may however be metadata | 2355 // because it has not been compiled yet. There may however be metadata |
2354 // fields because type parameters are parsed before the class body. Since | 2356 // fields because type parameters are parsed before the class body. Since |
2355 // 'ResolveAndFinalizeMemberTypes(cls)' has not been called yet, unfinalized | 2357 // 'ResolveAndFinalizeMemberTypes(cls)' has not been called yet, unfinalized |
2356 // member types could choke the snapshotter. | 2358 // member types could choke the snapshotter. |
2357 ASSERT(Array::Handle(cls.functions()).Length() == 0); | 2359 ASSERT(Array::Handle(cls.functions()).Length() == 0); |
2358 } | 2360 } |
2359 } | 2361 } |
2360 | 2362 |
2361 | 2363 |
2362 void ClassFinalizer::FinalizeClass(const Class& cls) { | 2364 void ClassFinalizer::FinalizeClass(const Class& cls) { |
2363 HANDLESCOPE(Isolate::Current()); | 2365 Thread* thread = Thread::Current(); |
| 2366 HANDLESCOPE(thread); |
2364 if (cls.is_finalized()) { | 2367 if (cls.is_finalized()) { |
2365 return; | 2368 return; |
2366 } | 2369 } |
2367 if (FLAG_trace_class_finalization) { | 2370 if (FLAG_trace_class_finalization) { |
2368 ISL_Print("Finalize %s\n", cls.ToCString()); | 2371 ISL_Print("Finalize %s\n", cls.ToCString()); |
2369 } | 2372 } |
2370 if (cls.is_patch()) { | 2373 if (cls.is_patch()) { |
2371 // The fields and functions of a patch class are copied to the | 2374 // The fields and functions of a patch class are copied to the |
2372 // patched class after parsing. There is nothing to finalize. | 2375 // patched class after parsing. There is nothing to finalize. |
2373 ASSERT(Array::Handle(cls.functions()).Length() == 0); | 2376 ASSERT(Array::Handle(cls.functions()).Length() == 0); |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2983 const String& field_name = String::Handle(field.name()); | 2986 const String& field_name = String::Handle(field.name()); |
2984 ReportError(cls, field.token_pos(), | 2987 ReportError(cls, field.token_pos(), |
2985 "const class '%s' has non-final field '%s'", | 2988 "const class '%s' has non-final field '%s'", |
2986 class_name.ToCString(), field_name.ToCString()); | 2989 class_name.ToCString(), field_name.ToCString()); |
2987 } | 2990 } |
2988 } | 2991 } |
2989 } | 2992 } |
2990 | 2993 |
2991 | 2994 |
2992 void ClassFinalizer::PrintClassInformation(const Class& cls) { | 2995 void ClassFinalizer::PrintClassInformation(const Class& cls) { |
2993 HANDLESCOPE(Isolate::Current()); | 2996 Thread* thread = Thread::Current(); |
| 2997 HANDLESCOPE(thread); |
2994 const String& class_name = String::Handle(cls.Name()); | 2998 const String& class_name = String::Handle(cls.Name()); |
2995 ISL_Print("class '%s'", class_name.ToCString()); | 2999 ISL_Print("class '%s'", class_name.ToCString()); |
2996 const Library& library = Library::Handle(cls.library()); | 3000 const Library& library = Library::Handle(cls.library()); |
2997 if (!library.IsNull()) { | 3001 if (!library.IsNull()) { |
2998 ISL_Print(" library '%s%s':\n", | 3002 ISL_Print(" library '%s%s':\n", |
2999 String::Handle(library.url()).ToCString(), | 3003 String::Handle(library.url()).ToCString(), |
3000 String::Handle(library.private_key()).ToCString()); | 3004 String::Handle(library.private_key()).ToCString()); |
3001 } else { | 3005 } else { |
3002 ISL_Print(" (null library):\n"); | 3006 ISL_Print(" (null library):\n"); |
3003 } | 3007 } |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3216 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3220 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
3217 field ^= fields_array.At(0); | 3221 field ^= fields_array.At(0); |
3218 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3222 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
3219 name ^= field.name(); | 3223 name ^= field.name(); |
3220 expected_name ^= String::New("_data"); | 3224 expected_name ^= String::New("_data"); |
3221 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3225 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
3222 #endif | 3226 #endif |
3223 } | 3227 } |
3224 | 3228 |
3225 } // namespace dart | 3229 } // namespace dart |
OLD | NEW |