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 9568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9579 Handle<Map> new_map = Copy(map, "CopyAsElementsKind"); | 9579 Handle<Map> new_map = Copy(map, "CopyAsElementsKind"); |
9580 new_map->set_elements_kind(kind); | 9580 new_map->set_elements_kind(kind); |
9581 return new_map; | 9581 return new_map; |
9582 } | 9582 } |
9583 | 9583 |
9584 | 9584 |
9585 Handle<Map> Map::AsLanguageMode(Handle<Map> initial_map, | 9585 Handle<Map> Map::AsLanguageMode(Handle<Map> initial_map, |
9586 LanguageMode language_mode, FunctionKind kind) { | 9586 LanguageMode language_mode, FunctionKind kind) { |
9587 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); | 9587 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); |
9588 // Initial map for sloppy mode function is stored in the function | 9588 // Initial map for sloppy mode function is stored in the function |
9589 // constructor. Initial maps for strict and strong modes are cached as | 9589 // constructor. Initial maps for strict mode are cached as special transitions |
9590 // special transitions using |strict_function_transition_symbol| and | 9590 // using |strict_function_transition_symbol| as a key. |
9591 // |strong_function_transition_symbol| respectively as a key. | |
9592 if (language_mode == SLOPPY) return initial_map; | 9591 if (language_mode == SLOPPY) return initial_map; |
9593 Isolate* isolate = initial_map->GetIsolate(); | 9592 Isolate* isolate = initial_map->GetIsolate(); |
9594 Factory* factory = isolate->factory(); | 9593 Factory* factory = isolate->factory(); |
9595 Handle<Symbol> transition_symbol; | 9594 Handle<Symbol> transition_symbol; |
9596 | 9595 |
9597 int map_index = Context::FunctionMapIndex(language_mode, kind); | 9596 int map_index = Context::FunctionMapIndex(language_mode, kind); |
9598 Handle<Map> function_map( | 9597 Handle<Map> function_map( |
9599 Map::cast(isolate->native_context()->get(map_index))); | 9598 Map::cast(isolate->native_context()->get(map_index))); |
9600 | 9599 |
9601 STATIC_ASSERT(LANGUAGE_END == 3); | 9600 STATIC_ASSERT(LANGUAGE_END == 3); |
9602 switch (language_mode) { | 9601 switch (language_mode) { |
9603 case STRICT: | 9602 case STRICT: |
9604 transition_symbol = factory->strict_function_transition_symbol(); | 9603 transition_symbol = factory->strict_function_transition_symbol(); |
9605 break; | 9604 break; |
9606 case STRONG: | |
9607 transition_symbol = factory->strong_function_transition_symbol(); | |
9608 break; | |
9609 default: | 9605 default: |
9610 UNREACHABLE(); | 9606 UNREACHABLE(); |
9611 break; | 9607 break; |
9612 } | 9608 } |
9613 Map* maybe_transition = | 9609 Map* maybe_transition = |
9614 TransitionArray::SearchSpecial(*initial_map, *transition_symbol); | 9610 TransitionArray::SearchSpecial(*initial_map, *transition_symbol); |
9615 if (maybe_transition != NULL) { | 9611 if (maybe_transition != NULL) { |
9616 return handle(maybe_transition, isolate); | 9612 return handle(maybe_transition, isolate); |
9617 } | 9613 } |
9618 initial_map->NotifyLeafMapLayoutChange(); | 9614 initial_map->NotifyLeafMapLayoutChange(); |
(...skipping 7171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16790 if (shared->HasSourceCode()) { | 16786 if (shared->HasSourceCode()) { |
16791 // Instead of using the SharedFunctionInfo pointer in the hash | 16787 // Instead of using the SharedFunctionInfo pointer in the hash |
16792 // code computation, we use a combination of the hash of the | 16788 // code computation, we use a combination of the hash of the |
16793 // script source code and the start position of the calling scope. | 16789 // script source code and the start position of the calling scope. |
16794 // We do this to ensure that the cache entries can survive garbage | 16790 // We do this to ensure that the cache entries can survive garbage |
16795 // collection. | 16791 // collection. |
16796 Script* script(Script::cast(shared->script())); | 16792 Script* script(Script::cast(shared->script())); |
16797 hash ^= String::cast(script->source())->Hash(); | 16793 hash ^= String::cast(script->source())->Hash(); |
16798 STATIC_ASSERT(LANGUAGE_END == 3); | 16794 STATIC_ASSERT(LANGUAGE_END == 3); |
16799 if (is_strict(language_mode)) hash ^= 0x8000; | 16795 if (is_strict(language_mode)) hash ^= 0x8000; |
16800 if (is_strong(language_mode)) hash ^= 0x10000; | |
16801 hash += scope_position; | 16796 hash += scope_position; |
16802 } | 16797 } |
16803 return hash; | 16798 return hash; |
16804 } | 16799 } |
16805 | 16800 |
16806 uint32_t Hash() override { | 16801 uint32_t Hash() override { |
16807 return StringSharedHashHelper(*source_, *shared_, language_mode_, | 16802 return StringSharedHashHelper(*source_, *shared_, language_mode_, |
16808 scope_position_); | 16803 scope_position_); |
16809 } | 16804 } |
16810 | 16805 |
(...skipping 3039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19850 if (cell->value() != *new_value) { | 19845 if (cell->value() != *new_value) { |
19851 cell->set_value(*new_value); | 19846 cell->set_value(*new_value); |
19852 Isolate* isolate = cell->GetIsolate(); | 19847 Isolate* isolate = cell->GetIsolate(); |
19853 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19848 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19854 isolate, DependentCode::kPropertyCellChangedGroup); | 19849 isolate, DependentCode::kPropertyCellChangedGroup); |
19855 } | 19850 } |
19856 } | 19851 } |
19857 | 19852 |
19858 } // namespace internal | 19853 } // namespace internal |
19859 } // namespace v8 | 19854 } // namespace v8 |
OLD | NEW |