OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 3051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3062 object->Print(os); | 3062 object->Print(os); |
3063 } | 3063 } |
3064 #endif | 3064 #endif |
3065 } | 3065 } |
3066 | 3066 |
3067 } // namespace | 3067 } // namespace |
3068 | 3068 |
3069 void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map, | 3069 void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map, |
3070 int expected_additional_properties) { | 3070 int expected_additional_properties) { |
3071 if (object->map() == *new_map) return; | 3071 if (object->map() == *new_map) return; |
3072 // If this object is a prototype (the callee will check), invalidate any | |
3073 // prototype chains involving it. | |
3074 InvalidatePrototypeChains(object->map()); | |
3075 Handle<Map> old_map(object->map()); | 3072 Handle<Map> old_map(object->map()); |
| 3073 if (old_map->is_prototype_map()) { |
| 3074 // If this object is a prototype (the callee will check), invalidate any |
| 3075 // prototype chains involving it. |
| 3076 InvalidatePrototypeChains(object->map()); |
3076 | 3077 |
3077 // If the map was registered with its prototype before, ensure that it | 3078 // If the map was registered with its prototype before, ensure that it |
3078 // registers with its new prototype now. This preserves the invariant that | 3079 // registers with its new prototype now. This preserves the invariant that |
3079 // when a map on a prototype chain is registered with its prototype, then | 3080 // when a map on a prototype chain is registered with its prototype, then |
3080 // all prototypes further up the chain are also registered with their | 3081 // all prototypes further up the chain are also registered with their |
3081 // respective prototypes. | 3082 // respective prototypes. |
3082 UpdatePrototypeUserRegistration(old_map, new_map, new_map->GetIsolate()); | 3083 UpdatePrototypeUserRegistration(old_map, new_map, new_map->GetIsolate()); |
| 3084 } |
3083 | 3085 |
3084 if (old_map->is_dictionary_map()) { | 3086 if (old_map->is_dictionary_map()) { |
3085 // For slow-to-fast migrations JSObject::MigrateSlowToFast() | 3087 // For slow-to-fast migrations JSObject::MigrateSlowToFast() |
3086 // must be used instead. | 3088 // must be used instead. |
3087 CHECK(new_map->is_dictionary_map()); | 3089 CHECK(new_map->is_dictionary_map()); |
3088 | 3090 |
3089 // Slow-to-slow migration is trivial. | 3091 // Slow-to-slow migration is trivial. |
3090 object->set_map(*new_map); | 3092 object->set_map(*new_map); |
3091 } else if (!new_map->is_dictionary_map()) { | 3093 } else if (!new_map->is_dictionary_map()) { |
3092 MigrateFastToFast(object, new_map); | 3094 MigrateFastToFast(object, new_map); |
(...skipping 16791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19884 if (cell->value() != *new_value) { | 19886 if (cell->value() != *new_value) { |
19885 cell->set_value(*new_value); | 19887 cell->set_value(*new_value); |
19886 Isolate* isolate = cell->GetIsolate(); | 19888 Isolate* isolate = cell->GetIsolate(); |
19887 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19889 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19888 isolate, DependentCode::kPropertyCellChangedGroup); | 19890 isolate, DependentCode::kPropertyCellChangedGroup); |
19889 } | 19891 } |
19890 } | 19892 } |
19891 | 19893 |
19892 } // namespace internal | 19894 } // namespace internal |
19893 } // namespace v8 | 19895 } // namespace v8 |
OLD | NEW |