This commit is contained in:
Athijegannathan Sundararajan 2013-07-29 10:28:03 +05:30
commit 95f14173b8
38 changed files with 438 additions and 318 deletions

View file

@ -152,14 +152,14 @@ public class ClassGenerator {
}
static MethodGenerator makeStaticInitializer(final ClassVisitor cv, final String name) {
final int access = ACC_PUBLIC | ACC_STATIC;
final int access = ACC_PUBLIC | ACC_STATIC;
final String desc = DEFAULT_INIT_DESC;
final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);
return new MethodGenerator(mv, access, name, desc);
}
static MethodGenerator makeConstructor(final ClassVisitor cv) {
final int access = ACC_PUBLIC;
final int access = 0;
final String name = INIT;
final String desc = DEFAULT_INIT_DESC;
final MethodVisitor mv = cv.visitMethod(access, name, desc, null, null);

View file

@ -25,6 +25,7 @@
package jdk.nashorn.internal.tools.nasgen;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_FINAL;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER;
import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKESTATIC;
@ -80,7 +81,7 @@ public class ConstructorGenerator extends ClassGenerator {
byte[] getClassBytes() {
// new class extensing from ScriptObject
final String superClass = (constructor != null)? SCRIPTFUNCTIONIMPL_TYPE : SCRIPTOBJECT_TYPE;
cw.visit(V1_7, ACC_PUBLIC | ACC_SUPER, className, null, superClass, null);
cw.visit(V1_7, ACC_FINAL, className, null, superClass, null);
if (memberCount > 0) {
// add fields
emitFields();

View file

@ -25,6 +25,7 @@
package jdk.nashorn.internal.tools.nasgen;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_FINAL;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER;
import static jdk.internal.org.objectweb.asm.Opcodes.V1_7;
@ -60,7 +61,7 @@ public class PrototypeGenerator extends ClassGenerator {
byte[] getClassBytes() {
// new class extensing from ScriptObject
cw.visit(V1_7, ACC_PUBLIC | ACC_SUPER, className, null, PROTOTYPEOBJECT_TYPE, null);
cw.visit(V1_7, ACC_FINAL | ACC_SUPER, className, null, PROTOTYPEOBJECT_TYPE, null);
if (memberCount > 0) {
// add fields
emitFields();

View file

@ -47,10 +47,10 @@
<!-- check if testng.jar is avaiable -->
<available property="testng.available" file="${file.reference.testng.jar}"/>
<!-- enable/disable make code coverage -->
<condition property="cc.enabled">
<istrue value="${make.code.coverage}" />
</condition>
<!-- enable/disable make code coverage -->
<condition property="cc.enabled">
<istrue value="${make.code.coverage}" />
</condition>
<!-- exclude tests in exclude lists -->
<condition property="exclude.list" value="./exclude/exclude_list_cc.txt" else="./exclude/exclude_list.txt">
@ -60,9 +60,9 @@
<target name="init" depends="init-conditions, init-cc">
<!-- extends jvm args -->
<property name="run.test.jvmargs" value="${run.test.jvmargs.main} ${run.test.cc.jvmargs}"/>
<property name="run.test.jvmargs.octane" value="${run.test.jvmargs.octane.main} ${run.test.cc.jvmargs}" />
<!-- extends jvm args -->
<property name="run.test.jvmargs" value="${run.test.jvmargs.main} ${run.test.cc.jvmargs}"/>
<property name="run.test.jvmargs.octane" value="${run.test.jvmargs.octane.main} ${run.test.cc.jvmargs}" />
<echo message="run.test.jvmargs=${run.test.jvmargs}"/>
<echo message="run.test.jvmargs.octane=${run.test.jvmargs.octane}"/>
@ -294,19 +294,6 @@ grant codeBase "file:/${basedir}/test/script/basic/classloader.js" {
</target>
<target name="test" depends="jar, check-testng, check-external-tests, compile-test, generate-policy-file" if="testng.available">
<java classname="${nashorn.shell.tool}" fork="true" dir="${test.script.dir}/representations" output="${build.dir}/output1.log" error="${build.dir}/err.log">
<jvmarg line="${ext.class.path}"/>
<jvmarg line="-Dnashorn.fields.dual=true"/>
<arg value="NASHORN-592a.js"/>
</java>
<java classname="${nashorn.shell.tool}" fork="true" dir="${test.script.dir}/representations" output="${build.dir}/output2.log" error="${build.dir}/err.log">
<jvmarg line="${ext.class.path}"/>
<arg value="NASHORN-592a.js"/>
</java>
<condition property="representation-ok">
<filesmatch file1="${build.dir}/output1.log" file2="${build.dir}/output2.log"/>
</condition>
<fail unless="representation-ok">Representation test failed - output differs!</fail>
<fileset id="test.classes" dir="${build.test.classes.dir}">
<include name="**/api/javaaccess/*Test.class"/>
<include name="**/api/scripting/*Test.class"/>

View file

@ -223,7 +223,6 @@ run.test.user.language=tr
run.test.user.country=TR
# -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMethods
# add '-Dtest.js.outofprocess' to run each test in a new sub-process
run.test.jvmargs.main=-server -Xmx${run.test.xmx} -XX:+TieredCompilation -ea -Dfile.encoding=UTF-8 -Duser.language=${run.test.user.language} -Duser.country=${run.test.user.country}
#-XX:+HeapDumpOnOutOfMemoryError -XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M
@ -231,6 +230,9 @@ run.test.jvmargs.octane.main=-Xms${run.test.xms} ${run.test.jvmargs.main}
run.test.jvmsecurityargs=-Xverify:all -Djava.security.properties=${basedir}/make/java.security.override -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy
# VM options for script tests with @fork option
test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} ${run.test.jvmsecurityargs}
# path of rhino.jar for benchmarks
rhino.jar=

View file

@ -35,7 +35,7 @@ import jdk.nashorn.internal.runtime.ScriptRuntime;
* must track their {@code [[TargetFunction]]} property for purposes of correctly implementing {@code [[HasInstance]]};
* see {@link ScriptFunction#isInstance(ScriptObject)}.
*/
class BoundScriptFunctionImpl extends ScriptFunctionImpl {
final class BoundScriptFunctionImpl extends ScriptFunctionImpl {
private final ScriptFunction targetFunction;
BoundScriptFunctionImpl(ScriptFunctionData data, ScriptFunction targetFunction) {

View file

@ -75,7 +75,7 @@ public class PrototypeObject extends ScriptObject {
*
* @param map property map
*/
public PrototypeObject(final PropertyMap map) {
PrototypeObject(final PropertyMap map) {
this(Global.instance(), map);
}
@ -89,7 +89,7 @@ public class PrototypeObject extends ScriptObject {
* @param self self reference
* @return constructor, probably, but not necessarily, a {@link ScriptFunction}
*/
public static Object getConstructor(final Object self) {
static Object getConstructor(final Object self) {
return (self instanceof PrototypeObject) ?
((PrototypeObject)self).getConstructor() :
UNDEFINED;
@ -100,7 +100,7 @@ public class PrototypeObject extends ScriptObject {
* @param self self reference
* @param constructor constructor, probably, but not necessarily, a {@link ScriptFunction}
*/
public static void setConstructor(final Object self, final Object constructor) {
static void setConstructor(final Object self, final Object constructor) {
if (self instanceof PrototypeObject) {
((PrototypeObject)self).setConstructor(constructor);
}

View file

@ -51,7 +51,7 @@ import jdk.nashorn.internal.lookup.MethodHandleFactory;
* An AccessorProperty is the most generic property type. An AccessorProperty is
* represented as fields in a ScriptObject class.
*/
public class AccessorProperty extends Property {
public final class AccessorProperty extends Property {
private static final MethodHandles.Lookup lookup = MethodHandles.lookup();
private static final MethodHandle REPLACE_MAP = findOwnMH("replaceMap", Object.class, Object.class, PropertyMap.class, String.class, Class.class, Class.class);
@ -149,7 +149,7 @@ public class AccessorProperty extends Property {
* @param property accessor property to rebind
* @param delegate delegate object to rebind receiver to
*/
public AccessorProperty(final AccessorProperty property, final Object delegate) {
AccessorProperty(final AccessorProperty property, final Object delegate) {
super(property);
this.primitiveGetter = bindTo(property.primitiveGetter, delegate);
@ -185,7 +185,7 @@ public class AccessorProperty extends Property {
* @param getter the property getter
* @param setter the property setter or null if non writable, non configurable
*/
public AccessorProperty(final String key, final int flags, final int slot, final MethodHandle getter, final MethodHandle setter) {
AccessorProperty(final String key, final int flags, final int slot, final MethodHandle getter, final MethodHandle setter) {
super(key, flags, slot);
// we don't need to prep the setters these will never be invalidated as this is a nasgen

View file

@ -33,7 +33,7 @@ import java.lang.invoke.MethodHandle;
* This is a subclass that represents a script function that may not be regenerated.
* This is used for example for bound functions and builtins.
*/
public final class FinalScriptFunctionData extends ScriptFunctionData {
final class FinalScriptFunctionData extends ScriptFunctionData {
/**
* Constructor - used for bind

View file

@ -47,7 +47,7 @@ import jdk.nashorn.internal.runtime.linker.InvokeByName;
* operations respectively, while {@link #addLast(Object)} and {@link #removeLast()} will translate to {@code push} and
* {@code pop}.
*/
public class ListAdapter extends AbstractList<Object> implements RandomAccess, Deque<Object> {
public final class ListAdapter extends AbstractList<Object> implements RandomAccess, Deque<Object> {
// These add to the back and front of the list
private static final InvokeByName PUSH = new InvokeByName("push", ScriptObject.class, void.class, Object.class);
private static final InvokeByName UNSHIFT = new InvokeByName("unshift", ScriptObject.class, void.class, Object.class);

View file

@ -100,7 +100,7 @@ public abstract class Property {
* @param flags property flags
* @param slot property field number or spill slot
*/
public Property(final String key, final int flags, final int slot) {
Property(final String key, final int flags, final int slot) {
assert key != null;
this.key = key;
this.flags = flags;
@ -112,7 +112,7 @@ public abstract class Property {
*
* @param property source property
*/
protected Property(final Property property) {
Property(final Property property) {
this.key = property.key;
this.flags = property.flags;
this.slot = property.slot;
@ -123,7 +123,7 @@ public abstract class Property {
*
* @return cloned property
*/
protected abstract Property copy();
abstract Property copy();
/**
* Property flag utility method for {@link PropertyDescriptor}s. Given two property descriptors,

View file

@ -32,6 +32,7 @@ import java.util.WeakHashMap;
* Helper class to manage property listeners and notification.
*/
public class PropertyListenerManager implements PropertyListener {
PropertyListenerManager() {}
/** property listeners for this object. */
private Map<PropertyListener,Boolean> listeners;

View file

@ -67,7 +67,7 @@ public abstract class ScriptFunctionData {
* @param isBuiltin is the function built in
* @param isConstructor is the function a constructor
*/
protected ScriptFunctionData(final String name, final int arity, final boolean isStrict, final boolean isBuiltin, final boolean isConstructor) {
ScriptFunctionData(final String name, final int arity, final boolean isStrict, final boolean isBuiltin, final boolean isConstructor) {
this.name = name;
this.arity = arity;
this.code = new CompiledFunctions();

View file

@ -83,7 +83,7 @@ public final class UserAccessorProperty extends Property {
* @param getterSlot getter slot, starting at first embed
* @param setterSlot setter slot, starting at first embed
*/
public UserAccessorProperty(final String key, final int flags, final int getterSlot, final int setterSlot) {
UserAccessorProperty(final String key, final int flags, final int getterSlot, final int setterSlot) {
super(key, flags, -1);
this.getterSlot = getterSlot;
this.setterSlot = setterSlot;

View file

@ -57,7 +57,7 @@ public final class WithObject extends ScriptObject implements Scope {
* @param scope scope object
* @param expression with expression
*/
public WithObject(final ScriptObject scope, final Object expression) {
WithObject(final ScriptObject scope, final Object expression) {
super(scope, null);
setIsScope();
this.expression = expression;

View file

@ -26,7 +26,7 @@
package jdk.nashorn.internal.runtime.linker;
@SuppressWarnings("serial")
class AdaptationException extends Exception {
final class AdaptationException extends Exception {
private final AdaptationResult adaptationResult;
AdaptationException(final AdaptationResult.Outcome outcome, final String classList) {

View file

@ -32,7 +32,7 @@ import jdk.nashorn.internal.runtime.ECMAException;
* A result of generating an adapter for a class. A tuple of an outcome and - in case of an error outcome - a list of
* classes that caused the error.
*/
class AdaptationResult {
final class AdaptationResult {
/**
* Contains various outcomes for attempting to generate an adapter class. These are stored in AdapterInfo instances.
* We have a successful outcome (adapter class was generated) and four possible error outcomes: superclass is final,

View file

@ -58,7 +58,7 @@ import java.lang.invoke.MethodHandle;
* you dynamically invoke a function with the same name from multiple places in your code, it is advisable to create a
* separate instance of this class for every place.
*/
public class InvokeByName {
public final class InvokeByName {
private final String name;
private final MethodHandle getter;
private final MethodHandle invoker;

View file

@ -56,7 +56,6 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Set;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Label;

View file

@ -37,7 +37,7 @@ import jdk.nashorn.internal.runtime.Undefined;
/**
* Provides static utility services to generated Java adapter classes.
*/
public class JavaAdapterServices {
public final class JavaAdapterServices {
private static final ThreadLocal<ScriptObject> classOverrides = new ThreadLocal<>();
private JavaAdapterServices() {

View file

@ -42,7 +42,7 @@ import jdk.nashorn.internal.runtime.ScriptObject;
* Utility class shared by {@code NashornLinker} and {@code NashornPrimitiveLinker} for converting JS values to Java
* types.
*/
public class JavaArgumentConverters {
final class JavaArgumentConverters {
private static final MethodHandle TO_BOOLEAN = findOwnMH("toBoolean", Boolean.class, Object.class);
private static final MethodHandle TO_STRING = findOwnMH("toString", String.class, Object.class);

View file

@ -39,7 +39,7 @@ import jdk.internal.dynalink.support.CallSiteDescriptorFactory;
* we can have a more compact representation, as we know that we're always only using {@code "dyn:*"} operations; also
* we're storing flags in an additional primitive field.
*/
public class NashornCallSiteDescriptor extends AbstractCallSiteDescriptor {
public final class NashornCallSiteDescriptor extends AbstractCallSiteDescriptor {
/** Flags that the call site references a scope variable (it's an identifier reference or a var declaration, not a
* property access expression. */
public static final int CALLSITE_SCOPE = 0x01;

View file

@ -46,7 +46,7 @@ import jdk.nashorn.internal.runtime.Undefined;
* This is the main dynamic linker for Nashorn. It is used for linking all {@link ScriptObject} and its subclasses (this
* includes {@link ScriptFunction} and its subclasses) as well as {@link Undefined}.
*/
public final class NashornLinker implements TypeBasedGuardingDynamicLinker, GuardingTypeConverterFactory, ConversionComparator {
final class NashornLinker implements TypeBasedGuardingDynamicLinker, GuardingTypeConverterFactory, ConversionComparator {
/**
* Returns true if {@code ScriptObject} is assignable from {@code type}, or it is {@code Undefined}.
*/

View file

@ -25,7 +25,6 @@
package jdk.nashorn.internal.runtime.linker;
import jdk.nashorn.internal.lookup.Lookup;
import static jdk.nashorn.internal.lookup.Lookup.MH;
import java.lang.invoke.MethodHandle;
@ -35,6 +34,7 @@ import jdk.internal.dynalink.linker.GuardedInvocation;
import jdk.internal.dynalink.linker.LinkRequest;
import jdk.internal.dynalink.support.CallSiteDescriptorFactory;
import jdk.internal.dynalink.support.Guards;
import jdk.nashorn.internal.lookup.Lookup;
import jdk.nashorn.internal.runtime.ScriptObject;
/**
@ -42,7 +42,7 @@ import jdk.nashorn.internal.runtime.ScriptObject;
* numbers). This class is only public so it can be accessed by classes in the {@code jdk.nashorn.internal.objects}
* package.
*/
public class PrimitiveLookup {
public final class PrimitiveLookup {
private PrimitiveLookup() {
}

View file

@ -36,7 +36,7 @@ import java.util.StringTokenizer;
*
* {@code --log=module1:level1,module2:level2... }
*/
public class KeyValueOption extends Option<String> {
public final class KeyValueOption extends Option<String> {
/**
* Map of keys given
*/

View file

@ -34,7 +34,7 @@ import jdk.nashorn.internal.runtime.QuotedStringTokenizer;
* bundle file. Metainfo such as parameters and description is here as well
* for context sensitive help generation.
*/
public class OptionTemplate implements Comparable<OptionTemplate> {
public final class OptionTemplate implements Comparable<OptionTemplate> {
/** Resource, e.g. "nashorn" for this option */
private final String resource;

View file

@ -0,0 +1,34 @@
/*
* Copyright (c) 2010, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* NASHORN-592-dual: test all combos of field types and getters and setters
* This time use dual field representation
*
* @test
* @option -Dnashorn.fields.dual=true
* @fork
* @run/ignore-std-error
*/
load(__DIR__ + 'NASHORN-592.js');

View file

@ -0,0 +1,44 @@
0
0
NaN
undefinedhej!
17
8
34
17hej!
17
8
34.9422
17.4711hej!
0
0
NaN
Fame and fortune Salamander Yahoo!hej!
24
11111
23.23
23
23
Have some pie!
4711.17
17172
23
23.23
23
23
Have some pie!
4711.17
23
111
4711.16
I like cake!
0
NaN
0
I like cake!
17
17.4711
salamander
4711.17
axolotl
lizard

View file

@ -0,0 +1,32 @@
/*
* Copyright (c) 2010, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @option -Dnashorn.compiler.splitter.threshold=1000
* @fork
* @runif external.octane
*/
compile_only = true;
load(__DIR__ + 'run-octane.js');

View file

@ -0,0 +1,13 @@
Compiled OK: box2d
Compiled OK: code-load
Compiled OK: crypto
Compiled OK: deltablue
Compiled OK: earley-boyer
Compiled OK: gbemu
Compiled OK: mandreel
Compiled OK: navier-stokes
Compiled OK: pdfjs
Compiled OK: raytrace
Compiled OK: regexp
Compiled OK: richards
Compiled OK: splay

View file

@ -33,7 +33,7 @@
function assertEq(a, b) {
if (a !== b) {
throw "ASSERTION FAILED: " + a + " should be " + b;
throw "ASSERTION FAILED: " + a + " should be " + b;
}
}
@ -44,18 +44,18 @@ var total_time = 0;
function runbench(name) {
var filename = name.split("/").pop();
if (verbose_run) {
print("Running " + filename);
print("Running " + filename);
}
var start = new Date;
for (var i = 0; i < iterations__; i++) {
load(name);
load(name);
}
var stop = new Date - start;
total_time += stop;
if (verbose_run) {
print(filename + " done in " + stop + " ms");
print(filename + " done in " + stop + " ms");
}
runs++;
}
@ -78,22 +78,18 @@ function runsuite(tests) {
Math.random = pseudorandom;
try {
for (var n = 0; n < tests.length; n++) {
runbench(tests[n].name);
if (typeof tests[n].actual !== 'undefined') {
assertEq(tests[n].actual(), tests[n].expected());
}
changed = true;
}
} catch (e) {
print("error: " + e.printStackTrace());
if (e.toString().indexOf(tests) == 1) {
throw e;
}
// no scripting or something, silently fail
for (var n = 0; n < tests.length; n++) {
path = dir + '../external/sunspider/tests/sunspider-1.0/' + tests[n].name
runbench(path);
if (typeof tests[n].actual !== 'undefined') {
assertEq(tests[n].actual(), tests[n].expected());
}
changed = true;
}
// no scripting or something, silently fail
} finally {
Math.random = oldRandom;
}
Math.random = oldRandom;
return changed;
}
@ -103,8 +99,8 @@ function hash(str) {
var h = 0;
var off = 0;
for (var i = 0; i < s.length; i++) {
h = 31 * h + s.charCodeAt(off++);
h &= 0x7fffffff;
h = 31 * h + s.charCodeAt(off++);
h &= 0x7fffffff;
}
return h ^ s.length;
}
@ -112,200 +108,200 @@ function hash(str) {
var tests = [
{ name: 'string-base64.js',
actual: function() {
return hash(str);
return hash(str);
},
expected: function() {
return 1544571068;
return 1544571068;
}
},
{ name: 'string-validate-input.js',
actual: function() {
return hash(endResult);
return hash(endResult);
},
expected: function() {
return 2016572373;
return 2016572373;
}
},
{ name: 'date-format-xparb.js',
actual: function() {
return shortFormat + longFormat;
return shortFormat + longFormat;
},
expected: function() {
return "2017-09-05Tuesday, September 05, 2017 8:43:48 AM";
return "2017-09-05Tuesday, September 05, 2017 8:43:48 AM";
}
},
{ name: '3d-morph.js',
actual: function() {
var acceptableDelta = 4e-15;
return (testOutput - 6.394884621840902e-14) < acceptableDelta;
var acceptableDelta = 4e-15;
return (testOutput - 6.394884621840902e-14) < acceptableDelta;
},
expected: function() {
return true;
return true;
}
},
{ name: 'crypto-aes.js',
actual: function() {
return plainText;
return plainText;
},
expected: function() {
return decryptedText;
return decryptedText;
}
},
{ name: 'crypto-md5.js',
actual: function() {
return md5Output;
return md5Output;
},
expected: function() {
return "a831e91e0f70eddcb70dc61c6f82f6cd";
return "a831e91e0f70eddcb70dc61c6f82f6cd";
}
},
{ name: 'crypto-sha1.js',
actual: function() {
return sha1Output;
return sha1Output;
},
expected: function() {
return "2524d264def74cce2498bf112bedf00e6c0b796d";
return "2524d264def74cce2498bf112bedf00e6c0b796d";
}
},
{ name: 'bitops-bitwise-and.js',
actual: function() {
return result;
return result;
},
expected: function() {
return 0;
return 0;
}
},
{ name: 'bitops-bits-in-byte.js',
actual: function() {
return result;
return result;
},
expected: function() {
return 358400;
return 358400;
}
},
{ name: 'bitops-nsieve-bits.js',
actual: function() {
var ret = 0;
for (var i = 0; i < result.length; ++i) {
ret += result[i];
}
ret += result.length;
return ret;
var ret = 0;
for (var i = 0; i < result.length; ++i) {
ret += result[i];
}
ret += result.length;
return ret;
},
expected: function() {
return -1286749539853;
return -1286749539853;
}
},
{ name: 'bitops-3bit-bits-in-byte.js',
actual: function() {
return sum;
return sum;
},
expected: function() {
return 512000;
return 512000;
}
},
{ name: 'access-nbody.js',
actual: function() {
return ret;
return ret;
},
expected: function() {
return -0.16906933525822856;
return -1.3524862408537381;
}
},
{ name: 'access-binary-trees.js',
actual: function() {
return ret;
return ret;
},
expected: function() {
return -1;
return -4;
}
},
{ name: 'access-fannkuch.js',
actual: function() {
return ret;
return ret;
},
expected: function() {
return 22;
return 22;
}
},
{ name: 'math-spectral-norm.js',
actual: function() {
var ret = '';
for (var i = 6; i <= 48; i *= 2) {
ret += spectralnorm(i) + ',';
}
return ret;
var ret = '';
for (var i = 6; i <= 48; i *= 2) {
ret += spectralnorm(i) + ',';
}
return ret;
},
expected: function() {
return "1.2657786149754053,1.2727355112619148,1.273989979775574,1.274190125290389,";
return "1.2657786149754053,1.2727355112619148,1.273989979775574,1.274190125290389,";
}
},
{ name: '3d-raytrace.js',
actual: function() {
return hash(testOutput);
return hash(testOutput);
},
expected: function() {
return 230692593;
return 230692593;
}
},
{ name: 'regexp-dna.js',
actual: function() {
return dnaOutputString;
return dnaOutputString;
},
expected: function() {
return "undefinedagggtaaa|tttaccct 0\n[cgt]gggtaaa|tttaccc[acg] 9\na[act]ggtaaa|tttacc[agt]t 27\nag[act]gtaaa|tttac[agt]ct 24\nagg[act]taaa|ttta[agt]cct 30\naggg[acg]aaa|ttt[cgt]ccct 9\nagggt[cgt]aa|tt[acg]accct 12\nagggta[cgt]a|t[acg]taccct 9\nagggtaa[cgt]|[acg]ttaccct 15\n";
return "agggtaaa|tttaccct 0\n[cgt]gggtaaa|tttaccc[acg] 9\na[act]ggtaaa|tttacc[agt]t 27\nag[act]gtaaa|tttac[agt]ct 24\nagg[act]taaa|ttta[agt]cct 30\naggg[acg]aaa|ttt[cgt]ccct 9\nagggt[cgt]aa|tt[acg]accct 12\nagggta[cgt]a|t[acg]taccct 9\nagggtaa[cgt]|[acg]ttaccct 15\n";
}
},
{ name: 'math-cordic.js',
actual: function() {
return total;
return total;
},
expected: function() {
return 10362.570468755888;
return 10362.570468755888;
}
},
{ name: 'controlflow-recursive.js',
actual: function() {
var ret = 0;
for (var i = 3; i <= 5; i++) {
ret += ack(3,i);
ret += fib(17.0+i);
ret += tak(3*i+3,2*i+2,i+1);
}
return ret;
var ret = 0;
for (var i = 3; i <= 5; i++) {
ret += ack(3,i);
ret += fib(17.0+i);
ret += tak(3*i+3,2*i+2,i+1);
}
return ret;
},
expected: function() {
return 57775;
return 57775;
}
},
{ name: 'date-format-tofte.js',
actual: function() {
return shortFormat + longFormat;
return shortFormat + longFormat;
},
expected: function() {
return "2008-05-01Thursday, May 01, 2008 6:31:22 PM";
return "2008-05-01Thursday, May 01, 2008 6:31:22 PM";
}
},
{ name: 'string-tagcloud.js',
actual: function() {
// The result string embeds floating-point numbers, which can vary a bit on different platforms,
// so we truncate them a bit before comparing.
var tagcloud_norm = tagcloud.replace(/([0-9.]+)px/g, function(str, p1) { return p1.substr(0, 10) + 'px' })
return tagcloud_norm.length;
// The result string embeds floating-point numbers, which can vary a bit on different platforms,
// so we truncate them a bit before comparing.
var tagcloud_norm = tagcloud.replace(/([0-9.]+)px/g, function(str, p1) { return p1.substr(0, 10) + 'px' })
return tagcloud_norm.length;
},
expected: function() {
return 295906;
return 295906;
}
},
{ name: 'string-unpack-code.js',
actual: function() {
return decompressedMochiKit.length == 106415 &&
decompressedMochiKit[2000] == '5' &&
decompressedMochiKit[12000] == '_' &&
decompressedMochiKit[82556] == '>';
return decompressedMochiKit.length == 106415 &&
decompressedMochiKit[2000] == '5' &&
decompressedMochiKit[12000] == '_' &&
decompressedMochiKit[82556] == '>';
},
expected: function() {
return true;
return true;
}
},
//TODO no easy way to sanity check result
@ -322,10 +318,6 @@ var tests = [
// support __DIR__ global variable.
var dir = (typeof(__DIR__) == 'undefined') ? "test/script/basic/" : __DIR__;
for (i in tests) {
tests[i].name = dir + '../external/sunspider/tests/sunspider-1.0/' + tests[i].name;
}
var verbose_run = false;
var args = [];
@ -337,8 +329,8 @@ if (typeof $ARGS !== 'undefined') {
for (i in args) {
if (args[i] === '--verbose') {
verbose_run = true;
break;
verbose_run = true;
break;
}
}

View file

@ -0,0 +1,36 @@
/*
* Copyright (c) 2010, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Test various scripts with low splitter threshold
*
* @test
* @option -Dnashorn.compiler.splitter.threshold=200
* @run
* @fork
*/
load(__DIR__ + 'prototype.js');
load(__DIR__ + 'yui.js');
load(__DIR__ + 'NASHORN-689.js');
load(__DIR__ + 'NASHORN-58.js');

View file

@ -0,0 +1,76 @@
parsed and compiled ok prototype.js
parsed and compiled ok yui-min.js
parsed and compiled ok yui.js
a=10
a=9
a=8
a=7
a=6
a=5
a=4
a=3
a=2
a=1
a=0
10
a=0
a=1
a=2
a=3
a=4
a=5
a=6
a=7
a=8
a=9
a=10
ok
a=0
a=1
a=2
a=3
a=4
a=5
a=6
a=7
a=8
a=9
a=10
done
no arg
x=0
x=1
x=2
x=3
x=4
x=5
x=6
x=7
x=8
x=9
x=10
ok
done
try
finally
3
try
finally
2
3
1
2
3
4
5
5
6
6
1
2
3
4
6
Error: testing
finally
SUCCESS

View file

@ -1,122 +0,0 @@
/*
* Copyright (c) 2010, 2013, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* NASHORN-592a: test all combos of field types and getters and setters
* This time use dual field representation
*
* @test
* @option --dual-fields
* @run
*/
//fortype undefined
var a;
print(a & 0xff);
print(a >>> 1);
print(a * 2);
print(a + "hej!");
var b;
b = 17; //set undefined->int
print(b & 0xff);
print(b >>> 1);
print(b * 2);
print(b + "hej!");
var c;
c = 17.4711 //set undefined->double
print(c & 0xff);
print(c >>> 1);
print(c * 2);
print(c + "hej!");
var d; // set undefined->double
d = "Fame and fortune Salamander Yahoo!";
print(d & 0xff);
print(d >>> 1);
print(d * 2);
print(d + "hej!");
// now we have exhausted all getters and undefined->everything setters.
var e = 23; // int to everything setters,
e = 24; //int to int
print(e);
e = (22222 >>> 1); //int to long;
print(e);
e = 23.23; //int to double
print(e);
e = 23; //double to int - still double
print(e);
print(e & 0xff);
e = "Have some pie!" //double to string
print(e);
e = 4711.17;
print(e); //still an object not a double
var f = (23222 >>> 1); // long to everything setters,
f = 34344 >>> 1; //long to long
print(f);
f = 23; //long to int - still long
print(f);
f = 23.23; //long to double
print(f);
f = 23; //double to int - still double
print(f);
print(f & 0xff);
f = "Have some pie!" //double to string
print(f);
f = 4711.17;
print(f); //still an object not a double
var g = 4811.16;
g = 23; //still double
print(g);
g = (222 >>> 1); //still double
print(g);
g = 4711.16; //double->double
print(g);
g = "I like cake!";
print(g); //object to various
print(g & 0xff);
print(g * 2);
print(g >>> 2);
print(g);
var h = {x:17, y:17.4711, z:"salamander"};
print(h.x);
print(h.y);
print(h.z);
h.x = 4711.17;
h.y = "axolotl";
h.z = "lizard";
print(h.x);
print(h.y);
print(h.z);

View file

@ -29,6 +29,7 @@ import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_CHECK_COMPI
import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_COMPARE;
import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_EXPECT_COMPILE_FAIL;
import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_EXPECT_RUN_FAIL;
import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_FORK;
import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_IGNORE_STD_ERROR;
import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_RUN;
import static jdk.nashorn.internal.test.framework.TestConfig.TEST_JS_FAIL_LIST;
@ -68,6 +69,8 @@ public abstract class AbstractScriptRunnable {
protected final boolean checkCompilerMsg;
// .EXPECTED file compared for this or test?
protected final boolean compare;
// should test run in a separate process?
protected final boolean fork;
// ignore stderr output?
protected final boolean ignoreStdError;
// Foo.js.OUTPUT file where test stdout messages go
@ -98,6 +101,7 @@ public abstract class AbstractScriptRunnable {
this.checkCompilerMsg = testOptions.containsKey(OPTIONS_CHECK_COMPILE_MSG);
this.ignoreStdError = testOptions.containsKey(OPTIONS_IGNORE_STD_ERROR);
this.compare = testOptions.containsKey(OPTIONS_COMPARE);
this.fork = testOptions.containsKey(OPTIONS_FORK);
final String testName = testFile.getName();
this.outputFileName = buildDir + File.separator + testName + ".OUTPUT";
@ -105,7 +109,6 @@ public abstract class AbstractScriptRunnable {
this.copyExpectedFileName = buildDir + File.separator + testName + ".EXPECTED";
this.expectedFileName = testFile.getPath() + ".EXPECTED";
final String failListString = System.getProperty(TEST_JS_FAIL_LIST);
if (failListString != null) {
final String[] failedTests = failListString.split(" ");
for (final String failedTest : failedTests) {
@ -147,10 +150,15 @@ public abstract class AbstractScriptRunnable {
}
// shared context or not?
protected static final boolean sharedContext;
protected static final boolean sharedContext = Boolean.getBoolean(TEST_JS_SHARED_CONTEXT);
protected static final String failListString = System.getProperty(TEST_JS_FAIL_LIST);
// VM options when a @fork test is executed by a separate process
protected static final String[] forkJVMOptions;
static {
sharedContext = Boolean.getBoolean(TEST_JS_SHARED_CONTEXT);
String vmOptions = System.getProperty(TestConfig.TEST_FORK_JVM_OPTIONS);
forkJVMOptions = (vmOptions != null)? vmOptions.split(" ") : new String[0];
}
private static ThreadLocal<ScriptEvaluator> evaluators = new ThreadLocal<>();
/**

View file

@ -43,6 +43,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import jdk.nashorn.tools.Shell;
import org.testng.Assert;
import org.testng.ITest;
import org.testng.annotations.Test;
@ -53,9 +55,6 @@ import org.testng.annotations.Test;
* corresponding .EXPECTED file.
*/
public final class ScriptRunnable extends AbstractScriptRunnable implements ITest {
// when test is run in a separate process, this is the command line
protected final ArrayList<String> separateProcessArgs;
public ScriptRunnable(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) {
super(framework, testFile, engineOptions, testOptions, scriptArguments);
@ -63,9 +62,6 @@ public final class ScriptRunnable extends AbstractScriptRunnable implements ITes
// add --dump-on-error option always so that we can get detailed error msg.
engineOptions.add("-doe");
}
final String separateProcess = System.getProperty("test.js.separateprocess");
this.separateProcessArgs = separateProcess == null ? null : new ArrayList<>(Arrays.asList(separateProcess.split(" ")));
}
@Override
@ -81,7 +77,7 @@ public final class ScriptRunnable extends AbstractScriptRunnable implements ITes
@Override
protected void execute() {
if (separateProcessArgs != null) {
if (fork) {
executeInNewProcess();
} else {
executeInThisProcess();
@ -172,15 +168,24 @@ public final class ScriptRunnable extends AbstractScriptRunnable implements ITes
}
private void executeInNewProcess() {
final List<String> args = separateProcessArgs;
final String separator = System.getProperty("file.separator");
final List<String> cmd = new ArrayList<>();
cmd.add(System.getProperty("java.home") + separator + "bin" + separator + "java");
cmd.add("-Djava.ext.dirs=dist");
for (String str : forkJVMOptions) {
cmd.add(str);
}
cmd.add(Shell.class.getName());
// now add the rest of the "in process" runtime arguments
args.addAll(getRuntimeArgs());
cmd.addAll(getRuntimeArgs());
final File outputFileHandle = new File(outputFileName);
final File errorFileHandle = new File(errorFileName);
try {
final ProcessBuilder pb = new ProcessBuilder(args);
final ProcessBuilder pb = new ProcessBuilder(cmd);
pb.redirectOutput(outputFileHandle);
pb.redirectError(errorFileHandle);
final Process process = pb.start();

View file

@ -36,6 +36,7 @@ public interface TestConfig {
public static final String OPTIONS_EXPECT_RUN_FAIL = "expect-run-fail";
public static final String OPTIONS_IGNORE_STD_ERROR = "ignore-std-error";
public static final String OPTIONS_COMPARE = "compare";
public static final String OPTIONS_FORK = "fork";
// System property names used for various test configurations
@ -73,6 +74,8 @@ public interface TestConfig {
// shared context mode or not
static final String TEST_JS_SHARED_CONTEXT = "test.js.shared.context";
static final String TEST_FORK_JVM_OPTIONS = "test.fork.jvm.options";
// file for storing last run's failed tests
static final String TEST_FAILED_LIST_FILE = "test.failed.list.file";
}

View file

@ -29,6 +29,7 @@ import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_CHECK_COMPI
import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_COMPARE;
import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_EXPECT_COMPILE_FAIL;
import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_EXPECT_RUN_FAIL;
import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_FORK;
import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_IGNORE_STD_ERROR;
import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_RUN;
import static jdk.nashorn.internal.test.framework.TestConfig.TEST_FAILED_LIST_FILE;
@ -208,6 +209,7 @@ final class TestFinder {
boolean checkCompilerMsg = false;
boolean noCompare = false;
boolean ignoreStdError = false;
boolean fork = false;
final List<String> engineOptions = new ArrayList<>();
final List<String> scriptArguments = new ArrayList<>();
@ -284,6 +286,9 @@ final class TestFinder {
case "@option":
engineOptions.add(scanner.next());
break;
case "@fork":
fork = true;
break;
}
// negative tests are expected to fail at runtime only
@ -324,6 +329,9 @@ final class TestFinder {
if (ignoreStdError) {
testOptions.put(OPTIONS_IGNORE_STD_ERROR, "true");
}
if (fork) {
testOptions.put(OPTIONS_FORK, "true");
}
tests.add(factory.createTest(framework, testFile.toFile(), engineOptions, testOptions, scriptArguments));
} else if (!isNotTest) {