From 39764ba293412adde99a77a66d0750695312e006 Mon Sep 17 00:00:00 2001 From: verwaest Date: Thu, 18 Aug 2016 01:58:57 -0700 Subject: [PATCH] There are only 2 language modes, not 3 BUG= Review-Url: https://codereview.chromium.org/2250703003 Cr-Commit-Position: refs/heads/master@{#38704} --- src/ast/scopes.h | 4 ++-- src/code-stubs.h | 4 ++-- src/globals.h | 3 +-- src/ic/ic-state.h | 4 ++-- src/objects-inl.h | 4 ++-- src/objects.cc | 17 +++++------------ src/objects.h | 6 ++---- src/parsing/parser.h | 2 +- src/runtime/runtime.h | 4 ++-- .../compiler/js-typed-lowering-unittest.cc | 3 +-- 10 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/ast/scopes.h b/src/ast/scopes.h index 05df42c198..72d04a5946 100644 --- a/src/ast/scopes.h +++ b/src/ast/scopes.h @@ -496,8 +496,8 @@ class Scope: public ZoneObject { // Scope-specific information computed during parsing. // // The language mode of this scope. - STATIC_ASSERT(LANGUAGE_END == 3); - LanguageMode language_mode_ : 2; + STATIC_ASSERT(LANGUAGE_END == 2); + LanguageMode language_mode_ : 1; // This scope is inside a 'with' of some outer scope. bool scope_inside_with_ : 1; // This scope or a nested catch scope or with scope contain an 'eval' call. At diff --git a/src/code-stubs.h b/src/code-stubs.h index 6d389d5b4e..c367a79db5 100644 --- a/src/code-stubs.h +++ b/src/code-stubs.h @@ -1845,8 +1845,8 @@ class StoreGlobalViaContextStub final : public PlatformCodeStub { private: class DepthBits : public BitField {}; STATIC_ASSERT(DepthBits::kMax == kMaximumDepth); - class LanguageModeBits : public BitField {}; - STATIC_ASSERT(LANGUAGE_END == 3); + class LanguageModeBits : public BitField {}; + STATIC_ASSERT(LANGUAGE_END == 2); DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreGlobalViaContext); DEFINE_PLATFORM_CODE_STUB(StoreGlobalViaContext, PlatformCodeStub); diff --git a/src/globals.h b/src/globals.h index eec83edaae..0d02f77fd6 100644 --- a/src/globals.h +++ b/src/globals.h @@ -272,8 +272,7 @@ template class List; // The Strict Mode (ECMA-262 5th edition, 4.2.2). -enum LanguageMode { SLOPPY, STRICT, LANGUAGE_END = 3 }; - +enum LanguageMode : uint32_t { SLOPPY, STRICT, LANGUAGE_END }; inline std::ostream& operator<<(std::ostream& os, const LanguageMode& mode) { switch (mode) { diff --git a/src/ic/ic-state.h b/src/ic/ic-state.h index ec33e8d0e9..6888a7ab5c 100644 --- a/src/ic/ic-state.h +++ b/src/ic/ic-state.h @@ -257,8 +257,8 @@ class StoreICState final BASE_EMBEDDED { return StoreICState(state).language_mode(); } - class LanguageModeState : public BitField {}; - STATIC_ASSERT(i::LANGUAGE_END == 3); + class LanguageModeState : public BitField {}; + STATIC_ASSERT(i::LANGUAGE_END == 2); // For convenience, a statically declared encoding of strict mode extra // IC state. diff --git a/src/objects-inl.h b/src/objects-inl.h index e83d8b6096..3d82bf8205 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -6015,14 +6015,14 @@ void SharedFunctionInfo::set_optimization_disabled(bool disable) { LanguageMode SharedFunctionInfo::language_mode() { - STATIC_ASSERT(LANGUAGE_END == 3); + STATIC_ASSERT(LANGUAGE_END == 2); return construct_language_mode( BooleanBit::get(compiler_hints(), kStrictModeFunction)); } void SharedFunctionInfo::set_language_mode(LanguageMode language_mode) { - STATIC_ASSERT(LANGUAGE_END == 3); + STATIC_ASSERT(LANGUAGE_END == 2); // We only allow language mode transitions that set the same language mode // again or go up in the chain: DCHECK(is_sloppy(this->language_mode()) || is_strict(language_mode)); diff --git a/src/objects.cc b/src/objects.cc index d1dd44c139..7a8664cfd6 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -9163,22 +9163,15 @@ Handle Map::AsLanguageMode(Handle initial_map, // using |strict_function_transition_symbol| as a key. if (language_mode == SLOPPY) return initial_map; Isolate* isolate = initial_map->GetIsolate(); - Factory* factory = isolate->factory(); - Handle transition_symbol; int map_index = Context::FunctionMapIndex(language_mode, kind); Handle function_map( Map::cast(isolate->native_context()->get(map_index))); - STATIC_ASSERT(LANGUAGE_END == 3); - switch (language_mode) { - case STRICT: - transition_symbol = factory->strict_function_transition_symbol(); - break; - default: - UNREACHABLE(); - break; - } + STATIC_ASSERT(LANGUAGE_END == 2); + DCHECK_EQ(STRICT, language_mode); + Handle transition_symbol = + isolate->factory()->strict_function_transition_symbol(); Map* maybe_transition = TransitionArray::SearchSpecial(*initial_map, *transition_symbol); if (maybe_transition != NULL) { @@ -16020,7 +16013,7 @@ class StringSharedKey : public HashTableKey { // collection. Script* script(Script::cast(shared->script())); hash ^= String::cast(script->source())->Hash(); - STATIC_ASSERT(LANGUAGE_END == 3); + STATIC_ASSERT(LANGUAGE_END == 2); if (is_strict(language_mode)) hash ^= 0x8000; hash += scope_position; } diff --git a/src/objects.h b/src/objects.h index 0432b83d9f..e8314e09d9 100644 --- a/src/objects.h +++ b/src/objects.h @@ -4404,9 +4404,9 @@ class ScopeInfo : public FixedArray { // Properties of scopes. class ScopeTypeField : public BitField {}; class CallsEvalField : public BitField {}; - STATIC_ASSERT(LANGUAGE_END == 3); + STATIC_ASSERT(LANGUAGE_END == 2); class LanguageModeField - : public BitField {}; + : public BitField {}; class DeclarationScopeField : public BitField {}; class ReceiverVariableField @@ -7508,8 +7508,6 @@ class SharedFunctionInfo: public HeapObject { kIsAsmWasmBroken, kCompilerHintsCount, // Pseudo entry }; - // Add hints for other modes when they're added. - STATIC_ASSERT(LANGUAGE_END == 3); // kFunctionKind has to be byte-aligned STATIC_ASSERT((kFunctionKind % kBitsPerByte) == 0); // Make sure that FunctionKind and byte 2 are in sync: diff --git a/src/parsing/parser.h b/src/parsing/parser.h index 9bb92e8408..b93823263e 100644 --- a/src/parsing/parser.h +++ b/src/parsing/parser.h @@ -175,7 +175,7 @@ class ParseInfo { return construct_language_mode(is_strict_mode()); } void set_language_mode(LanguageMode language_mode) { - STATIC_ASSERT(LANGUAGE_END == 3); + STATIC_ASSERT(LANGUAGE_END == 2); set_strict_mode(is_strict(language_mode)); } diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index e4590ad4dd..bbdbdf186b 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -1135,8 +1135,8 @@ class AllocateTargetSpace : public BitField {}; class DeclareGlobalsEvalFlag : public BitField {}; class DeclareGlobalsNativeFlag : public BitField {}; -STATIC_ASSERT(LANGUAGE_END == 3); -class DeclareGlobalsLanguageMode : public BitField {}; +STATIC_ASSERT(LANGUAGE_END == 2); +class DeclareGlobalsLanguageMode : public BitField {}; } // namespace internal } // namespace v8 diff --git a/test/unittests/compiler/js-typed-lowering-unittest.cc b/test/unittests/compiler/js-typed-lowering-unittest.cc index 8ab5d8fbf3..6b418d706d 100644 --- a/test/unittests/compiler/js-typed-lowering-unittest.cc +++ b/test/unittests/compiler/js-typed-lowering-unittest.cc @@ -65,8 +65,7 @@ const double kIntegerValues[] = {-V8_INFINITY, INT_MIN, -1000.0, -42.0, Type* const kJSTypes[] = {Type::Undefined(), Type::Null(), Type::Boolean(), Type::Number(), Type::String(), Type::Object()}; - -STATIC_ASSERT(LANGUAGE_END == 3); +STATIC_ASSERT(LANGUAGE_END == 2); const LanguageMode kLanguageModes[] = {SLOPPY, STRICT}; } // namespace