Commit 5e8eb624 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[asm.js] Prevent throwing of asm.js warning messages.

This fixes a corner case which allowed warnings during the asm.js
instantiation to be promoted to actual exceptions. Even instantiation
attempts that fail are not allowed to throw exceptions observable by
JavaScript, but need to fall back to JavaScript execution.

R=clemensh@chromium.org
TEST=mjsunit/regress/regress-6203
BUG=v8:6203

Change-Id: I86f5a3adda4bcfe63b5cddc42d8ae1c3dbb88147
Reviewed-on: https://chromium-review.googlesource.com/468808
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44414}
parent 639f44d4
......@@ -165,7 +165,6 @@ bool IsStdlibMemberValid(i::Isolate* isolate, Handle<JSReceiver> stdlib,
} // namespace
MaybeHandle<FixedArray> AsmJs::CompileAsmViaWasm(CompilationInfo* info) {
ErrorThrower thrower(info->isolate(), "Asm.js -> WebAssembly conversion");
wasm::ZoneBuffer* module = nullptr;
wasm::ZoneBuffer* asm_offsets = nullptr;
Handle<FixedArray> uses_array;
......@@ -239,11 +238,13 @@ MaybeHandle<FixedArray> AsmJs::CompileAsmViaWasm(CompilationInfo* info) {
base::ElapsedTimer compile_timer;
compile_timer.Start();
ErrorThrower thrower(info->isolate(), "Asm.js -> WebAssembly conversion");
MaybeHandle<JSObject> compiled = SyncCompileTranslatedAsmJs(
info->isolate(), &thrower,
wasm::ModuleWireBytes(module->begin(), module->end()), info->script(),
asm_offsets_vec);
DCHECK(!compiled.is_null());
DCHECK(!thrower.error());
double compile_time = compile_timer.Elapsed().InMillisecondsF();
DCHECK_GE(module->end(), module->begin());
uintptr_t wasm_size = module->end() - module->begin();
......@@ -307,8 +308,6 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(i::Isolate* isolate,
i::Handle<i::FixedArray> foreign_globals(
i::FixedArray::cast(wasm_data->get(kWasmDataForeignGlobals)));
ErrorThrower thrower(isolate, "Asm.js -> WebAssembly instantiation");
// Create the ffi object for foreign functions {"": foreign}.
Handle<JSObject> ffi_object;
if (!foreign.is_null()) {
......@@ -319,11 +318,14 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(i::Isolate* isolate,
foreign, NONE);
}
ErrorThrower thrower(isolate, "Asm.js -> WebAssembly instantiation");
i::MaybeHandle<i::Object> maybe_module_object =
i::wasm::SyncInstantiate(isolate, &thrower, module, ffi_object, memory);
if (maybe_module_object.is_null()) {
thrower.Reify(); // Ensure exceptions do not propagate.
return MaybeHandle<Object>();
}
DCHECK(!thrower.error());
i::Handle<i::Object> module_object = maybe_module_object.ToHandleChecked();
if (!FLAG_fast_validate_asm) {
......
......@@ -657,10 +657,6 @@
##############################################################################
['variant == asm_wasm', {
# Issue 6127: We won't fix these in the "old" validator. But we definitely
# need to re-enable these for the "new" validator.
'regress/regress-618608': [SKIP],
# Issue 6127: Currently {StashCode} breaks the source position table.
'wasm/asm-wasm-expr': [SKIP],
}], # variant == asm_wasm
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function Module(stdlib, imports, buffer) {
"use asm";
var a = imports.x | 0;
function f() {
return a | 0;
}
return { f:f };
}
try {
Module(this).f();
} catch(e) {
assertInstanceof(e, TypeError);
// The following print is needed to cross the API boundary and thereby flush
// out any leftover scheduled exceptions. Any other API function would do.
print(e);
}
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