Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 8901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8912 #endif | 8912 #endif |
| 8913 | 8913 |
| 8914 return result; | 8914 return result; |
| 8915 } | 8915 } |
| 8916 | 8916 |
| 8917 | 8917 |
| 8918 Handle<Map> Map::CopyInitialMap(Handle<Map> map, int instance_size, | 8918 Handle<Map> Map::CopyInitialMap(Handle<Map> map, int instance_size, |
| 8919 int in_object_properties, | 8919 int in_object_properties, |
| 8920 int unused_property_fields) { | 8920 int unused_property_fields) { |
| 8921 #ifdef DEBUG | 8921 #ifdef DEBUG |
| 8922 Object* constructor = map->GetConstructor(); | 8922 Isolate* isolate = map->GetIsolate(); |
| 8923 DCHECK(constructor->IsJSFunction()); | 8923 if (*isolate->strict_function_map() != *map && |
| 8924 DCHECK_EQ(*map, JSFunction::cast(constructor)->initial_map()); | 8924 *isolate->strong_function_map() != *map && |
| 8925 *isolate->strict_generator_function_map() != *map && | |
| 8926 *isolate->strong_generator_function_map() != *map) { | |
| 8927 // Strict and strong function maps have Function as a constructor but the | |
| 8928 // Function's initial map is a sloppy function map. Same holds for | |
| 8929 // GeneratorFunction and its initial map. | |
| 8930 Object* constructor = map->GetConstructor(); | |
| 8931 DCHECK(constructor->IsJSFunction()); | |
| 8932 DCHECK_EQ(*map, JSFunction::cast(constructor)->initial_map()); | |
|
Toon Verwaest
2015/12/09 21:40:03
so initial_map == map || map == strict_function_ma
Igor Sheludko
2015/12/10 10:50:41
Done.
| |
| 8933 } | |
| 8925 #endif | 8934 #endif |
| 8926 // Initial maps must always own their descriptors and it's descriptor array | 8935 // Initial maps must always own their descriptors and it's descriptor array |
| 8927 // does not contain descriptors that do not belong to the map. | 8936 // does not contain descriptors that do not belong to the map. |
| 8928 DCHECK(map->owns_descriptors()); | 8937 DCHECK(map->owns_descriptors()); |
| 8929 DCHECK_EQ(map->NumberOfOwnDescriptors(), | 8938 DCHECK_EQ(map->NumberOfOwnDescriptors(), |
| 8930 map->instance_descriptors()->number_of_descriptors()); | 8939 map->instance_descriptors()->number_of_descriptors()); |
| 8931 | 8940 |
| 8932 Handle<Map> result = RawCopy(map, instance_size); | 8941 Handle<Map> result = RawCopy(map, instance_size); |
| 8933 | 8942 |
| 8934 // Please note instance_type and instance_size are set when allocated. | 8943 // Please note instance_type and instance_size are set when allocated. |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9179 return new_map; | 9188 return new_map; |
| 9180 } | 9189 } |
| 9181 | 9190 |
| 9182 // Create a new free-floating map only if we are not allowed to store it. | 9191 // Create a new free-floating map only if we are not allowed to store it. |
| 9183 Handle<Map> new_map = Copy(map, "CopyAsElementsKind"); | 9192 Handle<Map> new_map = Copy(map, "CopyAsElementsKind"); |
| 9184 new_map->set_elements_kind(kind); | 9193 new_map->set_elements_kind(kind); |
| 9185 return new_map; | 9194 return new_map; |
| 9186 } | 9195 } |
| 9187 | 9196 |
| 9188 | 9197 |
| 9198 Handle<Map> Map::AsLanguageMode(Handle<Map> initial_map, | |
| 9199 LanguageMode language_mode, FunctionKind kind) { | |
| 9200 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); | |
| 9201 // Initial map for sloppy mode function is stored in the function | |
| 9202 // constructor. Initial maps for strict and strong modes are cached as | |
| 9203 // special transitions using |strict_function_transition_symbol| and | |
| 9204 // |strong_function_transition_symbol| respectively as a key. | |
| 9205 if (language_mode == SLOPPY) return initial_map; | |
| 9206 Isolate* isolate = initial_map->GetIsolate(); | |
| 9207 Factory* factory = isolate->factory(); | |
| 9208 Handle<Symbol> transition_symbol; | |
| 9209 | |
| 9210 int map_index = Context::FunctionMapIndex(language_mode, kind); | |
| 9211 Handle<Map> function_map( | |
| 9212 Map::cast(isolate->native_context()->get(map_index))); | |
| 9213 | |
| 9214 switch (language_mode) { | |
| 9215 case STRICT: | |
| 9216 transition_symbol = factory->strict_function_transition_symbol(); | |
| 9217 break; | |
| 9218 case STRONG: | |
| 9219 transition_symbol = factory->strong_function_transition_symbol(); | |
| 9220 break; | |
| 9221 default: | |
| 9222 UNREACHABLE(); | |
| 9223 break; | |
| 9224 } | |
| 9225 Map* maybe_transition = | |
| 9226 TransitionArray::SearchSpecial(*initial_map, *transition_symbol); | |
| 9227 if (maybe_transition != NULL) { | |
| 9228 return handle(maybe_transition, isolate); | |
| 9229 } | |
| 9230 | |
| 9231 // Create new map taking descriptors from the |function_map| and all | |
| 9232 // the other details from the |initial_map|. | |
| 9233 Handle<Map> map = | |
| 9234 Map::CopyInitialMap(function_map, initial_map->instance_size(), | |
| 9235 initial_map->GetInObjectProperties(), | |
| 9236 initial_map->unused_property_fields()); | |
| 9237 map->SetConstructor(initial_map->GetConstructor()); | |
| 9238 map->set_prototype(initial_map->prototype()); | |
| 9239 | |
| 9240 Map::ConnectTransition(initial_map, map, transition_symbol, | |
| 9241 SPECIAL_TRANSITION); | |
| 9242 return map; | |
| 9243 } | |
| 9244 | |
| 9245 | |
| 9189 Handle<Map> Map::CopyForObserved(Handle<Map> map) { | 9246 Handle<Map> Map::CopyForObserved(Handle<Map> map) { |
| 9190 DCHECK(!map->is_observed()); | 9247 DCHECK(!map->is_observed()); |
| 9191 | 9248 |
| 9192 Isolate* isolate = map->GetIsolate(); | 9249 Isolate* isolate = map->GetIsolate(); |
| 9193 | 9250 |
| 9194 bool insert_transition = | 9251 bool insert_transition = |
| 9195 TransitionArray::CanHaveMoreTransitions(map) && !map->is_prototype_map(); | 9252 TransitionArray::CanHaveMoreTransitions(map) && !map->is_prototype_map(); |
| 9196 | 9253 |
| 9197 if (insert_transition) { | 9254 if (insert_transition) { |
| 9198 Handle<Map> new_map = CopyForTransition(map, "CopyForObserved"); | 9255 Handle<Map> new_map = CopyForTransition(map, "CopyForObserved"); |
| (...skipping 9895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19094 if (cell->value() != *new_value) { | 19151 if (cell->value() != *new_value) { |
| 19095 cell->set_value(*new_value); | 19152 cell->set_value(*new_value); |
| 19096 Isolate* isolate = cell->GetIsolate(); | 19153 Isolate* isolate = cell->GetIsolate(); |
| 19097 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19154 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 19098 isolate, DependentCode::kPropertyCellChangedGroup); | 19155 isolate, DependentCode::kPropertyCellChangedGroup); |
| 19099 } | 19156 } |
| 19100 } | 19157 } |
| 19101 | 19158 |
| 19102 } // namespace internal | 19159 } // namespace internal |
| 19103 } // namespace v8 | 19160 } // namespace v8 |
| OLD | NEW |