annotate src/cpu/sparc/vm/args.cc @ 6812:988bf00cc564

7200261: G1: Liveness counting inconsistencies during marking verification Summary: The clipping code in the routine that sets the bits for a range of cards, in the liveness accounting verification code was incorrect. It set all the bits in the card bitmap from the given starting index which would lead to spurious marking verification failures. Reviewed-by: brutisso, jwilhelm, jmasa
author johnc
date Thu, 27 Sep 2012 15:44:01 -0700
parents c18cbe5936b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include <stdio.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include <string.h>
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 static const int R_O0_num = 1000;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 static const int R_I0_num = 2000;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 static const int R_F0_num = 3000;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 static const int R_F1_num = R_F0_num + 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 static const int R_F2_num = R_F0_num + 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 static const int STACK_num= 4000;
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 static bool LP64 = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 static bool LONGS_IN_ONE_ENTRY = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 static const int Op_RegI = 'I';
a61af66fc99e Initial load
duke
parents:
diff changeset
39 static const int Op_RegP = 'P';
a61af66fc99e Initial load
duke
parents:
diff changeset
40 static const int Op_RegF = 'F';
a61af66fc99e Initial load
duke
parents:
diff changeset
41 static const int Op_RegD = 'D';
a61af66fc99e Initial load
duke
parents:
diff changeset
42 static const int Op_RegL = 'L';
a61af66fc99e Initial load
duke
parents:
diff changeset
43 static const int SPARC_ARGS_IN_REGS_NUM=6;
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 static void print_reg( int reg ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 if( reg == 0 )
a61af66fc99e Initial load
duke
parents:
diff changeset
47 printf("__"); // halve's
a61af66fc99e Initial load
duke
parents:
diff changeset
48 else if( reg >= STACK_num && reg < STACK_num+100 )
a61af66fc99e Initial load
duke
parents:
diff changeset
49 printf("S%d_",reg - STACK_num);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 else if( reg >= R_F0_num && reg < R_F0_num+100 )
a61af66fc99e Initial load
duke
parents:
diff changeset
51 printf("F%d_",reg - R_F0_num);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 else if( reg >= R_O0_num && reg < R_O0_num+100 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 if( LONGS_IN_ONE_ENTRY ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 reg -= R_O0_num;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 printf("O%d",reg>>1);
a61af66fc99e Initial load
duke
parents:
diff changeset
56 printf(reg&1 ? "H" : "L");
a61af66fc99e Initial load
duke
parents:
diff changeset
57 } else
a61af66fc99e Initial load
duke
parents:
diff changeset
58 printf("O%d_",reg - R_O0_num);
a61af66fc99e Initial load
duke
parents:
diff changeset
59 } else
a61af66fc99e Initial load
duke
parents:
diff changeset
60 printf("Wretched: %d\n", reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 static void print_convention( int *sig, const char *s, int length ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // Print it out
a61af66fc99e Initial load
duke
parents:
diff changeset
65 for( int i = 0; i < length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 if( sig[i] == 0 ) continue; // do not print 'halves'
a61af66fc99e Initial load
duke
parents:
diff changeset
67 print_reg( sig[i] & 0xFFFF );
a61af66fc99e Initial load
duke
parents:
diff changeset
68 int reg = sig[i] >> 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 if( reg ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 printf(":");
a61af66fc99e Initial load
duke
parents:
diff changeset
71 print_reg( reg );
a61af66fc99e Initial load
duke
parents:
diff changeset
72 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 printf(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75 printf(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 printf("\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 static int INT_SCALE( int x ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 return LONGS_IN_ONE_ENTRY ? (x<<1) : x;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 static void java_convention( int *sig, const char *s, int length ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 if( LP64 && !LONGS_IN_ONE_ENTRY ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 printf("LP64 and 2-reg longs not supported\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 for( int i = 0; i < length; i++ )
a61af66fc99e Initial load
duke
parents:
diff changeset
90 sig[i] = s[i]; // Reset sig array
a61af66fc99e Initial load
duke
parents:
diff changeset
91 bool is_outgoing = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 int int_base = (is_outgoing ? R_O0_num : R_I0_num);
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // Convention is to pack the first 6 int/oop args into the first 6
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // registers (I0-I5), extras spill to the stack. Then pack the first
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // 32 float args into F0-F31, extras spill to the stack. Then pad
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // all register sets to align. Then put longs and doubles into the
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // same registers as they fit, else spill to the stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
100 int int_reg_max = SPARC_ARGS_IN_REGS_NUM;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 int flt_reg_max = 32;
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Count int/oop and float args. See how many stack slots we'll need
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // and where the longs & doubles will go.
a61af66fc99e Initial load
duke
parents:
diff changeset
105 int int_reg_cnt = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 int flt_reg_cnt = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 int stk_reg_pairs = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 for( int i = 0; i < length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 switch( sig[i] ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 case Op_RegL: // Longs-in-1-reg compete with int args
a61af66fc99e Initial load
duke
parents:
diff changeset
111 if( LONGS_IN_ONE_ENTRY ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if( int_reg_cnt < int_reg_max ) int_reg_cnt++;
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 case Op_RegP:
a61af66fc99e Initial load
duke
parents:
diff changeset
116 if( int_reg_cnt < int_reg_max ) int_reg_cnt++;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 else if( !LP64 ) stk_reg_pairs++;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 case Op_RegI:
a61af66fc99e Initial load
duke
parents:
diff changeset
120 if( int_reg_cnt < int_reg_max ) int_reg_cnt++;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 else stk_reg_pairs++;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 case Op_RegF:
a61af66fc99e Initial load
duke
parents:
diff changeset
124 if( flt_reg_cnt < flt_reg_max ) flt_reg_cnt++;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 else stk_reg_pairs++;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // This is where the longs/doubles start on the stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
131 stk_reg_pairs = (stk_reg_pairs+1) & ~1; // Round
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 int int_reg_pairs = (int_reg_cnt+1) & ~1; // 32-bit 2-reg longs only
a61af66fc99e Initial load
duke
parents:
diff changeset
134 int flt_reg_pairs = (flt_reg_cnt+1) & ~1;
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 int stk_reg = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 int int_reg = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
138 int flt_reg = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // Now do the signature layout
a61af66fc99e Initial load
duke
parents:
diff changeset
141 for( int i = 0; i < length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 int tmp = sig[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
143 if( tmp == Op_RegP )
a61af66fc99e Initial load
duke
parents:
diff changeset
144 tmp = LP64 ? Op_RegL : Op_RegI; // Treat ptrs and ints or long accordingly
a61af66fc99e Initial load
duke
parents:
diff changeset
145 switch( tmp ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 case Op_RegI:
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // case Op_RegP:
a61af66fc99e Initial load
duke
parents:
diff changeset
148 if( int_reg < int_reg_max) tmp = INT_SCALE(int_reg++) + int_base;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 else tmp = STACK_num + stk_reg++;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 sig[i] = tmp;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 case Op_RegL:
a61af66fc99e Initial load
duke
parents:
diff changeset
154 if( sig[i] != Op_RegP && sig[i+1] != 'h' ) { printf("expecting (h)alf, found %c\n", sig[i+1]); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // case Op_RegP:
a61af66fc99e Initial load
duke
parents:
diff changeset
156 if( LONGS_IN_ONE_ENTRY ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if( int_reg < int_reg_max ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 tmp = INT_SCALE(int_reg++) + int_base;
a61af66fc99e Initial load
duke
parents:
diff changeset
159 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 tmp = STACK_num + stk_reg_pairs;
a61af66fc99e Initial load
duke
parents:
diff changeset
161 stk_reg_pairs += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 if( int_reg_pairs < int_reg_max ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 tmp = int_reg_pairs + int_base;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 int_reg_pairs += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 tmp = STACK_num + stk_reg_pairs;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 stk_reg_pairs += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
172 sig[i] = tmp | (tmp+1)<<16; // Smear to pair
a61af66fc99e Initial load
duke
parents:
diff changeset
173 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 case Op_RegF:
a61af66fc99e Initial load
duke
parents:
diff changeset
176 sig[i] = (flt_reg < flt_reg_max) ? (R_F0_num + flt_reg++) : STACK_num + stk_reg++;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 case Op_RegD:
a61af66fc99e Initial load
duke
parents:
diff changeset
179 if( sig[i+1] != 'h' ) { printf("expecting (h)alf, found %c\n", sig[i+1]); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 if( flt_reg_pairs < flt_reg_max ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 tmp = R_F0_num + flt_reg_pairs;
a61af66fc99e Initial load
duke
parents:
diff changeset
182 flt_reg_pairs += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 tmp = STACK_num + stk_reg_pairs;
a61af66fc99e Initial load
duke
parents:
diff changeset
185 stk_reg_pairs += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187 sig[i] = tmp | (tmp+1)<<16; // Smear to pair
a61af66fc99e Initial load
duke
parents:
diff changeset
188 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
189 case 'h': sig[i] = 0; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
190 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
191 printf("Bad character: %c\n", sig[i] );
a61af66fc99e Initial load
duke
parents:
diff changeset
192 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 printf("java ");
a61af66fc99e Initial load
duke
parents:
diff changeset
197 printf(LP64 ? "LP64 " : "LP32 ");
a61af66fc99e Initial load
duke
parents:
diff changeset
198 printf(LONGS_IN_ONE_ENTRY ? "long1: " : "long2: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
199 print_convention(sig,s,length);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 static int int_stk_helper( int i ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 if( i < 6 ) return R_O0_num + (LONGS_IN_ONE_ENTRY ? i<<1 : i);
a61af66fc99e Initial load
duke
parents:
diff changeset
204 else return STACK_num + (LP64 ? i<<1 : i);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 static void native_convention( int *sig, const char *s, int length ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 if( LP64 && !LONGS_IN_ONE_ENTRY ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
209 printf("LP64 and 2-reg longs not supported\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
210 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 for( int i = 0; i < length; i++ )
a61af66fc99e Initial load
duke
parents:
diff changeset
213 sig[i] = s[i]; // Reset sig array
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // The native convention is V8 if !LP64, which means the V8 convention is
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // used both with and without LONGS_IN_ONE_ENTRY, an unfortunate split. The
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // same actual machine registers are used, but they are named differently in
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // the LONGS_IN_ONE_ENTRY mode. The LP64 convention is the V9 convention
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // which is slightly more sane.
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 if( LP64 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // V9 convention: All things "as-if" on double-wide stack slots.
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // Hoist any int/ptr/long's in the first 6 to int regs.
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // Hoist any flt/dbl's in the first 16 dbl regs.
a61af66fc99e Initial load
duke
parents:
diff changeset
225 int j = 0; // Count of actual args, not HALVES
a61af66fc99e Initial load
duke
parents:
diff changeset
226 for( int i=0; i<length; i++, j++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
227 int tmp;
a61af66fc99e Initial load
duke
parents:
diff changeset
228 switch( sig[i] ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
229 case Op_RegI:
a61af66fc99e Initial load
duke
parents:
diff changeset
230 sig[i] = int_stk_helper( j );
a61af66fc99e Initial load
duke
parents:
diff changeset
231 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 case Op_RegL:
a61af66fc99e Initial load
duke
parents:
diff changeset
233 if( sig[i+1] != 'h' ) { printf("expecting (h)alf, found %c\n", sig[i+1]); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
234 case Op_RegP:
a61af66fc99e Initial load
duke
parents:
diff changeset
235 tmp = int_stk_helper( j );
a61af66fc99e Initial load
duke
parents:
diff changeset
236 sig[i] = tmp | ((tmp+1) << 16); // Smear to pair
a61af66fc99e Initial load
duke
parents:
diff changeset
237 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
238 case Op_RegF: // V9ism: floats go in ODD registers
a61af66fc99e Initial load
duke
parents:
diff changeset
239 sig[i] = ((j < 16) ? R_F1_num : (STACK_num + 1)) + (j<<1);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
241 case Op_RegD: // V9ism: doubles go in EVEN/ODD regs
a61af66fc99e Initial load
duke
parents:
diff changeset
242 tmp = ((j < 16) ? R_F0_num : STACK_num) + (j<<1);
a61af66fc99e Initial load
duke
parents:
diff changeset
243 sig[i] = tmp | ((tmp+1) << 16); // Smear to pair
a61af66fc99e Initial load
duke
parents:
diff changeset
244 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
245 case 'h': sig[i] = 0; j--; break; // Do not count HALVES
a61af66fc99e Initial load
duke
parents:
diff changeset
246 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
247 printf("Bad character: %c\n", sig[i] );
a61af66fc99e Initial load
duke
parents:
diff changeset
248 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
250 }
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // V8 convention: first 6 things in O-regs, rest on stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
254 // Alignment is willy-nilly.
a61af66fc99e Initial load
duke
parents:
diff changeset
255 for( int i=0; i<length; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 int tmp;
a61af66fc99e Initial load
duke
parents:
diff changeset
257 switch( sig[i] ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 case Op_RegI:
a61af66fc99e Initial load
duke
parents:
diff changeset
259 case Op_RegP:
a61af66fc99e Initial load
duke
parents:
diff changeset
260 case Op_RegF:
a61af66fc99e Initial load
duke
parents:
diff changeset
261 sig[i] = int_stk_helper( i );
a61af66fc99e Initial load
duke
parents:
diff changeset
262 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
263 case Op_RegL:
a61af66fc99e Initial load
duke
parents:
diff changeset
264 case Op_RegD:
a61af66fc99e Initial load
duke
parents:
diff changeset
265 if( sig[i+1] != 'h' ) { printf("expecting (h)alf, found %c\n", sig[i+1]); return; }
a61af66fc99e Initial load
duke
parents:
diff changeset
266 tmp = int_stk_helper( i );
a61af66fc99e Initial load
duke
parents:
diff changeset
267 sig[i] = tmp | (int_stk_helper( i+1 ) << 16);
a61af66fc99e Initial load
duke
parents:
diff changeset
268 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
269 case 'h': sig[i] = 0; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
270 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
271 printf("Bad character: %c\n", sig[i] );
a61af66fc99e Initial load
duke
parents:
diff changeset
272 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 printf("natv ");
a61af66fc99e Initial load
duke
parents:
diff changeset
278 printf(LP64 ? "LP64 " : "LP32 ");
a61af66fc99e Initial load
duke
parents:
diff changeset
279 printf(LONGS_IN_ONE_ENTRY ? "long1: " : "long2: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
280 print_convention(sig,s,length);
a61af66fc99e Initial load
duke
parents:
diff changeset
281 }
a61af66fc99e Initial load
duke
parents:
diff changeset
282
a61af66fc99e Initial load
duke
parents:
diff changeset
283 int main( int argc, char **argv ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 if( argc != 2 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 printf("Usage: args IPFLhDh... (Java argument string)\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
287 printf("Returns argument layout\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
288 return -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 const char *s = argv[1];
a61af66fc99e Initial load
duke
parents:
diff changeset
292 int length = strlen(s);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 int sig[1000];
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 LP64 = false; LONGS_IN_ONE_ENTRY = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
296 java_convention( sig, s, length );
a61af66fc99e Initial load
duke
parents:
diff changeset
297 LP64 = false; LONGS_IN_ONE_ENTRY = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
298 java_convention( sig, s, length );
a61af66fc99e Initial load
duke
parents:
diff changeset
299 LP64 = true ; LONGS_IN_ONE_ENTRY = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
300 java_convention( sig, s, length );
a61af66fc99e Initial load
duke
parents:
diff changeset
301
a61af66fc99e Initial load
duke
parents:
diff changeset
302 LP64 = false; LONGS_IN_ONE_ENTRY = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
303 native_convention( sig, s, length );
a61af66fc99e Initial load
duke
parents:
diff changeset
304 LP64 = false; LONGS_IN_ONE_ENTRY = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
305 native_convention( sig, s, length );
a61af66fc99e Initial load
duke
parents:
diff changeset
306 LP64 = true ; LONGS_IN_ONE_ENTRY = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
307 native_convention( sig, s, length );
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
309