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

[wasm] Move ScheduledErrorThrower into wasm-js.cc file.

R=clemensh@chromium.org

Change-Id: I9f4fcddca2e478d5074d68870d0293aacdeb4aa1
Reviewed-on: https://chromium-review.googlesource.com/813920Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50951}
parent 3e43bbb5
......@@ -2125,8 +2125,6 @@ v8_source_set("v8_base") {
"src/wasm/signature-map.h",
"src/wasm/streaming-decoder.cc",
"src/wasm/streaming-decoder.h",
"src/wasm/wasm-api.cc",
"src/wasm/wasm-api.h",
"src/wasm/wasm-code-manager.cc",
"src/wasm/wasm-code-manager.h",
"src/wasm/wasm-code-specialization.cc",
......
......@@ -1455,8 +1455,6 @@
'../src/wasm/signature-map.h',
'../src/wasm/streaming-decoder.cc',
'../src/wasm/streaming-decoder.h',
'../src/wasm/wasm-api.cc',
'../src/wasm/wasm-api.h',
'../src/wasm/wasm-code-manager.cc',
'../src/wasm/wasm-code-manager.h',
'../src/wasm/wasm-code-specialization.cc',
......
// 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.
#include "src/wasm/wasm-api.h"
#include "src/isolate-inl.h"
#include "src/isolate.h"
namespace v8 {
namespace internal {
namespace wasm {
ScheduledErrorThrower::~ScheduledErrorThrower() {
// There should never be both a pending and a scheduled exception.
DCHECK(!isolate()->has_scheduled_exception() ||
!isolate()->has_pending_exception());
// Don't throw another error if there is already a scheduled error.
if (isolate()->has_scheduled_exception()) {
Reset();
} else if (isolate()->has_pending_exception()) {
Reset();
isolate()->OptionalRescheduleException(false);
} else if (error()) {
isolate()->ScheduleThrow(*Reify());
}
}
} // namespace wasm
} // namespace internal
} // namespace v8
// 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.
#ifndef V8_WASM_API_H_
#define V8_WASM_API_H_
#include "src/wasm/wasm-result.h"
namespace v8 {
namespace internal {
namespace wasm {
// Like an ErrorThrower, but turns all pending exceptions into scheduled
// exceptions when going out of scope. Use this in API methods.
// Note that pending exceptions are not necessarily created by the ErrorThrower,
// but e.g. by the wasm start function. There might also be a scheduled
// exception, created by another API call (e.g. v8::Object::Get). But there
// should never be both pending and scheduled exceptions.
class V8_EXPORT_PRIVATE ScheduledErrorThrower : public ErrorThrower {
public:
ScheduledErrorThrower(v8::Isolate* isolate, const char* context)
: ScheduledErrorThrower(reinterpret_cast<Isolate*>(isolate), context) {}
ScheduledErrorThrower(Isolate* isolate, const char* context)
: ErrorThrower(isolate, context) {}
~ScheduledErrorThrower();
};
} // namespace wasm
} // namespace internal
} // namespace v8
#endif // V8_WASM_API_H_
This diff is collapsed.
......@@ -13,7 +13,6 @@
#include "src/isolate.h"
#include "src/objects-inl.h"
#include "src/objects.h"
#include "src/wasm/wasm-api.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-module.h"
#include "test/common/wasm/flag-utils.h"
......
......@@ -7,7 +7,6 @@
#include "include/v8.h"
#include "src/isolate.h"
#include "src/objects-inl.h"
#include "src/wasm/wasm-api.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-module-builder.h"
#include "src/wasm/wasm-module.h"
......@@ -67,27 +66,35 @@ int FuzzWasmSection(SectionCode section, const uint8_t* data, size_t size) {
void InterpretAndExecuteModule(i::Isolate* isolate,
Handle<WasmModuleObject> module_object) {
ScheduledErrorThrower thrower(isolate, "WebAssembly Instantiation");
// Try to instantiate and interpret the module_object.
MaybeHandle<WasmInstanceObject> maybe_instance =
isolate->wasm_engine()->SyncInstantiate(
isolate, &thrower, module_object,
Handle<JSReceiver>::null(), // imports
MaybeHandle<JSArrayBuffer>()); // memory
ErrorThrower thrower(isolate, "WebAssembly Instantiation");
MaybeHandle<WasmInstanceObject> maybe_instance;
Handle<WasmInstanceObject> instance;
if (!maybe_instance.ToHandle(&instance)) return;
// Try to instantiate and interpret the module_object.
maybe_instance = isolate->wasm_engine()->SyncInstantiate(
isolate, &thrower, module_object,
Handle<JSReceiver>::null(), // imports
MaybeHandle<JSArrayBuffer>()); // memory
if (!maybe_instance.ToHandle(&instance)) {
isolate->clear_pending_exception();
thrower.Reset(); // Ignore errors.
return;
}
if (!testing::InterpretWasmModuleForTesting(isolate, instance, "main", 0,
nullptr)) {
return;
}
// Instantiate and execute the module_object.
// Try to instantiate and execute the module_object.
maybe_instance = isolate->wasm_engine()->SyncInstantiate(
isolate, &thrower, module_object,
Handle<JSReceiver>::null(), // imports
MaybeHandle<JSArrayBuffer>()); // memory
if (!maybe_instance.ToHandle(&instance)) return;
if (!maybe_instance.ToHandle(&instance)) {
isolate->clear_pending_exception();
thrower.Reset(); // Ignore errors.
return;
}
testing::RunWasmModuleForTesting(isolate, instance, 0, nullptr);
}
......
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