| 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 2409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2420 } | 2420 } |
| 2421 // A top level class is parsed eagerly so just finalize it. | 2421 // A top level class is parsed eagerly so just finalize it. |
| 2422 if (cls.IsTopLevel()) { | 2422 if (cls.IsTopLevel()) { |
| 2423 FinalizeClass(cls); | 2423 FinalizeClass(cls); |
| 2424 } else { | 2424 } else { |
| 2425 // This class should not contain any functions or user-defined fields yet, | 2425 // This class should not contain any functions or user-defined fields yet, |
| 2426 // because it has not been compiled yet. There may however be metadata | 2426 // because it has not been compiled yet. There may however be metadata |
| 2427 // fields because type parameters are parsed before the class body. Since | 2427 // fields because type parameters are parsed before the class body. Since |
| 2428 // 'ResolveAndFinalizeMemberTypes(cls)' has not been called yet, unfinalized | 2428 // 'ResolveAndFinalizeMemberTypes(cls)' has not been called yet, unfinalized |
| 2429 // member types could choke the snapshotter. | 2429 // member types could choke the snapshotter. |
| 2430 ASSERT(Array::Handle(cls.functions()).Length() == 0); | 2430 // Or |
| 2431 // if the class is being refinalized because a patch is being applied |
| 2432 // after the class has been finalized then it is ok for the class to have |
| 2433 // functions. |
| 2434 ASSERT((Array::Handle(cls.functions()).Length() == 0) || |
| 2435 cls.is_refinalize_after_patch()); |
| 2431 } | 2436 } |
| 2432 } | 2437 } |
| 2433 | 2438 |
| 2434 | 2439 |
| 2435 void ClassFinalizer::FinalizeClass(const Class& cls) { | 2440 void ClassFinalizer::FinalizeClass(const Class& cls) { |
| 2436 Thread* thread = Thread::Current(); | 2441 Thread* thread = Thread::Current(); |
| 2437 HANDLESCOPE(thread); | 2442 HANDLESCOPE(thread); |
| 2438 ASSERT(cls.is_type_finalized()); | 2443 ASSERT(cls.is_type_finalized()); |
| 2439 if (cls.is_finalized()) { | 2444 if (cls.is_finalized()) { |
| 2440 return; | 2445 return; |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3305 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); | 3310 ASSERT(fields_array.Length() == ByteBuffer::NumberOfFields()); |
| 3306 field ^= fields_array.At(0); | 3311 field ^= fields_array.At(0); |
| 3307 ASSERT(field.Offset() == ByteBuffer::data_offset()); | 3312 ASSERT(field.Offset() == ByteBuffer::data_offset()); |
| 3308 name ^= field.name(); | 3313 name ^= field.name(); |
| 3309 expected_name ^= String::New("_data"); | 3314 expected_name ^= String::New("_data"); |
| 3310 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 3315 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
| 3311 #endif | 3316 #endif |
| 3312 } | 3317 } |
| 3313 | 3318 |
| 3314 } // namespace dart | 3319 } // namespace dart |
| OLD | NEW |