[no-wasm][parsing] Remove asm detection

asm validation and translation to wasm is disabled in no-wasm builds,
hence remove respective detection and marking of scopes and functions.

R=verwaest@chromium.org

Bug: v8:11238
Change-Id: I2ac8a84024fa37a0c5896a0f85ea4beea4d93137
Cq-Include-Trybots: luci.v8.try:v8_linux64_no_wasm_compile_rel
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2757689
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73410}
This commit is contained in:
Clemens Backes 2021-03-12 20:20:08 +01:00 committed by Commit Bot
parent a88503ba07
commit 3c702243d2
9 changed files with 44 additions and 3 deletions

View File

@ -296,7 +296,9 @@ Scope::Scope(Zone* zone, const AstRawString* catch_variable_name,
void DeclarationScope::SetDefaults() {
is_declaration_scope_ = true;
has_simple_parameters_ = true;
#if V8_ENABLE_WEBASSEMBLY
is_asm_module_ = false;
#endif // V8_ENABLE_WEBASSEMBLY
force_eager_compilation_ = false;
has_arguments_parameter_ = false;
uses_super_property_ = false;
@ -373,6 +375,7 @@ void DeclarationScope::set_should_eager_compile() {
should_eager_compile_ = !was_lazily_parsed_;
}
#if V8_ENABLE_WEBASSEMBLY
void DeclarationScope::set_is_asm_module() { is_asm_module_ = true; }
bool Scope::IsAsmModule() const {
@ -393,6 +396,7 @@ bool Scope::ContainsAsmModule() const {
return false;
}
#endif // V8_ENABLE_WEBASSEMBLY
Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
ScopeInfo scope_info,
@ -430,9 +434,11 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
} else if (scope_info.scope_type() == FUNCTION_SCOPE) {
outer_scope = zone->New<DeclarationScope>(
zone, FUNCTION_SCOPE, ast_value_factory, handle(scope_info, isolate));
#if V8_ENABLE_WEBASSEMBLY
if (scope_info.IsAsmModule()) {
outer_scope->AsDeclarationScope()->set_is_asm_module();
}
#endif // V8_ENABLE_WEBASSEMBLY
} else if (scope_info.scope_type() == EVAL_SCOPE) {
outer_scope = zone->New<DeclarationScope>(
zone, EVAL_SCOPE, ast_value_factory, handle(scope_info, isolate));
@ -1850,7 +1856,9 @@ void Scope::Print(int n) {
if (is_strict(language_mode())) {
Indent(n1, "// strict mode scope\n");
}
#if V8_ENABLE_WEBASSEMBLY
if (IsAsmModule()) Indent(n1, "// scope is an asm module\n");
#endif // V8_ENABLE_WEBASSEMBLY
if (is_declaration_scope() &&
AsDeclarationScope()->sloppy_eval_can_extend_vars()) {
Indent(n1, "// scope calls sloppy 'eval'\n");
@ -2501,7 +2509,10 @@ void Scope::AllocateVariablesRecursively() {
// scope.
bool must_have_context =
scope->is_with_scope() || scope->is_module_scope() ||
scope->IsAsmModule() || scope->ForceContextForLanguageMode() ||
#if V8_ENABLE_WEBASSEMBLY
scope->IsAsmModule() ||
#endif // V8_ENABLE_WEBASSEMBLY
scope->ForceContextForLanguageMode() ||
(scope->is_function_scope() &&
scope->AsDeclarationScope()->sloppy_eval_can_extend_vars()) ||
(scope->is_block_scope() && scope->is_declaration_scope() &&

View File

@ -389,10 +389,14 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
bool private_name_lookup_skips_outer_class() const {
return private_name_lookup_skips_outer_class_;
}
#if V8_ENABLE_WEBASSEMBLY
bool IsAsmModule() const;
// Returns true if this scope or any inner scopes that might be eagerly
// compiled are asm modules.
bool ContainsAsmModule() const;
#endif // V8_ENABLE_WEBASSEMBLY
// Does this scope have the potential to execute declarations non-linearly?
bool is_nonlinear() const { return scope_nonlinear_; }
// Returns if we need to force a context because the current scope is stricter
@ -972,8 +976,10 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
scope_info_ = scope_info;
}
#if V8_ENABLE_WEBASSEMBLY
bool is_asm_module() const { return is_asm_module_; }
void set_is_asm_module();
#endif // V8_ENABLE_WEBASSEMBLY
bool should_ban_arguments() const {
return IsClassMembersInitializerFunction(function_kind());
@ -1242,8 +1248,10 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
void RecalcPrivateNameContextChain();
bool has_simple_parameters_ : 1;
#if V8_ENABLE_WEBASSEMBLY
// This scope contains an "use asm" annotation.
bool is_asm_module_ : 1;
#endif // V8_ENABLE_WEBASSEMBLY
bool force_eager_compilation_ : 1;
// This function scope has a rest parameter.
bool has_rest_ : 1;

View File

@ -190,7 +190,9 @@ Handle<ScopeInfo> ScopeInfo::Create(LocalIsolate* isolate, Zone* zone,
if (scope->is_function_scope()) {
DeclarationScope* function_scope = scope->AsDeclarationScope();
has_simple_parameters = function_scope->has_simple_parameters();
#if V8_ENABLE_WEBASSEMBLY
is_asm_module = function_scope->is_asm_module();
#endif // V8_ENABLE_WEBASSEMBLY
}
FunctionKind function_kind = kNormalFunction;
if (scope->is_declaration_scope()) {

View File

@ -195,7 +195,9 @@ ParseInfo::ParseInfo(const UnoptimizedCompileFlags flags,
source_range_map_(nullptr),
literal_(nullptr),
allow_eval_cache_(false),
#if V8_ENABLE_WEBASSEMBLY
contains_asm_module_(false),
#endif // V8_ENABLE_WEBASSEMBLY
language_mode_(flags.outer_language_mode()) {
if (flags.block_coverage_enabled()) {
AllocateSourceRangeMap();

View File

@ -254,8 +254,12 @@ class V8_EXPORT_PRIVATE ParseInfo {
// Accessor methods for output flags.
bool allow_eval_cache() const { return allow_eval_cache_; }
void set_allow_eval_cache(bool value) { allow_eval_cache_ = value; }
#if V8_ENABLE_WEBASSEMBLY
bool contains_asm_module() const { return contains_asm_module_; }
void set_contains_asm_module(bool value) { contains_asm_module_ = value; }
#endif // V8_ENABLE_WEBASSEMBLY
LanguageMode language_mode() const { return language_mode_; }
void set_language_mode(LanguageMode value) { language_mode_ = value; }
@ -347,7 +351,9 @@ class V8_EXPORT_PRIVATE ParseInfo {
//----------- Output of parsing and scope analysis ------------------------
FunctionLiteral* literal_;
bool allow_eval_cache_ : 1;
#if V8_ENABLE_WEBASSEMBLY
bool contains_asm_module_ : 1;
#endif // V8_ENABLE_WEBASSEMBLY
LanguageMode language_mode_ : 1;
};

View File

@ -5036,14 +5036,18 @@ void ParserBase<Impl>::ParseStatementList(StatementListT* body,
while (peek() == Token::STRING) {
bool use_strict = false;
#if V8_ENABLE_WEBASSEMBLY
bool use_asm = false;
#endif // V8_ENABLE_WEBASSEMBLY
Scanner::Location token_loc = scanner()->peek_location();
if (scanner()->NextLiteralExactlyEquals("use strict")) {
use_strict = true;
#if V8_ENABLE_WEBASSEMBLY
} else if (scanner()->NextLiteralExactlyEquals("use asm")) {
use_asm = true;
#endif // V8_ENABLE_WEBASSEMBLY
}
StatementT stat = ParseStatementListItem();
@ -5065,9 +5069,11 @@ void ParserBase<Impl>::ParseStatementList(StatementListT* body,
"use strict");
return;
}
#if V8_ENABLE_WEBASSEMBLY
} else if (use_asm) {
// Directive "use asm".
impl()->SetAsmModule();
#endif // V8_ENABLE_WEBASSEMBLY
} else {
// Possibly an unknown directive.
// Should not change mode, but will increment usage counters

View File

@ -489,12 +489,14 @@ void Parser::DeserializeScopeChain(
namespace {
void MaybeResetCharacterStream(ParseInfo* info, FunctionLiteral* literal) {
#if V8_ENABLE_WEBASSEMBLY
// Don't reset the character stream if there is an asm.js module since it will
// be used again by the asm-parser.
if (info->contains_asm_module()) {
if (FLAG_stress_validate_asm) return;
if (literal != nullptr && literal->scope()->ContainsAsmModule()) return;
}
#endif // V8_ENABLE_WEBASSEMBLY
info->ResetCharacterStream();
}
@ -3435,6 +3437,7 @@ void Parser::SetLanguageMode(Scope* scope, LanguageMode mode) {
scope->SetLanguageMode(mode);
}
#if V8_ENABLE_WEBASSEMBLY
void Parser::SetAsmModule() {
// Store the usage count; The actual use counter on the isolate is
// incremented after parsing is done.
@ -3443,6 +3446,7 @@ void Parser::SetAsmModule() {
scope()->AsDeclarationScope()->set_is_asm_module();
info_->set_contains_asm_module(true);
}
#endif // V8_ENABLE_WEBASSEMBLY
Expression* Parser::ExpressionListToExpression(
const ScopedPtrList<Expression>& args) {

View File

@ -502,7 +502,9 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
Expression* RewriteSuperCall(Expression* call_expression);
void SetLanguageMode(Scope* scope, LanguageMode mode);
#if V8_ENABLE_WEBASSEMBLY
void SetAsmModule();
#endif // V8_ENABLE_WEBASSEMBLY
Expression* RewriteSpreads(ArrayLiteral* lit);

View File

@ -4323,6 +4323,7 @@ TEST(MaybeAssignedTopLevel) {
}
}
#if V8_ENABLE_WEBASSEMBLY
namespace {
i::Scope* DeserializeFunctionScope(i::Isolate* isolate, i::Zone* zone,
@ -4365,7 +4366,6 @@ TEST(AsmModuleFlag) {
CHECK(s->IsAsmModule() && s->AsDeclarationScope()->is_asm_module());
}
TEST(UseAsmUseCount) {
i::Isolate* isolate = CcTest::i_isolate();
i::HandleScope scope(isolate);
@ -4378,7 +4378,7 @@ TEST(UseAsmUseCount) {
"function bar() { \"use asm\"; var baz = 1; }");
CHECK_LT(0, use_counts[v8::Isolate::kUseAsm]);
}
#endif // V8_ENABLE_WEBASSEMBLY
TEST(StrictModeUseCount) {
i::Isolate* isolate = CcTest::i_isolate();