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 if (map->instance_type() != JS_FUNCTION_TYPE) { |
| 8923 DCHECK(constructor->IsJSFunction()); | 8923 // Function initial maps does not have a constructor. |
| 8924 DCHECK_EQ(*map, JSFunction::cast(constructor)->initial_map()); | 8924 Object* constructor = map->GetConstructor(); |
| 8925 DCHECK(constructor->IsJSFunction()); | |
| 8926 DCHECK_EQ(*map, JSFunction::cast(constructor)->initial_map()); | |
| 8927 } | |
| 8925 #endif | 8928 #endif |
| 8926 // Initial maps must always own their descriptors and it's descriptor array | 8929 // Initial maps must always own their descriptors and it's descriptor array |
| 8927 // does not contain descriptors that do not belong to the map. | 8930 // does not contain descriptors that do not belong to the map. |
| 8928 DCHECK(map->owns_descriptors()); | 8931 DCHECK(map->owns_descriptors()); |
| 8929 DCHECK_EQ(map->NumberOfOwnDescriptors(), | 8932 DCHECK_EQ(map->NumberOfOwnDescriptors(), |
| 8930 map->instance_descriptors()->number_of_descriptors()); | 8933 map->instance_descriptors()->number_of_descriptors()); |
| 8931 | 8934 |
| 8932 Handle<Map> result = RawCopy(map, instance_size); | 8935 Handle<Map> result = RawCopy(map, instance_size); |
| 8933 | 8936 |
| 8934 // Please note instance_type and instance_size are set when allocated. | 8937 // 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; | 9182 return new_map; |
| 9180 } | 9183 } |
| 9181 | 9184 |
| 9182 // Create a new free-floating map only if we are not allowed to store it. | 9185 // Create a new free-floating map only if we are not allowed to store it. |
| 9183 Handle<Map> new_map = Copy(map, "CopyAsElementsKind"); | 9186 Handle<Map> new_map = Copy(map, "CopyAsElementsKind"); |
| 9184 new_map->set_elements_kind(kind); | 9187 new_map->set_elements_kind(kind); |
| 9185 return new_map; | 9188 return new_map; |
| 9186 } | 9189 } |
| 9187 | 9190 |
| 9188 | 9191 |
| 9192 Handle<Map> Map::AsLanguageMode(Handle<Map> initial_map, | |
| 9193 LanguageMode language_mode) { | |
| 9194 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); | |
| 9195 Isolate* isolate = initial_map->GetIsolate(); | |
| 9196 Factory* factory = isolate->factory(); | |
| 9197 Handle<Symbol> transition_symbol; | |
| 9198 Handle<Map> function_map; | |
| 9199 | |
| 9200 switch (language_mode) { | |
| 9201 case SLOPPY: | |
| 9202 transition_symbol = factory->sloppy_function_symbol(); | |
| 9203 function_map = isolate->sloppy_function_map(); | |
|
Toon Verwaest
2015/12/08 20:01:08
What about making the initial map be the sloppy ma
Igor Sheludko
2015/12/10 10:50:41
Done.
| |
| 9204 break; | |
| 9205 case STRICT: | |
| 9206 transition_symbol = factory->strict_function_symbol(); | |
| 9207 function_map = isolate->strict_function_map(); | |
| 9208 break; | |
| 9209 case STRONG: | |
| 9210 transition_symbol = factory->strong_function_symbol(); | |
| 9211 function_map = isolate->strong_function_map(); | |
| 9212 break; | |
| 9213 default: | |
| 9214 UNREACHABLE(); | |
| 9215 break; | |
| 9216 } | |
| 9217 Map* maybe_transition = | |
| 9218 TransitionArray::SearchSpecial(*initial_map, *transition_symbol); | |
| 9219 if (maybe_transition != NULL) { | |
| 9220 return handle(maybe_transition, isolate); | |
| 9221 } | |
| 9222 | |
| 9223 Handle<Map> map = | |
| 9224 Map::CopyInitialMap(function_map, initial_map->instance_size(), | |
| 9225 initial_map->GetInObjectProperties(), | |
| 9226 initial_map->unused_property_fields()); | |
| 9227 // We set |function_map|'s descriptor array to |map|, so clear the ownership | |
| 9228 // flag to prevent |function_map|'s descriptors corruption. | |
| 9229 map->set_owns_descriptors(false); | |
|
Toon Verwaest
2015/12/08 20:01:08
I don't immediately understand this ...
If we shar
Igor Sheludko
2015/12/10 10:50:41
Done.
| |
| 9230 // Take constructor and prototype values from |initial_map|. | |
| 9231 map->SetConstructor(initial_map->GetConstructor()); | |
| 9232 map->set_prototype(initial_map->prototype()); | |
|
Toon Verwaest
2015/12/08 20:01:08
Is this correct for strong-mode?...
| |
| 9233 | |
| 9234 Map::ConnectTransition(initial_map, map, transition_symbol, | |
| 9235 SPECIAL_TRANSITION); | |
| 9236 return map; | |
| 9237 } | |
| 9238 | |
| 9239 | |
| 9189 Handle<Map> Map::CopyForObserved(Handle<Map> map) { | 9240 Handle<Map> Map::CopyForObserved(Handle<Map> map) { |
| 9190 DCHECK(!map->is_observed()); | 9241 DCHECK(!map->is_observed()); |
| 9191 | 9242 |
| 9192 Isolate* isolate = map->GetIsolate(); | 9243 Isolate* isolate = map->GetIsolate(); |
| 9193 | 9244 |
| 9194 bool insert_transition = | 9245 bool insert_transition = |
| 9195 TransitionArray::CanHaveMoreTransitions(map) && !map->is_prototype_map(); | 9246 TransitionArray::CanHaveMoreTransitions(map) && !map->is_prototype_map(); |
| 9196 | 9247 |
| 9197 if (insert_transition) { | 9248 if (insert_transition) { |
| 9198 Handle<Map> new_map = CopyForTransition(map, "CopyForObserved"); | 9249 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) { | 19145 if (cell->value() != *new_value) { |
| 19095 cell->set_value(*new_value); | 19146 cell->set_value(*new_value); |
| 19096 Isolate* isolate = cell->GetIsolate(); | 19147 Isolate* isolate = cell->GetIsolate(); |
| 19097 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19148 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 19098 isolate, DependentCode::kPropertyCellChangedGroup); | 19149 isolate, DependentCode::kPropertyCellChangedGroup); |
| 19099 } | 19150 } |
| 19100 } | 19151 } |
| 19101 | 19152 |
| 19102 } // namespace internal | 19153 } // namespace internal |
| 19103 } // namespace v8 | 19154 } // namespace v8 |
| OLD | NEW |