Expose WeakMap::Delete on debug interface

Bug: chromium:1213393
Change-Id: I100c5caba38cab3a1ef9511125937ef7b34d818f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2966381
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75203}
This commit is contained in:
Sigurd Schneider 2021-06-16 13:00:48 +02:00 committed by V8 LUCI CQ
parent a117f6657a
commit 0fe26ef950
5 changed files with 24 additions and 2 deletions

View File

@ -1175,6 +1175,21 @@ v8::MaybeLocal<v8::Value> WeakMap::Get(v8::Local<v8::Context> context,
RETURN_ESCAPED(result);
}
v8::Maybe<bool> WeakMap::Delete(v8::Local<v8::Context> context,
v8::Local<v8::Value> key) {
PREPARE_FOR_EXECUTION_WITH_CONTEXT(context, WeakMap, Delete, Nothing<bool>(),
InternalEscapableScope, false);
auto self = Utils::OpenHandle(this);
Local<Value> result;
i::Handle<i::Object> argv[] = {Utils::OpenHandle(*key)};
has_pending_exception = !ToLocal<Value>(
i::Execution::CallBuiltin(isolate, isolate->weakmap_delete(), self,
arraysize(argv), argv),
&result);
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return Just(result->IsTrue());
}
v8::MaybeLocal<WeakMap> WeakMap::Set(v8::Local<v8::Context> context,
v8::Local<v8::Value> key,
v8::Local<v8::Value> value) {

View File

@ -568,6 +568,8 @@ class WeakMap : public v8::Object {
WeakMap() = delete;
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT v8::MaybeLocal<v8::Value> Get(
v8::Local<v8::Context> context, v8::Local<v8::Value> key);
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT v8::Maybe<bool> Delete(
v8::Local<v8::Context> context, v8::Local<v8::Value> key);
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT v8::MaybeLocal<WeakMap> Set(
v8::Local<v8::Context> context, v8::Local<v8::Value> key,
v8::Local<v8::Value> value);

View File

@ -3732,8 +3732,11 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
Handle<JSObject> prototype(JSObject::cast(cons->instance_prototype()),
isolate());
SimpleInstallFunction(isolate_, prototype, "delete",
Builtin::kWeakMapPrototypeDelete, 1, true);
Handle<JSFunction> weakmap_delete =
SimpleInstallFunction(isolate_, prototype, "delete",
Builtin::kWeakMapPrototypeDelete, 1, true);
native_context()->set_weakmap_delete(*weakmap_delete);
Handle<JSFunction> weakmap_get = SimpleInstallFunction(
isolate_, prototype, "get", Builtin::kWeakMapGet, 1, true);
native_context()->set_weakmap_get(*weakmap_get);

View File

@ -298,6 +298,7 @@ class RuntimeCallTimer final {
V(WasmCompileError_New) \
V(WasmLinkError_New) \
V(WasmRuntimeError_New) \
V(WeakMap_Delete) \
V(WeakMap_Get) \
V(WeakMap_New) \
V(WeakMap_Set)

View File

@ -341,6 +341,7 @@ enum ContextLookupFlags {
wasm_runtime_error_function) \
V(WEAKMAP_SET_INDEX, JSFunction, weakmap_set) \
V(WEAKMAP_GET_INDEX, JSFunction, weakmap_get) \
V(WEAKMAP_DELETE_INDEX, JSFunction, weakmap_delete) \
V(WEAKSET_ADD_INDEX, JSFunction, weakset_add) \
V(RETAINED_MAPS, WeakArrayList, retained_maps) \
V(OSR_CODE_CACHE_INDEX, WeakFixedArray, osr_code_cache)