@@ -74,50 +74,6 @@ i::MaybeHandle<i::WasmModuleObject> GetFirstArgumentAsModule(
7474 v8::Utils::OpenHandle (*module_obj));
7575}
7676
77- bool IsCompilationAllowed (i::Isolate* isolate, ErrorThrower* thrower,
78- v8::Local<v8::Value> source, bool is_async) {
79- // Allow caller to do one final check on thrower state, rather than
80- // one at each step. No information is lost - failure reason is captured
81- // in the thrower state.
82- if (thrower->error ()) return false ;
83-
84- AllowWasmCompileCallback callback = isolate->allow_wasm_compile_callback ();
85- if (callback != nullptr &&
86- !callback (reinterpret_cast <v8::Isolate*>(isolate), source, is_async)) {
87- thrower->RangeError (
88- " %ssynchronous compilation disallowed due to module size limit set by "
89- " embedder" ,
90- is_async ? " a" : " " );
91- return false ;
92- }
93- return true ;
94- }
95-
96- bool IsInstantiationAllowed (i::Isolate* isolate, ErrorThrower* thrower,
97- v8::Local<v8::Value> module_or_bytes,
98- i::MaybeHandle<i::JSReceiver> ffi, bool is_async) {
99- // Allow caller to do one final check on thrower state, rather than
100- // one at each step. No information is lost - failure reason is captured
101- // in the thrower state.
102- if (thrower->error ()) return false ;
103- v8::MaybeLocal<v8::Value> v8_ffi;
104- if (!ffi.is_null ()) {
105- v8_ffi = v8::Local<v8::Value>::Cast (Utils::ToLocal (ffi.ToHandleChecked ()));
106- }
107- AllowWasmInstantiateCallback callback =
108- isolate->allow_wasm_instantiate_callback ();
109- if (callback != nullptr &&
110- !callback (reinterpret_cast <v8::Isolate*>(isolate), module_or_bytes,
111- v8_ffi, is_async)) {
112- thrower->RangeError (
113- " %ssynchronous instantiation disallowed due to module size limit set "
114- " by embedder" ,
115- is_async ? " a" : " " );
116- return false ;
117- }
118- return true ;
119- }
120-
12177i::wasm::ModuleWireBytes GetFirstArgumentAsBytes (
12278 const v8::FunctionCallbackInfo<v8::Value>& args, ErrorThrower* thrower) {
12379 if (args.Length () < 1 ) {
@@ -190,12 +146,11 @@ void WebAssemblyCompile(const v8::FunctionCallbackInfo<v8::Value>& args) {
190146 return_value.Set (resolver->GetPromise ());
191147
192148 auto bytes = GetFirstArgumentAsBytes (args, &thrower);
193- if (! IsCompilationAllowed (i_isolate, & thrower, args[ 0 ], true )) {
149+ if (thrower. error ( )) {
194150 auto maybe = resolver->Reject (context, Utils::ToLocal (thrower.Reify ()));
195151 CHECK (!maybe.IsNothing ());
196152 return ;
197153 }
198- DCHECK (!thrower.error ());
199154 i::Handle<i::JSPromise> promise = Utils::OpenHandle (*resolver->GetPromise ());
200155 i::wasm::AsyncCompile (i_isolate, promise, bytes);
201156}
@@ -230,9 +185,10 @@ void WebAssemblyModule(const v8::FunctionCallbackInfo<v8::Value>& args) {
230185 ErrorThrower thrower (i_isolate, " WebAssembly.Module()" );
231186
232187 auto bytes = GetFirstArgumentAsBytes (args, &thrower);
233- if (!IsCompilationAllowed (i_isolate, &thrower, args[0 ], false )) return ;
234188
235- DCHECK (!thrower.error ());
189+ if (thrower.error ()) {
190+ return ;
191+ }
236192 i::MaybeHandle<i::Object> module_obj =
237193 i::wasm::SyncCompile (i_isolate, &thrower, bytes);
238194 if (module_obj.is_null ()) return ;
@@ -309,11 +265,7 @@ void WebAssemblyInstance(const v8::FunctionCallbackInfo<v8::Value>& args) {
309265 if (thrower.error ()) return ;
310266
311267 auto maybe_imports = GetSecondArgumentAsImports (args, &thrower);
312- if (!IsInstantiationAllowed (i_isolate, &thrower, args[0 ], maybe_imports,
313- false )) {
314- return ;
315- }
316- DCHECK (!thrower.error ());
268+ if (thrower.error ()) return ;
317269
318270 i::MaybeHandle<i::Object> instance_object = i::wasm::SyncInstantiate (
319271 i_isolate, &thrower, maybe_module.ToHandleChecked (), maybe_imports,
@@ -366,12 +318,6 @@ void WebAssemblyInstantiate(const v8::FunctionCallbackInfo<v8::Value>& args) {
366318 CHECK (!maybe.IsNothing ());
367319 return ;
368320 }
369- if (!IsInstantiationAllowed (i_isolate, &thrower, args[0 ], maybe_imports,
370- true )) {
371- auto maybe = resolver->Reject (context, Utils::ToLocal (thrower.Reify ()));
372- CHECK (!maybe.IsNothing ());
373- return ;
374- }
375321 i::Handle<i::JSPromise> promise = Utils::OpenHandle (*resolver->GetPromise ());
376322 if (HasBrand (first_arg, i::Handle<i::Symbol>(i_context->wasm_module_sym ()))) {
377323 // WebAssembly.instantiate(module, imports) -> WebAssembly.Instance
0 commit comments