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