PR preprocessor/29966:
[official-gcc.git] / libjava / interpret.cc
blob7e694a392a1d38d8c554a16cc8dc3a58ac9e3a07
1 // interpret.cc - Code for the interpreter
3 /* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 details. */
11 /* Author: Kresten Krab Thorup <krab@gnu.org> */
13 #include <config.h>
14 #include <platform.h>
16 #pragma implementation "java-interp.h"
18 #include <jvm.h>
19 #include <java-cpool.h>
20 #include <java-interp.h>
21 #include <java/lang/System.h>
22 #include <java/lang/String.h>
23 #include <java/lang/Integer.h>
24 #include <java/lang/Long.h>
25 #include <java/lang/StringBuffer.h>
26 #include <java/lang/Class.h>
27 #include <java/lang/reflect/Modifier.h>
28 #include <java/lang/InternalError.h>
29 #include <java/lang/NullPointerException.h>
30 #include <java/lang/ArithmeticException.h>
31 #include <java/lang/IncompatibleClassChangeError.h>
32 #include <java/lang/InstantiationException.h>
33 #include <java/lang/Thread.h>
34 #include <java-insns.h>
35 #include <java-signal.h>
36 #include <java/lang/ClassFormatError.h>
37 #include <execution.h>
38 #include <java/lang/reflect/Modifier.h>
40 #include <jvmti.h>
41 #include "jvmti-int.h"
43 #include <gnu/classpath/jdwp/Jdwp.h>
44 #include <gnu/gcj/jvmti/Breakpoint.h>
45 #include <gnu/gcj/jvmti/BreakpointManager.h>
47 #ifdef INTERPRETER
49 // Execution engine for interpreted code.
50 _Jv_InterpreterEngine _Jv_soleInterpreterEngine;
52 #include <stdlib.h>
54 using namespace gcj;
56 static void throw_internal_error (const char *msg)
57 __attribute__ ((__noreturn__));
58 static void throw_incompatible_class_change_error (jstring msg)
59 __attribute__ ((__noreturn__));
60 static void throw_null_pointer_exception ()
61 __attribute__ ((__noreturn__));
63 static void throw_class_format_error (jstring msg)
64 __attribute__ ((__noreturn__));
65 static void throw_class_format_error (const char *msg)
66 __attribute__ ((__noreturn__));
68 #ifdef DIRECT_THREADED
69 // Lock to ensure that methods are not compiled concurrently.
70 // We could use a finer-grained lock here, however it is not safe to use
71 // the Class monitor as user code in another thread could hold it.
72 static _Jv_Mutex_t compile_mutex;
74 void
75 _Jv_InitInterpreter()
77 _Jv_MutexInit (&compile_mutex);
79 #else
80 void _Jv_InitInterpreter() {}
81 #endif
83 // The breakpoint instruction. For the direct threaded case,
84 // _Jv_InterpMethod::compile will initialize breakpoint_insn
85 // the first time it is called.
86 #ifdef DIRECT_THREADED
87 insn_slot _Jv_InterpMethod::bp_insn_slot;
88 pc_t _Jv_InterpMethod::breakpoint_insn = NULL;
89 #else
90 unsigned char _Jv_InterpMethod::bp_insn_opcode
91 = static_cast<unsigned char> (op_breakpoint);
92 pc_t _Jv_InterpMethod::breakpoint_insn = &_Jv_InterpMethod::bp_insn_opcode;
93 #endif
95 extern "C" double __ieee754_fmod (double,double);
97 static inline void dupx (_Jv_word *sp, int n, int x)
99 // first "slide" n+x elements n to the right
100 int top = n-1;
101 for (int i = 0; i < n+x; i++)
103 sp[(top-i)] = sp[(top-i)-n];
106 // next, copy the n top elements, n+x down
107 for (int i = 0; i < n; i++)
109 sp[top-(n+x)-i] = sp[top-i];
113 // Used to convert from floating types to integral types.
114 template<typename TO, typename FROM>
115 static inline TO
116 convert (FROM val, TO min, TO max)
118 TO ret;
119 if (val >= (FROM) max)
120 ret = max;
121 else if (val <= (FROM) min)
122 ret = min;
123 else if (val != val)
124 ret = 0;
125 else
126 ret = (TO) val;
127 return ret;
130 #define PUSHA(V) (sp++)->o = (V)
131 #define PUSHI(V) (sp++)->i = (V)
132 #define PUSHF(V) (sp++)->f = (V)
133 #if SIZEOF_VOID_P == 8
134 # define PUSHL(V) (sp->l = (V), sp += 2)
135 # define PUSHD(V) (sp->d = (V), sp += 2)
136 #else
137 # define PUSHL(V) do { _Jv_word2 w2; w2.l=(V); \
138 (sp++)->ia[0] = w2.ia[0]; \
139 (sp++)->ia[0] = w2.ia[1]; } while (0)
140 # define PUSHD(V) do { _Jv_word2 w2; w2.d=(V); \
141 (sp++)->ia[0] = w2.ia[0]; \
142 (sp++)->ia[0] = w2.ia[1]; } while (0)
143 #endif
145 #define POPA() ((--sp)->o)
146 #define POPI() ((jint) (--sp)->i) // cast since it may be promoted
147 #define POPF() ((jfloat) (--sp)->f)
148 #if SIZEOF_VOID_P == 8
149 # define POPL() (sp -= 2, (jlong) sp->l)
150 # define POPD() (sp -= 2, (jdouble) sp->d)
151 #else
152 # define POPL() ({ _Jv_word2 w2; \
153 w2.ia[1] = (--sp)->ia[0]; \
154 w2.ia[0] = (--sp)->ia[0]; w2.l; })
155 # define POPD() ({ _Jv_word2 w2; \
156 w2.ia[1] = (--sp)->ia[0]; \
157 w2.ia[0] = (--sp)->ia[0]; w2.d; })
158 #endif
160 #define LOADA(I) (sp++)->o = locals[I].o
161 #define LOADI(I) (sp++)->i = locals[I].i
162 #define LOADF(I) (sp++)->f = locals[I].f
163 #if SIZEOF_VOID_P == 8
164 # define LOADL(I) (sp->l = locals[I].l, sp += 2)
165 # define LOADD(I) (sp->d = locals[I].d, sp += 2)
166 #else
167 # define LOADL(I) do { jint __idx = (I); \
168 (sp++)->ia[0] = locals[__idx].ia[0]; \
169 (sp++)->ia[0] = locals[__idx+1].ia[0]; \
170 } while (0)
171 # define LOADD(I) LOADL(I)
172 #endif
174 #define STOREA(I) \
175 do { \
176 DEBUG_LOCALS_INSN (I, 'o'); \
177 locals[I].o = (--sp)->o; \
178 } while (0)
179 #define STOREI(I) \
180 do { \
181 DEBUG_LOCALS_INSN (I, 'i'); \
182 locals[I].i = (--sp)->i; \
183 } while (0)
184 #define STOREF(I) \
185 do { \
186 DEBUG_LOCALS_INSN (I, 'f'); \
187 locals[I].f = (--sp)->f; \
188 } while (0)
189 #if SIZEOF_VOID_P == 8
190 # define STOREL(I) \
191 do { \
192 DEBUG_LOCALS_INSN (I, 'l'); \
193 (sp -= 2, locals[I].l = sp->l); \
194 } while (0)
195 # define STORED(I) \
196 do { \
197 DEBUG_LOCALS_INSN (I, 'd'); \
198 (sp -= 2, locals[I].d = sp->d); \
199 } while (0)
201 #else
202 # define STOREL(I) \
203 do { \
204 DEBUG_LOCALS_INSN (I, 'l'); \
205 jint __idx = (I); \
206 locals[__idx+1].ia[0] = (--sp)->ia[0]; \
207 locals[__idx].ia[0] = (--sp)->ia[0]; \
208 } while (0)
209 # define STORED(I) \
210 do { \
211 DEBUG_LOCALS_INSN(I, 'd'); \
212 jint __idx = (I); \
213 locals[__idx+1].ia[0] = (--sp)->ia[0]; \
214 locals[__idx].ia[0] = (--sp)->ia[0]; \
215 } while (0)
216 #endif
218 #define PEEKI(I) (locals+(I))->i
219 #define PEEKA(I) (locals+(I))->o
221 #define POKEI(I,V) \
222 DEBUG_LOCALS_INSN(I,'i'); \
223 ((locals+(I))->i = (V))
226 #define BINOPI(OP) { \
227 jint value2 = POPI(); \
228 jint value1 = POPI(); \
229 PUSHI(value1 OP value2); \
232 #define BINOPF(OP) { \
233 jfloat value2 = POPF(); \
234 jfloat value1 = POPF(); \
235 PUSHF(value1 OP value2); \
238 #define BINOPL(OP) { \
239 jlong value2 = POPL(); \
240 jlong value1 = POPL(); \
241 PUSHL(value1 OP value2); \
244 #define BINOPD(OP) { \
245 jdouble value2 = POPD(); \
246 jdouble value1 = POPD(); \
247 PUSHD(value1 OP value2); \
250 static inline jint
251 get1s (unsigned char* loc)
253 return *(signed char*)loc;
256 static inline jint
257 get1u (unsigned char* loc)
259 return *loc;
262 static inline jint
263 get2s(unsigned char* loc)
265 return (((jint)*(signed char*)loc) << 8) | ((jint)*(loc+1));
268 static inline jint
269 get2u (unsigned char* loc)
271 return (((jint)(*loc)) << 8) | ((jint)*(loc+1));
274 static jint
275 get4 (unsigned char* loc)
277 return (((jint)(loc[0])) << 24)
278 | (((jint)(loc[1])) << 16)
279 | (((jint)(loc[2])) << 8)
280 | (((jint)(loc[3])) << 0);
283 #define SAVE_PC() frame_desc.pc = pc
285 // We used to define this conditionally, depending on HANDLE_SEGV.
286 // However, that runs into a problem if a chunk in low memory is
287 // mapped and we try to look at a field near the end of a large
288 // object. See PR 26858 for details. It is, most likely, relatively
289 // inexpensive to simply do this check always.
290 #define NULLCHECK(X) \
291 do { SAVE_PC(); if ((X)==NULL) throw_null_pointer_exception (); } while (0)
293 // Note that we can still conditionally define NULLARRAYCHECK, since
294 // we know that all uses of an array will first reference the length
295 // field, which is first -- and thus will trigger a SEGV.
296 #ifdef HANDLE_SEGV
297 #define NULLARRAYCHECK(X) SAVE_PC()
298 #else
299 #define NULLARRAYCHECK(X) \
300 do \
302 SAVE_PC(); \
303 if ((X) == NULL) { throw_null_pointer_exception (); } \
304 } while (0)
305 #endif
307 #define ARRAYBOUNDSCHECK(array, index) \
308 do \
310 if (((unsigned) index) >= (unsigned) (array->length)) \
311 _Jv_ThrowBadArrayIndex (index); \
312 } while (0)
314 void
315 _Jv_InterpMethod::run_normal (ffi_cif *,
316 void *ret,
317 ffi_raw *args,
318 void *__this)
320 _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this;
321 run (ret, args, _this);
324 void
325 _Jv_InterpMethod::run_normal_debug (ffi_cif *,
326 void *ret,
327 ffi_raw *args,
328 void *__this)
330 _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this;
331 run_debug (ret, args, _this);
334 void
335 _Jv_InterpMethod::run_synch_object (ffi_cif *,
336 void *ret,
337 ffi_raw *args,
338 void *__this)
340 _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this;
342 jobject rcv = (jobject) args[0].ptr;
343 JvSynchronize mutex (rcv);
345 run (ret, args, _this);
348 void
349 _Jv_InterpMethod::run_synch_object_debug (ffi_cif *,
350 void *ret,
351 ffi_raw *args,
352 void *__this)
354 _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this;
356 jobject rcv = (jobject) args[0].ptr;
357 JvSynchronize mutex (rcv);
359 run_debug (ret, args, _this);
362 void
363 _Jv_InterpMethod::run_class (ffi_cif *,
364 void *ret,
365 ffi_raw *args,
366 void *__this)
368 _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this;
369 _Jv_InitClass (_this->defining_class);
370 run (ret, args, _this);
373 void
374 _Jv_InterpMethod::run_class_debug (ffi_cif *,
375 void *ret,
376 ffi_raw *args,
377 void *__this)
379 _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this;
380 _Jv_InitClass (_this->defining_class);
381 run_debug (ret, args, _this);
384 void
385 _Jv_InterpMethod::run_synch_class (ffi_cif *,
386 void *ret,
387 ffi_raw *args,
388 void *__this)
390 _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this;
392 jclass sync = _this->defining_class;
393 _Jv_InitClass (sync);
394 JvSynchronize mutex (sync);
396 run (ret, args, _this);
399 void
400 _Jv_InterpMethod::run_synch_class_debug (ffi_cif *,
401 void *ret,
402 ffi_raw *args,
403 void *__this)
405 _Jv_InterpMethod *_this = (_Jv_InterpMethod *) __this;
407 jclass sync = _this->defining_class;
408 _Jv_InitClass (sync);
409 JvSynchronize mutex (sync);
411 run_debug (ret, args, _this);
414 #ifdef DIRECT_THREADED
415 // "Compile" a method by turning it from bytecode to direct-threaded
416 // code.
417 void
418 _Jv_InterpMethod::compile (const void * const *insn_targets)
420 insn_slot *insns = NULL;
421 int next = 0;
422 unsigned char *codestart = bytecode ();
423 unsigned char *end = codestart + code_length;
424 _Jv_word *pool_data = defining_class->constants.data;
426 #define SET_ONE(Field, Value) \
427 do \
429 if (first_pass) \
430 ++next; \
431 else \
432 insns[next++].Field = Value; \
434 while (0)
436 #define SET_INSN(Value) SET_ONE (insn, (void *) Value)
437 #define SET_INT(Value) SET_ONE (int_val, Value)
438 #define SET_DATUM(Value) SET_ONE (datum, Value)
440 // Map from bytecode PC to slot in INSNS.
441 int *pc_mapping = (int *) __builtin_alloca (sizeof (int) * code_length);
442 for (int i = 0; i < code_length; ++i)
443 pc_mapping[i] = -1;
445 for (int i = 0; i < 2; ++i)
447 jboolean first_pass = i == 0;
449 if (! first_pass)
451 insns = (insn_slot *) _Jv_AllocBytes (sizeof (insn_slot) * next);
452 number_insn_slots = next;
453 next = 0;
456 unsigned char *pc = codestart;
457 while (pc < end)
459 int base_pc_val = pc - codestart;
460 if (first_pass)
461 pc_mapping[base_pc_val] = next;
463 java_opcode opcode = (java_opcode) *pc++;
464 // Just elide NOPs.
465 if (opcode == op_nop)
466 continue;
467 SET_INSN (insn_targets[opcode]);
469 switch (opcode)
471 case op_nop:
472 case op_aconst_null:
473 case op_iconst_m1:
474 case op_iconst_0:
475 case op_iconst_1:
476 case op_iconst_2:
477 case op_iconst_3:
478 case op_iconst_4:
479 case op_iconst_5:
480 case op_lconst_0:
481 case op_lconst_1:
482 case op_fconst_0:
483 case op_fconst_1:
484 case op_fconst_2:
485 case op_dconst_0:
486 case op_dconst_1:
487 case op_iload_0:
488 case op_iload_1:
489 case op_iload_2:
490 case op_iload_3:
491 case op_lload_0:
492 case op_lload_1:
493 case op_lload_2:
494 case op_lload_3:
495 case op_fload_0:
496 case op_fload_1:
497 case op_fload_2:
498 case op_fload_3:
499 case op_dload_0:
500 case op_dload_1:
501 case op_dload_2:
502 case op_dload_3:
503 case op_aload_0:
504 case op_aload_1:
505 case op_aload_2:
506 case op_aload_3:
507 case op_iaload:
508 case op_laload:
509 case op_faload:
510 case op_daload:
511 case op_aaload:
512 case op_baload:
513 case op_caload:
514 case op_saload:
515 case op_istore_0:
516 case op_istore_1:
517 case op_istore_2:
518 case op_istore_3:
519 case op_lstore_0:
520 case op_lstore_1:
521 case op_lstore_2:
522 case op_lstore_3:
523 case op_fstore_0:
524 case op_fstore_1:
525 case op_fstore_2:
526 case op_fstore_3:
527 case op_dstore_0:
528 case op_dstore_1:
529 case op_dstore_2:
530 case op_dstore_3:
531 case op_astore_0:
532 case op_astore_1:
533 case op_astore_2:
534 case op_astore_3:
535 case op_iastore:
536 case op_lastore:
537 case op_fastore:
538 case op_dastore:
539 case op_aastore:
540 case op_bastore:
541 case op_castore:
542 case op_sastore:
543 case op_pop:
544 case op_pop2:
545 case op_dup:
546 case op_dup_x1:
547 case op_dup_x2:
548 case op_dup2:
549 case op_dup2_x1:
550 case op_dup2_x2:
551 case op_swap:
552 case op_iadd:
553 case op_isub:
554 case op_imul:
555 case op_idiv:
556 case op_irem:
557 case op_ishl:
558 case op_ishr:
559 case op_iushr:
560 case op_iand:
561 case op_ior:
562 case op_ixor:
563 case op_ladd:
564 case op_lsub:
565 case op_lmul:
566 case op_ldiv:
567 case op_lrem:
568 case op_lshl:
569 case op_lshr:
570 case op_lushr:
571 case op_land:
572 case op_lor:
573 case op_lxor:
574 case op_fadd:
575 case op_fsub:
576 case op_fmul:
577 case op_fdiv:
578 case op_frem:
579 case op_dadd:
580 case op_dsub:
581 case op_dmul:
582 case op_ddiv:
583 case op_drem:
584 case op_ineg:
585 case op_i2b:
586 case op_i2c:
587 case op_i2s:
588 case op_lneg:
589 case op_fneg:
590 case op_dneg:
591 case op_i2l:
592 case op_i2f:
593 case op_i2d:
594 case op_l2i:
595 case op_l2f:
596 case op_l2d:
597 case op_f2i:
598 case op_f2l:
599 case op_f2d:
600 case op_d2i:
601 case op_d2l:
602 case op_d2f:
603 case op_lcmp:
604 case op_fcmpl:
605 case op_fcmpg:
606 case op_dcmpl:
607 case op_dcmpg:
608 case op_monitorenter:
609 case op_monitorexit:
610 case op_ireturn:
611 case op_lreturn:
612 case op_freturn:
613 case op_dreturn:
614 case op_areturn:
615 case op_return:
616 case op_athrow:
617 case op_arraylength:
618 // No argument, nothing else to do.
619 break;
621 case op_bipush:
622 SET_INT (get1s (pc));
623 ++pc;
624 break;
626 case op_ldc:
628 int index = get1u (pc);
629 ++pc;
630 // For an unresolved class we want to delay resolution
631 // until execution.
632 if (defining_class->constants.tags[index] == JV_CONSTANT_Class)
634 --next;
635 SET_INSN (insn_targets[int (op_jsr_w) + 1]);
636 SET_INT (index);
638 else
639 SET_DATUM (pool_data[index].o);
641 break;
643 case op_ret:
644 case op_iload:
645 case op_lload:
646 case op_fload:
647 case op_dload:
648 case op_aload:
649 case op_istore:
650 case op_lstore:
651 case op_fstore:
652 case op_dstore:
653 case op_astore:
654 case op_newarray:
655 SET_INT (get1u (pc));
656 ++pc;
657 break;
659 case op_iinc:
660 SET_INT (get1u (pc));
661 SET_INT (get1s (pc + 1));
662 pc += 2;
663 break;
665 case op_ldc_w:
667 int index = get2u (pc);
668 pc += 2;
669 // For an unresolved class we want to delay resolution
670 // until execution.
671 if (defining_class->constants.tags[index] == JV_CONSTANT_Class)
673 --next;
674 SET_INSN (insn_targets[int (op_jsr_w) + 1]);
675 SET_INT (index);
677 else
678 SET_DATUM (pool_data[index].o);
680 break;
682 case op_ldc2_w:
684 int index = get2u (pc);
685 pc += 2;
686 SET_DATUM (&pool_data[index]);
688 break;
690 case op_sipush:
691 SET_INT (get2s (pc));
692 pc += 2;
693 break;
695 case op_new:
696 case op_getstatic:
697 case op_getfield:
698 case op_putfield:
699 case op_putstatic:
700 case op_anewarray:
701 case op_instanceof:
702 case op_checkcast:
703 case op_invokespecial:
704 case op_invokestatic:
705 case op_invokevirtual:
706 SET_INT (get2u (pc));
707 pc += 2;
708 break;
710 case op_multianewarray:
711 SET_INT (get2u (pc));
712 SET_INT (get1u (pc + 2));
713 pc += 3;
714 break;
716 case op_jsr:
717 case op_ifeq:
718 case op_ifne:
719 case op_iflt:
720 case op_ifge:
721 case op_ifgt:
722 case op_ifle:
723 case op_if_icmpeq:
724 case op_if_icmpne:
725 case op_if_icmplt:
726 case op_if_icmpge:
727 case op_if_icmpgt:
728 case op_if_icmple:
729 case op_if_acmpeq:
730 case op_if_acmpne:
731 case op_ifnull:
732 case op_ifnonnull:
733 case op_goto:
735 int offset = get2s (pc);
736 pc += 2;
738 int new_pc = base_pc_val + offset;
740 bool orig_was_goto = opcode == op_goto;
742 // Thread jumps. We limit the loop count; this lets
743 // us avoid infinite loops if the bytecode contains
744 // such. `10' is arbitrary.
745 int count = 10;
746 while (codestart[new_pc] == op_goto && count-- > 0)
747 new_pc += get2s (&codestart[new_pc + 1]);
749 // If the jump takes us to a `return' instruction and
750 // the original branch was an unconditional goto, then
751 // we hoist the return.
752 opcode = (java_opcode) codestart[new_pc];
753 if (orig_was_goto
754 && (opcode == op_ireturn || opcode == op_lreturn
755 || opcode == op_freturn || opcode == op_dreturn
756 || opcode == op_areturn || opcode == op_return))
758 --next;
759 SET_INSN (insn_targets[opcode]);
761 else
762 SET_DATUM (&insns[pc_mapping[new_pc]]);
764 break;
766 case op_tableswitch:
768 while ((pc - codestart) % 4 != 0)
769 ++pc;
771 jint def = get4 (pc);
772 SET_DATUM (&insns[pc_mapping[base_pc_val + def]]);
773 pc += 4;
775 int low = get4 (pc);
776 SET_INT (low);
777 pc += 4;
778 int high = get4 (pc);
779 SET_INT (high);
780 pc += 4;
782 for (int i = low; i <= high; ++i)
784 SET_DATUM (&insns[pc_mapping[base_pc_val + get4 (pc)]]);
785 pc += 4;
788 break;
790 case op_lookupswitch:
792 while ((pc - codestart) % 4 != 0)
793 ++pc;
795 jint def = get4 (pc);
796 SET_DATUM (&insns[pc_mapping[base_pc_val + def]]);
797 pc += 4;
799 jint npairs = get4 (pc);
800 pc += 4;
801 SET_INT (npairs);
803 while (npairs-- > 0)
805 jint match = get4 (pc);
806 jint offset = get4 (pc + 4);
807 SET_INT (match);
808 SET_DATUM (&insns[pc_mapping[base_pc_val + offset]]);
809 pc += 8;
812 break;
814 case op_invokeinterface:
816 jint index = get2u (pc);
817 pc += 2;
818 // We ignore the next two bytes.
819 pc += 2;
820 SET_INT (index);
822 break;
824 case op_wide:
826 opcode = (java_opcode) get1u (pc);
827 pc += 1;
828 jint val = get2u (pc);
829 pc += 2;
831 // We implement narrow and wide instructions using the
832 // same code in the interpreter. So we rewrite the
833 // instruction slot here.
834 if (! first_pass)
835 insns[next - 1].insn = (void *) insn_targets[opcode];
836 SET_INT (val);
838 if (opcode == op_iinc)
840 SET_INT (get2s (pc));
841 pc += 2;
844 break;
846 case op_jsr_w:
847 case op_goto_w:
849 jint offset = get4 (pc);
850 pc += 4;
851 SET_DATUM (&insns[pc_mapping[base_pc_val + offset]]);
853 break;
855 // Some "can't happen" cases that we include for
856 // error-checking purposes.
857 case op_putfield_1:
858 case op_putfield_2:
859 case op_putfield_4:
860 case op_putfield_8:
861 case op_putfield_a:
862 case op_putstatic_1:
863 case op_putstatic_2:
864 case op_putstatic_4:
865 case op_putstatic_8:
866 case op_putstatic_a:
867 case op_getfield_1:
868 case op_getfield_2s:
869 case op_getfield_2u:
870 case op_getfield_4:
871 case op_getfield_8:
872 case op_getfield_a:
873 case op_getstatic_1:
874 case op_getstatic_2s:
875 case op_getstatic_2u:
876 case op_getstatic_4:
877 case op_getstatic_8:
878 case op_getstatic_a:
879 case op_breakpoint:
880 default:
881 // Fail somehow.
882 break;
887 // Now update exceptions.
888 _Jv_InterpException *exc = exceptions ();
889 for (int i = 0; i < exc_count; ++i)
891 exc[i].start_pc.p = &insns[pc_mapping[exc[i].start_pc.i]];
892 exc[i].end_pc.p = &insns[pc_mapping[exc[i].end_pc.i]];
893 exc[i].handler_pc.p = &insns[pc_mapping[exc[i].handler_pc.i]];
894 // FIXME: resolve_pool_entry can throw - we shouldn't be doing this
895 // during compilation.
896 jclass handler
897 = (_Jv_Linker::resolve_pool_entry (defining_class,
898 exc[i].handler_type.i)).clazz;
899 exc[i].handler_type.p = handler;
902 // Translate entries in the LineNumberTable from bytecode PC's to direct
903 // threaded interpreter instruction values.
904 for (int i = 0; i < line_table_len; i++)
906 int byte_pc = line_table[i].bytecode_pc;
907 // It isn't worth throwing an exception if this table is
908 // corrupted, but at the same time we don't want a crash.
909 if (byte_pc < 0 || byte_pc >= code_length)
910 byte_pc = 0;
911 line_table[i].pc = &insns[pc_mapping[byte_pc]];
914 prepared = insns;
916 if (breakpoint_insn == NULL)
918 bp_insn_slot.insn = const_cast<void *> (insn_targets[op_breakpoint]);
919 breakpoint_insn = &bp_insn_slot;
922 #endif /* DIRECT_THREADED */
924 /* Run the given method.
925 When args is NULL, don't run anything -- just compile it. */
926 void
927 _Jv_InterpMethod::run (void *retp, ffi_raw *args, _Jv_InterpMethod *meth)
929 #undef DEBUG
930 #undef DEBUG_LOCALS_INSN
931 #define DEBUG_LOCALS_INSN(s, t) do {} while(0)
933 #include "interpret-run.cc"
936 void
937 _Jv_InterpMethod::run_debug (void *retp, ffi_raw *args, _Jv_InterpMethod *meth)
939 #define DEBUG
940 #undef DEBUG_LOCALS_INSN
941 #define DEBUG_LOCALS_INSN(s, t) do {} while(0)
943 #include "interpret-run.cc"
946 static void
947 throw_internal_error (const char *msg)
949 throw new java::lang::InternalError (JvNewStringLatin1 (msg));
952 static void
953 throw_incompatible_class_change_error (jstring msg)
955 throw new java::lang::IncompatibleClassChangeError (msg);
958 static void
959 throw_null_pointer_exception ()
961 throw new java::lang::NullPointerException;
964 /* Look up source code line number for given bytecode (or direct threaded
965 interpreter) PC. */
967 _Jv_InterpMethod::get_source_line(pc_t mpc)
969 int line = line_table_len > 0 ? line_table[0].line : -1;
970 for (int i = 1; i < line_table_len; i++)
971 if (line_table[i].pc > mpc)
972 break;
973 else
974 line = line_table[i].line;
976 return line;
979 /** Do static initialization for fields with a constant initializer */
980 void
981 _Jv_InitField (jobject obj, jclass klass, int index)
983 using namespace java::lang::reflect;
985 if (obj != 0 && klass == 0)
986 klass = obj->getClass ();
988 if (!_Jv_IsInterpretedClass (klass))
989 return;
991 _Jv_InterpClass *iclass = (_Jv_InterpClass*)klass->aux_info;
993 _Jv_Field * field = (&klass->fields[0]) + index;
995 if (index > klass->field_count)
996 throw_internal_error ("field out of range");
998 int init = iclass->field_initializers[index];
999 if (init == 0)
1000 return;
1002 _Jv_Constants *pool = &klass->constants;
1003 int tag = pool->tags[init];
1005 if (! field->isResolved ())
1006 throw_internal_error ("initializing unresolved field");
1008 if (obj==0 && ((field->flags & Modifier::STATIC) == 0))
1009 throw_internal_error ("initializing non-static field with no object");
1011 void *addr = 0;
1013 if ((field->flags & Modifier::STATIC) != 0)
1014 addr = (void*) field->u.addr;
1015 else
1016 addr = (void*) (((char*)obj) + field->u.boffset);
1018 switch (tag)
1020 case JV_CONSTANT_String:
1022 jstring str;
1023 str = _Jv_NewStringUtf8Const (pool->data[init].utf8);
1024 pool->data[init].string = str;
1025 pool->tags[init] = JV_CONSTANT_ResolvedString;
1027 /* fall through */
1029 case JV_CONSTANT_ResolvedString:
1030 if (! (field->type == &java::lang::String::class$
1031 || field->type == &java::lang::Class::class$))
1032 throw_class_format_error ("string initialiser to non-string field");
1034 *(jstring*)addr = pool->data[init].string;
1035 break;
1037 case JV_CONSTANT_Integer:
1039 int value = pool->data[init].i;
1041 if (field->type == JvPrimClass (boolean))
1042 *(jboolean*)addr = (jboolean)value;
1044 else if (field->type == JvPrimClass (byte))
1045 *(jbyte*)addr = (jbyte)value;
1047 else if (field->type == JvPrimClass (char))
1048 *(jchar*)addr = (jchar)value;
1050 else if (field->type == JvPrimClass (short))
1051 *(jshort*)addr = (jshort)value;
1053 else if (field->type == JvPrimClass (int))
1054 *(jint*)addr = (jint)value;
1056 else
1057 throw_class_format_error ("erroneous field initializer");
1059 break;
1061 case JV_CONSTANT_Long:
1062 if (field->type != JvPrimClass (long))
1063 throw_class_format_error ("erroneous field initializer");
1065 *(jlong*)addr = _Jv_loadLong (&pool->data[init]);
1066 break;
1068 case JV_CONSTANT_Float:
1069 if (field->type != JvPrimClass (float))
1070 throw_class_format_error ("erroneous field initializer");
1072 *(jfloat*)addr = pool->data[init].f;
1073 break;
1075 case JV_CONSTANT_Double:
1076 if (field->type != JvPrimClass (double))
1077 throw_class_format_error ("erroneous field initializer");
1079 *(jdouble*)addr = _Jv_loadDouble (&pool->data[init]);
1080 break;
1082 default:
1083 throw_class_format_error ("erroneous field initializer");
1087 inline static unsigned char*
1088 skip_one_type (unsigned char* ptr)
1090 int ch = *ptr++;
1092 while (ch == '[')
1094 ch = *ptr++;
1097 if (ch == 'L')
1099 do { ch = *ptr++; } while (ch != ';');
1102 return ptr;
1105 static ffi_type*
1106 get_ffi_type_from_signature (unsigned char* ptr)
1108 switch (*ptr)
1110 case 'L':
1111 case '[':
1112 return &ffi_type_pointer;
1113 break;
1115 case 'Z':
1116 // On some platforms a bool is a byte, on others an int.
1117 if (sizeof (jboolean) == sizeof (jbyte))
1118 return &ffi_type_sint8;
1119 else
1121 JvAssert (sizeof (jbyte) == sizeof (jint));
1122 return &ffi_type_sint32;
1124 break;
1126 case 'B':
1127 return &ffi_type_sint8;
1128 break;
1130 case 'C':
1131 return &ffi_type_uint16;
1132 break;
1134 case 'S':
1135 return &ffi_type_sint16;
1136 break;
1138 case 'I':
1139 return &ffi_type_sint32;
1140 break;
1142 case 'J':
1143 return &ffi_type_sint64;
1144 break;
1146 case 'F':
1147 return &ffi_type_float;
1148 break;
1150 case 'D':
1151 return &ffi_type_double;
1152 break;
1154 case 'V':
1155 return &ffi_type_void;
1156 break;
1159 throw_internal_error ("unknown type in signature");
1162 /* this function yields the number of actual arguments, that is, if the
1163 * function is non-static, then one is added to the number of elements
1164 * found in the signature */
1166 int
1167 _Jv_count_arguments (_Jv_Utf8Const *signature,
1168 jboolean staticp)
1170 unsigned char *ptr = (unsigned char*) signature->chars();
1171 int arg_count = staticp ? 0 : 1;
1173 /* first, count number of arguments */
1175 // skip '('
1176 ptr++;
1178 // count args
1179 while (*ptr != ')')
1181 ptr = skip_one_type (ptr);
1182 arg_count += 1;
1185 return arg_count;
1188 /* This beast will build a cif, given the signature. Memory for
1189 * the cif itself and for the argument types must be allocated by the
1190 * caller.
1193 int
1194 _Jv_init_cif (_Jv_Utf8Const* signature,
1195 int arg_count,
1196 jboolean staticp,
1197 ffi_cif *cif,
1198 ffi_type **arg_types,
1199 ffi_type **rtype_p)
1201 unsigned char *ptr = (unsigned char*) signature->chars();
1203 int arg_index = 0; // arg number
1204 int item_count = 0; // stack-item count
1206 // setup receiver
1207 if (!staticp)
1209 arg_types[arg_index++] = &ffi_type_pointer;
1210 item_count += 1;
1213 // skip '('
1214 ptr++;
1216 // assign arg types
1217 while (*ptr != ')')
1219 arg_types[arg_index++] = get_ffi_type_from_signature (ptr);
1221 if (*ptr == 'J' || *ptr == 'D')
1222 item_count += 2;
1223 else
1224 item_count += 1;
1226 ptr = skip_one_type (ptr);
1229 // skip ')'
1230 ptr++;
1231 ffi_type *rtype = get_ffi_type_from_signature (ptr);
1233 ptr = skip_one_type (ptr);
1234 if (ptr != (unsigned char*)signature->chars() + signature->len())
1235 throw_internal_error ("did not find end of signature");
1237 if (ffi_prep_cif (cif, FFI_DEFAULT_ABI,
1238 arg_count, rtype, arg_types) != FFI_OK)
1239 throw_internal_error ("ffi_prep_cif failed");
1241 if (rtype_p != NULL)
1242 *rtype_p = rtype;
1244 return item_count;
1247 #if FFI_NATIVE_RAW_API
1248 # define FFI_PREP_RAW_CLOSURE ffi_prep_raw_closure
1249 # define FFI_RAW_SIZE ffi_raw_size
1250 #else
1251 # define FFI_PREP_RAW_CLOSURE ffi_prep_java_raw_closure
1252 # define FFI_RAW_SIZE ffi_java_raw_size
1253 #endif
1255 /* we put this one here, and not in interpret.cc because it
1256 * calls the utility routines _Jv_count_arguments
1257 * which are static to this module. The following struct defines the
1258 * layout we use for the stubs, it's only used in the ncode method. */
1260 typedef struct {
1261 ffi_raw_closure closure;
1262 ffi_cif cif;
1263 ffi_type *arg_types[0];
1264 } ncode_closure;
1266 typedef void (*ffi_closure_fun) (ffi_cif*,void*,ffi_raw*,void*);
1268 void *
1269 _Jv_InterpMethod::ncode ()
1271 using namespace java::lang::reflect;
1273 if (self->ncode != 0)
1274 return self->ncode;
1276 jboolean staticp = (self->accflags & Modifier::STATIC) != 0;
1277 int arg_count = _Jv_count_arguments (self->signature, staticp);
1279 ncode_closure *closure =
1280 (ncode_closure*)_Jv_AllocBytes (sizeof (ncode_closure)
1281 + arg_count * sizeof (ffi_type*));
1283 _Jv_init_cif (self->signature,
1284 arg_count,
1285 staticp,
1286 &closure->cif,
1287 &closure->arg_types[0],
1288 NULL);
1290 ffi_closure_fun fun;
1292 args_raw_size = FFI_RAW_SIZE (&closure->cif);
1294 JvAssert ((self->accflags & Modifier::NATIVE) == 0);
1296 if ((self->accflags & Modifier::SYNCHRONIZED) != 0)
1298 if (staticp)
1300 if (::gnu::classpath::jdwp::Jdwp::isDebugging)
1301 fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_class_debug;
1302 else
1303 fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_class;
1305 else
1307 if (::gnu::classpath::jdwp::Jdwp::isDebugging)
1308 fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_object_debug;
1309 else
1310 fun = (ffi_closure_fun)&_Jv_InterpMethod::run_synch_object;
1313 else
1315 if (staticp)
1317 if (::gnu::classpath::jdwp::Jdwp::isDebugging)
1318 fun = (ffi_closure_fun)&_Jv_InterpMethod::run_class_debug;
1319 else
1320 fun = (ffi_closure_fun)&_Jv_InterpMethod::run_class;
1322 else
1324 if (::gnu::classpath::jdwp::Jdwp::isDebugging)
1325 fun = (ffi_closure_fun)&_Jv_InterpMethod::run_normal_debug;
1326 else
1327 fun = (ffi_closure_fun)&_Jv_InterpMethod::run_normal;
1331 FFI_PREP_RAW_CLOSURE (&closure->closure,
1332 &closure->cif,
1333 fun,
1334 (void*)this);
1336 self->ncode = (void*)closure;
1337 return self->ncode;
1340 /* Find the index of the given insn in the array of insn slots
1341 for this method. Returns -1 if not found. */
1342 jlong
1343 _Jv_InterpMethod::insn_index (pc_t pc)
1345 jlong left = 0;
1346 #ifdef DIRECT_THREADED
1347 jlong right = number_insn_slots;
1348 pc_t insns = prepared;
1349 #else
1350 jlong right = code_length;
1351 pc_t insns = bytecode ();
1352 #endif
1354 while (right >= 0)
1356 jlong mid = (left + right) / 2;
1357 if (&insns[mid] == pc)
1358 return mid;
1360 if (pc < &insns[mid])
1361 right = mid - 1;
1362 else
1363 left = mid + 1;
1366 return -1;
1369 void
1370 _Jv_InterpMethod::get_line_table (jlong& start, jlong& end,
1371 jintArray& line_numbers,
1372 jlongArray& code_indices)
1374 #ifdef DIRECT_THREADED
1375 /* For the DIRECT_THREADED case, if the method has not yet been
1376 * compiled, the linetable will change to insn slots instead of
1377 * bytecode PCs. It is probably easiest, in this case, to simply
1378 * compile the method and guarantee that we are using insn
1379 * slots.
1381 _Jv_CompileMethod (this);
1383 if (line_table_len > 0)
1385 start = 0;
1386 end = number_insn_slots;
1387 line_numbers = JvNewIntArray (line_table_len);
1388 code_indices = JvNewLongArray (line_table_len);
1390 jint* lines = elements (line_numbers);
1391 jlong* indices = elements (code_indices);
1392 for (int i = 0; i < line_table_len; ++i)
1394 lines[i] = line_table[i].line;
1395 indices[i] = insn_index (line_table[i].pc);
1398 #else // !DIRECT_THREADED
1399 if (line_table_len > 0)
1401 start = 0;
1402 end = code_length;
1403 line_numbers = JvNewIntArray (line_table_len);
1404 code_indices = JvNewLongArray (line_table_len);
1406 jint* lines = elements (line_numbers);
1407 jlong* indices = elements (code_indices);
1408 for (int i = 0; i < line_table_len; ++i)
1410 lines[i] = line_table[i].line;
1411 indices[i] = (jlong) line_table[i].bytecode_pc;
1414 #endif // !DIRECT_THREADED
1417 pc_t
1418 _Jv_InterpMethod::install_break (jlong index)
1420 return set_insn (index, breakpoint_insn);
1423 pc_t
1424 _Jv_InterpMethod::get_insn (jlong index)
1426 pc_t code;
1428 #ifdef DIRECT_THREADED
1429 if (index >= number_insn_slots || index < 0)
1430 return NULL;
1432 code = prepared;
1433 #else // !DIRECT_THREADED
1434 if (index >= code_length || index < 0)
1435 return NULL;
1437 code = reinterpret_cast<pc_t> (bytecode ());
1438 #endif // !DIRECT_THREADED
1440 return &code[index];
1443 pc_t
1444 _Jv_InterpMethod::set_insn (jlong index, pc_t insn)
1446 #ifdef DIRECT_THREADED
1447 if (index >= number_insn_slots || index < 0)
1448 return NULL;
1450 pc_t code = prepared;
1451 code[index].insn = insn->insn;
1452 #else // !DIRECT_THREADED
1453 if (index >= code_length || index < 0)
1454 return NULL;
1456 pc_t code = reinterpret_cast<pc_t> (bytecode ());
1457 code[index] = *insn;
1458 #endif // !DIRECT_THREADED
1460 return &code[index];
1463 void *
1464 _Jv_JNIMethod::ncode ()
1466 using namespace java::lang::reflect;
1468 if (self->ncode != 0)
1469 return self->ncode;
1471 jboolean staticp = (self->accflags & Modifier::STATIC) != 0;
1472 int arg_count = _Jv_count_arguments (self->signature, staticp);
1474 ncode_closure *closure =
1475 (ncode_closure*)_Jv_AllocBytes (sizeof (ncode_closure)
1476 + arg_count * sizeof (ffi_type*));
1478 ffi_type *rtype;
1479 _Jv_init_cif (self->signature,
1480 arg_count,
1481 staticp,
1482 &closure->cif,
1483 &closure->arg_types[0],
1484 &rtype);
1486 ffi_closure_fun fun;
1488 args_raw_size = FFI_RAW_SIZE (&closure->cif);
1490 // Initialize the argument types and CIF that represent the actual
1491 // underlying JNI function.
1492 int extra_args = 1;
1493 if ((self->accflags & Modifier::STATIC))
1494 ++extra_args;
1495 jni_arg_types = (ffi_type **) _Jv_AllocBytes ((extra_args + arg_count)
1496 * sizeof (ffi_type *));
1497 int offset = 0;
1498 jni_arg_types[offset++] = &ffi_type_pointer;
1499 if ((self->accflags & Modifier::STATIC))
1500 jni_arg_types[offset++] = &ffi_type_pointer;
1501 memcpy (&jni_arg_types[offset], &closure->arg_types[0],
1502 arg_count * sizeof (ffi_type *));
1504 if (ffi_prep_cif (&jni_cif, _Jv_platform_ffi_abi,
1505 extra_args + arg_count, rtype,
1506 jni_arg_types) != FFI_OK)
1507 throw_internal_error ("ffi_prep_cif failed for JNI function");
1509 JvAssert ((self->accflags & Modifier::NATIVE) != 0);
1511 // FIXME: for now we assume that all native methods for
1512 // interpreted code use JNI.
1513 fun = (ffi_closure_fun) &_Jv_JNIMethod::call;
1515 FFI_PREP_RAW_CLOSURE (&closure->closure,
1516 &closure->cif,
1517 fun,
1518 (void*) this);
1520 self->ncode = (void *) closure;
1521 return self->ncode;
1524 static void
1525 throw_class_format_error (jstring msg)
1527 throw (msg
1528 ? new java::lang::ClassFormatError (msg)
1529 : new java::lang::ClassFormatError);
1532 static void
1533 throw_class_format_error (const char *msg)
1535 throw_class_format_error (JvNewStringLatin1 (msg));
1540 void
1541 _Jv_InterpreterEngine::do_verify (jclass klass)
1543 _Jv_InterpClass *iclass = (_Jv_InterpClass *) klass->aux_info;
1544 for (int i = 0; i < klass->method_count; i++)
1546 using namespace java::lang::reflect;
1547 _Jv_MethodBase *imeth = iclass->interpreted_methods[i];
1548 _Jv_ushort accflags = klass->methods[i].accflags;
1549 if ((accflags & (Modifier::NATIVE | Modifier::ABSTRACT)) == 0)
1551 _Jv_InterpMethod *im = reinterpret_cast<_Jv_InterpMethod *> (imeth);
1552 _Jv_VerifyMethod (im);
1557 void
1558 _Jv_InterpreterEngine::do_create_ncode (jclass klass)
1560 _Jv_InterpClass *iclass = (_Jv_InterpClass *) klass->aux_info;
1561 for (int i = 0; i < klass->method_count; i++)
1563 // Just skip abstract methods. This is particularly important
1564 // because we don't resize the interpreted_methods array when
1565 // miranda methods are added to it.
1566 if ((klass->methods[i].accflags
1567 & java::lang::reflect::Modifier::ABSTRACT)
1568 != 0)
1569 continue;
1571 _Jv_MethodBase *imeth = iclass->interpreted_methods[i];
1573 if ((klass->methods[i].accflags & java::lang::reflect::Modifier::NATIVE)
1574 != 0)
1576 // You might think we could use a virtual `ncode' method in
1577 // the _Jv_MethodBase and unify the native and non-native
1578 // cases. Well, we can't, because we don't allocate these
1579 // objects using `new', and thus they don't get a vtable.
1580 _Jv_JNIMethod *jnim = reinterpret_cast<_Jv_JNIMethod *> (imeth);
1581 klass->methods[i].ncode = jnim->ncode ();
1583 else if (imeth != 0) // it could be abstract
1585 _Jv_InterpMethod *im = reinterpret_cast<_Jv_InterpMethod *> (imeth);
1586 klass->methods[i].ncode = im->ncode ();
1591 void
1592 _Jv_InterpreterEngine::do_allocate_static_fields (jclass klass,
1593 int pointer_size,
1594 int other_size)
1596 _Jv_InterpClass *iclass = (_Jv_InterpClass *) klass->aux_info;
1598 // Splitting the allocations here lets us scan reference fields and
1599 // avoid scanning non-reference fields. How reference fields are
1600 // scanned is a bit tricky: we allocate using _Jv_AllocRawObj, which
1601 // means that this memory will be scanned conservatively (same
1602 // difference, since we know all the contents here are pointers).
1603 // Then we put pointers into this memory into the 'fields'
1604 // structure. Most of these are interior pointers, which is ok (but
1605 // even so the pointer to the first reference field will be used and
1606 // that is not an interior pointer). The 'fields' array is also
1607 // allocated with _Jv_AllocRawObj (see defineclass.cc), so it will
1608 // be scanned. A pointer to this array is held by Class and thus
1609 // seen by the collector.
1610 char *reference_fields = (char *) _Jv_AllocRawObj (pointer_size);
1611 char *non_reference_fields = (char *) _Jv_AllocBytes (other_size);
1613 for (int i = 0; i < klass->field_count; i++)
1615 _Jv_Field *field = &klass->fields[i];
1617 if ((field->flags & java::lang::reflect::Modifier::STATIC) == 0)
1618 continue;
1620 char *base = field->isRef() ? reference_fields : non_reference_fields;
1621 field->u.addr = base + field->u.boffset;
1623 if (iclass->field_initializers[i] != 0)
1625 _Jv_Linker::resolve_field (field, klass->loader);
1626 _Jv_InitField (0, klass, i);
1630 // Now we don't need the field_initializers anymore, so let the
1631 // collector get rid of it.
1632 iclass->field_initializers = 0;
1635 _Jv_ResolvedMethod *
1636 _Jv_InterpreterEngine::do_resolve_method (_Jv_Method *method, jclass klass,
1637 jboolean staticp)
1639 int arg_count = _Jv_count_arguments (method->signature, staticp);
1641 _Jv_ResolvedMethod* result = (_Jv_ResolvedMethod*)
1642 _Jv_AllocBytes (sizeof (_Jv_ResolvedMethod)
1643 + arg_count*sizeof (ffi_type*));
1645 result->stack_item_count
1646 = _Jv_init_cif (method->signature,
1647 arg_count,
1648 staticp,
1649 &result->cif,
1650 &result->arg_types[0],
1651 NULL);
1653 result->method = method;
1654 result->klass = klass;
1656 return result;
1659 void
1660 _Jv_InterpreterEngine::do_post_miranda_hook (jclass klass)
1662 _Jv_InterpClass *iclass = (_Jv_InterpClass *) klass->aux_info;
1663 for (int i = 0; i < klass->method_count; i++)
1665 // Just skip abstract methods. This is particularly important
1666 // because we don't resize the interpreted_methods array when
1667 // miranda methods are added to it.
1668 if ((klass->methods[i].accflags
1669 & java::lang::reflect::Modifier::ABSTRACT)
1670 != 0)
1671 continue;
1672 // Miranda method additions mean that the `methods' array moves.
1673 // We cache a pointer into this array, so we have to update.
1674 iclass->interpreted_methods[i]->self = &klass->methods[i];
1678 #ifdef DIRECT_THREADED
1679 void
1680 _Jv_CompileMethod (_Jv_InterpMethod* method)
1682 if (method->prepared == NULL)
1683 _Jv_InterpMethod::run (NULL, NULL, method);
1685 #endif // DIRECT_THREADED
1687 #endif // INTERPRETER