Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/isolate_reload.h" | 5 #include "vm/isolate_reload.h" |
| 6 | 6 |
| 7 #include "vm/become.h" | 7 #include "vm/become.h" |
| 8 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
| 9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 953 | 953 |
| 954 #ifdef DEBUG | 954 #ifdef DEBUG |
| 955 VerifyMaps(); | 955 VerifyMaps(); |
| 956 #endif | 956 #endif |
| 957 | 957 |
| 958 { | 958 { |
| 959 TIMELINE_SCOPE(CopyStaticFieldsAndPatchFieldsAndFunctions); | 959 TIMELINE_SCOPE(CopyStaticFieldsAndPatchFieldsAndFunctions); |
| 960 // Copy static field values from the old classes to the new classes. | 960 // Copy static field values from the old classes to the new classes. |
| 961 // Patch fields and functions in the old classes so that they retain | 961 // Patch fields and functions in the old classes so that they retain |
| 962 // the old script. | 962 // the old script. |
| 963 Class& cls = Class::Handle(); | 963 Class& old_cls = Class::Handle(); |
| 964 Class& new_cls = Class::Handle(); | 964 Class& new_cls = Class::Handle(); |
| 965 | 965 Array& functions = Array::Handle(); |
| 966 Function& old_func = Function::Handle(); | |
| 967 String& selector = String::Handle(); | |
| 968 Function& new_func = Function::Handle(); | |
| 969 Instance& old_closure = Instance::Handle(); | |
| 970 Instance& new_closure = Instance::Handle(); | |
| 966 UnorderedHashMap<ClassMapTraits> class_map(class_map_storage_); | 971 UnorderedHashMap<ClassMapTraits> class_map(class_map_storage_); |
| 967 | 972 |
| 968 { | 973 { |
| 969 UnorderedHashMap<ClassMapTraits>::Iterator it(&class_map); | 974 UnorderedHashMap<ClassMapTraits>::Iterator it(&class_map); |
| 970 while (it.MoveNext()) { | 975 while (it.MoveNext()) { |
| 971 const intptr_t entry = it.Current(); | 976 const intptr_t entry = it.Current(); |
| 972 new_cls = Class::RawCast(class_map.GetKey(entry)); | 977 new_cls = Class::RawCast(class_map.GetKey(entry)); |
| 973 cls = Class::RawCast(class_map.GetPayload(entry, 0)); | 978 old_cls = Class::RawCast(class_map.GetPayload(entry, 0)); |
| 974 if (new_cls.raw() != cls.raw()) { | 979 if (new_cls.raw() != old_cls.raw()) { |
| 975 ASSERT(new_cls.is_enum_class() == cls.is_enum_class()); | 980 ASSERT(new_cls.is_enum_class() == old_cls.is_enum_class()); |
| 976 if (new_cls.is_enum_class() && new_cls.is_finalized()) { | 981 if (new_cls.is_enum_class() && new_cls.is_finalized()) { |
| 977 new_cls.ReplaceEnum(cls); | 982 new_cls.ReplaceEnum(old_cls); |
| 978 } else { | 983 } else { |
| 979 new_cls.CopyStaticFieldValues(cls); | 984 new_cls.CopyStaticFieldValues(old_cls); |
| 980 } | 985 } |
| 981 cls.PatchFieldsAndFunctions(); | 986 old_cls.PatchFieldsAndFunctions(); |
| 987 | |
| 988 // Map implicit static closures. | |
| 989 functions = old_cls.functions(); | |
|
Cutch
2016/08/01 22:26:04
please factor this into a function that lives in o
rmacnak
2016/08/02 00:43:45
Done.
| |
| 990 for (intptr_t i = 0; i < functions.Length(); i++) { | |
| 991 old_func ^= functions.At(i); | |
| 992 if (old_func.is_static() && | |
| 993 old_func.HasImplicitClosureFunction()) { | |
| 994 selector = old_func.name(); | |
| 995 new_func = new_cls.LookupFunction(selector); | |
| 996 if (!new_func.IsNull() && new_func.is_static()) { | |
| 997 old_func = old_func.ImplicitClosureFunction(); | |
| 998 old_closure = old_func.ImplicitStaticClosure(); | |
| 999 new_func = new_func.ImplicitClosureFunction(); | |
| 1000 new_closure = new_func.ImplicitStaticClosure(); | |
| 1001 AddBecomeMapping(old_closure, new_closure); | |
| 1002 } | |
| 1003 } | |
| 1004 } | |
|
turnidge
2016/08/01 21:04:28
Perhaps this should be implemented in a separate f
| |
| 982 } | 1005 } |
| 983 } | 1006 } |
| 984 } | 1007 } |
| 985 | 1008 |
| 986 class_map.Release(); | 1009 class_map.Release(); |
| 987 } | 1010 } |
| 988 | 1011 |
| 989 // Copy over certain properties of libraries, e.g. is the library | 1012 // Copy over certain properties of libraries, e.g. is the library |
| 990 // debuggable? | 1013 // debuggable? |
| 991 { | 1014 { |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1586 ASSERT(!super_cls.IsNull()); | 1609 ASSERT(!super_cls.IsNull()); |
| 1587 super_cls.AddDirectSubclass(cls); | 1610 super_cls.AddDirectSubclass(cls); |
| 1588 } | 1611 } |
| 1589 } | 1612 } |
| 1590 } | 1613 } |
| 1591 } | 1614 } |
| 1592 | 1615 |
| 1593 #endif // !PRODUCT | 1616 #endif // !PRODUCT |
| 1594 | 1617 |
| 1595 } // namespace dart | 1618 } // namespace dart |
| OLD | NEW |