37
37
print_local(curr_jvm_stack); \
38
38
*(type *)(curr_jvm_stack->operand_stack + \
39
39
curr_jvm_stack->offset) = (type)value; \
40
- curr_jvm_stack -> offset += sizeof (type ); \
40
+ curr_jvm_stack -> offset += sizeof (void * ); \
41
41
print_local (curr_jvm_stack ); \
42
42
} while (0 );
43
43
44
44
#define pop_operand_stack (type , value ) \
45
45
do { \
46
46
print_local(curr_jvm_stack); \
47
- curr_jvm_stack->offset -= sizeof(type); \
47
+ curr_jvm_stack->offset -= sizeof(void *); \
48
48
value = *(type *)(curr_jvm_stack->operand_stack + \
49
49
curr_jvm_stack->offset); \
50
50
*(type *)(curr_jvm_stack->operand_stack + \
55
55
#define copy_operand_stack (type , value ) \
56
56
do { \
57
57
print_local(curr_jvm_stack); \
58
- curr_jvm_stack->offset -= sizeof(type); \
58
+ curr_jvm_stack->offset -= sizeof(void *); \
59
59
value = *(type *)(curr_jvm_stack->operand_stack + \
60
60
curr_jvm_stack->offset); \
61
- curr_jvm_stack->offset += sizeof(type); \
61
+ curr_jvm_stack->offset += sizeof(void *); \
62
62
*(type *)(curr_jvm_stack->operand_stack + \
63
63
curr_jvm_stack->offset) = (type)value; \
64
- curr_jvm_stack->offset += sizeof(type); \
64
+ curr_jvm_stack->offset += sizeof(void *); \
65
65
print_local(curr_jvm_stack); \
66
66
} while(0);
67
67
68
68
#define get_local_table (value , type , index ) \
69
69
do { \
70
70
print_local(curr_jvm_stack); \
71
- value = *(type *)(curr_jvm_stack->local_var_table + index * sizeof(type ));\
71
+ value = *(type *)(curr_jvm_stack->local_var_table + index * sizeof(void * ));\
72
72
print_local(curr_jvm_stack); \
73
73
} while(0);
74
74
75
75
#define set_local_table (type , index , value ) \
76
76
do { \
77
77
print_local(curr_jvm_stack); \
78
- *(type *)(curr_jvm_stack->local_var_table + index * sizeof(type )) = value;\
78
+ *(type *)(curr_jvm_stack->local_var_table + index * sizeof(void * )) = value;\
79
79
print_local(curr_jvm_stack); \
80
80
} while(0);
81
81
82
82
#define push_operand_stack_arg (jvm_stack , type , value ) \
83
83
do { \
84
84
print_local(jvm_stack); \
85
85
*(type *)(jvm_stack->operand_stack + jvm_stack->offset) = (type)value; \
86
- jvm_stack->offset += sizeof(type ); \
86
+ jvm_stack->offset += sizeof(void * ); \
87
87
print_local(jvm_stack); \
88
88
} while(0);
89
89
90
90
#define pop_operand_stack_arg (jvm_stack , type , value ) \
91
91
do { \
92
92
print_local(jvm_stack); \
93
- jvm_stack->offset -= sizeof(type ); \
93
+ jvm_stack->offset -= sizeof(void * ); \
94
94
value = *(type *)(jvm_stack->operand_stack + jvm_stack->offset); \
95
95
*(type *)(jvm_stack->operand_stack + jvm_stack->offset) = '\0'; \
96
96
print_local(jvm_stack); \
100
100
#define set_local_table_arg (jvm_stack , type , index , value ) \
101
101
do { \
102
102
print_local(jvm_stack); \
103
- *(type *)(jvm_stack->local_var_table + index * sizeof(type )) = value; \
103
+ *(type *)(jvm_stack->local_var_table + index * sizeof(void * )) = value; \
104
104
print_local(jvm_stack); \
105
105
} while(0);
106
106
@@ -111,10 +111,10 @@ void print_local(JVM_STACK_FRAME *jvm_stack)
111
111
112
112
printf ("#local: " );
113
113
for (i = 0 ; i < jvm_stack -> max_locals ; i ++ )
114
- printf ("0x%x " , * (int * )(jvm_stack -> local_var_table + i * sizeof (int )));
114
+ printf ("0x%x " , * (int * )(jvm_stack -> local_var_table + i * sizeof (void * )));
115
115
printf ("\t#stack: " );
116
116
for (i = 0 ; i < jvm_stack -> max_stack ; i ++ )
117
- printf ("0x%x " , * (int * )(jvm_stack -> operand_stack + i * sizeof (int )));
117
+ printf ("0x%x " , * (int * )(jvm_stack -> operand_stack + i * sizeof (void * )));
118
118
printf ("\n" );
119
119
}
120
120
#else
@@ -295,10 +295,28 @@ int jvm_interp_ldc_w(u2 len, char *symbol, void *base)
295
295
296
296
int jvm_interp_ldc2_w (u2 len , char * symbol , void * base )
297
297
{
298
+ u1 tmp1 , tmp2 ;
299
+ u2 index ;
300
+ int high_bytes , low_bytes ;
301
+ long value ;
302
+
303
+ index = (u2 )(((* (u1 * )(base + 1 )) << 8 ) | (* (u1 * )(base + 2 )));
298
304
if (jvm_arg -> disass_class ) {
299
- printf ("%s %x %x \n" , symbol , base + 1 , base + 3 );
305
+ show_disassember_code ("%s #%x \n" , symbol , index );
300
306
return 0 ;
301
307
}
308
+
309
+ debug_vm_interp ("%s #%x\n" , symbol , index );
310
+ high_bytes = ((struct CONSTANT_Long_info * )
311
+ curr_jvm_interp_env -> constant_info [index ].base )-> high_bytes ;
312
+ low_bytes = ((struct CONSTANT_Long_info * )
313
+ curr_jvm_interp_env -> constant_info [index ].base )-> low_bytes ;
314
+
315
+ value = ((long )high_bytes << 32 ) + low_bytes ;
316
+ push_operand_stack (long , value )
317
+
318
+ jvm_pc .pc += len ;
319
+ return 0 ;
302
320
}
303
321
304
322
#define INTERP_LOAD_VAR (type , index , fmt , ...) \
@@ -1505,6 +1523,7 @@ int jvm_interp_return(u2 len, char *symbol, void *base)
1505
1523
tmp_env = curr_jvm_interp_env -> prev_env ;
1506
1524
memcpy (curr_jvm_interp_env , tmp_env , sizeof (JVM_INTERP_ENV ));
1507
1525
free (tmp_env );
1526
+ }
1508
1527
1509
1528
jvm_stack_depth -- ;
1510
1529
if (jvm_stack_depth == 0 ) {
@@ -2267,8 +2286,8 @@ int compute_stack_size(struct list_head *list_head)
2267
2286
list_for_each (s , list_head ) {
2268
2287
p = list_entry (s , CLASS_METHOD , list );
2269
2288
if (p && p -> code_attr ) {
2270
- size += (int )p -> code_attr -> max_stack * sizeof (int );
2271
- size += (int )p -> code_attr -> max_locals * sizeof (int );
2289
+ size += (int )p -> code_attr -> max_stack * sizeof (void * );
2290
+ size += (int )p -> code_attr -> max_locals * sizeof (void * );
2272
2291
}
2273
2292
}
2274
2293
0 commit comments