Skip to content

Commit 6226576

Browse files
mtrofinCommit bot
authored andcommitted
[wasm] Deleted old way of checking embedder limits on wasm size.
BUG=v8:6027 Review-Url: https://codereview.chromium.org/2772203005 Cr-Commit-Position: refs/heads/master@{#44168}
1 parent 85cf24d commit 6226576

4 files changed

Lines changed: 6 additions & 94 deletions

File tree

include/v8.h

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5994,20 +5994,6 @@ typedef void (*FailedAccessCheckCallback)(Local<Object> target,
59945994
typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context);
59955995

59965996
// --- WASM compilation callbacks ---
5997-
5998-
/**
5999-
* Callback to check if a buffer source may be compiled to WASM, given
6000-
* the compilation is attempted as a promise or not.
6001-
*/
6002-
6003-
typedef bool (*AllowWasmCompileCallback)(Isolate* isolate, Local<Value> source,
6004-
bool as_promise);
6005-
6006-
typedef bool (*AllowWasmInstantiateCallback)(Isolate* isolate,
6007-
Local<Value> module_or_bytes,
6008-
MaybeLocal<Value> ffi,
6009-
bool as_promise);
6010-
60115997
typedef bool (*ExtensionCallback)(const FunctionCallbackInfo<Value>&);
60125998

60135999
// --- Garbage Collection Callbacks ---
@@ -7244,15 +7230,8 @@ class V8_EXPORT Isolate {
72447230
AllowCodeGenerationFromStringsCallback callback);
72457231

72467232
/**
7247-
* Set the callback to invoke to check if wasm compilation from
7248-
* the specified object is allowed. By default, wasm compilation
7249-
* is allowed.
7250-
*
7251-
* Similar for instantiate.
7233+
* Embedder over{ride|load} injection points for wasm APIs.
72527234
*/
7253-
void SetAllowWasmCompileCallback(AllowWasmCompileCallback callback);
7254-
void SetAllowWasmInstantiateCallback(AllowWasmInstantiateCallback callback);
7255-
72567235
void SetWasmModuleCallback(ExtensionCallback callback);
72577236
void SetWasmCompileCallback(ExtensionCallback callback);
72587237
void SetWasmInstanceCallback(ExtensionCallback callback);

src/api.cc

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8724,17 +8724,6 @@ void Isolate::SetAllowCodeGenerationFromStringsCallback(
87248724
isolate->set_allow_code_gen_callback(callback);
87258725
}
87268726

8727-
void Isolate::SetAllowWasmCompileCallback(AllowWasmCompileCallback callback) {
8728-
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
8729-
isolate->set_allow_wasm_compile_callback(callback);
8730-
}
8731-
8732-
void Isolate::SetAllowWasmInstantiateCallback(
8733-
AllowWasmInstantiateCallback callback) {
8734-
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
8735-
isolate->set_allow_wasm_instantiate_callback(callback);
8736-
}
8737-
87388727
#define CALLBACK_SETTER(ExternalName, Type, InternalName) \
87398728
void Isolate::Set##ExternalName(Type callback) { \
87408729
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); \

src/isolate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,6 @@ typedef List<HeapObject*> DebugObjectCache;
395395
V(OOMErrorCallback, oom_behavior, nullptr) \
396396
V(LogEventCallback, event_logger, nullptr) \
397397
V(AllowCodeGenerationFromStringsCallback, allow_code_gen_callback, nullptr) \
398-
V(AllowWasmCompileCallback, allow_wasm_compile_callback, nullptr) \
399-
V(AllowWasmInstantiateCallback, allow_wasm_instantiate_callback, nullptr) \
400398
V(ExtensionCallback, wasm_module_callback, &NoExtension) \
401399
V(ExtensionCallback, wasm_instance_callback, &NoExtension) \
402400
V(ExtensionCallback, wasm_compile_callback, &NoExtension) \

src/wasm/wasm-js.cc

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
12177
i::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

Comments
 (0)