diff --git a/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/BuiltinBenchmark.java b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/BuiltinBenchmark.java index 9071d4f7bb..665a89bc00 100644 --- a/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/BuiltinBenchmark.java +++ b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/BuiltinBenchmark.java @@ -19,9 +19,13 @@ public class BuiltinBenchmark { @State(Scope.Thread) public static class AbstractClassState { + @Param({"false", "true"}) + public boolean interpreted; + public void init() throws IllegalAccessException, InvocationTargetException, InstantiationException { cx = Context.enter(); + cx.setInterpretedMode(interpreted); cx.setLanguageVersion(Context.VERSION_ES6); scope = cx.initStandardObjects(); diff --git a/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/MathBenchmark.java b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/MathBenchmark.java index e298919eff..60e34430a9 100644 --- a/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/MathBenchmark.java +++ b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/MathBenchmark.java @@ -33,9 +33,13 @@ public static class MathState { Function bitwiseRsh; Function bitwiseSignedRsh; + @Param({"false", "true"}) + public boolean interpreted; + @Setup(Level.Trial) public void setup() throws IOException { cx = Context.enter(); + cx.setInterpretedMode(interpreted); cx.setLanguageVersion(Context.VERSION_ES6); scope = cx.initStandardObjects(); diff --git a/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/ObjectBenchmark.java b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/ObjectBenchmark.java index 269469a2f1..eda405d858 100644 --- a/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/ObjectBenchmark.java +++ b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/ObjectBenchmark.java @@ -33,10 +33,14 @@ public static class FieldTestState { Scriptable strings; Scriptable ints; + @Param({"false", "true"}) + public boolean interpreted; + @Setup(Level.Trial) @SuppressWarnings("unused") public void create() throws IOException { cx = Context.enter(); + cx.setInterpretedMode(interpreted); cx.setLanguageVersion(Context.VERSION_ES6); scope = new Global(cx); diff --git a/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/PropertyBenchmark.java b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/PropertyBenchmark.java index 402f003934..b93ac4e46b 100644 --- a/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/PropertyBenchmark.java +++ b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/PropertyBenchmark.java @@ -24,9 +24,13 @@ public static class PropertyState { Object object; + @Param({"false", "true"}) + public boolean interpreted; + @Setup(Level.Trial) public void setup() throws IOException { cx = Context.enter(); + cx.setInterpretedMode(interpreted); cx.setLanguageVersion(Context.VERSION_ES6); scope = cx.initStandardObjects(); diff --git a/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/SunSpiderBenchmark.java b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/SunSpiderBenchmark.java index 12555f6c0a..8e6d202144 100644 --- a/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/SunSpiderBenchmark.java +++ b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/SunSpiderBenchmark.java @@ -22,9 +22,12 @@ abstract static class AbstractState { this.fileName = TEST_BASE + fileName; } + protected abstract boolean isInterpreted(); + @Setup(Level.Trial) public void setUp() { cx = Context.enter(); + cx.setInterpretedMode(isInterpreted()); cx.setLanguageVersion(Context.VERSION_ES6); scope = cx.initStandardObjects(); @@ -47,10 +50,18 @@ Object run() { @State(Scope.Thread) public static class ThreeDCubeState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public ThreeDCubeState() { super("3d-cube.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object threeDCube(ThreeDCubeState state) { return state.run(); @@ -59,10 +70,18 @@ public Object threeDCube(ThreeDCubeState state) { @State(Scope.Thread) public static class ThreeDMorphState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public ThreeDMorphState() { super("3d-morph.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object threeDMorph(ThreeDMorphState state) { return state.run(); @@ -71,10 +90,18 @@ public Object threeDMorph(ThreeDMorphState state) { @State(Scope.Thread) public static class ThreeDRayState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public ThreeDRayState() { super("3d-raytrace.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object threeDRayTrace(ThreeDRayState state) { return state.run(); @@ -83,10 +110,18 @@ public Object threeDRayTrace(ThreeDRayState state) { @State(Scope.Thread) public static class AccessBinaryTreesState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public AccessBinaryTreesState() { super("access-binary-trees.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object accessBinaryTrees(AccessBinaryTreesState state) { return state.run(); @@ -95,10 +130,18 @@ public Object accessBinaryTrees(AccessBinaryTreesState state) { @State(Scope.Thread) public static class AccessFannkuchState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public AccessFannkuchState() { super("access-fannkuch.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object accessFannkuch(AccessFannkuchState state) { return state.run(); @@ -107,10 +150,18 @@ public Object accessFannkuch(AccessFannkuchState state) { @State(Scope.Thread) public static class AccessNBodyState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public AccessNBodyState() { super("access-nbody.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object accessNBody(AccessNBodyState state) { return state.run(); @@ -119,10 +170,18 @@ public Object accessNBody(AccessNBodyState state) { @State(Scope.Thread) public static class AccessFannAccessNsieveState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public AccessFannAccessNsieveState() { super("access-nsieve.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object accessNsieve(AccessFannAccessNsieveState state) { return state.run(); @@ -131,10 +190,18 @@ public Object accessNsieve(AccessFannAccessNsieveState state) { @State(Scope.Thread) public static class Bitops3BitState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public Bitops3BitState() { super("bitops-3bit-bits-in-byte.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object bitops3BitBitsInByte(Bitops3BitState state) { return state.run(); @@ -143,10 +210,18 @@ public Object bitops3BitBitsInByte(Bitops3BitState state) { @State(Scope.Thread) public static class BitopsBitsState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public BitopsBitsState() { super("bitops-bits-in-byte.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object bitopsBitsInByte(BitopsBitsState state) { return state.run(); @@ -155,10 +230,18 @@ public Object bitopsBitsInByte(BitopsBitsState state) { @State(Scope.Thread) public static class BitopsAndState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public BitopsAndState() { super("bitops-bitwise-and.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object bitopsBitwiseAnd(BitopsAndState state) { return state.run(); @@ -167,10 +250,18 @@ public Object bitopsBitwiseAnd(BitopsAndState state) { @State(Scope.Thread) public static class BitopsNsieveState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public BitopsNsieveState() { super("bitops-nsieve-bits.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object bitopsNsieveBits(BitopsNsieveState state) { return state.run(); @@ -179,10 +270,18 @@ public Object bitopsNsieveBits(BitopsNsieveState state) { @State(Scope.Thread) public static class RecursiveState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public RecursiveState() { super("controlflow-recursive.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object controlflowRecursive(RecursiveState state) { return state.run(); @@ -191,10 +290,18 @@ public Object controlflowRecursive(RecursiveState state) { @State(Scope.Thread) public static class CryptoAesState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public CryptoAesState() { super("crypto-aes.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object cryptoAes(CryptoAesState state) { return state.run(); @@ -203,10 +310,18 @@ public Object cryptoAes(CryptoAesState state) { @State(Scope.Thread) public static class CryptoMd5State extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public CryptoMd5State() { super("crypto-md5.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object cryptoMd5(CryptoMd5State state) { return state.run(); @@ -215,10 +330,18 @@ public Object cryptoMd5(CryptoMd5State state) { @State(Scope.Thread) public static class CryptoShaState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public CryptoShaState() { super("crypto-sha1.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object cryptoSha1(CryptoShaState state) { return state.run(); @@ -227,10 +350,18 @@ public Object cryptoSha1(CryptoShaState state) { @State(Scope.Thread) public static class DateFormatToFteState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public DateFormatToFteState() { super("date-format-tofte.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object dateFormatToFte(DateFormatToFteState state) { return state.run(); @@ -239,10 +370,18 @@ public Object dateFormatToFte(DateFormatToFteState state) { @State(Scope.Thread) public static class DateFormatXparbState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public DateFormatXparbState() { super("date-format-xparb.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object dateFormatXparb(DateFormatXparbState state) { return state.run(); @@ -251,10 +390,18 @@ public Object dateFormatXparb(DateFormatXparbState state) { @State(Scope.Thread) public static class MathCordicState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public MathCordicState() { super("math-cordic.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object mathCordic(MathCordicState state) { return state.run(); @@ -263,10 +410,18 @@ public Object mathCordic(MathCordicState state) { @State(Scope.Thread) public static class MathPartialState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public MathPartialState() { super("math-partial-sums.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object mathPartialSums(MathPartialState state) { return state.run(); @@ -275,10 +430,18 @@ public Object mathPartialSums(MathPartialState state) { @State(Scope.Thread) public static class MathSpectralNormState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public MathSpectralNormState() { super("math-spectral-norm.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object mathSpectralNorm(MathSpectralNormState state) { return state.run(); @@ -287,10 +450,18 @@ public Object mathSpectralNorm(MathSpectralNormState state) { @State(Scope.Thread) public static class RegexpState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public RegexpState() { super("regexp-dna.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object regexpDna(RegexpState state) { return state.run(); @@ -299,10 +470,18 @@ public Object regexpDna(RegexpState state) { @State(Scope.Thread) public static class StringBase64State extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public StringBase64State() { super("string-base64.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object stringBase64(StringBase64State state) { return state.run(); @@ -311,10 +490,18 @@ public Object stringBase64(StringBase64State state) { @State(Scope.Thread) public static class StringFastaState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public StringFastaState() { super("string-fasta.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object stringFasta(StringFastaState state) { return state.run(); @@ -323,10 +510,18 @@ public Object stringFasta(StringFastaState state) { @State(Scope.Thread) public static class StringTagcloudState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public StringTagcloudState() { super("string-tagcloud.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object stringTagcloud(StringTagcloudState state) { return state.run(); @@ -335,10 +530,18 @@ public Object stringTagcloud(StringTagcloudState state) { @State(Scope.Thread) public static class StringUnpackState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public StringUnpackState() { super("string-unpack-code.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object stringUnpackCode(StringUnpackState state) { return state.run(); @@ -347,10 +550,18 @@ public Object stringUnpackCode(StringUnpackState state) { @State(Scope.Thread) public static class StringValidateState extends AbstractState { + @Param({"false", "true"}) + public boolean interpreted; + public StringValidateState() { super("string-validate-input.js"); } + @Override + protected boolean isInterpreted() { + return interpreted; + } + @Benchmark public Object stringValidateInput(StringValidateState state) { return state.run(); diff --git a/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/V8Benchmark.java b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/V8Benchmark.java index 9c38ffe717..cc9e953c13 100644 --- a/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/V8Benchmark.java +++ b/benchmarks/src/jmh/java/org/mozilla/javascript/benchmarks/V8Benchmark.java @@ -38,8 +38,9 @@ void evaluateSource(Context cx, Scriptable scope, String fileName) { } } - void initialize() { + void initialize(boolean interpreted) { cx = Context.enter(); + cx.setInterpretedMode(interpreted); cx.setLanguageVersion(Context.VERSION_ES6); scope = cx.initStandardObjects(); evaluateSource(cx, scope, "testsrc/benchmarks/framework.js"); @@ -64,9 +65,12 @@ void runCleanup() { public static class SplayState extends AbstractState { Callable splay; + @Param({"false", "true"}) + public boolean interpreted; + @Setup(Level.Trial) public void setUp() { - initialize(); + initialize(interpreted); evaluateSource(cx, scope, "testsrc/benchmarks/v8-benchmarks-v6/splay.js"); runSetup(); splay = getRunFunc("Splay"); @@ -89,9 +93,12 @@ public static class CryptoState extends AbstractState { Callable encrypt; Callable decrypt; + @Param({"false", "true"}) + public boolean interpreted; + @Setup(Level.Trial) public void setUp() { - initialize(); + initialize(interpreted); evaluateSource(cx, scope, "testsrc/benchmarks/v8-benchmarks-v6/crypto.js"); runSetup(); encrypt = getRunFunc("Encrypt"); @@ -121,9 +128,12 @@ public Object cryptoDecrypt(CryptoState state) { public static class DeltaBlueState extends AbstractState { Callable db; + @Param({"false", "true"}) + public boolean interpreted; + @Setup(Level.Trial) public void setUp() { - initialize(); + initialize(interpreted); evaluateSource(cx, scope, "testsrc/benchmarks/v8-benchmarks-v6/deltablue.js"); runSetup(); db = getRunFunc("DeltaBlue"); @@ -145,9 +155,12 @@ public Object deltaBlue(DeltaBlueState state) { public static class RayTraceState extends AbstractState { Callable rt; + @Param({"false", "true"}) + public boolean interpreted; + @Setup(Level.Trial) public void setUp() { - initialize(); + initialize(interpreted); evaluateSource(cx, scope, "testsrc/benchmarks/v8-benchmarks-v6/raytrace.js"); runSetup(); rt = getRunFunc("RayTrace"); @@ -195,9 +208,12 @@ public Object regExp(RegExpState state) { public static class RichardsState extends AbstractState { Callable r; + @Param({"false", "true"}) + public boolean interpreted; + @Setup(Level.Trial) public void setUp() { - initialize(); + initialize(interpreted); evaluateSource(cx, scope, "testsrc/benchmarks/v8-benchmarks-v6/richards.js"); runSetup(); r = getRunFunc("Richards"); @@ -220,9 +236,12 @@ public static class EarleyBoyerState extends AbstractState { Callable earley; Callable boyer; + @Param({"false", "true"}) + public boolean interpreted; + @Setup(Level.Trial) public void setUp() { - initialize(); + initialize(interpreted); evaluateSource(cx, scope, "testsrc/benchmarks/v8-benchmarks-v6/earley-boyer.js"); runSetup(); earley = getRunFunc("Earley");