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 <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 9133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9144 | 9144 |
9145 | 9145 |
9146 Handle<Map> Map::AsLanguageMode(Handle<Map> initial_map, | 9146 Handle<Map> Map::AsLanguageMode(Handle<Map> initial_map, |
9147 LanguageMode language_mode, FunctionKind kind) { | 9147 LanguageMode language_mode, FunctionKind kind) { |
9148 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); | 9148 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); |
9149 // Initial map for sloppy mode function is stored in the function | 9149 // Initial map for sloppy mode function is stored in the function |
9150 // constructor. Initial maps for strict mode are cached as special transitions | 9150 // constructor. Initial maps for strict mode are cached as special transitions |
9151 // using |strict_function_transition_symbol| as a key. | 9151 // using |strict_function_transition_symbol| as a key. |
9152 if (language_mode == SLOPPY) return initial_map; | 9152 if (language_mode == SLOPPY) return initial_map; |
9153 Isolate* isolate = initial_map->GetIsolate(); | 9153 Isolate* isolate = initial_map->GetIsolate(); |
9154 Factory* factory = isolate->factory(); | |
9155 Handle<Symbol> transition_symbol; | |
9156 | 9154 |
9157 int map_index = Context::FunctionMapIndex(language_mode, kind); | 9155 int map_index = Context::FunctionMapIndex(language_mode, kind); |
9158 Handle<Map> function_map( | 9156 Handle<Map> function_map( |
9159 Map::cast(isolate->native_context()->get(map_index))); | 9157 Map::cast(isolate->native_context()->get(map_index))); |
9160 | 9158 |
9161 STATIC_ASSERT(LANGUAGE_END == 3); | 9159 STATIC_ASSERT(LANGUAGE_END == 2); |
9162 switch (language_mode) { | 9160 DCHECK_EQ(STRICT, language_mode); |
9163 case STRICT: | 9161 Handle<Symbol> transition_symbol = |
9164 transition_symbol = factory->strict_function_transition_symbol(); | 9162 isolate->factory()->strict_function_transition_symbol(); |
9165 break; | |
9166 default: | |
9167 UNREACHABLE(); | |
9168 break; | |
9169 } | |
9170 Map* maybe_transition = | 9163 Map* maybe_transition = |
9171 TransitionArray::SearchSpecial(*initial_map, *transition_symbol); | 9164 TransitionArray::SearchSpecial(*initial_map, *transition_symbol); |
9172 if (maybe_transition != NULL) { | 9165 if (maybe_transition != NULL) { |
9173 return handle(maybe_transition, isolate); | 9166 return handle(maybe_transition, isolate); |
9174 } | 9167 } |
9175 initial_map->NotifyLeafMapLayoutChange(); | 9168 initial_map->NotifyLeafMapLayoutChange(); |
9176 | 9169 |
9177 // Create new map taking descriptors from the |function_map| and all | 9170 // Create new map taking descriptors from the |function_map| and all |
9178 // the other details from the |initial_map|. | 9171 // the other details from the |initial_map|. |
9179 Handle<Map> map = | 9172 Handle<Map> map = |
(...skipping 7431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16611 int scope_position) { | 16604 int scope_position) { |
16612 uint32_t hash = source->Hash(); | 16605 uint32_t hash = source->Hash(); |
16613 if (shared->HasSourceCode()) { | 16606 if (shared->HasSourceCode()) { |
16614 // Instead of using the SharedFunctionInfo pointer in the hash | 16607 // Instead of using the SharedFunctionInfo pointer in the hash |
16615 // code computation, we use a combination of the hash of the | 16608 // code computation, we use a combination of the hash of the |
16616 // script source code and the start position of the calling scope. | 16609 // script source code and the start position of the calling scope. |
16617 // We do this to ensure that the cache entries can survive garbage | 16610 // We do this to ensure that the cache entries can survive garbage |
16618 // collection. | 16611 // collection. |
16619 Script* script(Script::cast(shared->script())); | 16612 Script* script(Script::cast(shared->script())); |
16620 hash ^= String::cast(script->source())->Hash(); | 16613 hash ^= String::cast(script->source())->Hash(); |
16621 STATIC_ASSERT(LANGUAGE_END == 3); | 16614 STATIC_ASSERT(LANGUAGE_END == 2); |
16622 if (is_strict(language_mode)) hash ^= 0x8000; | 16615 if (is_strict(language_mode)) hash ^= 0x8000; |
16623 hash += scope_position; | 16616 hash += scope_position; |
16624 } | 16617 } |
16625 return hash; | 16618 return hash; |
16626 } | 16619 } |
16627 | 16620 |
16628 uint32_t Hash() override { | 16621 uint32_t Hash() override { |
16629 return StringSharedHashHelper(*source_, *shared_, language_mode_, | 16622 return StringSharedHashHelper(*source_, *shared_, language_mode_, |
16630 scope_position_); | 16623 scope_position_); |
16631 } | 16624 } |
(...skipping 3242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19874 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, | 19867 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, |
19875 PrototypeIterator::END_AT_NULL); | 19868 PrototypeIterator::END_AT_NULL); |
19876 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { | 19869 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { |
19877 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; | 19870 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; |
19878 } | 19871 } |
19879 return false; | 19872 return false; |
19880 } | 19873 } |
19881 | 19874 |
19882 } // namespace internal | 19875 } // namespace internal |
19883 } // namespace v8 | 19876 } // namespace v8 |
OLD | NEW |