Commit db1b27e8 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[compiler] Remove dangerous language mode accessors.

The language mode is no longer constant accross a compilation unit. For
example the extends clause of a class literal can be in strict mode even
though the surrounding function is in sloppy mode. This makes any global
language mode predicate that reasons over an entire function inherently
dangerous. Instead one should use the appropriate predicate on scopes or
literals directly.

R=bmeurer@chromium.org

Review-Url: https://codereview.chromium.org/1949013002
Cr-Commit-Position: refs/heads/master@{#36010}
parent a0543313
......@@ -54,7 +54,6 @@ PARSE_INFO_GETTER(bool, is_eval)
PARSE_INFO_GETTER(bool, is_native)
PARSE_INFO_GETTER(bool, is_module)
PARSE_INFO_GETTER(FunctionLiteral*, literal)
PARSE_INFO_GETTER_WITH_DEFAULT(LanguageMode, language_mode, STRICT)
PARSE_INFO_GETTER_WITH_DEFAULT(Scope*, scope, nullptr)
PARSE_INFO_GETTER_WITH_DEFAULT(Handle<Context>, context,
Handle<Context>::null())
......@@ -270,7 +269,7 @@ StackFrame::Type CompilationInfo::GetOutputStackFrameType() const {
}
bool CompilationInfo::ExpectsJSReceiverAsReceiver() {
return is_sloppy(language_mode()) && !is_native();
return is_sloppy(parse_info()->language_mode()) && !is_native();
}
#if DEBUG
......@@ -1527,7 +1526,7 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForScript(
}
parse_info.set_language_mode(
static_cast<LanguageMode>(info.language_mode() | language_mode));
static_cast<LanguageMode>(parse_info.language_mode() | language_mode));
result = CompileToplevel(&info);
if (extension == NULL && !result.is_null()) {
compilation_cache->PutScript(source, context, language_mode, result);
......
......@@ -178,7 +178,6 @@ class CompilationInfo final {
bool is_eval() const;
bool is_native() const;
bool is_module() const;
LanguageMode language_mode() const;
FunctionLiteral* literal() const;
Scope* scope() const;
Handle<Context> context() const;
......
......@@ -519,7 +519,7 @@ Reduction JSInliner::ReduceJSCall(Node* node, Handle<JSFunction> function) {
// in that frame state tho, as the conversion of the receiver can be repeated
// any number of times, it's not observable.
if (node->opcode() == IrOpcode::kJSCallFunction &&
is_sloppy(info.language_mode()) && !shared_info->native()) {
is_sloppy(parse_info.language_mode()) && !shared_info->native()) {
const CallFunctionParameters& p = CallFunctionParametersOf(node->op());
Node* effect = NodeProperties::GetEffectInput(node);
Node* convert = jsgraph_->graph()->NewNode(
......
......@@ -135,8 +135,6 @@ class LCodeGen: public LCodeGenBase {
#undef DECLARE_DO
private:
LanguageMode language_mode() const { return info()->language_mode(); }
Scope* scope() const { return scope_; }
Register scratch0() { return r9; }
......
......@@ -12266,10 +12266,9 @@ void HOptimizedGraphBuilder::VisitDeclarations(
Handle<FixedArray> array =
isolate()->factory()->NewFixedArray(globals_.length(), TENURED);
for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i));
int flags =
DeclareGlobalsEvalFlag::encode(current_info()->is_eval()) |
DeclareGlobalsNativeFlag::encode(current_info()->is_native()) |
DeclareGlobalsLanguageMode::encode(current_info()->language_mode());
int flags = DeclareGlobalsEvalFlag::encode(current_info()->is_eval()) |
DeclareGlobalsNativeFlag::encode(current_info()->is_native()) |
DeclareGlobalsLanguageMode::encode(function_language_mode());
Add<HDeclareGlobals>(array, flags);
globals_.Rewind(0);
}
......
......@@ -2246,7 +2246,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
function_state()->ClearInlinedTestContext();
}
LanguageMode function_language_mode() {
return function_state()->compilation_info()->language_mode();
return function_state()->compilation_info()->parse_info()->language_mode();
}
#define FOR_EACH_HYDROGEN_INTRINSIC(F) \
......
......@@ -115,8 +115,6 @@ class LCodeGen: public LCodeGenBase {
#undef DECLARE_DO
private:
LanguageMode language_mode() const { return info()->language_mode(); }
Scope* scope() const { return scope_; }
XMMRegister double_scratch0() const { return xmm0; }
......
......@@ -134,8 +134,6 @@ class LCodeGen: public LCodeGenBase {
#undef DECLARE_DO
private:
LanguageMode language_mode() const { return info()->language_mode(); }
Scope* scope() const { return scope_; }
Register scratch0() { return kLithiumScratchReg; }
......
......@@ -136,8 +136,6 @@ class LCodeGen: public LCodeGenBase {
#undef DECLARE_DO
private:
LanguageMode language_mode() const { return info()->language_mode(); }
Scope* scope() const { return scope_; }
Register scratch0() { return kLithiumScratchReg; }
......
......@@ -128,8 +128,6 @@ class LCodeGen : public LCodeGenBase {
#undef DECLARE_DO
private:
LanguageMode language_mode() const { return info()->language_mode(); }
Scope* scope() const { return scope_; }
Register scratch0() { return kLithiumScratch; }
......
......@@ -127,8 +127,6 @@ class LCodeGen : public LCodeGenBase {
#undef DECLARE_DO
private:
LanguageMode language_mode() const { return info()->language_mode(); }
Scope* scope() const { return scope_; }
Register scratch0() { return kLithiumScratch; }
......
......@@ -111,8 +111,6 @@ class LCodeGen: public LCodeGenBase {
#undef DECLARE_DO
private:
LanguageMode language_mode() const { return info()->language_mode(); }
LPlatformChunk* chunk() const { return chunk_; }
Scope* scope() const { return scope_; }
HGraph* graph() const { return chunk()->graph(); }
......
......@@ -150,8 +150,6 @@ class LCodeGen: public LCodeGenBase {
#undef DECLARE_DO
private:
LanguageMode language_mode() const { return info()->language_mode(); }
Scope* scope() const { return scope_; }
void EmitClassOfTest(Label* if_true,
......
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