34 */ |
34 */ |
35 public final class Specialization { |
35 public final class Specialization { |
36 private final MethodHandle mh; |
36 private final MethodHandle mh; |
37 private final Class<? extends LinkLogic> linkLogicClass; |
37 private final Class<? extends LinkLogic> linkLogicClass; |
38 private final boolean isOptimistic; |
38 private final boolean isOptimistic; |
|
39 private final boolean convertsNumericArgs; |
39 |
40 |
40 /** |
41 /** |
41 * Constructor |
42 * Constructor |
42 * |
43 * |
43 * @param mh invoker method handler |
44 * @param mh invoker method handler |
44 */ |
45 */ |
45 public Specialization(final MethodHandle mh) { |
46 public Specialization(final MethodHandle mh) { |
46 this(mh, false); |
47 this(mh, false, true); |
47 } |
48 } |
48 |
49 |
49 /** |
50 /** |
50 * Constructor |
51 * Constructor |
51 * |
52 * |
52 * @param mh invoker method handler |
53 * @param mh invoker method handler |
53 * @param isOptimistic is this an optimistic native method, i.e. can it throw {@link UnwarrantedOptimismException} |
54 * @param isOptimistic is this an optimistic native method, i.e. can it throw {@link UnwarrantedOptimismException} |
54 * which would have to lead to a relink and return value processing |
55 * which would have to lead to a relink and return value processing |
|
56 * @param convertsNumericArgs true if it is safe to convert arguments to numbers |
55 */ |
57 */ |
56 public Specialization(final MethodHandle mh, final boolean isOptimistic) { |
58 public Specialization(final MethodHandle mh, final boolean isOptimistic, final boolean convertsNumericArgs) { |
57 this(mh, null, isOptimistic); |
59 this(mh, null, isOptimistic, convertsNumericArgs); |
58 } |
60 } |
59 |
61 |
60 /** |
62 /** |
61 * Constructor |
63 * Constructor |
62 * |
64 * |
63 * @param mh invoker method handler |
65 * @param mh invoker method handler |
64 * @param linkLogicClass extra link logic needed for this function. Instances of this class also contains logic for checking |
66 * @param linkLogicClass extra link logic needed for this function. Instances of this class also contains logic for checking |
65 * if this can be linked on its first encounter, which is needed as per our standard linker semantics |
67 * if this can be linked on its first encounter, which is needed as per our standard linker semantics |
66 * @param isOptimistic is this an optimistic native method, i.e. can it throw {@link UnwarrantedOptimismException} |
68 * @param isOptimistic is this an optimistic native method, i.e. can it throw {@link UnwarrantedOptimismException} |
67 * which would have to lead to a relink and return value processing |
69 * which would have to lead to a relink and return value processing |
|
70 * @param convertsNumericArgs true if it is safe to convert arguments to numbers |
68 */ |
71 */ |
69 public Specialization(final MethodHandle mh, final Class<? extends LinkLogic> linkLogicClass, final boolean isOptimistic) { |
72 public Specialization(final MethodHandle mh, final Class<? extends LinkLogic> linkLogicClass, |
|
73 final boolean isOptimistic, final boolean convertsNumericArgs) { |
70 this.mh = mh; |
74 this.mh = mh; |
71 this.isOptimistic = isOptimistic; |
75 this.isOptimistic = isOptimistic; |
|
76 this.convertsNumericArgs = convertsNumericArgs; |
72 if (linkLogicClass != null) { |
77 if (linkLogicClass != null) { |
73 //null out the "empty" link logic class for optimization purposes |
78 //null out the "empty" link logic class for optimization purposes |
74 //we only use the empty instance because we can't default class annotations |
79 //we only use the empty instance because we can't default class annotations |
75 //to null |
80 //to null |
76 this.linkLogicClass = LinkLogic.isEmpty(linkLogicClass) ? null : linkLogicClass; |
81 this.linkLogicClass = LinkLogic.isEmpty(linkLogicClass) ? null : linkLogicClass; |