| OLD | NEW |
| 1 // Copyright (c) 2012, 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/flags.h" | 7 #include "vm/flags.h" |
| 8 #include "vm/heap.h" | 8 #include "vm/heap.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
| 11 #include "vm/object_store.h" | 11 #include "vm/object_store.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 | 32 |
| 33 // Removes optimized code once we load more classes, since --use_cha based | 33 // Removes optimized code once we load more classes, since --use_cha based |
| 34 // optimizations may have become invalid. | 34 // optimizations may have become invalid. |
| 35 // Only methods which owner classes where subclasses can be invalid. | 35 // Only methods which owner classes where subclasses can be invalid. |
| 36 // TODO(srdjan): Be even more precise by recording the exact CHA optimization. | 36 // TODO(srdjan): Be even more precise by recording the exact CHA optimization. |
| 37 static void RemoveOptimizedCode( | 37 static void RemoveOptimizedCode( |
| 38 const GrowableArray<intptr_t>& added_subclasses_to_cids) { | 38 const GrowableArray<intptr_t>& added_subclasses_to_cids) { |
| 39 ASSERT(FLAG_use_cha); | 39 ASSERT(FLAG_use_cha); |
| 40 if (added_subclasses_to_cids.is_empty()) return; | 40 if (added_subclasses_to_cids.is_empty()) return; |
| 41 // TODO(regis): Reenable this code for arm and mips when possible. |
| 42 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
| 41 // Deoptimize all live frames. | 43 // Deoptimize all live frames. |
| 42 DeoptimizeIfOwner(added_subclasses_to_cids); | 44 DeoptimizeIfOwner(added_subclasses_to_cids); |
| 43 // Switch all functions' code to unoptimized. | 45 // Switch all functions' code to unoptimized. |
| 44 const ClassTable& class_table = *Isolate::Current()->class_table(); | 46 const ClassTable& class_table = *Isolate::Current()->class_table(); |
| 45 Class& cls = Class::Handle(); | 47 Class& cls = Class::Handle(); |
| 46 Array& array = Array::Handle(); | 48 Array& array = Array::Handle(); |
| 47 Function& function = Function::Handle(); | 49 Function& function = Function::Handle(); |
| 48 for (intptr_t i = 0; i < added_subclasses_to_cids.length(); i++) { | 50 for (intptr_t i = 0; i < added_subclasses_to_cids.length(); i++) { |
| 49 intptr_t cid = added_subclasses_to_cids[i]; | 51 intptr_t cid = added_subclasses_to_cids[i]; |
| 50 cls = class_table.At(cid); | 52 cls = class_table.At(cid); |
| 51 ASSERT(!cls.IsNull()); | 53 ASSERT(!cls.IsNull()); |
| 52 array = cls.functions(); | 54 array = cls.functions(); |
| 53 intptr_t num_functions = array.IsNull() ? 0 : array.Length(); | 55 intptr_t num_functions = array.IsNull() ? 0 : array.Length(); |
| 54 for (intptr_t f = 0; f < num_functions; f++) { | 56 for (intptr_t f = 0; f < num_functions; f++) { |
| 55 function ^= array.At(f); | 57 function ^= array.At(f); |
| 56 ASSERT(!function.IsNull()); | 58 ASSERT(!function.IsNull()); |
| 57 if (function.HasOptimizedCode()) { | 59 if (function.HasOptimizedCode()) { |
| 58 function.SwitchToUnoptimizedCode(); | 60 function.SwitchToUnoptimizedCode(); |
| 59 } | 61 } |
| 60 } | 62 } |
| 61 } | 63 } |
| 64 #endif |
| 62 } | 65 } |
| 63 | 66 |
| 64 | 67 |
| 65 void AddSuperType(const Type& type, | 68 void AddSuperType(const Type& type, |
| 66 GrowableArray<intptr_t>* finalized_super_classes) { | 69 GrowableArray<intptr_t>* finalized_super_classes) { |
| 67 ASSERT(type.HasResolvedTypeClass()); | 70 ASSERT(type.HasResolvedTypeClass()); |
| 68 if (type.IsObjectType()) { | 71 if (type.IsObjectType()) { |
| 69 return; | 72 return; |
| 70 } | 73 } |
| 71 const Class& cls = Class::Handle(type.type_class()); | 74 const Class& cls = Class::Handle(type.type_class()); |
| (...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1577 void ClassFinalizer::ReportError(const char* format, ...) { | 1580 void ClassFinalizer::ReportError(const char* format, ...) { |
| 1578 va_list args; | 1581 va_list args; |
| 1579 va_start(args, format); | 1582 va_start(args, format); |
| 1580 const Error& error = Error::Handle( | 1583 const Error& error = Error::Handle( |
| 1581 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); | 1584 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); |
| 1582 va_end(args); | 1585 va_end(args); |
| 1583 ReportError(error); | 1586 ReportError(error); |
| 1584 } | 1587 } |
| 1585 | 1588 |
| 1586 } // namespace dart | 1589 } // namespace dart |
| OLD | NEW |