Mercurial > hg > graal-jvmci-8
comparison jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/JavaKind.java @ 23393:1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 12 May 2016 20:57:31 +0200 |
parents | 4b58c92e939b |
children |
comparison
equal
deleted
inserted
replaced
23392:b3a816d3b844 | 23393:1d4ce2d19e52 |
---|---|
31 * {@link JavaKind#Int} for {@code int} and {@link JavaKind#Object} for all object types. A kind has | 31 * {@link JavaKind#Int} for {@code int} and {@link JavaKind#Object} for all object types. A kind has |
32 * a single character short name, a Java name, and a set of flags further describing its behavior. | 32 * a single character short name, a Java name, and a set of flags further describing its behavior. |
33 */ | 33 */ |
34 public enum JavaKind { | 34 public enum JavaKind { |
35 /** The primitive boolean kind, represented as an int on the stack. */ | 35 /** The primitive boolean kind, represented as an int on the stack. */ |
36 Boolean('z', "boolean", 1, true, java.lang.Boolean.TYPE, java.lang.Boolean.class), | 36 Boolean('Z', "boolean", 1, true, java.lang.Boolean.TYPE, java.lang.Boolean.class), |
37 | 37 |
38 /** The primitive byte kind, represented as an int on the stack. */ | 38 /** The primitive byte kind, represented as an int on the stack. */ |
39 Byte('b', "byte", 1, true, java.lang.Byte.TYPE, java.lang.Byte.class), | 39 Byte('B', "byte", 1, true, java.lang.Byte.TYPE, java.lang.Byte.class), |
40 | 40 |
41 /** The primitive short kind, represented as an int on the stack. */ | 41 /** The primitive short kind, represented as an int on the stack. */ |
42 Short('s', "short", 1, true, java.lang.Short.TYPE, java.lang.Short.class), | 42 Short('S', "short", 1, true, java.lang.Short.TYPE, java.lang.Short.class), |
43 | 43 |
44 /** The primitive char kind, represented as an int on the stack. */ | 44 /** The primitive char kind, represented as an int on the stack. */ |
45 Char('c', "char", 1, true, java.lang.Character.TYPE, java.lang.Character.class), | 45 Char('C', "char", 1, true, java.lang.Character.TYPE, java.lang.Character.class), |
46 | 46 |
47 /** The primitive int kind, represented as an int on the stack. */ | 47 /** The primitive int kind, represented as an int on the stack. */ |
48 Int('i', "int", 1, true, java.lang.Integer.TYPE, java.lang.Integer.class), | 48 Int('I', "int", 1, true, java.lang.Integer.TYPE, java.lang.Integer.class), |
49 | 49 |
50 /** The primitive float kind. */ | 50 /** The primitive float kind. */ |
51 Float('f', "float", 1, false, java.lang.Float.TYPE, java.lang.Float.class), | 51 Float('F', "float", 1, false, java.lang.Float.TYPE, java.lang.Float.class), |
52 | 52 |
53 /** The primitive long kind. */ | 53 /** The primitive long kind. */ |
54 Long('j', "long", 2, false, java.lang.Long.TYPE, java.lang.Long.class), | 54 Long('J', "long", 2, false, java.lang.Long.TYPE, java.lang.Long.class), |
55 | 55 |
56 /** The primitive double kind. */ | 56 /** The primitive double kind. */ |
57 Double('d', "double", 2, false, java.lang.Double.TYPE, java.lang.Double.class), | 57 Double('D', "double", 2, false, java.lang.Double.TYPE, java.lang.Double.class), |
58 | 58 |
59 /** The Object kind, also used for arrays. */ | 59 /** The Object kind, also used for arrays. */ |
60 Object('a', "Object", 1, false, null, null), | 60 Object('A', "Object", 1, false, null, null), |
61 | 61 |
62 /** The void float kind. */ | 62 /** The void kind. */ |
63 Void('v', "void", 0, false, java.lang.Void.TYPE, java.lang.Void.class), | 63 Void('V', "void", 0, false, java.lang.Void.TYPE, java.lang.Void.class), |
64 | 64 |
65 /** The non-type. */ | 65 /** The non-type. */ |
66 Illegal('-', "illegal", 0, false, null, null); | 66 Illegal('-', "illegal", 0, false, null, null); |
67 | 67 |
68 private final char typeChar; | 68 private final char typeChar; |
96 public boolean needsTwoSlots() { | 96 public boolean needsTwoSlots() { |
97 return this.slotCount == 2; | 97 return this.slotCount == 2; |
98 } | 98 } |
99 | 99 |
100 /** | 100 /** |
101 * Returns the name of the kind as a single character. | 101 * Returns the name of the kind as a single upper case character. For the void and primitive |
102 * kinds, this is the <i>FieldType</i> term in | |
103 * <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.3.2-200"> | |
104 * table 4.3-A</a> of the JVM Specification. For {@link #Object}, the character {@code 'A'} is | |
105 * returned and for {@link #Illegal}, {@code '-'} is returned. | |
102 */ | 106 */ |
103 public char getTypeChar() { | 107 public char getTypeChar() { |
104 return typeChar; | 108 return typeChar; |
105 } | 109 } |
106 | 110 |
202 } | 206 } |
203 | 207 |
204 /** | 208 /** |
205 * Returns the kind from the character describing a primitive or void. | 209 * Returns the kind from the character describing a primitive or void. |
206 * | 210 * |
207 * @param ch the character | 211 * @param ch the character for a void or primitive kind as returned by {@link #getTypeChar()} |
208 * @return the kind | 212 * @return the kind |
209 */ | 213 */ |
210 public static JavaKind fromPrimitiveOrVoidTypeChar(char ch) { | 214 public static JavaKind fromPrimitiveOrVoidTypeChar(char ch) { |
211 switch (ch) { | 215 switch (ch) { |
212 case 'Z': | 216 case 'Z': |
367 } | 371 } |
368 return buf.append('}').toString(); | 372 return buf.append('}').toString(); |
369 } | 373 } |
370 | 374 |
371 /** | 375 /** |
372 * The minimum value that can be represented as a value of this kind. | 376 * Gets the minimum value that can be represented as a value of this kind. |
373 * | 377 * |
374 * @return the minimum value | 378 * @return the minimum value represented as a {@code long} |
375 */ | 379 */ |
376 public long getMinValue() { | 380 public long getMinValue() { |
377 switch (this) { | 381 switch (this) { |
378 case Boolean: | 382 case Boolean: |
379 return 0; | 383 return 0; |
385 return java.lang.Short.MIN_VALUE; | 389 return java.lang.Short.MIN_VALUE; |
386 case Int: | 390 case Int: |
387 return java.lang.Integer.MIN_VALUE; | 391 return java.lang.Integer.MIN_VALUE; |
388 case Long: | 392 case Long: |
389 return java.lang.Long.MIN_VALUE; | 393 return java.lang.Long.MIN_VALUE; |
394 case Float: | |
395 return java.lang.Float.floatToRawIntBits(java.lang.Float.MIN_VALUE); | |
396 case Double: | |
397 return java.lang.Double.doubleToRawLongBits(java.lang.Double.MIN_VALUE); | |
390 default: | 398 default: |
391 throw new IllegalArgumentException("illegal call to minValue on " + this); | 399 throw new IllegalArgumentException("illegal call to minValue on " + this); |
392 } | 400 } |
393 } | 401 } |
394 | 402 |
395 /** | 403 /** |
396 * The maximum value that can be represented as a value of this kind. | 404 * Gets the maximum value that can be represented as a value of this kind. |
397 * | 405 * |
398 * @return the maximum value | 406 * @return the maximum value represented as a {@code long} |
399 */ | 407 */ |
400 public long getMaxValue() { | 408 public long getMaxValue() { |
401 switch (this) { | 409 switch (this) { |
402 case Boolean: | 410 case Boolean: |
403 return 1; | 411 return 1; |
409 return java.lang.Short.MAX_VALUE; | 417 return java.lang.Short.MAX_VALUE; |
410 case Int: | 418 case Int: |
411 return java.lang.Integer.MAX_VALUE; | 419 return java.lang.Integer.MAX_VALUE; |
412 case Long: | 420 case Long: |
413 return java.lang.Long.MAX_VALUE; | 421 return java.lang.Long.MAX_VALUE; |
422 case Float: | |
423 return java.lang.Float.floatToRawIntBits(java.lang.Float.MAX_VALUE); | |
424 case Double: | |
425 return java.lang.Double.doubleToRawLongBits(java.lang.Double.MAX_VALUE); | |
414 default: | 426 default: |
415 throw new IllegalArgumentException("illegal call to maxValue on " + this); | 427 throw new IllegalArgumentException("illegal call to maxValue on " + this); |
416 } | 428 } |
417 } | 429 } |
418 | 430 |