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

[wasm] Add flag to validate asm.js modules.

This adds the --validate-asm flag which will trigger validation of all
asm.js modules before they are being compiled. In case a module doesn't
pass validation, a warning will be printed, but compilation as well as
execution will continue unhampered.

R=mvstanton@chromium.org

Review-Url: https://codereview.chromium.org/1972593002
Cr-Commit-Position: refs/heads/master@{#36216}
parent 4a7b9b97
......@@ -961,6 +961,8 @@ void Scope::Print(int n) {
if (is_strict(language_mode())) {
Indent(n1, "// strict mode scope\n");
}
if (asm_module_) Indent(n1, "// scope is an asm module\n");
if (asm_function_) Indent(n1, "// scope is an asm function\n");
if (scope_inside_with_) Indent(n1, "// scope inside 'with'\n");
if (scope_calls_eval_) Indent(n1, "// scope calls 'eval'\n");
if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n");
......
......@@ -30,6 +30,7 @@
#include "src/profiler/cpu-profiler.h"
#include "src/runtime-profiler.h"
#include "src/snapshot/code-serializer.h"
#include "src/typing-asm.h"
#include "src/vm-state-inl.h"
namespace v8 {
......@@ -464,6 +465,17 @@ int CodeAndMetadataSize(CompilationInfo* info) {
bool GenerateUnoptimizedCode(CompilationInfo* info) {
bool success;
EnsureFeedbackVector(info);
if (FLAG_validate_asm && info->scope()->asm_module()) {
AsmTyper typer(info->isolate(), info->zone(), *(info->script()),
info->literal());
if (FLAG_enable_simd_asmjs) {
typer.set_allow_simd(true);
}
if (!typer.Validate()) {
DCHECK(!info->isolate()->has_pending_exception());
PrintF("Validation of asm.js module failed: %s", typer.error_message());
}
}
if (FLAG_ignition && UseIgnition(info)) {
success = interpreter::Interpreter::MakeBytecode(info);
} else {
......
......@@ -490,6 +490,7 @@ DEFINE_BOOL(wasm_break_on_decoder_error, false,
DEFINE_BOOL(wasm_loop_assignment_analysis, true,
"perform loop assignment analysis for WASM")
DEFINE_BOOL(validate_asm, false, "validate asm.js modules before compiling")
DEFINE_BOOL(enable_simd_asmjs, false, "enable SIMD.js in asm.js stdlib")
DEFINE_BOOL(dump_wasm_module, false, "dump WASM module bytes")
......
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