aboutsummaryrefslogtreecommitdiff
path: root/src/jdk/nashorn/internal/runtime/linker/NashornGuards.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jdk/nashorn/internal/runtime/linker/NashornGuards.java')
-rw-r--r--src/jdk/nashorn/internal/runtime/linker/NashornGuards.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/jdk/nashorn/internal/runtime/linker/NashornGuards.java b/src/jdk/nashorn/internal/runtime/linker/NashornGuards.java
index ca3e10c4..77c5e93c 100644
--- a/src/jdk/nashorn/internal/runtime/linker/NashornGuards.java
+++ b/src/jdk/nashorn/internal/runtime/linker/NashornGuards.java
@@ -31,6 +31,7 @@ import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.ref.WeakReference;
import jdk.internal.dynalink.CallSiteDescriptor;
+import jdk.nashorn.api.scripting.JSObject;
import jdk.nashorn.internal.codegen.ObjectClassGenerator;
import jdk.nashorn.internal.objects.Global;
import jdk.nashorn.internal.runtime.Property;
@@ -43,6 +44,7 @@ import jdk.nashorn.internal.runtime.ScriptObject;
*/
public final class NashornGuards {
private static final MethodHandle IS_SCRIPTOBJECT = findOwnMH("isScriptObject", boolean.class, Object.class);
+ private static final MethodHandle IS_NOT_JSOBJECT = findOwnMH("isNotJSObject", boolean.class, Object.class);
private static final MethodHandle IS_SCRIPTFUNCTION = findOwnMH("isScriptFunction", boolean.class, Object.class);
private static final MethodHandle IS_MAP = findOwnMH("isMap", boolean.class, Object.class, PropertyMap.class);
private static final MethodHandle SAME_OBJECT = findOwnMH("sameObject", boolean.class, Object.class, WeakReference.class);
@@ -61,6 +63,14 @@ public final class NashornGuards {
}
/**
+ * Get the guard that checks if an item is not a {@code JSObject}
+ * @return method handle for guard
+ */
+ public static MethodHandle getNotJSObjectGuard() {
+ return IS_NOT_JSOBJECT;
+ }
+
+ /**
* Get the guard that checks if an item is a {@code ScriptFunction}
* @return method handle for guard
*/
@@ -157,6 +167,11 @@ public final class NashornGuards {
}
@SuppressWarnings("unused")
+ private static boolean isNotJSObject(final Object self) {
+ return !(self instanceof JSObject);
+ }
+
+ @SuppressWarnings("unused")
private static boolean isScriptFunction(final Object self) {
return self instanceof ScriptFunction;
}