Commit 8fd0ce04 authored by hablich's avatar hablich Committed by Commit bot

Revert of There are only 2 language modes, not 3 (patchset #4 id:60001 of...

Revert of There are only 2 language modes, not 3 (patchset #4 id:60001 of https://codereview.chromium.org/2250703003/ )

Reason for revert:
Breaks ARM and MIPS builds e.g. https://build.chromium.org/p/client.v8.ports/builders/V8%20Arm%20-%20debug%20builder/builds/2479/steps/compile/logs/stdio

Original issue's description:
> There are only 2 language modes, not 3
>
> BUG=
>
> Committed: https://crrev.com/39764ba293412adde99a77a66d0750695312e006
> Cr-Commit-Position: refs/heads/master@{#38704}

TBR=neis@chromium.org,marja@chromium.org,verwaest@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=

Review-Url: https://codereview.chromium.org/2257133002
Cr-Commit-Position: refs/heads/master@{#38714}
parent 8fdf6031
......@@ -496,8 +496,8 @@ class Scope: public ZoneObject {
// Scope-specific information computed during parsing.
//
// The language mode of this scope.
STATIC_ASSERT(LANGUAGE_END == 2);
LanguageMode language_mode_ : 1;
STATIC_ASSERT(LANGUAGE_END == 3);
LanguageMode language_mode_ : 2;
// 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
......
......@@ -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, 1> {};
STATIC_ASSERT(LANGUAGE_END == 2);
class LanguageModeBits : public BitField<LanguageMode, 4, 2> {};
STATIC_ASSERT(LANGUAGE_END == 3);
DEFINE_CALL_INTERFACE_DESCRIPTOR(StoreGlobalViaContext);
DEFINE_PLATFORM_CODE_STUB(StoreGlobalViaContext, PlatformCodeStub);
......
......@@ -272,7 +272,8 @@ template <typename T, class P = FreeStoreAllocationPolicy> class List;
// The Strict Mode (ECMA-262 5th edition, 4.2.2).
enum LanguageMode : uint32_t { SLOPPY, STRICT, LANGUAGE_END };
enum LanguageMode { SLOPPY, STRICT, LANGUAGE_END = 3 };
inline std::ostream& operator<<(std::ostream& os, const LanguageMode& mode) {
switch (mode) {
......
......@@ -257,8 +257,8 @@ class StoreICState final BASE_EMBEDDED {
return StoreICState(state).language_mode();
}
class LanguageModeState : public BitField<LanguageMode, 1, 1> {};
STATIC_ASSERT(i::LANGUAGE_END == 2);
class LanguageModeState : public BitField<LanguageMode, 1, 2> {};
STATIC_ASSERT(i::LANGUAGE_END == 3);
// For convenience, a statically declared encoding of strict mode extra
// IC state.
......
......@@ -6015,14 +6015,14 @@ void SharedFunctionInfo::set_optimization_disabled(bool disable) {
LanguageMode SharedFunctionInfo::language_mode() {
STATIC_ASSERT(LANGUAGE_END == 2);
STATIC_ASSERT(LANGUAGE_END == 3);
return construct_language_mode(
BooleanBit::get(compiler_hints(), kStrictModeFunction));
}
void SharedFunctionInfo::set_language_mode(LanguageMode language_mode) {
STATIC_ASSERT(LANGUAGE_END == 2);
STATIC_ASSERT(LANGUAGE_END == 3);
// 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));
......
......@@ -9163,15 +9163,22 @@ 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 == 2);
DCHECK_EQ(STRICT, language_mode);
Handle<Symbol> transition_symbol =
isolate->factory()->strict_function_transition_symbol();
STATIC_ASSERT(LANGUAGE_END == 3);
switch (language_mode) {
case STRICT:
transition_symbol = factory->strict_function_transition_symbol();
break;
default:
UNREACHABLE();
break;
}
Map* maybe_transition =
TransitionArray::SearchSpecial(*initial_map, *transition_symbol);
if (maybe_transition != NULL) {
......@@ -16013,7 +16020,7 @@ class StringSharedKey : public HashTableKey {
// collection.
Script* script(Script::cast(shared->script()));
hash ^= String::cast(script->source())->Hash();
STATIC_ASSERT(LANGUAGE_END == 2);
STATIC_ASSERT(LANGUAGE_END == 3);
if (is_strict(language_mode)) hash ^= 0x8000;
hash += scope_position;
}
......
......@@ -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 == 2);
STATIC_ASSERT(LANGUAGE_END == 3);
class LanguageModeField
: public BitField<LanguageMode, CallsEvalField::kNext, 1> {};
: public BitField<LanguageMode, CallsEvalField::kNext, 2> {};
class DeclarationScopeField
: public BitField<bool, LanguageModeField::kNext, 1> {};
class ReceiverVariableField
......@@ -7508,6 +7508,8 @@ 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:
......
......@@ -175,7 +175,7 @@ class ParseInfo {
return construct_language_mode(is_strict_mode());
}
void set_language_mode(LanguageMode language_mode) {
STATIC_ASSERT(LANGUAGE_END == 2);
STATIC_ASSERT(LANGUAGE_END == 3);
set_strict_mode(is_strict(language_mode));
}
......
......@@ -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 == 2);
class DeclareGlobalsLanguageMode : public BitField<LanguageMode, 2, 1> {};
STATIC_ASSERT(LANGUAGE_END == 3);
class DeclareGlobalsLanguageMode : public BitField<LanguageMode, 2, 2> {};
} // namespace internal
} // namespace v8
......
......@@ -65,7 +65,8 @@ 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 == 2);
STATIC_ASSERT(LANGUAGE_END == 3);
const LanguageMode kLanguageModes[] = {SLOPPY, STRICT};
} // namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment