Skip to content

Commit a143651

Browse files
committed
[GR-45437] [GR-45497] Backport: Adding HandleScope also for the primary weak callback.
PullRequest: js/2786
2 parents f34735d + 6b4a83c commit a143651

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2023, 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
*/
7+
8+
/**
9+
* Regression test of Set.prototype.size getter.
10+
*/
11+
12+
load("assert.js");
13+
14+
const sizeOfThisSet = Object.getOwnPropertyDescriptor(Set.prototype, 'size').get;
15+
16+
assertThrows(() => sizeOfThisSet.call({}), TypeError);
17+
assertSame(0, sizeOfThisSet.call(new Set()));
18+
assertThrows(() => sizeOfThisSet.call(new Map()), TypeError);

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/builtins/SetPrototypeBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ protected static int doSet(JSSetObject thisObj) {
770770
}
771771

772772
@SuppressWarnings("unused")
773-
@Specialization(guards = {"!isJSMap(thisObj)"})
773+
@Specialization(guards = {"!isJSSet(thisObj)"})
774774
protected static int notSet(@SuppressWarnings("unused") Object thisObj) {
775775
throw Errors.createTypeErrorSetExpected();
776776
}

graal-nodejs/deps/v8/src/graal/callbacks.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,10 @@ void GraalWeakCallback(JNIEnv* env, jclass nativeAccess, jlong callback, jlong d
622622
v8::WeakCallbackInfo<void>::Callback second_callback = nullptr;
623623
v8::Isolate* isolate = v8::Isolate::GetCurrent();
624624
v8::WeakCallbackInfo<void> callback_info = v8::WeakCallbackInfo<void>(isolate, (void*) data, internalFields, &second_callback);
625-
v8_callback(callback_info);
625+
{
626+
v8::HandleScope scope(isolate);
627+
v8_callback(callback_info);
628+
}
626629
if (second_callback) {
627630
v8::HandleScope scope(isolate);
628631
second_callback(callback_info);
@@ -633,7 +636,10 @@ void GraalWeakCallback(JNIEnv* env, jclass nativeAccess, jlong callback, jlong d
633636
v8::WeakCallbackInfo<void>::Callback second_callback = nullptr;
634637
v8::Isolate* isolate = v8::Isolate::GetCurrent();
635638
v8::WeakCallbackInfo<void> callback_info = v8::WeakCallbackInfo<void>(isolate, internalFields[v8::kInternalFieldsInWeakCallback], internalFields, &second_callback);
636-
v8_callback(callback_info);
639+
{
640+
v8::HandleScope scope(isolate);
641+
v8_callback(callback_info);
642+
}
637643
if (second_callback) {
638644
v8::HandleScope scope(isolate);
639645
second_callback(callback_info);

0 commit comments

Comments
 (0)