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