There are only 2 language modes, not 3

BUG=

Review-Url: https://codereview.chromium.org/2250703003
Cr-Commit-Position: refs/heads/master@{#38704}
This commit is contained in:
verwaest 2016-08-18 01:58:57 -07:00 committed by Commit bot
parent 4484bb41b5
commit 39764ba293
10 changed files with 20 additions and 31 deletions

View File

@ -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

View File

@ -1845,8 +1845,8 @@ class StoreGlobalViaContextStub final : public PlatformCodeStub {
private:
class DepthBits : public BitField<int, 0, 4> {};
STATIC_ASSERT(DepthBits::kMax == kMaximumDepth);
class LanguageModeBits : public BitField<LanguageMode, 4, 2> {};
STATIC_ASSERT(LANGUAGE_END == 3);
class LanguageModeBits : public BitField<LanguageMode, 4, 1> {};
STATIC_ASSERT(LANGUAGE_END == 2);
DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreGlobalViaContext);
DEFINE_PLATFORM_CODE_STUB(StoreGlobalViaContext, PlatformCodeStub);

View File

@ -272,8 +272,7 @@ template <typename T, class P = FreeStoreAllocationPolicy> 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) {

View File

@ -257,8 +257,8 @@ class StoreICState final BASE_EMBEDDED {
return StoreICState(state).language_mode();
}
class LanguageModeState : public BitField<LanguageMode, 1, 2> {};
STATIC_ASSERT(i::LANGUAGE_END == 3);
class LanguageModeState : public BitField<LanguageMode, 1, 1> {};
STATIC_ASSERT(i::LANGUAGE_END == 2);
// For convenience, a statically declared encoding of strict mode extra
// IC state.

View File

@ -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));

View File

@ -9163,22 +9163,15 @@ Handle<Map> Map::AsLanguageMode(Handle<Map> 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<Symbol> transition_symbol;
int map_index = Context::FunctionMapIndex(language_mode, kind);
Handle<Map> 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<Symbol> 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;
}

View File

@ -4404,9 +4404,9 @@ class ScopeInfo : public FixedArray {
// Properties of scopes.
class ScopeTypeField : public BitField<ScopeType, 0, 4> {};
class CallsEvalField : public BitField<bool, ScopeTypeField::kNext, 1> {};
STATIC_ASSERT(LANGUAGE_END == 3);
STATIC_ASSERT(LANGUAGE_END == 2);
class LanguageModeField
: public BitField<LanguageMode, CallsEvalField::kNext, 2> {};
: public BitField<LanguageMode, CallsEvalField::kNext, 1> {};
class DeclarationScopeField
: public BitField<bool, LanguageModeField::kNext, 1> {};
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:

View File

@ -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));
}

View File

@ -1135,8 +1135,8 @@ class AllocateTargetSpace : public BitField<AllocationSpace, 1, 3> {};
class DeclareGlobalsEvalFlag : public BitField<bool, 0, 1> {};
class DeclareGlobalsNativeFlag : public BitField<bool, 1, 1> {};
STATIC_ASSERT(LANGUAGE_END == 3);
class DeclareGlobalsLanguageMode : public BitField<LanguageMode, 2, 2> {};
STATIC_ASSERT(LANGUAGE_END == 2);
class DeclareGlobalsLanguageMode : public BitField<LanguageMode, 2, 1> {};
} // namespace internal
} // namespace v8

View File

@ -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