Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: src/wasm/wasm-js.cc

Issue 2772203005: [wasm] Deleted old way of checking embedder limits on wasm size. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/isolate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-js.cc
diff --git a/src/wasm/wasm-js.cc b/src/wasm/wasm-js.cc
index 9c16597b5d99cd67ddd055d9df86ba1ebc0bc3e2..e88efba82d03c73e8a463a5ec1e68d826a2e0f6f 100644
--- a/src/wasm/wasm-js.cc
+++ b/src/wasm/wasm-js.cc
@@ -74,50 +74,6 @@ i::MaybeHandle<i::WasmModuleObject> GetFirstArgumentAsModule(
v8::Utils::OpenHandle(*module_obj));
}
-bool IsCompilationAllowed(i::Isolate* isolate, ErrorThrower* thrower,
- v8::Local<v8::Value> source, bool is_async) {
- // Allow caller to do one final check on thrower state, rather than
- // one at each step. No information is lost - failure reason is captured
- // in the thrower state.
- if (thrower->error()) return false;
-
- AllowWasmCompileCallback callback = isolate->allow_wasm_compile_callback();
- if (callback != nullptr &&
- !callback(reinterpret_cast<v8::Isolate*>(isolate), source, is_async)) {
- thrower->RangeError(
- "%ssynchronous compilation disallowed due to module size limit set by "
- "embedder",
- is_async ? "a" : "");
- return false;
- }
- return true;
-}
-
-bool IsInstantiationAllowed(i::Isolate* isolate, ErrorThrower* thrower,
- v8::Local<v8::Value> module_or_bytes,
- i::MaybeHandle<i::JSReceiver> ffi, bool is_async) {
- // Allow caller to do one final check on thrower state, rather than
- // one at each step. No information is lost - failure reason is captured
- // in the thrower state.
- if (thrower->error()) return false;
- v8::MaybeLocal<v8::Value> v8_ffi;
- if (!ffi.is_null()) {
- v8_ffi = v8::Local<v8::Value>::Cast(Utils::ToLocal(ffi.ToHandleChecked()));
- }
- AllowWasmInstantiateCallback callback =
- isolate->allow_wasm_instantiate_callback();
- if (callback != nullptr &&
- !callback(reinterpret_cast<v8::Isolate*>(isolate), module_or_bytes,
- v8_ffi, is_async)) {
- thrower->RangeError(
- "%ssynchronous instantiation disallowed due to module size limit set "
- "by embedder",
- is_async ? "a" : "");
- return false;
- }
- return true;
-}
-
i::wasm::ModuleWireBytes GetFirstArgumentAsBytes(
const v8::FunctionCallbackInfo<v8::Value>& args, ErrorThrower* thrower) {
if (args.Length() < 1) {
@@ -190,12 +146,11 @@ void WebAssemblyCompile(const v8::FunctionCallbackInfo<v8::Value>& args) {
return_value.Set(resolver->GetPromise());
auto bytes = GetFirstArgumentAsBytes(args, &thrower);
- if (!IsCompilationAllowed(i_isolate, &thrower, args[0], true)) {
+ if (thrower.error()) {
auto maybe = resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
CHECK(!maybe.IsNothing());
return;
}
- DCHECK(!thrower.error());
i::Handle<i::JSPromise> promise = Utils::OpenHandle(*resolver->GetPromise());
i::wasm::AsyncCompile(i_isolate, promise, bytes);
}
@@ -230,9 +185,10 @@ void WebAssemblyModule(const v8::FunctionCallbackInfo<v8::Value>& args) {
ErrorThrower thrower(i_isolate, "WebAssembly.Module()");
auto bytes = GetFirstArgumentAsBytes(args, &thrower);
- if (!IsCompilationAllowed(i_isolate, &thrower, args[0], false)) return;
- DCHECK(!thrower.error());
+ if (thrower.error()) {
+ return;
+ }
i::MaybeHandle<i::Object> module_obj =
i::wasm::SyncCompile(i_isolate, &thrower, bytes);
if (module_obj.is_null()) return;
@@ -309,11 +265,7 @@ void WebAssemblyInstance(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (thrower.error()) return;
auto maybe_imports = GetSecondArgumentAsImports(args, &thrower);
- if (!IsInstantiationAllowed(i_isolate, &thrower, args[0], maybe_imports,
- false)) {
- return;
- }
- DCHECK(!thrower.error());
+ if (thrower.error()) return;
i::MaybeHandle<i::Object> instance_object = i::wasm::SyncInstantiate(
i_isolate, &thrower, maybe_module.ToHandleChecked(), maybe_imports,
@@ -366,12 +318,6 @@ void WebAssemblyInstantiate(const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK(!maybe.IsNothing());
return;
}
- if (!IsInstantiationAllowed(i_isolate, &thrower, args[0], maybe_imports,
- true)) {
- auto maybe = resolver->Reject(context, Utils::ToLocal(thrower.Reify()));
- CHECK(!maybe.IsNothing());
- return;
- }
i::Handle<i::JSPromise> promise = Utils::OpenHandle(*resolver->GetPromise());
if (HasBrand(first_arg, i::Handle<i::Symbol>(i_context->wasm_module_sym()))) {
// WebAssembly.instantiate(module, imports) -> WebAssembly.Instance
« no previous file with comments | « src/isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698