[no-wasm] Exclude asm->wasm translation code

The v8_enable_webassembly=false configuration will not be a able to run
any wasm code, hence remove the whole asm to wasm translation from the
binary.

In order to skip specific unit tests in that configuration, we move the
definition of the v8_enable_webassembly gn argument from BUILD.gn to
v8.gni, such that it is available in all gn files.

R=ecmziegler@chromium.org, machenbach@chromium.org

Bug: v8:11238
Change-Id: Id4e290df3e42ffd2f05c377bdd3a368871815daf
Cq-Include-Trybots: luci.v8.try:v8_linux64_no_wasm_compile_rel
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2712562
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Emanuel Ziegler <ecmziegler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72945}
This commit is contained in:
Clemens Backes 2021-02-22 14:28:17 +01:00 committed by Commit Bot
parent 0c5a0a7205
commit ca89bf259f
9 changed files with 48 additions and 36 deletions

View File

@ -292,11 +292,6 @@ declare_args() {
# header files are placed in a separate header file v8-gn.h.
v8_generate_external_defines_header = false
# Include support for WebAssembly. If disabled, the 'WebAssembly' global
# will not be available, and embedder APIs to generate WebAssembly modules
# will fail.
v8_enable_webassembly = true
# Experimental feature for tracking constness of properties in non-global
# dictionaries. Enabling this also always keeps prototypes in dict mode,
# meaning that they are not switched to fast mode.
@ -2531,15 +2526,6 @@ v8_source_set("v8_base_without_compiler") {
"src/api/api-natives.h",
"src/api/api.cc",
"src/api/api.h",
"src/asmjs/asm-js.cc",
"src/asmjs/asm-js.h",
"src/asmjs/asm-names.h",
"src/asmjs/asm-parser.cc",
"src/asmjs/asm-parser.h",
"src/asmjs/asm-scanner.cc",
"src/asmjs/asm-scanner.h",
"src/asmjs/asm-types.cc",
"src/asmjs/asm-types.h",
"src/ast/ast-function-literal-id-reindexer.cc",
"src/ast/ast-function-literal-id-reindexer.h",
"src/ast/ast-source-ranges.h",
@ -3677,6 +3663,20 @@ v8_source_set("v8_base_without_compiler") {
"src/zone/zone.h",
]
if (v8_enable_webassembly) {
sources += [
"src/asmjs/asm-js.cc",
"src/asmjs/asm-js.h",
"src/asmjs/asm-names.h",
"src/asmjs/asm-parser.cc",
"src/asmjs/asm-parser.h",
"src/asmjs/asm-scanner.cc",
"src/asmjs/asm-scanner.h",
"src/asmjs/asm-types.cc",
"src/asmjs/asm-types.h",
]
}
if (!v8_control_flow_integrity) {
sources += [ "src/execution/pointer-authentication-dummy.h" ]
}

View File

@ -64,6 +64,12 @@ declare_args() {
# Enable WebAssembly debugging via GDB-remote protocol.
v8_enable_wasm_gdb_remote_debugging = false
# Include support for WebAssembly. If disabled, the 'WebAssembly' global
# will not be available, and embedder APIs to generate WebAssembly modules
# will fail. Also, asm.js will not be translated to WebAssembly and will be
# executed as standard JavaScript instead.
v8_enable_webassembly = true
# Add fuzzilli fuzzer support.
v8_fuzzilli = false

View File

@ -499,6 +499,7 @@ void OptimizedCompilationJob::RecordFunctionCompilation(
namespace {
#if V8_ENABLE_WEBASSEMBLY
bool UseAsmWasm(FunctionLiteral* literal, bool asm_wasm_broken) {
// Check whether asm.js validation is enabled.
if (!FLAG_validate_asm) return false;
@ -513,6 +514,7 @@ bool UseAsmWasm(FunctionLiteral* literal, bool asm_wasm_broken) {
// In general, we respect the "use asm" directive.
return literal->scope()->IsAsmModule();
}
#endif
void InstallInterpreterTrampolineCopy(Isolate* isolate,
Handle<SharedFunctionInfo> shared_info) {
@ -740,6 +742,7 @@ ExecuteSingleUnoptimizedCompilationJob(
AccountingAllocator* allocator,
std::vector<FunctionLiteral*>* eager_inner_literals,
LocalIsolate* local_isolate) {
#if V8_ENABLE_WEBASSEMBLY
if (UseAsmWasm(literal, parse_info->flags().is_asm_wasm_broken())) {
std::unique_ptr<UnoptimizedCompilationJob> asm_job(
AsmJs::NewCompilationJob(parse_info, literal, allocator));
@ -752,6 +755,7 @@ ExecuteSingleUnoptimizedCompilationJob(
// with a validation error or another error that could be solve by falling
// through to standard unoptimized compile.
}
#endif
std::unique_ptr<UnoptimizedCompilationJob> job(
interpreter::Interpreter::NewCompilationJob(
parse_info, literal, allocator, eager_inner_literals, local_isolate));

View File

@ -205,10 +205,12 @@ RUNTIME_FUNCTION(Runtime_InstantiateAsmJs) {
}
Handle<SharedFunctionInfo> shared(function->shared(), isolate);
if (shared->HasAsmWasmData()) {
#if V8_ENABLE_WEBASSEMBLY
Handle<AsmWasmData> data(shared->asm_wasm_data(), isolate);
MaybeHandle<Object> result = AsmJs::InstantiateAsmWasm(
isolate, shared, data, stdlib, foreign, memory);
if (!result.is_null()) return *result.ToHandleChecked();
#endif
// Remove wasm data, mark as broken for asm->wasm, replace function code
// with UncompiledData, and return a smi 0 to indicate failure.
SharedFunctionInfo::DiscardCompiled(isolate, shared);

View File

@ -1685,12 +1685,18 @@ void InstanceBuilder::ProcessExports(Handle<WasmInstanceObject> instance) {
Handle<JSObject> exports_object;
MaybeHandle<String> single_function_name;
bool is_asm_js = is_asmjs_module(module_);
// TODO(clemensb): Remove this #if once this compilation unit is fully
// excluded from non-wasm builds.
if (is_asm_js) {
#if V8_ENABLE_WEBASSEMBLY
Handle<JSFunction> object_function = Handle<JSFunction>(
isolate_->native_context()->object_function(), isolate_);
exports_object = isolate_->factory()->NewJSObject(object_function);
single_function_name =
isolate_->factory()->InternalizeUtf8String(AsmJs::kSingleFunctionName);
#else
UNREACHABLE();
#endif
} else {
exports_object = isolate_->factory()->NewJSObjectWithNullProto();
}

View File

@ -511,6 +511,7 @@
##############################################################################
# TODO(v8:7777): Change this once wasm is supported in jitless mode.
['not has_webassembly or variant == jitless', {
'test-api/TurboAsmDisablesDetach': [SKIP],
'test-api/WasmI32AtomicWaitCallback': [SKIP],
'test-api/WasmI64AtomicWaitCallback': [SKIP],
'test-api-wasm/WasmStreaming*': [SKIP],
@ -626,7 +627,6 @@
'serializer-tester/SerializeConstructWithSpread': [SKIP],
'serializer-tester/SerializeInlinedClosure': [SKIP],
'serializer-tester/SerializeInlinedFunction': [SKIP],
'test-api/TurboAsmDisablesDetach': [SKIP],
'test-cpu-profiler/TickLinesOptimized': [SKIP],
'test-heap/TestOptimizeAfterBytecodeFlushingCandidate': [SKIP],
'test-js-to-wasm/*': [SKIP],

View File

@ -15468,7 +15468,7 @@ static int asm_warning_triggered = 0;
static void AsmJsWarningListener(v8::Local<v8::Message> message,
v8::Local<Value>) {
DCHECK_EQ(v8::Isolate::kMessageWarning, message->ErrorLevel());
CHECK_EQ(v8::Isolate::kMessageWarning, message->ErrorLevel());
asm_warning_triggered = 1;
}
@ -15490,7 +15490,12 @@ TEST(AsmJsWarning) {
" return {};\n"
"}\n"
"module();");
DCHECK_EQ(1, asm_warning_triggered);
#if V8_ENABLE_WEBASSEMBLY
int kExpectedWarnings = 1;
#else
int kExpectedWarnings = 0;
#endif
CHECK_EQ(kExpectedWarnings, asm_warning_triggered);
isolate->RemoveMessageListeners(AsmJsWarningListener);
}

View File

@ -328,6 +328,7 @@
# TODO(v8:7777): Change this once wasm is supported in jitless mode.
['not has_webassembly or variant == jitless', {
# Skip tests that require webassembly.
'regress/asm/*': [SKIP],
'regress/wasm/*': [SKIP],
'wasm/*': [SKIP],
@ -350,28 +351,11 @@
##############################################################################
['lite_mode or variant == jitless', {
# Other tests that use optimized code.
'regress/asm/regress-599719': [SKIP],
'regress/asm/regress-6196': [SKIP],
'regress/asm/regress-6700': [SKIP],
'regress/asm/regress-6838-2': [SKIP],
'regress/asm/regress-6838-3': [SKIP],
'regress/asm/regress-6838-4': [SKIP],
'regress/asm/regress-9022': [SKIP],
'regress/asm/regress-crbug-934138': [SKIP],
'regress/asm/regress-crbug-976934': [SKIP],
# Timeouts in lite / jitless mode.
'asm/embenchen/*': [SKIP],
# Tests that generate code at runtime.
'code-comments': [SKIP],
'regress/asm/regress-617526': [SKIP],
'regress/asm/regress-7893': [SKIP],
'regress/asm/regress-8377': [SKIP],
'regress/asm/regress-crbug-721835': [SKIP],
'regress/asm/regress-crbug-759327': [SKIP],
'regress/asm/regress-crbug-898974': [SKIP],
'regexp-tier-up': [SKIP],
'regexp-tier-up-multiple': [SKIP],
'regress/regress-996234': [SKIP],

View File

@ -203,8 +203,6 @@ v8_source_set("unittests_sources") {
"api/remote-object-unittest.cc",
"api/resource-constraints-unittest.cc",
"api/v8-object-unittest.cc",
"asmjs/asm-scanner-unittest.cc",
"asmjs/asm-types-unittest.cc",
"base/address-region-unittest.cc",
"base/atomic-utils-unittest.cc",
"base/bits-unittest.cc",
@ -403,6 +401,13 @@ v8_source_set("unittests_sources") {
"zone/zone-unittest.cc",
]
if (v8_enable_webassembly) {
sources += [
"asmjs/asm-scanner-unittest.cc",
"asmjs/asm-types-unittest.cc",
]
}
if (v8_enable_wasm_gdb_remote_debugging) {
sources += [ "wasm/wasm-gdbserver-unittest.cc" ]
}