| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 HANDLESCOPE(isolate); | 114 HANDLESCOPE(isolate); |
| 115 ObjectStore* object_store = isolate->object_store(); | 115 ObjectStore* object_store = isolate->object_store(); |
| 116 const Error& error = Error::Handle(isolate, object_store->sticky_error()); | 116 const Error& error = Error::Handle(isolate, object_store->sticky_error()); |
| 117 if (!error.IsNull()) { | 117 if (!error.IsNull()) { |
| 118 return false; | 118 return false; |
| 119 } | 119 } |
| 120 if (AllClassesFinalized()) { | 120 if (AllClassesFinalized()) { |
| 121 return true; | 121 return true; |
| 122 } | 122 } |
| 123 | 123 |
| 124 LongJump* base = isolate->long_jump_base(); | 124 LongJumpScope jump; |
| 125 LongJump jump; | |
| 126 isolate->set_long_jump_base(&jump); | |
| 127 if (setjmp(*jump.Set()) == 0) { | 125 if (setjmp(*jump.Set()) == 0) { |
| 128 GrowableObjectArray& class_array = GrowableObjectArray::Handle(); | 126 GrowableObjectArray& class_array = GrowableObjectArray::Handle(); |
| 129 class_array = object_store->pending_classes(); | 127 class_array = object_store->pending_classes(); |
| 130 ASSERT(!class_array.IsNull()); | 128 ASSERT(!class_array.IsNull()); |
| 131 Class& cls = Class::Handle(); | 129 Class& cls = Class::Handle(); |
| 132 // First resolve all superclasses. | 130 // First resolve all superclasses. |
| 133 for (intptr_t i = 0; i < class_array.Length(); i++) { | 131 for (intptr_t i = 0; i < class_array.Length(); i++) { |
| 134 cls ^= class_array.At(i); | 132 cls ^= class_array.At(i); |
| 135 GrowableArray<intptr_t> visited_interfaces; | 133 GrowableArray<intptr_t> visited_interfaces; |
| 136 ResolveSuperTypeAndInterfaces(cls, &visited_interfaces); | 134 ResolveSuperTypeAndInterfaces(cls, &visited_interfaces); |
| 137 } | 135 } |
| 138 // Finalize all classes. | 136 // Finalize all classes. |
| 139 for (intptr_t i = 0; i < class_array.Length(); i++) { | 137 for (intptr_t i = 0; i < class_array.Length(); i++) { |
| 140 cls ^= class_array.At(i); | 138 cls ^= class_array.At(i); |
| 141 FinalizeTypesInClass(cls); | 139 FinalizeTypesInClass(cls); |
| 142 } | 140 } |
| 143 if (FLAG_print_classes) { | 141 if (FLAG_print_classes) { |
| 144 for (intptr_t i = 0; i < class_array.Length(); i++) { | 142 for (intptr_t i = 0; i < class_array.Length(); i++) { |
| 145 cls ^= class_array.At(i); | 143 cls ^= class_array.At(i); |
| 146 PrintClassInformation(cls); | 144 PrintClassInformation(cls); |
| 147 } | 145 } |
| 148 } | 146 } |
| 149 // Clear pending classes array. | 147 // Clear pending classes array. |
| 150 class_array = GrowableObjectArray::New(); | 148 class_array = GrowableObjectArray::New(); |
| 151 object_store->set_pending_classes(class_array); | 149 object_store->set_pending_classes(class_array); |
| 152 VerifyImplicitFieldOffsets(); // Verification after an error may fail. | 150 VerifyImplicitFieldOffsets(); // Verification after an error may fail. |
| 153 } else { | 151 } else { |
| 154 retval = false; | 152 retval = false; |
| 155 } | 153 } |
| 156 isolate->set_long_jump_base(base); | |
| 157 return retval; | 154 return retval; |
| 158 } | 155 } |
| 159 | 156 |
| 160 | 157 |
| 161 // Adds all interfaces of cls into 'collected'. Duplicate entries may occur. | 158 // Adds all interfaces of cls into 'collected'. Duplicate entries may occur. |
| 162 // No cycles are allowed. | 159 // No cycles are allowed. |
| 163 void ClassFinalizer::CollectInterfaces(const Class& cls, | 160 void ClassFinalizer::CollectInterfaces(const Class& cls, |
| 164 const GrowableObjectArray& collected) { | 161 const GrowableObjectArray& collected) { |
| 165 const Array& interface_array = Array::Handle(cls.interfaces()); | 162 const Array& interface_array = Array::Handle(cls.interfaces()); |
| 166 AbstractType& interface = AbstractType::Handle(); | 163 AbstractType& interface = AbstractType::Handle(); |
| (...skipping 2636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2803 expected_name ^= String::New("_offset"); | 2800 expected_name ^= String::New("_offset"); |
| 2804 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); | 2801 ASSERT(String::EqualsIgnoringPrivateKey(name, expected_name)); |
| 2805 field ^= fields_array.At(2); | 2802 field ^= fields_array.At(2); |
| 2806 ASSERT(field.Offset() == TypedDataView::length_offset()); | 2803 ASSERT(field.Offset() == TypedDataView::length_offset()); |
| 2807 name ^= field.name(); | 2804 name ^= field.name(); |
| 2808 ASSERT(name.Equals("length")); | 2805 ASSERT(name.Equals("length")); |
| 2809 #endif | 2806 #endif |
| 2810 } | 2807 } |
| 2811 | 2808 |
| 2812 } // namespace dart | 2809 } // namespace dart |
| OLD | NEW |