--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/BooleanType.java Thu Feb 04 16:50:15 2016 -0800
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/BooleanType.java Mon Feb 08 12:59:08 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -134,11 +134,8 @@
@Override
public Type add(final MethodVisitor method, final int programPoint) {
// Adding booleans in JavaScript is perfectly valid, they add as if false=0 and true=1
- if(programPoint == INVALID_PROGRAM_POINT) {
- method.visitInsn(IADD);
- } else {
- method.visitInvokeDynamicInsn("iadd", "(II)I", MATHBOOTSTRAP, programPoint);
- }
+ assert programPoint == INVALID_PROGRAM_POINT;
+ method.visitInsn(IADD);
return INT;
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/IntType.java Thu Feb 04 16:50:15 2016 -0800
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/IntType.java Mon Feb 08 12:59:08 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -155,7 +155,8 @@
if(programPoint == INVALID_PROGRAM_POINT) {
method.visitInsn(IADD);
} else {
- method.visitInvokeDynamicInsn("iadd", "(II)I", MATHBOOTSTRAP, programPoint);
+ ldc(method, programPoint);
+ JSType.ADD_EXACT.invoke(method);
}
return INT;
}
@@ -214,7 +215,8 @@
if(programPoint == INVALID_PROGRAM_POINT) {
method.visitInsn(ISUB);
} else {
- method.visitInvokeDynamicInsn("isub", "(II)I", MATHBOOTSTRAP, programPoint);
+ ldc(method, programPoint);
+ JSType.SUB_EXACT.invoke(method);
}
return INT;
}
@@ -224,7 +226,8 @@
if(programPoint == INVALID_PROGRAM_POINT) {
method.visitInsn(IMUL);
} else {
- method.visitInvokeDynamicInsn("imul", "(II)I", MATHBOOTSTRAP, programPoint);
+ ldc(method, programPoint);
+ JSType.MUL_EXACT.invoke(method);
}
return INT;
}
@@ -234,7 +237,8 @@
if (programPoint == INVALID_PROGRAM_POINT) {
JSType.DIV_ZERO.invoke(method);
} else {
- method.visitInvokeDynamicInsn("idiv", "(II)I", MATHBOOTSTRAP, programPoint);
+ ldc(method, programPoint);
+ JSType.DIV_EXACT.invoke(method);
}
return INT;
}
@@ -244,7 +248,8 @@
if (programPoint == INVALID_PROGRAM_POINT) {
JSType.REM_ZERO.invoke(method);
} else {
- method.visitInvokeDynamicInsn("irem", "(II)I", MATHBOOTSTRAP, programPoint);
+ ldc(method, programPoint);
+ JSType.REM_EXACT.invoke(method);
}
return INT;
}
@@ -254,7 +259,8 @@
if(programPoint == INVALID_PROGRAM_POINT) {
method.visitInsn(INEG);
} else {
- method.visitInvokeDynamicInsn("ineg", "(I)I", MATHBOOTSTRAP, programPoint);
+ ldc(method, programPoint);
+ JSType.NEGATE_EXACT.invoke(method);
}
return INT;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/LongType.java Thu Feb 04 16:50:15 2016 -0800
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/LongType.java Mon Feb 08 12:59:08 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
import static jdk.internal.org.objectweb.asm.Opcodes.L2D;
import static jdk.internal.org.objectweb.asm.Opcodes.L2I;
-import static jdk.internal.org.objectweb.asm.Opcodes.LADD;
import static jdk.internal.org.objectweb.asm.Opcodes.LCONST_0;
import static jdk.internal.org.objectweb.asm.Opcodes.LCONST_1;
import static jdk.internal.org.objectweb.asm.Opcodes.LLOAD;
@@ -35,7 +34,6 @@
import static jdk.internal.org.objectweb.asm.Opcodes.LSTORE;
import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup;
import static jdk.nashorn.internal.runtime.JSType.UNDEFINED_LONG;
-import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.nashorn.internal.codegen.CompilerConstants;
@@ -125,12 +123,7 @@
@Override
public Type add(final MethodVisitor method, final int programPoint) {
- if(programPoint == INVALID_PROGRAM_POINT) {
- method.visitInsn(LADD);
- } else {
- method.visitInvokeDynamicInsn("ladd", "(JJ)J", MATHBOOTSTRAP, programPoint);
- }
- return LONG;
+ throw new UnsupportedOperationException("add");
}
@Override
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/Type.java Thu Feb 04 16:50:15 2016 -0800
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/Type.java Mon Feb 08 12:59:08 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,6 @@
import static jdk.internal.org.objectweb.asm.Opcodes.DUP2_X2;
import static jdk.internal.org.objectweb.asm.Opcodes.DUP_X1;
import static jdk.internal.org.objectweb.asm.Opcodes.DUP_X2;
-import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKESTATIC;
import static jdk.internal.org.objectweb.asm.Opcodes.IALOAD;
import static jdk.internal.org.objectweb.asm.Opcodes.IASTORE;
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESTATIC;
@@ -46,28 +45,22 @@
import static jdk.internal.org.objectweb.asm.Opcodes.T_DOUBLE;
import static jdk.internal.org.objectweb.asm.Opcodes.T_INT;
import static jdk.internal.org.objectweb.asm.Opcodes.T_LONG;
-import static jdk.nashorn.internal.codegen.CompilerConstants.staticCallNoLookup;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.Serializable;
-import java.lang.invoke.CallSite;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodType;
import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import jdk.internal.org.objectweb.asm.Handle;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import jdk.nashorn.internal.codegen.CompilerConstants.Call;
import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.Undefined;
-import jdk.nashorn.internal.runtime.linker.Bootstrap;
/**
* This is the representation of a JavaScript type, disassociated from java
@@ -124,10 +117,6 @@
/** Set way below Integer.MAX_VALUE to prevent overflow when adding weights. Objects are still heaviest. */
protected static final int MAX_WEIGHT = 20;
- static final Call BOOTSTRAP = staticCallNoLookup(Bootstrap.class, "mathBootstrap", CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class, int.class);
-
- static final Handle MATHBOOTSTRAP = new Handle(H_INVOKESTATIC, BOOTSTRAP.className(), "mathBootstrap", BOOTSTRAP.descriptor());
-
/**
* Constructor
*
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java Thu Feb 04 16:50:15 2016 -0800
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java Mon Feb 08 12:59:08 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
import java.lang.invoke.CallSite;
-import java.lang.invoke.ConstantCallSite;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
@@ -204,42 +203,6 @@
}
/**
- * Boostrapper for math calls that may overflow
- * @param lookup lookup
- * @param name name of operation
- * @param type method type
- * @param programPoint program point to bind to callsite
- *
- * @return callsite for a math intrinsic node
- */
- public static CallSite mathBootstrap(final Lookup lookup, final String name, final MethodType type, final int programPoint) {
- final MethodHandle mh;
- switch (name) {
- case "iadd":
- mh = JSType.ADD_EXACT.methodHandle();
- break;
- case "isub":
- mh = JSType.SUB_EXACT.methodHandle();
- break;
- case "imul":
- mh = JSType.MUL_EXACT.methodHandle();
- break;
- case "idiv":
- mh = JSType.DIV_EXACT.methodHandle();
- break;
- case "irem":
- mh = JSType.REM_EXACT.methodHandle();
- break;
- case "ineg":
- mh = JSType.NEGATE_EXACT.methodHandle();
- break;
- default:
- throw new AssertionError("unsupported math intrinsic");
- }
- return new ConstantCallSite(MH.insertArguments(mh, mh.type().parameterCount() - 1, programPoint));
- }
-
- /**
* Returns a dynamic invoker for a specified dynamic operation using the
* public lookup. You can use this method to create a method handle that
* when invoked acts completely as if it were a Nashorn-linked call site.