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 4538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4549 if (from_kind == FAST_SLOPPY_ARGUMENTS_ELEMENTS) { | 4549 if (from_kind == FAST_SLOPPY_ARGUMENTS_ELEMENTS) { |
4550 if (*map == native_context->fast_aliased_arguments_map()) { | 4550 if (*map == native_context->fast_aliased_arguments_map()) { |
4551 DCHECK_EQ(SLOW_SLOPPY_ARGUMENTS_ELEMENTS, to_kind); | 4551 DCHECK_EQ(SLOW_SLOPPY_ARGUMENTS_ELEMENTS, to_kind); |
4552 return handle(native_context->slow_aliased_arguments_map()); | 4552 return handle(native_context->slow_aliased_arguments_map()); |
4553 } | 4553 } |
4554 } else if (from_kind == SLOW_SLOPPY_ARGUMENTS_ELEMENTS) { | 4554 } else if (from_kind == SLOW_SLOPPY_ARGUMENTS_ELEMENTS) { |
4555 if (*map == native_context->slow_aliased_arguments_map()) { | 4555 if (*map == native_context->slow_aliased_arguments_map()) { |
4556 DCHECK_EQ(FAST_SLOPPY_ARGUMENTS_ELEMENTS, to_kind); | 4556 DCHECK_EQ(FAST_SLOPPY_ARGUMENTS_ELEMENTS, to_kind); |
4557 return handle(native_context->fast_aliased_arguments_map()); | 4557 return handle(native_context->fast_aliased_arguments_map()); |
4558 } | 4558 } |
4559 } else { | 4559 } else if (IsFastElementsKind(from_kind) && IsFastElementsKind(to_kind)) { |
4560 Object* maybe_array_maps = map->is_strong() | |
4561 ? native_context->js_array_strong_maps() | |
4562 : native_context->js_array_maps(); | |
4563 // Reuse map transitions for JSArrays. | 4560 // Reuse map transitions for JSArrays. |
4564 if (maybe_array_maps->IsFixedArray()) { | 4561 DisallowHeapAllocation no_gc; |
4565 DisallowHeapAllocation no_gc; | 4562 Strength strength = map->is_strong() ? Strength::STRONG : Strength::WEAK; |
4566 FixedArray* array_maps = FixedArray::cast(maybe_array_maps); | 4563 if (native_context->get(Context::ArrayMapIndex(from_kind, strength)) == |
4567 if (array_maps->get(from_kind) == *map) { | 4564 *map) { |
4568 Object* maybe_transitioned_map = array_maps->get(to_kind); | 4565 Object* maybe_transitioned_map = |
4569 if (maybe_transitioned_map->IsMap()) { | 4566 native_context->get(Context::ArrayMapIndex(to_kind, strength)); |
4570 return handle(Map::cast(maybe_transitioned_map)); | 4567 if (maybe_transitioned_map->IsMap()) { |
4571 } | 4568 return handle(Map::cast(maybe_transitioned_map), isolate); |
4572 } | 4569 } |
4573 } | 4570 } |
4574 } | 4571 } |
4575 | 4572 |
4576 DCHECK(!map->IsUndefined()); | 4573 DCHECK(!map->IsUndefined()); |
4577 // Check if we can go back in the elements kind transition chain. | 4574 // Check if we can go back in the elements kind transition chain. |
4578 if (IsHoleyElementsKind(from_kind) && | 4575 if (IsHoleyElementsKind(from_kind) && |
4579 to_kind == GetPackedElementsKind(from_kind) && | 4576 to_kind == GetPackedElementsKind(from_kind) && |
4580 map->GetBackPointer()->IsMap() && | 4577 map->GetBackPointer()->IsMap() && |
4581 Map::cast(map->GetBackPointer())->elements_kind() == to_kind) { | 4578 Map::cast(map->GetBackPointer())->elements_kind() == to_kind) { |
(...skipping 7937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12519 WriteBarrierMode wb_mode = | 12516 WriteBarrierMode wb_mode = |
12520 prototype->IsNull() ? SKIP_WRITE_BARRIER : UPDATE_WRITE_BARRIER; | 12517 prototype->IsNull() ? SKIP_WRITE_BARRIER : UPDATE_WRITE_BARRIER; |
12521 map->set_prototype(*prototype, wb_mode); | 12518 map->set_prototype(*prototype, wb_mode); |
12522 } | 12519 } |
12523 | 12520 |
12524 | 12521 |
12525 Handle<Object> CacheInitialJSArrayMaps( | 12522 Handle<Object> CacheInitialJSArrayMaps( |
12526 Handle<Context> native_context, Handle<Map> initial_map) { | 12523 Handle<Context> native_context, Handle<Map> initial_map) { |
12527 // Replace all of the cached initial array maps in the native context with | 12524 // Replace all of the cached initial array maps in the native context with |
12528 // the appropriate transitioned elements kind maps. | 12525 // the appropriate transitioned elements kind maps. |
12529 Factory* factory = native_context->GetIsolate()->factory(); | 12526 Strength strength = |
12530 Handle<FixedArray> maps = factory->NewFixedArrayWithHoles( | 12527 initial_map->is_strong() ? Strength::STRONG : Strength::WEAK; |
12531 kElementsKindCount, TENURED); | |
12532 | |
12533 Handle<Map> current_map = initial_map; | 12528 Handle<Map> current_map = initial_map; |
12534 ElementsKind kind = current_map->elements_kind(); | 12529 ElementsKind kind = current_map->elements_kind(); |
12535 DCHECK(kind == GetInitialFastElementsKind()); | 12530 DCHECK_EQ(GetInitialFastElementsKind(), kind); |
12536 maps->set(kind, *current_map); | 12531 native_context->set(Context::ArrayMapIndex(kind, strength), *current_map); |
12537 for (int i = GetSequenceIndexFromFastElementsKind(kind) + 1; | 12532 for (int i = GetSequenceIndexFromFastElementsKind(kind) + 1; |
12538 i < kFastElementsKindCount; ++i) { | 12533 i < kFastElementsKindCount; ++i) { |
12539 Handle<Map> new_map; | 12534 Handle<Map> new_map; |
12540 ElementsKind next_kind = GetFastElementsKindFromSequenceIndex(i); | 12535 ElementsKind next_kind = GetFastElementsKindFromSequenceIndex(i); |
12541 Map* maybe_elements_transition = current_map->ElementsTransitionMap(); | 12536 if (Map* maybe_elements_transition = current_map->ElementsTransitionMap()) { |
12542 if (maybe_elements_transition != NULL) { | |
12543 new_map = handle(maybe_elements_transition); | 12537 new_map = handle(maybe_elements_transition); |
12544 DCHECK(new_map->elements_kind() == next_kind); | |
12545 } else { | 12538 } else { |
12546 new_map = Map::CopyAsElementsKind( | 12539 new_map = Map::CopyAsElementsKind( |
12547 current_map, next_kind, INSERT_TRANSITION); | 12540 current_map, next_kind, INSERT_TRANSITION); |
12548 } | 12541 } |
12549 maps->set(next_kind, *new_map); | 12542 DCHECK_EQ(next_kind, new_map->elements_kind()); |
| 12543 native_context->set(Context::ArrayMapIndex(next_kind, strength), *new_map); |
12550 current_map = new_map; | 12544 current_map = new_map; |
12551 } | 12545 } |
12552 if (initial_map->is_strong()) | |
12553 native_context->set_js_array_strong_maps(*maps); | |
12554 else | |
12555 native_context->set_js_array_maps(*maps); | |
12556 return initial_map; | 12546 return initial_map; |
12557 } | 12547 } |
12558 | 12548 |
12559 | 12549 |
12560 void JSFunction::SetInstancePrototype(Handle<JSFunction> function, | 12550 void JSFunction::SetInstancePrototype(Handle<JSFunction> function, |
12561 Handle<Object> value) { | 12551 Handle<Object> value) { |
12562 Isolate* isolate = function->GetIsolate(); | 12552 Isolate* isolate = function->GetIsolate(); |
12563 | 12553 |
12564 DCHECK(value->IsJSReceiver()); | 12554 DCHECK(value->IsJSReceiver()); |
12565 | 12555 |
(...skipping 6693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19259 if (cell->value() != *new_value) { | 19249 if (cell->value() != *new_value) { |
19260 cell->set_value(*new_value); | 19250 cell->set_value(*new_value); |
19261 Isolate* isolate = cell->GetIsolate(); | 19251 Isolate* isolate = cell->GetIsolate(); |
19262 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19252 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19263 isolate, DependentCode::kPropertyCellChangedGroup); | 19253 isolate, DependentCode::kPropertyCellChangedGroup); |
19264 } | 19254 } |
19265 } | 19255 } |
19266 | 19256 |
19267 } // namespace internal | 19257 } // namespace internal |
19268 } // namespace v8 | 19258 } // namespace v8 |
OLD | NEW |