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 <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 3786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3797 } | 3797 } |
3798 | 3798 |
3799 | 3799 |
3800 Handle<Map> Map::TransitionElementsTo(Handle<Map> map, | 3800 Handle<Map> Map::TransitionElementsTo(Handle<Map> map, |
3801 ElementsKind to_kind) { | 3801 ElementsKind to_kind) { |
3802 ElementsKind from_kind = map->elements_kind(); | 3802 ElementsKind from_kind = map->elements_kind(); |
3803 if (from_kind == to_kind) return map; | 3803 if (from_kind == to_kind) return map; |
3804 | 3804 |
3805 Isolate* isolate = map->GetIsolate(); | 3805 Isolate* isolate = map->GetIsolate(); |
3806 Context* native_context = isolate->context()->native_context(); | 3806 Context* native_context = isolate->context()->native_context(); |
3807 Object* maybe_array_maps = native_context->js_array_maps(); | 3807 Object* maybe_array_maps = map->is_strong() |
| 3808 ? native_context->js_array_strong_maps() |
| 3809 : native_context->js_array_maps(); |
3808 if (maybe_array_maps->IsFixedArray()) { | 3810 if (maybe_array_maps->IsFixedArray()) { |
3809 DisallowHeapAllocation no_gc; | 3811 DisallowHeapAllocation no_gc; |
3810 FixedArray* array_maps = FixedArray::cast(maybe_array_maps); | 3812 FixedArray* array_maps = FixedArray::cast(maybe_array_maps); |
3811 if (array_maps->get(from_kind) == *map) { | 3813 if (array_maps->get(from_kind) == *map) { |
3812 Object* maybe_transitioned_map = array_maps->get(to_kind); | 3814 Object* maybe_transitioned_map = array_maps->get(to_kind); |
3813 if (maybe_transitioned_map->IsMap()) { | 3815 if (maybe_transitioned_map->IsMap()) { |
3814 return handle(Map::cast(maybe_transitioned_map)); | 3816 return handle(Map::cast(maybe_transitioned_map)); |
3815 } | 3817 } |
3816 } | 3818 } |
3817 } | 3819 } |
(...skipping 6493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10311 if (maybe_elements_transition != NULL) { | 10313 if (maybe_elements_transition != NULL) { |
10312 new_map = handle(maybe_elements_transition); | 10314 new_map = handle(maybe_elements_transition); |
10313 DCHECK(new_map->elements_kind() == next_kind); | 10315 DCHECK(new_map->elements_kind() == next_kind); |
10314 } else { | 10316 } else { |
10315 new_map = Map::CopyAsElementsKind( | 10317 new_map = Map::CopyAsElementsKind( |
10316 current_map, next_kind, INSERT_TRANSITION); | 10318 current_map, next_kind, INSERT_TRANSITION); |
10317 } | 10319 } |
10318 maps->set(next_kind, *new_map); | 10320 maps->set(next_kind, *new_map); |
10319 current_map = new_map; | 10321 current_map = new_map; |
10320 } | 10322 } |
10321 native_context->set_js_array_maps(*maps); | 10323 if (initial_map->is_strong()) |
| 10324 native_context->set_js_array_strong_maps(*maps); |
| 10325 else |
| 10326 native_context->set_js_array_maps(*maps); |
10322 return initial_map; | 10327 return initial_map; |
10323 } | 10328 } |
10324 | 10329 |
10325 | 10330 |
10326 void JSFunction::SetInstancePrototype(Handle<JSFunction> function, | 10331 void JSFunction::SetInstancePrototype(Handle<JSFunction> function, |
10327 Handle<Object> value) { | 10332 Handle<Object> value) { |
10328 Isolate* isolate = function->GetIsolate(); | 10333 Isolate* isolate = function->GetIsolate(); |
10329 | 10334 |
10330 DCHECK(value->IsJSReceiver()); | 10335 DCHECK(value->IsJSReceiver()); |
10331 | 10336 |
(...skipping 14 matching lines...) Expand all Loading... |
10346 initial_map->instance_type() == JS_OBJECT_TYPE) { | 10351 initial_map->instance_type() == JS_OBJECT_TYPE) { |
10347 // Put the value in the initial map field until an initial map is needed. | 10352 // Put the value in the initial map field until an initial map is needed. |
10348 // At that point, a new initial map is created and the prototype is put | 10353 // At that point, a new initial map is created and the prototype is put |
10349 // into the initial map where it belongs. | 10354 // into the initial map where it belongs. |
10350 function->set_prototype_or_initial_map(*value); | 10355 function->set_prototype_or_initial_map(*value); |
10351 } else { | 10356 } else { |
10352 Handle<Map> new_map = Map::Copy(initial_map, "SetInstancePrototype"); | 10357 Handle<Map> new_map = Map::Copy(initial_map, "SetInstancePrototype"); |
10353 JSFunction::SetInitialMap(function, new_map, value); | 10358 JSFunction::SetInitialMap(function, new_map, value); |
10354 | 10359 |
10355 // If the function is used as the global Array function, cache the | 10360 // If the function is used as the global Array function, cache the |
10356 // initial map (and transitioned versions) in the native context. | 10361 // updated initial maps (and transitioned versions) in the native context. |
10357 Context* native_context = function->context()->native_context(); | 10362 Handle<Context> native_context(function->context()->native_context(), |
10358 Object* array_function = | 10363 isolate); |
10359 native_context->get(Context::ARRAY_FUNCTION_INDEX); | 10364 Handle<Object> array_function( |
| 10365 native_context->get(Context::ARRAY_FUNCTION_INDEX), isolate); |
10360 if (array_function->IsJSFunction() && | 10366 if (array_function->IsJSFunction() && |
10361 *function == JSFunction::cast(array_function)) { | 10367 *function == JSFunction::cast(*array_function)) { |
10362 CacheInitialJSArrayMaps(handle(native_context, isolate), new_map); | 10368 CacheInitialJSArrayMaps(native_context, new_map); |
| 10369 Handle<Map> new_strong_map = |
| 10370 Map::Copy(initial_map, "SetInstancePrototype"); |
| 10371 new_strong_map->set_is_strong(true); |
| 10372 CacheInitialJSArrayMaps(native_context, new_strong_map); |
10363 } | 10373 } |
10364 } | 10374 } |
10365 | 10375 |
10366 // Deoptimize all code that embeds the previous initial map. | 10376 // Deoptimize all code that embeds the previous initial map. |
10367 initial_map->dependent_code()->DeoptimizeDependentCodeGroup( | 10377 initial_map->dependent_code()->DeoptimizeDependentCodeGroup( |
10368 isolate, DependentCode::kInitialMapChangedGroup); | 10378 isolate, DependentCode::kInitialMapChangedGroup); |
10369 } else { | 10379 } else { |
10370 // Put the value in the initial map field until an initial map is | 10380 // Put the value in the initial map field until an initial map is |
10371 // needed. At that point, a new initial map is created and the | 10381 // needed. At that point, a new initial map is created and the |
10372 // prototype is put into the initial map where it belongs. | 10382 // prototype is put into the initial map where it belongs. |
(...skipping 6877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17250 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, | 17260 void PropertyCell::SetValueWithInvalidation(Handle<PropertyCell> cell, |
17251 Handle<Object> new_value) { | 17261 Handle<Object> new_value) { |
17252 if (cell->value() != *new_value) { | 17262 if (cell->value() != *new_value) { |
17253 cell->set_value(*new_value); | 17263 cell->set_value(*new_value); |
17254 Isolate* isolate = cell->GetIsolate(); | 17264 Isolate* isolate = cell->GetIsolate(); |
17255 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17265 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
17256 isolate, DependentCode::kPropertyCellChangedGroup); | 17266 isolate, DependentCode::kPropertyCellChangedGroup); |
17257 } | 17267 } |
17258 } | 17268 } |
17259 } } // namespace v8::internal | 17269 } } // namespace v8::internal |
OLD | NEW |