3131import static org .junit .Assert .fail ;
3232import static org .junit .Assume .assumeTrue ;
3333
34+ import java .util .ArrayList ;
3435import java .util .List ;
3536
3637import org .graalvm .polyglot .Context ;
5152import com .oracle .truffle .api .bytecode .ContinuationResult ;
5253import com .oracle .truffle .api .bytecode .test .BytecodeDSLTestLanguage ;
5354import com .oracle .truffle .api .bytecode .test .basic_interpreter .AbstractBasicInterpreterTest ;
55+ import com .oracle .truffle .api .bytecode .test .basic_interpreter .AbstractBasicInterpreterTest .TestRun ;
5456import com .oracle .truffle .api .bytecode .test .basic_interpreter .BasicInterpreter ;
5557import com .oracle .truffle .api .bytecode .test .basic_interpreter .BasicInterpreterBuilder ;
5658import com .oracle .truffle .api .bytecode .test .basic_interpreter .BasicInterpreterBuilder .BytecodeVariant ;
7072public class BytecodeDSLCompilationTest extends TestWithSynchronousCompiling {
7173
7274 @ Parameters (name = "{0}" )
73- public static List <BytecodeVariant > getBytecodeVariants () {
74- return AbstractBasicInterpreterTest .allVariants ();
75+ public static List <TestRun > getParameters () {
76+ List <TestRun > result = new ArrayList <>();
77+ for (BytecodeVariant bc : AbstractBasicInterpreterTest .allVariants ()) {
78+ result .add (new TestRun (bc , false , false ));
79+ }
80+ return result ;
7581 }
7682
77- @ Parameter (0 ) public BytecodeVariant bytecode ;
83+ @ Parameter (0 ) public TestRun run ;
7884
7985 private boolean hasBoxingElimination () {
80- return new AbstractBasicInterpreterTest . TestRun ( bytecode , false ) .hasBoxingElimination ();
86+ return run .hasBoxingElimination ();
8187 }
8288
8389 Context context ;
@@ -124,7 +130,7 @@ public static void beforeClass() {
124130 */
125131 @ Test
126132 public void testOSR1 () {
127- BasicInterpreter root = parseNode (bytecode , BytecodeDSLTestLanguage .REF .get (null ), false , "osrRoot" , b -> {
133+ BasicInterpreter root = parseNode (run , BytecodeDSLTestLanguage .REF .get (null ), "osrRoot" , b -> {
128134 b .beginRoot ();
129135
130136 BytecodeLocal iLoc = b .createLocal ();
@@ -224,7 +230,7 @@ public void testOSR1() {
224230 */
225231 @ Test
226232 public void testOSR2 () {
227- BasicInterpreter root = parseNode (bytecode , BytecodeDSLTestLanguage .REF .get (null ), false , "osrRoot" , b -> {
233+ BasicInterpreter root = parseNode (run , BytecodeDSLTestLanguage .REF .get (null ), "osrRoot" , b -> {
228234 b .beginRoot ();
229235
230236 BytecodeLocal iLoc = b .createLocal ();
@@ -342,7 +348,7 @@ public void testOSR2() {
342348
343349 @ Test
344350 public void testCompiles () {
345- BasicInterpreter root = parseNodeForCompilation (bytecode , "addTwoConstants" , b -> {
351+ BasicInterpreter root = parseNodeForCompilation (run , "addTwoConstants" , b -> {
346352 b .beginRoot ();
347353
348354 b .beginReturn ();
@@ -366,7 +372,7 @@ public void testCompiles() {
366372 @ Test
367373 public void testMultipleReturns () {
368374 // return 30 + (arg0 ? 12 : (return 123; 0))
369- BasicInterpreter root = parseNodeForCompilation (bytecode , "multipleReturns" , b -> {
375+ BasicInterpreter root = parseNodeForCompilation (run , "multipleReturns" , b -> {
370376 b .beginRoot ();
371377
372378 b .beginReturn ();
@@ -404,7 +410,7 @@ public void testMultipleReturns() {
404410 @ Test
405411 public void testStoreInvalidatesCode () {
406412 assumeTrue (hasBoxingElimination ());
407- BytecodeRootNodes <BasicInterpreter > rootNodes = createNodes (bytecode , BytecodeDSLTestLanguage .REF .get (null ), false , BytecodeConfig .DEFAULT , b -> {
413+ BytecodeRootNodes <BasicInterpreter > rootNodes = createNodes (run , BytecodeDSLTestLanguage .REF .get (null ), BytecodeConfig .DEFAULT , b -> {
408414 b .beginRoot ();
409415 BytecodeLocal x = b .createLocal ("x" , null );
410416 b .beginStoreLocal (x );
@@ -464,7 +470,7 @@ public void testStoreInvalidatesCode() {
464470 @ Test
465471 public void testBytecodeNodeStoreInvalidatesCode () {
466472 assumeTrue (hasBoxingElimination ());
467- BytecodeRootNodes <BasicInterpreter > rootNodes = createNodes (bytecode , BytecodeDSLTestLanguage .REF .get (null ), false , BytecodeConfig .DEFAULT , b -> {
473+ BytecodeRootNodes <BasicInterpreter > rootNodes = createNodes (run , BytecodeDSLTestLanguage .REF .get (null ), BytecodeConfig .DEFAULT , b -> {
468474 b .beginRoot ();
469475 BytecodeLocal x = b .createLocal ("x" , null );
470476 b .beginStoreLocal (x );
@@ -538,7 +544,7 @@ public void testBytecodeNodeStoreInvalidatesCode() {
538544 @ Test
539545 public void testMaterializedStoreInvalidatesCode () {
540546 assumeTrue (hasBoxingElimination ());
541- BytecodeRootNodes <BasicInterpreter > rootNodes = createNodes (bytecode , BytecodeDSLTestLanguage .REF .get (null ), false , BytecodeConfig .DEFAULT , b -> {
547+ BytecodeRootNodes <BasicInterpreter > rootNodes = createNodes (run , BytecodeDSLTestLanguage .REF .get (null ), BytecodeConfig .DEFAULT , b -> {
542548 b .beginRoot ();
543549 BytecodeLocal x = b .createLocal ("x" , null );
544550 b .beginStoreLocal (x );
@@ -616,7 +622,7 @@ public void testMaterializedStoreInvalidatesCode() {
616622 @ Test
617623 public void testMaterializedAccessorStoreInvalidatesCode () {
618624 assumeTrue (hasBoxingElimination ());
619- BytecodeRootNodes <BasicInterpreter > rootNodes = createNodes (bytecode , BytecodeDSLTestLanguage .REF .get (null ), false , BytecodeConfig .DEFAULT , b -> {
625+ BytecodeRootNodes <BasicInterpreter > rootNodes = createNodes (run , BytecodeDSLTestLanguage .REF .get (null ), BytecodeConfig .DEFAULT , b -> {
620626 b .beginRoot ();
621627 BytecodeLocal x = b .createLocal ("x" , null );
622628 b .beginStoreLocal (x );
@@ -689,7 +695,7 @@ public void testMaterializedAccessorStoreInvalidatesCode() {
689695
690696 @ Test
691697 public void testInstrumentation () {
692- BasicInterpreter root = parseNodeForCompilation (bytecode , "addTwoConstantsInstrumented" , b -> {
698+ BasicInterpreter root = parseNodeForCompilation (run , "addTwoConstantsInstrumented" , b -> {
693699 b .beginRoot ();
694700
695701 b .beginReturn ();
@@ -711,7 +717,7 @@ public void testInstrumentation() {
711717
712718 // Instrumentation should invalidate the compiled code.
713719 root .getRootNodes ().update (
714- bytecode .newConfigBuilder ().addInstrumentation (BasicInterpreter .IncrementValue .class ).build ());
720+ run . bytecode () .newConfigBuilder ().addInstrumentation (BasicInterpreter .IncrementValue .class ).build ());
715721 assertNotCompiled (target );
716722
717723 // The instrumented interpreter should be recompiled.
@@ -724,7 +730,7 @@ public void testInstrumentation() {
724730
725731 @ Test
726732 public void testYield () {
727- BasicInterpreter root = parseNodeForCompilation (bytecode , "addYield" , b -> {
733+ BasicInterpreter root = parseNodeForCompilation (run , "addYield" , b -> {
728734 b .beginRoot ();
729735
730736 b .beginReturn ();
@@ -764,7 +770,7 @@ public void testYield() {
764770
765771 @ Test
766772 public void testYieldInstrumentation () {
767- BasicInterpreter root = parseNodeForCompilation (bytecode , "addYieldInstrumented" , b -> {
773+ BasicInterpreter root = parseNodeForCompilation (run , "addYieldInstrumented" , b -> {
768774 b .beginRoot ();
769775
770776 b .beginReturn ();
@@ -798,7 +804,7 @@ public void testYieldInstrumentation() {
798804
799805 // Instrumentation should invalidate the compiled code.
800806 root .getRootNodes ().update (
801- bytecode .newConfigBuilder ().addInstrumentation (BasicInterpreter .IncrementValue .class ).build ());
807+ run . bytecode () .newConfigBuilder ().addInstrumentation (BasicInterpreter .IncrementValue .class ).build ());
802808 assertNotCompiled (target );
803809 assertNotCompiled (continuationCallTarget );
804810
@@ -816,7 +822,7 @@ public void testYieldInstrumentation() {
816822 @ Test
817823 public void testCompiledSourceInfo () {
818824 Source s = Source .newBuilder ("test" , "return sourcePosition" , "compiledSourceInfo" ).build ();
819- BasicInterpreter root = parseNodeForCompilation (bytecode , "compiledSourceInfo" , b -> {
825+ BasicInterpreter root = parseNodeForCompilation (run , "compiledSourceInfo" , b -> {
820826 b .beginSource (s );
821827 b .beginSourceSection (0 , 21 );
822828 b .beginRoot ();
@@ -864,7 +870,7 @@ public void testCompiledSourceInfo() {
864870
865871 @ Test
866872 public void testTagInstrumentation () {
867- BasicInterpreter root = parseNodeForCompilation (bytecode , "tagInstrumentation" , b -> {
873+ BasicInterpreter root = parseNodeForCompilation (run , "tagInstrumentation" , b -> {
868874 b .beginRoot ();
869875
870876 // i = 0
@@ -991,9 +997,9 @@ public void onEnter(VirtualFrame f) {
991997 return c ;
992998 }
993999
994- private static BasicInterpreter parseNodeForCompilation (BytecodeVariant bytecode ,
1000+ private static BasicInterpreter parseNodeForCompilation (TestRun run ,
9951001 String rootName , BytecodeParser <BasicInterpreterBuilder > builder ) {
996- BasicInterpreter result = parseNode (bytecode , BytecodeDSLTestLanguage .REF .get (null ), false , rootName , builder );
1002+ BasicInterpreter result = parseNode (run , BytecodeDSLTestLanguage .REF .get (null ), rootName , builder );
9971003 result .getBytecodeNode ().setUncachedThreshold (0 ); // force interpreter to skip tier 0
9981004 return result ;
9991005 }
0 commit comments