Skip to content

Commit cb9a478

Browse files
iamstoliswoess
authored andcommitted
[GR-51214] Optimizing delete operator applied to a global object.
1 parent 00641ba commit cb9a478

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/nodes/control/DeletePropertyNode.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -82,6 +82,8 @@
8282
import com.oracle.truffle.js.runtime.SafeInteger;
8383
import com.oracle.truffle.js.runtime.Strings;
8484
import com.oracle.truffle.js.runtime.Symbol;
85+
import com.oracle.truffle.js.runtime.builtins.JSGlobal;
86+
import com.oracle.truffle.js.runtime.builtins.JSGlobalObject;
8587
import com.oracle.truffle.js.runtime.builtins.JSString;
8688
import com.oracle.truffle.js.runtime.objects.JSDynamicObject;
8789
import com.oracle.truffle.js.runtime.objects.JSObject;
@@ -91,7 +93,7 @@
9193
/**
9294
* 11.4.1 The delete Operator ({@code delete object[property]}).
9395
*/
94-
@ImportStatic(JSConfig.class)
96+
@ImportStatic({JSConfig.class, JSGlobal.class})
9597
@NodeInfo(shortName = "delete")
9698
public abstract class DeletePropertyNode extends JSTargetableNode {
9799
protected final boolean strict;
@@ -194,8 +196,15 @@ protected final boolean doJSOrdinaryObject(JSDynamicObject targetObject, Object
194196
}
195197
}
196198

199+
@Specialization
200+
protected final boolean doJSGlobalObject(JSGlobalObject targetObject, Object key,
201+
@Shared("toPropertyKey") @Cached JSToPropertyKeyNode toPropertyKeyNode,
202+
@CachedLibrary(limit = "InteropLibraryLimit") DynamicObjectLibrary dynamicObjectLib) {
203+
return doJSOrdinaryObject(targetObject, key, toPropertyKeyNode, dynamicObjectLib);
204+
}
205+
197206
@SuppressWarnings("truffle-static-method")
198-
@Specialization(guards = {"!isJSOrdinaryObject(targetObject)"})
207+
@Specialization(guards = {"!isJSOrdinaryObject(targetObject)", "!isJSGlobalObject(targetObject)"})
199208
protected final boolean doJSObject(JSDynamicObject targetObject, Object key,
200209
@Bind("this") Node node,
201210
@Cached("createIsFastArray()") IsArrayNode isArrayNode,

0 commit comments

Comments
 (0)