OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 9480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9491 Handle<Map> new_map = Copy(map, "CopyAsElementsKind"); | 9491 Handle<Map> new_map = Copy(map, "CopyAsElementsKind"); |
9492 new_map->set_elements_kind(kind); | 9492 new_map->set_elements_kind(kind); |
9493 return new_map; | 9493 return new_map; |
9494 } | 9494 } |
9495 | 9495 |
9496 | 9496 |
9497 Handle<Map> Map::AsLanguageMode(Handle<Map> initial_map, | 9497 Handle<Map> Map::AsLanguageMode(Handle<Map> initial_map, |
9498 LanguageMode language_mode, FunctionKind kind) { | 9498 LanguageMode language_mode, FunctionKind kind) { |
9499 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); | 9499 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); |
9500 // Initial map for sloppy mode function is stored in the function | 9500 // Initial map for sloppy mode function is stored in the function |
9501 // constructor. Initial maps for strict and strong modes are cached as | 9501 // constructor. Initial maps for strict mode are cached as special transitions |
9502 // special transitions using |strict_function_transition_symbol| and | 9502 // using |strict_function_transition_symbol| as a key. |
9503 // |strong_function_transition_symbol| respectively as a key. | |
9504 if (language_mode == SLOPPY) return initial_map; | 9503 if (language_mode == SLOPPY) return initial_map; |
9505 Isolate* isolate = initial_map->GetIsolate(); | 9504 Isolate* isolate = initial_map->GetIsolate(); |
9506 Factory* factory = isolate->factory(); | 9505 Factory* factory = isolate->factory(); |
9507 Handle<Symbol> transition_symbol; | 9506 Handle<Symbol> transition_symbol; |
9508 | 9507 |
9509 int map_index = Context::FunctionMapIndex(language_mode, kind); | 9508 int map_index = Context::FunctionMapIndex(language_mode, kind); |
9510 Handle<Map> function_map( | 9509 Handle<Map> function_map( |
9511 Map::cast(isolate->native_context()->get(map_index))); | 9510 Map::cast(isolate->native_context()->get(map_index))); |
9512 | 9511 |
9513 STATIC_ASSERT(LANGUAGE_END == 3); | 9512 STATIC_ASSERT(LANGUAGE_END == 3); |
9514 switch (language_mode) { | 9513 switch (language_mode) { |
9515 case STRICT: | 9514 case STRICT: |
9516 transition_symbol = factory->strict_function_transition_symbol(); | 9515 transition_symbol = factory->strict_function_transition_symbol(); |
9517 break; | 9516 break; |
9518 case STRONG: | |
9519 transition_symbol = factory->strong_function_transition_symbol(); | |
9520 break; | |
9521 default: | 9517 default: |
9522 UNREACHABLE(); | 9518 UNREACHABLE(); |
9523 break; | 9519 break; |
9524 } | 9520 } |
9525 Map* maybe_transition = | 9521 Map* maybe_transition = |
9526 TransitionArray::SearchSpecial(*initial_map, *transition_symbol); | 9522 TransitionArray::SearchSpecial(*initial_map, *transition_symbol); |
9527 if (maybe_transition != NULL) { | 9523 if (maybe_transition != NULL) { |
9528 return handle(maybe_transition, isolate); | 9524 return handle(maybe_transition, isolate); |
9529 } | 9525 } |
9530 initial_map->NotifyLeafMapLayoutChange(); | 9526 initial_map->NotifyLeafMapLayoutChange(); |
(...skipping 7176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16707 if (shared->HasSourceCode()) { | 16703 if (shared->HasSourceCode()) { |
16708 // Instead of using the SharedFunctionInfo pointer in the hash | 16704 // Instead of using the SharedFunctionInfo pointer in the hash |
16709 // code computation, we use a combination of the hash of the | 16705 // code computation, we use a combination of the hash of the |
16710 // script source code and the start position of the calling scope. | 16706 // script source code and the start position of the calling scope. |
16711 // We do this to ensure that the cache entries can survive garbage | 16707 // We do this to ensure that the cache entries can survive garbage |
16712 // collection. | 16708 // collection. |
16713 Script* script(Script::cast(shared->script())); | 16709 Script* script(Script::cast(shared->script())); |
16714 hash ^= String::cast(script->source())->Hash(); | 16710 hash ^= String::cast(script->source())->Hash(); |
16715 STATIC_ASSERT(LANGUAGE_END == 3); | 16711 STATIC_ASSERT(LANGUAGE_END == 3); |
16716 if (is_strict(language_mode)) hash ^= 0x8000; | 16712 if (is_strict(language_mode)) hash ^= 0x8000; |
16717 if (is_strong(language_mode)) hash ^= 0x10000; | |
16718 hash += scope_position; | 16713 hash += scope_position; |
16719 } | 16714 } |
16720 return hash; | 16715 return hash; |
16721 } | 16716 } |
16722 | 16717 |
16723 uint32_t Hash() override { | 16718 uint32_t Hash() override { |
16724 return StringSharedHashHelper(*source_, *shared_, language_mode_, | 16719 return StringSharedHashHelper(*source_, *shared_, language_mode_, |
16725 scope_position_); | 16720 scope_position_); |
16726 } | 16721 } |
16727 | 16722 |
(...skipping 3028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19756 if (cell->value() != *new_value) { | 19751 if (cell->value() != *new_value) { |
19757 cell->set_value(*new_value); | 19752 cell->set_value(*new_value); |
19758 Isolate* isolate = cell->GetIsolate(); | 19753 Isolate* isolate = cell->GetIsolate(); |
19759 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19754 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19760 isolate, DependentCode::kPropertyCellChangedGroup); | 19755 isolate, DependentCode::kPropertyCellChangedGroup); |
19761 } | 19756 } |
19762 } | 19757 } |
19763 | 19758 |
19764 } // namespace internal | 19759 } // namespace internal |
19765 } // namespace v8 | 19760 } // namespace v8 |
OLD | NEW |