author | stefank |
Mon, 04 Apr 2016 09:15:01 +0200 | |
changeset 37241 | b9961c99c356 |
parent 30820 | 0d4717a011d3 |
permissions | -rw-r--r-- |
9646 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
19075
diff
changeset
|
2 |
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. |
9646 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
package test.sun.invoke.util; |
|
25 |
||
26 |
import sun.invoke.util.ValueConversions; |
|
27 |
import sun.invoke.util.Wrapper; |
|
26474
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
28 |
import java.lang.invoke.MethodHandles; |
9646 | 29 |
import java.lang.invoke.MethodType; |
30 |
import java.lang.invoke.MethodHandle; |
|
31 |
import java.io.Serializable; |
|
32 |
import java.util.Arrays; |
|
33 |
import org.junit.Test; |
|
34 |
import static org.junit.Assert.*; |
|
35 |
||
36 |
/* @test |
|
37 |
* @summary unit tests for value-type conversion utilities |
|
30820 | 38 |
* @modules java.base/sun.invoke.util |
19075
63e635266eec
8006324: [TEST_BUG] sun/invoke/util/ValueConversionsTest.java should be modified
rbackman
parents:
14342
diff
changeset
|
39 |
* @compile -XDignore.symbol.file ValueConversionsTest.java |
9646 | 40 |
* @run junit/othervm test.sun.invoke.util.ValueConversionsTest |
41 |
*/ |
|
42 |
||
43 |
/** |
|
44 |
* |
|
45 |
* @author jrose |
|
46 |
*/ |
|
47 |
public class ValueConversionsTest { |
|
48 |
@Test |
|
49 |
public void testUnbox() throws Throwable { |
|
50 |
testUnbox(false); |
|
51 |
} |
|
52 |
||
53 |
@Test |
|
54 |
public void testUnboxCast() throws Throwable { |
|
55 |
testUnbox(true); |
|
56 |
} |
|
57 |
||
58 |
private void testUnbox(boolean doCast) throws Throwable { |
|
59 |
for (Wrapper dst : Wrapper.values()) { |
|
60 |
for (Wrapper src : Wrapper.values()) { |
|
61 |
testUnbox(doCast, dst, src); |
|
62 |
} |
|
63 |
} |
|
64 |
} |
|
65 |
||
66 |
private void testUnbox(boolean doCast, Wrapper dst, Wrapper src) throws Throwable { |
|
67 |
boolean expectThrow = !doCast && !dst.isConvertibleFrom(src); |
|
68 |
if (dst == Wrapper.OBJECT || src == Wrapper.OBJECT) return; // must have prims |
|
26474
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
69 |
if (dst == Wrapper.VOID || src == Wrapper.VOID ) return; // must have values |
9646 | 70 |
if (dst == Wrapper.OBJECT) |
71 |
expectThrow = false; // everything (even VOID==null here) converts to OBJECT |
|
72 |
try { |
|
73 |
for (int n = -5; n < 10; n++) { |
|
74 |
Object box = src.wrap(n); |
|
75 |
switch (src) { |
|
76 |
case VOID: assertEquals(box, null); break; |
|
77 |
case OBJECT: box = box.toString(); break; |
|
78 |
case SHORT: assertEquals(box.getClass(), Short.class); break; |
|
79 |
default: assertEquals(box.getClass(), src.wrapperType()); break; |
|
80 |
} |
|
81 |
MethodHandle unboxer; |
|
82 |
if (doCast) |
|
26474
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
83 |
unboxer = ValueConversions.unboxCast(dst); |
9646 | 84 |
else |
26474
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
85 |
unboxer = ValueConversions.unboxWiden(dst); |
9646 | 86 |
Object expResult = (box == null) ? dst.zero() : dst.wrap(box); |
87 |
Object result = null; |
|
88 |
switch (dst) { |
|
89 |
case INT: result = (int) unboxer.invokeExact(box); break; |
|
90 |
case LONG: result = (long) unboxer.invokeExact(box); break; |
|
91 |
case FLOAT: result = (float) unboxer.invokeExact(box); break; |
|
92 |
case DOUBLE: result = (double) unboxer.invokeExact(box); break; |
|
93 |
case CHAR: result = (char) unboxer.invokeExact(box); break; |
|
94 |
case BYTE: result = (byte) unboxer.invokeExact(box); break; |
|
95 |
case SHORT: result = (short) unboxer.invokeExact(box); break; |
|
96 |
case BOOLEAN: result = (boolean) unboxer.invokeExact(box); break; |
|
97 |
} |
|
98 |
if (expectThrow) { |
|
99 |
expResult = "(need an exception)"; |
|
100 |
} |
|
101 |
assertEquals("(doCast,expectThrow,dst,src,n,box)="+Arrays.asList(doCast,expectThrow,dst,src,n,box), |
|
102 |
expResult, result); |
|
103 |
} |
|
104 |
} catch (RuntimeException ex) { |
|
105 |
if (expectThrow) return; |
|
106 |
System.out.println("Unexpected throw for (doCast,expectThrow,dst,src)="+Arrays.asList(doCast,expectThrow,dst,src)); |
|
107 |
throw ex; |
|
108 |
} |
|
109 |
} |
|
110 |
||
111 |
@Test |
|
112 |
public void testBox() throws Throwable { |
|
113 |
for (Wrapper w : Wrapper.values()) { |
|
26474
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
114 |
if (w == Wrapper.VOID) continue; // skip this; no unboxed form |
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
115 |
if (w == Wrapper.OBJECT) continue; // skip this; already unboxed |
9646 | 116 |
for (int n = -5; n < 10; n++) { |
117 |
Object box = w.wrap(n); |
|
26474
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
118 |
MethodHandle boxer = ValueConversions.boxExact(w); |
9646 | 119 |
Object expResult = box; |
120 |
Object result = null; |
|
121 |
switch (w) { |
|
26474
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
122 |
case INT: result = (Integer) boxer.invokeExact(/*int*/n); break; |
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
123 |
case LONG: result = (Long) boxer.invokeExact((long)n); break; |
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
124 |
case FLOAT: result = (Float) boxer.invokeExact((float)n); break; |
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
125 |
case DOUBLE: result = (Double) boxer.invokeExact((double)n); break; |
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
126 |
case CHAR: result = (Character) boxer.invokeExact((char)n); break; |
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
127 |
case BYTE: result = (Byte) boxer.invokeExact((byte)n); break; |
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
128 |
case SHORT: result = (Short) boxer.invokeExact((short)n); break; |
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
129 |
case BOOLEAN: result = (Boolean) boxer.invokeExact((n & 1) != 0); break; |
9646 | 130 |
} |
131 |
assertEquals("(dst,src,n,box)="+Arrays.asList(w,w,n,box), |
|
132 |
expResult, result); |
|
133 |
} |
|
134 |
} |
|
135 |
} |
|
136 |
||
137 |
@Test |
|
138 |
public void testCast() throws Throwable { |
|
139 |
Class<?>[] types = { Object.class, Serializable.class, String.class, Number.class, Integer.class }; |
|
140 |
Object[] objects = { new Object(), Boolean.FALSE, "hello", (Long)12L, (Integer)6 }; |
|
141 |
for (Class<?> dst : types) { |
|
26474
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
142 |
MethodHandle caster = ValueConversions.cast().bindTo(dst); |
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
143 |
assertEquals(caster.type(), MethodHandles.identity(Object.class).type()); |
9646 | 144 |
for (Object obj : objects) { |
145 |
Class<?> src = obj.getClass(); |
|
13610
28122b96858e
7191102: nightly failures after JSR 292 lazy method handle update (round 3)
jrose
parents:
13423
diff
changeset
|
146 |
boolean canCast = dst.isAssignableFrom(src); |
9646 | 147 |
try { |
148 |
Object result = caster.invokeExact(obj); |
|
149 |
if (canCast) |
|
150 |
assertEquals(obj, result); |
|
151 |
else |
|
152 |
assertEquals("cast should not have succeeded", dst, obj); |
|
153 |
} catch (ClassCastException ex) { |
|
154 |
if (canCast) |
|
155 |
throw ex; |
|
156 |
} |
|
157 |
} |
|
158 |
} |
|
159 |
} |
|
160 |
||
161 |
@Test |
|
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
162 |
public void testConvert() throws Throwable { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
163 |
for (long tval = 0, ctr = 0;;) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
164 |
if (++ctr > 99999) throw new AssertionError("too many test values"); |
26466
3bbb6a284bd4
8049555: Move varargsArray from sun.invoke.util package to java.lang.invoke
vlivanov
parents:
23010
diff
changeset
|
165 |
// prints 3776 test patterns (3776 = 8*59*8) |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
166 |
tval = nextTestValue(tval); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
167 |
if (tval == 0) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
168 |
break; // repeat |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
169 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
170 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
171 |
for (Wrapper src : Wrapper.values()) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
172 |
for (Wrapper dst : Wrapper.values()) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
173 |
testConvert(src, dst, 0); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
174 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
175 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
176 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
177 |
static void testConvert(Wrapper src, Wrapper dst, long tval) throws Throwable { |
26474
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
178 |
if (dst == Wrapper.OBJECT || src == Wrapper.OBJECT) return; // must have prims |
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
179 |
if (dst == Wrapper.VOID || src == Wrapper.VOID ) return; // must have values |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
180 |
boolean testSingleCase = (tval != 0); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
181 |
final long tvalInit = tval; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
182 |
MethodHandle conv = ValueConversions.convertPrimitive(src, dst); |
26474
655d08549e43
8050877: Improve code for pairwise argument conversions and value boxing/unboxing
vlivanov
parents:
26466
diff
changeset
|
183 |
MethodType convType = MethodType.methodType(dst.primitiveType(), src.primitiveType()); |
13423
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
184 |
assertEquals(convType, conv.type()); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
185 |
MethodHandle converter = conv.asType(conv.type().changeReturnType(Object.class)); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
186 |
for (;;) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
187 |
long n = tval; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
188 |
Object testValue = src.wrap(n); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
189 |
Object expResult = dst.cast(testValue, dst.primitiveType()); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
190 |
Object result; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
191 |
switch (src) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
192 |
case INT: result = converter.invokeExact((int)n); break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
193 |
case LONG: result = converter.invokeExact(/*long*/n); break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
194 |
case FLOAT: result = converter.invokeExact((float)n); break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
195 |
case DOUBLE: result = converter.invokeExact((double)n); break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
196 |
case CHAR: result = converter.invokeExact((char)n); break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
197 |
case BYTE: result = converter.invokeExact((byte)n); break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
198 |
case SHORT: result = converter.invokeExact((short)n); break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
199 |
case BOOLEAN: result = converter.invokeExact((n & 1) != 0); break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
200 |
default: throw new AssertionError(); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
201 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
202 |
assertEquals("(src,dst,n,testValue)="+Arrays.asList(src,dst,"0x"+Long.toHexString(n),testValue), |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
203 |
expResult, result); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
204 |
if (testSingleCase) break; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
205 |
// next test value: |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
206 |
tval = nextTestValue(tval); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
207 |
if (tval == tvalInit) break; // repeat |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
208 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
209 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
210 |
static long tweakSign(long x) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
211 |
// Assuming that x is mostly zeroes, make those zeroes follow bit #62 (just below the sign). |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
212 |
// This function is self-inverse. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
213 |
final long MID_SIGN_BIT = 62; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
214 |
long sign = -((x >>> MID_SIGN_BIT) & 1); // all ones or all zeroes |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
215 |
long flip = (sign >>> -MID_SIGN_BIT); // apply the sign below the mid-bit |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
216 |
return x ^ flip; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
217 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
218 |
static long nextTestValue(long x) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
219 |
// Produce 64 bits with three component bitfields: [ high:3 | mid:58 | low:3 ]. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
220 |
// The high and low fields vary through all possible bit patterns. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
221 |
// The middle field is either all zero or has a single bit set. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
222 |
// For better coverage of the neighborhood of zero, an internal sign bit is xored downward also. |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
223 |
long ux = tweakSign(x); // unsign the middle field |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
224 |
final long LOW_BITS = 3, LOW_BITS_MASK = (1L << LOW_BITS)-1; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
225 |
final long HIGH_BITS = 3, HIGH_BITS_MASK = ~(-1L >>> HIGH_BITS); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
226 |
if ((ux & LOW_BITS_MASK) != LOW_BITS_MASK) { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
227 |
++ux; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
228 |
} else { |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
229 |
ux &= ~LOW_BITS_MASK; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
230 |
long midBit = (ux & ~HIGH_BITS_MASK); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
231 |
if (midBit == 0) |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
232 |
midBit = (1L<<LOW_BITS); // introduce a low bit |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
233 |
ux += midBit; |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
234 |
} |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
235 |
return tweakSign(ux); |
17843fff200d
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
11534
diff
changeset
|
236 |
} |
9646 | 237 |
} |