Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/objects.cc

Issue 2257133002: Revert of There are only 2 language modes, not 3 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
9154 9156
9155 int map_index = Context::FunctionMapIndex(language_mode, kind); 9157 int map_index = Context::FunctionMapIndex(language_mode, kind);
9156 Handle<Map> function_map( 9158 Handle<Map> function_map(
9157 Map::cast(isolate->native_context()->get(map_index))); 9159 Map::cast(isolate->native_context()->get(map_index)));
9158 9160
9159 STATIC_ASSERT(LANGUAGE_END == 2); 9161 STATIC_ASSERT(LANGUAGE_END == 3);
9160 DCHECK_EQ(STRICT, language_mode); 9162 switch (language_mode) {
9161 Handle<Symbol> transition_symbol = 9163 case STRICT:
9162 isolate->factory()->strict_function_transition_symbol(); 9164 transition_symbol = factory->strict_function_transition_symbol();
9165 break;
9166 default:
9167 UNREACHABLE();
9168 break;
9169 }
9163 Map* maybe_transition = 9170 Map* maybe_transition =
9164 TransitionArray::SearchSpecial(*initial_map, *transition_symbol); 9171 TransitionArray::SearchSpecial(*initial_map, *transition_symbol);
9165 if (maybe_transition != NULL) { 9172 if (maybe_transition != NULL) {
9166 return handle(maybe_transition, isolate); 9173 return handle(maybe_transition, isolate);
9167 } 9174 }
9168 initial_map->NotifyLeafMapLayoutChange(); 9175 initial_map->NotifyLeafMapLayoutChange();
9169 9176
9170 // Create new map taking descriptors from the |function_map| and all 9177 // Create new map taking descriptors from the |function_map| and all
9171 // the other details from the |initial_map|. 9178 // the other details from the |initial_map|.
9172 Handle<Map> map = 9179 Handle<Map> map =
(...skipping 7431 matching lines...) Expand 10 before | Expand all | Expand 10 after
16604 int scope_position) { 16611 int scope_position) {
16605 uint32_t hash = source->Hash(); 16612 uint32_t hash = source->Hash();
16606 if (shared->HasSourceCode()) { 16613 if (shared->HasSourceCode()) {
16607 // Instead of using the SharedFunctionInfo pointer in the hash 16614 // Instead of using the SharedFunctionInfo pointer in the hash
16608 // code computation, we use a combination of the hash of the 16615 // code computation, we use a combination of the hash of the
16609 // script source code and the start position of the calling scope. 16616 // script source code and the start position of the calling scope.
16610 // We do this to ensure that the cache entries can survive garbage 16617 // We do this to ensure that the cache entries can survive garbage
16611 // collection. 16618 // collection.
16612 Script* script(Script::cast(shared->script())); 16619 Script* script(Script::cast(shared->script()));
16613 hash ^= String::cast(script->source())->Hash(); 16620 hash ^= String::cast(script->source())->Hash();
16614 STATIC_ASSERT(LANGUAGE_END == 2); 16621 STATIC_ASSERT(LANGUAGE_END == 3);
16615 if (is_strict(language_mode)) hash ^= 0x8000; 16622 if (is_strict(language_mode)) hash ^= 0x8000;
16616 hash += scope_position; 16623 hash += scope_position;
16617 } 16624 }
16618 return hash; 16625 return hash;
16619 } 16626 }
16620 16627
16621 uint32_t Hash() override { 16628 uint32_t Hash() override {
16622 return StringSharedHashHelper(*source_, *shared_, language_mode_, 16629 return StringSharedHashHelper(*source_, *shared_, language_mode_,
16623 scope_position_); 16630 scope_position_);
16624 } 16631 }
(...skipping 3242 matching lines...) Expand 10 before | Expand all | Expand 10 after
19867 for (PrototypeIterator iter(isolate, this, kStartAtReceiver, 19874 for (PrototypeIterator iter(isolate, this, kStartAtReceiver,
19868 PrototypeIterator::END_AT_NULL); 19875 PrototypeIterator::END_AT_NULL);
19869 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) { 19876 !iter.IsAtEnd(); iter.AdvanceIgnoringProxies()) {
19870 if (iter.GetCurrent<Object>()->IsJSProxy()) return true; 19877 if (iter.GetCurrent<Object>()->IsJSProxy()) return true;
19871 } 19878 }
19872 return false; 19879 return false;
19873 } 19880 }
19874 19881
19875 } // namespace internal 19882 } // namespace internal
19876 } // namespace v8 19883 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698