| 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 9145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9156 | 9156 |
| 9157 | 9157 |
| 9158 Handle<Map> Map::AsLanguageMode(Handle<Map> initial_map, | 9158 Handle<Map> Map::AsLanguageMode(Handle<Map> initial_map, |
| 9159 LanguageMode language_mode, FunctionKind kind) { | 9159 LanguageMode language_mode, FunctionKind kind) { |
| 9160 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); | 9160 DCHECK_EQ(JS_FUNCTION_TYPE, initial_map->instance_type()); |
| 9161 // Initial map for sloppy mode function is stored in the function | 9161 // Initial map for sloppy mode function is stored in the function |
| 9162 // constructor. Initial maps for strict mode are cached as special transitions | 9162 // constructor. Initial maps for strict mode are cached as special transitions |
| 9163 // using |strict_function_transition_symbol| as a key. | 9163 // using |strict_function_transition_symbol| as a key. |
| 9164 if (language_mode == SLOPPY) return initial_map; | 9164 if (language_mode == SLOPPY) return initial_map; |
| 9165 Isolate* isolate = initial_map->GetIsolate(); | 9165 Isolate* isolate = initial_map->GetIsolate(); |
| 9166 Factory* factory = isolate->factory(); | |
| 9167 Handle<Symbol> transition_symbol; | |
| 9168 | 9166 |
| 9169 int map_index = Context::FunctionMapIndex(language_mode, kind); | 9167 int map_index = Context::FunctionMapIndex(language_mode, kind); |
| 9170 Handle<Map> function_map( | 9168 Handle<Map> function_map( |
| 9171 Map::cast(isolate->native_context()->get(map_index))); | 9169 Map::cast(isolate->native_context()->get(map_index))); |
| 9172 | 9170 |
| 9173 STATIC_ASSERT(LANGUAGE_END == 3); | 9171 STATIC_ASSERT(LANGUAGE_END == 2); |
| 9174 switch (language_mode) { | 9172 DCHECK_EQ(STRICT, language_mode); |
| 9175 case STRICT: | 9173 Handle<Symbol> transition_symbol = |
| 9176 transition_symbol = factory->strict_function_transition_symbol(); | 9174 isolate->factory()->strict_function_transition_symbol(); |
| 9177 break; | |
| 9178 default: | |
| 9179 UNREACHABLE(); | |
| 9180 break; | |
| 9181 } | |
| 9182 Map* maybe_transition = | 9175 Map* maybe_transition = |
| 9183 TransitionArray::SearchSpecial(*initial_map, *transition_symbol); | 9176 TransitionArray::SearchSpecial(*initial_map, *transition_symbol); |
| 9184 if (maybe_transition != NULL) { | 9177 if (maybe_transition != NULL) { |
| 9185 return handle(maybe_transition, isolate); | 9178 return handle(maybe_transition, isolate); |
| 9186 } | 9179 } |
| 9187 initial_map->NotifyLeafMapLayoutChange(); | 9180 initial_map->NotifyLeafMapLayoutChange(); |
| 9188 | 9181 |
| 9189 // Create new map taking descriptors from the |function_map| and all | 9182 // Create new map taking descriptors from the |function_map| and all |
| 9190 // the other details from the |initial_map|. | 9183 // the other details from the |initial_map|. |
| 9191 Handle<Map> map = | 9184 Handle<Map> map = |
| (...skipping 6821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16013 int scope_position) { | 16006 int scope_position) { |
| 16014 uint32_t hash = source->Hash(); | 16007 uint32_t hash = source->Hash(); |
| 16015 if (shared->HasSourceCode()) { | 16008 if (shared->HasSourceCode()) { |
| 16016 // Instead of using the SharedFunctionInfo pointer in the hash | 16009 // Instead of using the SharedFunctionInfo pointer in the hash |
| 16017 // code computation, we use a combination of the hash of the | 16010 // code computation, we use a combination of the hash of the |
| 16018 // script source code and the start position of the calling scope. | 16011 // script source code and the start position of the calling scope. |
| 16019 // We do this to ensure that the cache entries can survive garbage | 16012 // We do this to ensure that the cache entries can survive garbage |
| 16020 // collection. | 16013 // collection. |
| 16021 Script* script(Script::cast(shared->script())); | 16014 Script* script(Script::cast(shared->script())); |
| 16022 hash ^= String::cast(script->source())->Hash(); | 16015 hash ^= String::cast(script->source())->Hash(); |
| 16023 STATIC_ASSERT(LANGUAGE_END == 3); | 16016 STATIC_ASSERT(LANGUAGE_END == 2); |
| 16024 if (is_strict(language_mode)) hash ^= 0x8000; | 16017 if (is_strict(language_mode)) hash ^= 0x8000; |
| 16025 hash += scope_position; | 16018 hash += scope_position; |
| 16026 } | 16019 } |
| 16027 return hash; | 16020 return hash; |
| 16028 } | 16021 } |
| 16029 | 16022 |
| 16030 uint32_t Hash() override { | 16023 uint32_t Hash() override { |
| 16031 return StringSharedHashHelper(*source_, *shared_, language_mode_, | 16024 return StringSharedHashHelper(*source_, *shared_, language_mode_, |
| 16032 scope_position_); | 16025 scope_position_); |
| 16033 } | 16026 } |
| (...skipping 3242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19276 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, | 19269 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, |
| 19277 PrototypeIterator::END_AT_NULL); | 19270 PrototypeIterator::END_AT_NULL); |
| 19278 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { | 19271 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { |
| 19279 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; | 19272 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; |
| 19280 } | 19273 } |
| 19281 return false; | 19274 return false; |
| 19282 } | 19275 } |
| 19283 | 19276 |
| 19284 } // namespace internal | 19277 } // namespace internal |
| 19285 } // namespace v8 | 19278 } // namespace v8 |
| OLD | NEW |