Mercurial > hg > graal-compiler
comparison c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotSignature.java @ 1422:3483ec571caf
* using reflected objects instead of oops
* removed scratch from allocatable registers
* instanceof xir snippet
* arraylength xir snippet
* exceptionobject xir snippet
* VMEntries and VMExits as interfaces
* calls to VMEntries and VMExits are routet through logging proxies
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Mon, 02 Aug 2010 15:44:38 -0700 |
parents | 6223633ce7dd |
children | 760213a60e8b |
comparison
equal
deleted
inserted
replaced
1421:6223633ce7dd | 1422:3483ec571caf |
---|---|
12 private final List<String> arguments = new ArrayList<String>(); | 12 private final List<String> arguments = new ArrayList<String>(); |
13 private final String returnType; | 13 private final String returnType; |
14 private final String originalString; | 14 private final String originalString; |
15 | 15 |
16 public HotSpotSignature(String signature) { | 16 public HotSpotSignature(String signature) { |
17 | |
18 assert signature.length() > 0; | 17 assert signature.length() > 0; |
19 this.originalString = signature; | 18 this.originalString = signature; |
20 | 19 |
21 if (signature.charAt(0) == '(') { | 20 if (signature.charAt(0) == '(') { |
22 int cur = 1; | 21 int cur = 1; |
23 while (cur < signature.length() && signature.charAt(cur) != ')') { | 22 while (cur < signature.length() && signature.charAt(cur) != ')') { |
24 int nextCur = parseSignature(signature, cur); | 23 int nextCur = parseSignature(signature, cur); |
25 arguments.add(signature.substring(cur, nextCur)); | 24 arguments.add(signature.substring(cur, nextCur)); |
26 cur = nextCur; | 25 cur = nextCur; |
27 } | 26 } |
27 StringBuilder str = new StringBuilder(); | |
28 for (String param : arguments) { | |
29 str.append(param).append(", "); | |
30 } | |
31 Logger.log("signature " + signature + ": " + str); | |
28 | 32 |
29 cur++; | 33 cur++; |
30 int nextCur = parseSignature(signature, cur); | 34 int nextCur = parseSignature(signature, cur); |
31 returnType = signature.substring(cur, nextCur); | 35 returnType = signature.substring(cur, nextCur); |
32 assert nextCur == signature.length(); | 36 assert nextCur == signature.length(); |
37 | 41 |
38 private int parseSignature(String signature, int cur) { | 42 private int parseSignature(String signature, int cur) { |
39 | 43 |
40 char first = signature.charAt(cur); | 44 char first = signature.charAt(cur); |
41 switch (first) { | 45 switch (first) { |
42 | |
43 case '[': | 46 case '[': |
44 return parseSignature(signature, cur + 1); | 47 return parseSignature(signature, cur + 1); |
45 | |
46 case 'L': | 48 case 'L': |
47 while (signature.charAt(cur) != ';') | 49 while (signature.charAt(cur) != ';') |
48 cur++; | 50 cur++; |
49 cur++; | 51 cur++; |
50 break; | 52 break; |
51 | |
52 case 'V': | 53 case 'V': |
53 case 'I': | 54 case 'I': |
54 case 'B': | 55 case 'B': |
55 case 'C': | 56 case 'C': |
56 case 'D': | 57 case 'D': |
58 case 'J': | 59 case 'J': |
59 case 'S': | 60 case 'S': |
60 case 'Z': | 61 case 'Z': |
61 cur++; | 62 cur++; |
62 break; | 63 break; |
63 | |
64 default: | 64 default: |
65 assert false; | 65 assert false; |
66 | |
67 } | 66 } |
68 | |
69 return cur; | 67 return cur; |
70 } | 68 } |
71 | 69 |
72 @Override | 70 @Override |
73 public int argumentCount(boolean withReceiver) { | 71 public int argumentCount(boolean withReceiver) { |
92 return argSlots + (withReceiver ? 1 : 0); | 90 return argSlots + (withReceiver ? 1 : 0); |
93 } | 91 } |
94 | 92 |
95 @Override | 93 @Override |
96 public RiType argumentTypeAt(int index, RiType accessingClass) { | 94 public RiType argumentTypeAt(int index, RiType accessingClass) { |
97 System.out.println("argument type at " + index); | 95 Class<?> accessor = null; |
98 Object accessor = null; | |
99 if (accessingClass instanceof HotSpotType) { | 96 if (accessingClass instanceof HotSpotType) { |
100 accessor = ((HotSpotType) accessingClass).klassOop; | 97 accessor = ((HotSpotType) accessingClass).klass; |
101 } | 98 } |
102 return Compiler.getVMEntries().RiSignature_lookupType(arguments.get(index), accessor); | 99 return Compiler.getVMEntries().RiSignature_lookupType(arguments.get(index), accessor); |
103 } | 100 } |
104 | 101 |
105 @Override | 102 @Override |
112 return CiKind.fromTypeString(returnType); | 109 return CiKind.fromTypeString(returnType); |
113 } | 110 } |
114 | 111 |
115 @Override | 112 @Override |
116 public RiType returnType(RiType accessingClass) { | 113 public RiType returnType(RiType accessingClass) { |
117 return Compiler.getVMEntries().RiSignature_lookupType(returnType, accessingClass); | 114 Class<?> accessor = null; |
115 if (accessingClass instanceof HotSpotType) { | |
116 accessor = ((HotSpotType) accessingClass).klass; | |
117 } | |
118 return Compiler.getVMEntries().RiSignature_lookupType(returnType, accessor); | |
118 } | 119 } |
119 | 120 |
120 } | 121 } |