|
38 | 38 | import java.io.File;
|
39 | 39 | import java.io.FileOutputStream;
|
40 | 40 | import java.io.IOException;
|
| 41 | +import java.lang.invoke.LambdaForm.BasicType; |
| 42 | +import java.lang.invoke.LambdaForm.Name; |
| 43 | +import java.lang.invoke.LambdaForm.NamedFunction; |
41 | 44 | import java.lang.reflect.Modifier;
|
42 | 45 | import java.util.ArrayList;
|
43 | 46 | import java.util.Arrays;
|
@@ -111,7 +114,12 @@ private InvokerBytecodeGenerator(LambdaForm lambdaForm, int localsMapSize,
|
111 | 114 | if (DUMP_CLASS_FILES) {
|
112 | 115 | className = makeDumpableClassName(className);
|
113 | 116 | }
|
114 |
| - this.className = className; |
| 117 | + int uniqueID = lambdaForm.toString().hashCode() |
| 118 | + ^ className.hashCode() |
| 119 | + ^ invokerName.hashCode() |
| 120 | + ^ invokerType.toString().hashCode(); |
| 121 | + uniqueID &= 0x7fffffff; |
| 122 | + this.className = className + "$" + uniqueID; |
115 | 123 | this.lambdaForm = lambdaForm;
|
116 | 124 | this.invokerName = invokerName;
|
117 | 125 | this.invokerType = invokerType;
|
@@ -690,6 +698,10 @@ static MemberName generateCustomizedCode(LambdaForm form, MethodType invokerType
|
690 | 698 | if (pregenerated != null) return pregenerated; // pre-generated bytecode
|
691 | 699 |
|
692 | 700 | InvokerBytecodeGenerator g = new InvokerBytecodeGenerator("MH", form, invokerType);
|
| 701 | + Class<?> customized = MethodHandleNatives.findInSCC(CLASS_PREFIX + g.className, HOST_CLASS); |
| 702 | + if (customized != null) { |
| 703 | + return resolveInvokerMember(customized, g.invokerName, g.invokerType); |
| 704 | + } |
693 | 705 | return g.loadMethod(g.generateCustomizedCodeBytes());
|
694 | 706 | }
|
695 | 707 |
|
@@ -1766,6 +1778,10 @@ static MemberName generateLambdaFormInterpreterEntryPoint(MethodType mt) {
|
1766 | 1778 | MethodType type = mt; // includes leading argument
|
1767 | 1779 | type = type.changeParameterType(0, MethodHandle.class);
|
1768 | 1780 | InvokerBytecodeGenerator g = new InvokerBytecodeGenerator("LFI", name, type);
|
| 1781 | + Class<?> customized = MethodHandleNatives.findInSCC(CLASS_PREFIX + g.className, HOST_CLASS); |
| 1782 | + if (customized != null) { |
| 1783 | + return resolveInvokerMember(customized, g.invokerName, g.invokerType); |
| 1784 | + } |
1769 | 1785 | return g.loadMethod(g.generateLambdaFormInterpreterEntryPointBytes());
|
1770 | 1786 | }
|
1771 | 1787 |
|
@@ -1825,6 +1841,10 @@ static MemberName generateNamedFunctionInvoker(MethodTypeForm typeForm) {
|
1825 | 1841 | MethodType invokerType = NamedFunction.INVOKER_METHOD_TYPE;
|
1826 | 1842 | String invokerName = "invoke_" + shortenSignature(basicTypeSignature(typeForm.erasedType()));
|
1827 | 1843 | InvokerBytecodeGenerator g = new InvokerBytecodeGenerator("NFI", invokerName, invokerType);
|
| 1844 | + Class<?> customized = MethodHandleNatives.findInSCC(CLASS_PREFIX + g.className, HOST_CLASS); |
| 1845 | + if (customized != null) { |
| 1846 | + return resolveInvokerMember(customized, g.invokerName, g.invokerType); |
| 1847 | + } |
1828 | 1848 | return g.loadMethod(g.generateNamedFunctionInvokerImpl(typeForm));
|
1829 | 1849 | }
|
1830 | 1850 |
|
|
0 commit comments