52 |
52 |
53 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
53 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
54 |
54 |
55 private static boolean enableChecks = true; |
55 private static boolean enableChecks = true; |
56 |
56 |
57 public static void setup_test() { |
57 private static boolean compile(Class<?> clazz, String name) { |
|
58 try { |
|
59 Method method = clazz.getMethod(name); |
|
60 boolean enqueued = WHITE_BOX.enqueueMethodForCompilation(method, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION); |
|
61 if (!enqueued) { |
|
62 System.out.println("Warning: Blocking compilation failed for " + clazz.getName() + "." + name + " (timeout?)"); |
|
63 return false; |
|
64 } else if (!WHITE_BOX.isMethodCompiled(method)) { |
|
65 throw new RuntimeException(clazz.getName() + "." + name + " is not compiled"); |
|
66 } |
|
67 } catch (NoSuchMethodException e) { |
|
68 throw new RuntimeException(clazz.getName() + "." + name + " not found", e); |
|
69 } |
|
70 return true; |
|
71 } |
|
72 |
|
73 public static boolean setup_test() { |
58 // Assure all exceptions are loaded. |
74 // Assure all exceptions are loaded. |
59 new AbstractMethodError(); |
75 new AbstractMethodError(); |
60 new IncompatibleClassChangeError(); |
76 new IncompatibleClassChangeError(); |
61 |
77 |
62 enableChecks = false; |
78 enableChecks = false; |
65 test_ame5_compiled_vtable_stub(); |
81 test_ame5_compiled_vtable_stub(); |
66 test_ame6_compiled_itable_stub(); |
82 test_ame6_compiled_itable_stub(); |
67 enableChecks = true; |
83 enableChecks = true; |
68 |
84 |
69 // Compile |
85 // Compile |
70 try { |
86 if (!compile(AbstractMethodErrorTest.class, "test_ame5_compiled_vtable_stub") || |
71 Method method = AbstractMethodErrorTest.class.getMethod("test_ame5_compiled_vtable_stub"); |
87 !compile(AbstractMethodErrorTest.class, "test_ame6_compiled_itable_stub") || |
72 WHITE_BOX.enqueueMethodForCompilation(method, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION); |
88 !compile(AME5_C.class, "mc") || |
73 if (!WHITE_BOX.isMethodCompiled(method)) { |
89 !compile(AME5_D.class, "mc") || |
74 throw new RuntimeException(method.getName() + " is not compiled"); |
90 !compile(AME5_E.class, "mc") || |
75 } |
91 !compile(AME6_C.class, "mc") || |
76 method = AbstractMethodErrorTest.class.getMethod("test_ame6_compiled_itable_stub"); |
92 !compile(AME6_D.class, "mc") || |
77 WHITE_BOX.enqueueMethodForCompilation(method, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION); |
93 !compile(AME6_E.class, "mc")) { |
78 if (!WHITE_BOX.isMethodCompiled(method)) { |
94 return false; |
79 throw new RuntimeException(method.getName() + " is not compiled"); |
95 } |
80 } |
96 |
81 method = AME5_C.class.getMethod("c"); |
97 System.out.println("warmup done."); |
82 WHITE_BOX.enqueueMethodForCompilation(method, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION); |
98 return true; |
83 if (!WHITE_BOX.isMethodCompiled(method)) { |
|
84 throw new RuntimeException("AME5_C." + method.getName() + " is not compiled"); |
|
85 } |
|
86 method = AME5_D.class.getMethod("c"); |
|
87 WHITE_BOX.enqueueMethodForCompilation(method, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION); |
|
88 if (!WHITE_BOX.isMethodCompiled(method)) { |
|
89 throw new RuntimeException("AME5_D." + method.getName() + " is not compiled"); |
|
90 } |
|
91 method = AME5_E.class.getMethod("c"); |
|
92 WHITE_BOX.enqueueMethodForCompilation(method, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION); |
|
93 if (!WHITE_BOX.isMethodCompiled(method)) { |
|
94 throw new RuntimeException("AME5_E." + method.getName() + " is not compiled"); |
|
95 } |
|
96 method = AME6_C.class.getMethod("c"); |
|
97 WHITE_BOX.enqueueMethodForCompilation(method, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION); |
|
98 if (!WHITE_BOX.isMethodCompiled(method)) { |
|
99 throw new RuntimeException("AME6_C." + method.getName() + " is not compiled"); |
|
100 } |
|
101 method = AME6_D.class.getMethod("c"); |
|
102 WHITE_BOX.enqueueMethodForCompilation(method, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION); |
|
103 if (!WHITE_BOX.isMethodCompiled(method)) { |
|
104 throw new RuntimeException("AME6_D." + method.getName() + " is not compiled"); |
|
105 } |
|
106 method = AME6_E.class.getMethod("c"); |
|
107 WHITE_BOX.enqueueMethodForCompilation(method, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION); |
|
108 if (!WHITE_BOX.isMethodCompiled(method)) { |
|
109 throw new RuntimeException("AME6_E." + method.getName() + " is not compiled"); |
|
110 } |
|
111 } catch (NoSuchMethodException e) { } |
|
112 } |
99 } |
113 |
100 |
114 private static String expectedErrorMessageAME1_1 = |
101 private static String expectedErrorMessageAME1_1 = |
115 "Missing implementation of resolved method abstract " + |
102 "Missing implementation of resolved method abstract " + |
116 "anAbstractMethod()Ljava/lang/String; of abstract class AME1_B."; |
103 "anAbstractMethod()Ljava/lang/String; of abstract class AME1_B."; |
754 // Test: |
743 // Test: |
755 // - Call D.mc() / E.mc() / F.mc() several times to force real vtable call constrution |
744 // - Call D.mc() / E.mc() / F.mc() several times to force real vtable call constrution |
756 // - Call errorneous B.mc() in the end to raise the AbstraceMethodError |
745 // - Call errorneous B.mc() in the end to raise the AbstraceMethodError |
757 |
746 |
758 abstract class AME5_A { |
747 abstract class AME5_A { |
759 abstract void ma(); |
748 public abstract void ma(); |
760 abstract void mb(); |
749 public abstract void mb(); |
761 abstract void mc(); |
750 public abstract void mc(); |
762 } |
751 } |
763 |
752 |
764 class AME5_B extends AME5_A { |
753 class AME5_B extends AME5_A { |
765 void ma() { |
754 public void ma() { |
766 System.out.print("B.ma() "); |
755 System.out.print("B.ma() "); |
767 } |
756 } |
768 |
757 |
769 void mb() { |
758 public void mb() { |
770 System.out.print("B.mb() "); |
759 System.out.print("B.mb() "); |
771 } |
760 } |
772 |
761 |
773 // This method is missing in the .jasm implementation. |
762 // This method is missing in the .jasm implementation. |
774 void mc() { |
763 public void mc() { |
775 System.out.print("B.mc() "); |
764 System.out.print("B.mc() "); |
776 } |
765 } |
777 } |
766 } |
778 |
767 |
779 class AME5_C extends AME5_A { |
768 class AME5_C extends AME5_A { |
780 void ma() { |
769 public void ma() { |
781 System.out.print("C.ma() "); |
770 System.out.print("C.ma() "); |
782 } |
771 } |
783 |
772 |
784 void mb() { |
773 public void mb() { |
785 System.out.print("C.mb() "); |
774 System.out.print("C.mb() "); |
786 } |
775 } |
787 |
776 |
788 void mc() { |
777 public void mc() { |
789 System.out.print("C.mc() "); |
778 System.out.print("C.mc() "); |
790 } |
779 } |
791 } |
780 } |
792 |
781 |
793 class AME5_D extends AME5_A { |
782 class AME5_D extends AME5_A { |
794 void ma() { |
783 public void ma() { |
795 System.out.print("D.ma() "); |
784 System.out.print("D.ma() "); |
796 } |
785 } |
797 |
786 |
798 void mb() { |
787 public void mb() { |
799 System.out.print("D.mb() "); |
788 System.out.print("D.mb() "); |
800 } |
789 } |
801 |
790 |
802 void mc() { |
791 public void mc() { |
803 System.out.print("D.mc() "); |
792 System.out.print("D.mc() "); |
804 } |
793 } |
805 } |
794 } |
806 |
795 |
807 class AME5_E extends AME5_A { |
796 class AME5_E extends AME5_A { |
808 void ma() { |
797 public void ma() { |
809 System.out.print("E.ma() "); |
798 System.out.print("E.ma() "); |
810 } |
799 } |
811 |
800 |
812 void mb() { |
801 public void mb() { |
813 System.out.print("E.mb() "); |
802 System.out.print("E.mb() "); |
814 } |
803 } |
815 |
804 |
816 void mc() { |
805 public void mc() { |
817 System.out.print("E.mc() "); |
806 System.out.print("E.mc() "); |
818 } |
807 } |
819 } |
808 } |
820 |
809 |
821 //------------------------------------------------------------------------- |
810 //------------------------------------------------------------------------- |
822 // Test AbstractMethod error detected while processing |
811 // Test AbstractMethod error detected while processing |
823 // the itable stub. |
812 // the itable stub. |