1 /* jit/i386/asmpart.S - Java-C interface functions for i386
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 Institut f. Computersprachen, TU Wien
5 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Probst,
6 S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich,
9 This file is part of CACAO.
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2, or (at
14 your option) any later version.
16 This program is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 Contact: cacao@complang.tuwien.ac.at
28 Authors: Andreas Krall
32 $Id: asmpart.S 1111 2004-05-29 07:51:40Z jowenn $
40 /* data segment offsets */
42 #define MethodPointer -4
48 #define LineNumberTableSize -28
49 #define LineNumberTableStart -32
50 #define ExTableSize -36
51 #define ExTableStart -36
53 #define ExEntrySize -16
56 #define ExHandlerPC -12
57 #define ExCatchType -16
60 #define LineEntrySize -8
73 /********************* exported functions and variables ***********************/
75 .globl asm_calljavafunction
76 .globl asm_calljavafunction2
77 .globl asm_calljavafunction2long
78 .globl asm_calljavafunction2double
80 .globl asm_call_jit_compiler
81 .globl asm_handle_builtin_exception
82 .globl asm_handle_nat_exception
83 .globl asm_handle_exception
84 .globl asm_check_clinit
85 .globl asm_builtin_checkcast
86 .globl asm_builtin_checkarraycast
87 .globl asm_builtin_newarray
88 .globl asm_builtin_anewarray
89 .globl asm_builtin_newarray_array
90 .globl asm_builtin_aastore
91 .globl asm_builtin_monitorenter
92 .globl asm_builtin_monitorexit
93 .globl asm_builtin_ldiv
94 .globl asm_builtin_lrem
95 .globl asm_builtin_f2i
96 .globl asm_builtin_f2l
97 .globl asm_builtin_d2i
98 .globl asm_builtin_d2l
99 .globl asm_builtin_arrayinstanceof
100 .globl asm_perform_threadswitch
101 .globl asm_initialize_thread_stack
102 .globl asm_switchstackandcall
103 .globl asm_getcallingmethod
104 .globl Java_java_lang_VMSecurityManager_getClassContext
105 .globl Java_java_lang_VMSecurityManager_currentClassLoader
106 .globl asm_builtin_new
107 .globl asm_get_stackTrace
108 .globl asm_criticalsections
109 .globl asm_getclassvalues_atomic
111 /*************************** imported functions *******************************/
114 .globl builtin_monitorexit
115 .globl builtin_throw_exception
116 .globl builtin_trace_exception
117 .globl class_java_lang_Object
118 .globl codegen_findmethod
119 .globl builtin_asm_createclasscontextarray
120 .globl builtin_asm_getclassloader
121 .globl callgetexceptionptrptr
122 .globl asm_throw_and_handle_hardware_nullpointer_exception
123 .globl asm_throw_and_handle_hardware_arithmetic_exception
126 /********************* function asm_calljavafunction ***************************
128 * This function calls a Java-method (which possibly needs compilation) *
129 * with up to 4 address parameters. *
131 * This functions calls the JIT-compiler which eventually translates the *
132 * method into machine code. *
135 * javaobject_header *asm_calljavamethod (methodinfo *m, *
136 * void *arg1, void *arg2, void *arg3, void *arg4); *
138 *******************************************************************************/
141 .ascii "calljavafunction\0\0"
144 .long 0 /* catch type all */
145 .long calljava_xhandler /* handler pc */
146 .long calljava_xhandler /* end pc */
147 .long asm_calljavafunction /* start pc */
148 .long 1 /* extable size */
149 .long 0 /* line number table start */
150 .long 0 /* line number table size */
151 .long 0 /* fltsave */
152 .long 0 /* intsave */
155 .long 32 /* frame size */
156 .long 0 /* method pointer (pointer to name) */
158 asm_calljavafunction:
159 push %ebp /* allocate stack space */
162 push %ebx /* save registers */
166 sub $32,%esp /* pass the remaining parameters */
169 mov %edx,28(%esp) /* convert parms to 8 byte */
185 mov 8(%ebp),%eax /* move function pointer to %eax */
187 lea asm_call_jit_compiler,%edx
188 call *%edx /* call JIT compiler */
192 pop %edi /* restore registers */
199 push %eax /* pass exception pointer */
200 call builtin_throw_exception
204 pop %edi /* restore registers */
211 /********************* function asm_calljavafunction ***************************
213 * This function calls a Java-method (which possibly needs compilation) *
214 * with up to 4 address parameters. *
216 * This functions calls the JIT-compiler which eventually translates the *
217 * method into machine code. *
220 * javaobject_header *asm_calljavafunction2(methodinfo *m, *
221 * u4 count, u4 size, void *callblock); *
223 *******************************************************************************/
226 .ascii "calljavafunction2\0\0"
229 .long 0 /* catch type all */
230 .long calljava_xhandler2 /* handler pc */
231 .long calljava_xhandler2 /* end pc */
232 .long asm_calljavafunction2 /* start pc */
233 .long 1 /* extable size */
234 .long 0 /* line number table start */
235 .long 0 /* line number table size */
236 .long 0 /* fltsave */
237 .long 0 /* intsave */
240 .long 32 /* frame size */
241 .long 0 /* method pointer (pointer to name) */
243 asm_calljavafunction2:
244 asm_calljavafunction2double:
245 asm_calljavafunction2long:
247 mov %esp,%ebp /* save stackptr */
249 push %ebx /* save registers */
253 mov 20(%ebp),%eax /* pointer to arg block */
254 mov 12(%ebp),%ecx /* arg count */
255 test %ecx,%ecx /* maybe we have no args */
256 jle calljava_copydone
258 mov %ecx,%edx /* calculate stack size */
260 mov %edx,%esi /* save in callee saved register */
261 sub %esi,%esp /* stack frame for arguments */
265 mov offjniitem(%eax),%edx
267 mov offjniitem+4(%eax),%edx
270 sub $1,%ecx /* are there any args left? */
272 jle calljava_copydone
274 add $sizejniblock,%eax /* goto next argument block */
275 add $8,%edi /* increase sp to next argument */
276 jmp calljava_copyloop
279 mov 8(%ebp),%eax /* move function pointer to %eax */
281 lea asm_call_jit_compiler,%edx
282 call *%edx /* call JIT compiler */
285 add %esi,%esp /* remove arg stack frame */
286 pop %edi /* restore registers */
293 push %eax /* pass exception pointer */
294 call builtin_throw_exception
297 add %esi,%esp /* remove arg stack frame */
298 pop %edi /* restore registers */
305 /****************** function asm_call_jit_compiler *****************************
307 * invokes the compiler for untranslated JavaVM methods. *
309 * Register R0 contains a pointer to the method info structure (prepared *
310 * by createcompilerstub). Using the return address in R26 and the *
311 * offset in the LDA instruction or using the value in methodptr R28 the *
312 * patching address for storing the method address can be computed: *
314 * method address was either loaded using *
316 * i386_mov_imm_reg(a, REG_ITMP2) ; invokestatic/special *
317 * i386_call_reg(REG_ITMP2) *
321 * i386_mov_membase_reg(REG_SP, 0, REG_ITMP1) ; invokevirtual/interface *
322 * i386_mov_membase_reg(REG_ITMP1, OFFSET(, vftbl), REG_ITMP2) *
323 * i386_mov_membase_reg(REG_ITMP2, OFFSET(vftbl, table[0]) + \ *
324 * sizeof(methodptr) * m->vftblindex, REG_ITMP1) *
325 * i386_call_reg(REG_ITMP1) *
327 * in the static case the method pointer can be computed using the *
328 * return address and the lda function following the jmp instruction *
330 *******************************************************************************/
332 asm_call_jit_compiler:
333 push %ebx /* save register */
336 mov 8(%esp),%ebp /* get return address (2 push) */
337 mov -1(%ebp),%bl /* get function code */
338 cmp $0xd1,%bl /* called with `call *REG_ITMP2' (%ecx)? */
339 jne L_not_static_special
341 sub $6,%ebp /* calculate address of immediate */
342 jmp L_call_jit_compile
344 L_not_static_special:
345 cmp $0xd0,%bl /* called with `call *REG_ITMP1' (%eax) */
346 jne L_not_virtual_interface
348 sub $6,%ebp /* calculate address of offset */
349 mov (%ebp),%ebp /* get offset */
350 add itmp2,%ebp /* add base address to get method address */
351 jmp L_call_jit_compile
353 L_not_virtual_interface: /* a call from asm_calljavafunction */
357 push %ebp /* save address for method pointer */
359 push %eax /* push methodpointer on stack */
363 pop %ebp /* restore address for method pointer */
365 test %eax,%eax /* check for exception */
368 test %ebp,%ebp /* is address == 0 (asm_calljavafunction) */
371 mov %eax,(%ebp) /* and now save the new pointer */
374 pop %ebp /* restore registers */
377 jmp *%eax /* ...and now call the new method */
380 pop %ebp /* restore registers */
383 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
384 call builtin_asm_get_exceptionptrptr
386 mov (%ecx),%eax /* get the exception pointer */
387 movl $0,(%ecx) /* clear the exception pointer */
389 lea _exceptionptr,%ecx
390 mov (%ecx),%eax /* get the exception pointer */
391 movl $0,(%ecx) /* clear the exception pointer */
394 pop %ecx /* delete return address */
395 sub $2,%ecx /* faulting address is return adress - 2 */
397 jmp asm_handle_exception
400 /********************* function asm_handle_exception ***************************
402 * This function handles an exception. It does not use the usual calling *
403 * conventions. The exception pointer is passed in REG_ITMP1 and the *
404 * pc from the exception raising position is passed in REG_ITMP2. It searches *
405 * the local exception table for a handler. If no one is found, it unwinds *
406 * stacks and continues searching the callers. *
408 * void asm_handle_exception (exceptionptr, exceptionpc); *
410 *******************************************************************************/
412 asm_handle_nat_exception:
413 add $4,%esp /* clear return address of native stub */
415 asm_handle_exception:
419 push %eax /* exception pointer */
420 push %ecx /* excepiton pc */
422 call asm_get_stackTrace
428 asm_handle_exception_loop:
432 push %eax /* save exception pointer */
433 push %ecx /* save exception pc */
435 call codegen_findmethod /* get the data segment ptr */
439 mov -8(%ebp),%ecx /* could be changed in findmethod */
441 push %edx /* save data segment pointer */
448 mov %eax,(%esp) /* exception pointer */
449 mov MethodPointer(%edx),%eax /* method pointer */
451 mov %ecx,8(%esp) /* exception pc */
452 movl $0,12(%esp) /* line number */
453 movl $1,16(%esp) /* set no unwind flag */
454 call builtin_trace_exception
456 mov -12(%ebp),%esi /* %esi = data segment pointer */
457 mov ExTableSize(%esi),%ecx /* %ecx = exception table size */
458 test %ecx,%ecx /* if empty table skip */
461 lea ExTableStart(%esi),%edi /* %edi = start of exception table*/
462 mov -4(%ebp),%eax /* get xptr */
465 mov -8(%ebp),%edx /* get xpc */
467 mov ExStartPC(%edi),%ebx /* %ebx = exception start pc */
468 cmp %edx,%ebx /* %ebx = (startpc <= xpc) */
469 jg ex_table_cont /* if (false) continue */
470 mov ExEndPC(%edi),%ebx /* %ebx = exception end pc */
471 cmp %ebx,%edx /* %ebx = (xpc < endpc) */
472 jge ex_table_cont /* if (false) continue */
473 mov ExCatchType(%edi),%ebx /* arg1 = exception catch type */
474 test %ebx,%ebx /* NULL catches everything */
477 cmpl $0,offclassloaded(%ebx) /* check if class is loaded */
481 mov %eax,1*4(%esp) /* save not callee saved regs */
484 mov %ebx,0*4(%esp) /* exception class is argument */
492 cmpl $0,offclasslinked(%ebx)
496 mov %eax,1*4(%esp) /* save not callee saved regs */
499 mov %ebx,0*4(%esp) /* exception class is argument */
507 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
515 mov offobjvftbl(%eax),%esi /* %esi = vftblptr(xptr) */
516 mov offclassvftbl(%ebx),%ebx /* %ebx = vftblptr(catchtype) class (not obj) */
517 mov offbaseval(%esi),%esi /* %esi = baseval(xptr) */
518 mov offbaseval(%ebx),%edx /* %edx = baseval(catchtype) */
519 mov offdiffval(%ebx),%ebx /* %ebx = diffval(catchtype) */
521 sub %edx,%esi /* %esi = baseval(xptr) - baseval(catchtype) */
523 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
527 cmp %ebx,%esi /* xptr is instanceof catchtype */
531 mov ExHandlerPC(%edi),%edx
533 pop %edi /* restore registers */
536 add $8,%esp /* suck %ecx, %edx */
537 pop %eax /* restore xptr */
540 jmp *%edx /* jump to exception handler */
543 lea ExEntrySize(%edi),%edi
552 pop %edx /* restore data segment pointer */
557 push %eax /* save exception pointer */
560 mov IsSync(%edx),%eax /* %eax = SyncOffset */
561 test %eax,%eax /* if zero no monitorexit */
565 mov -4(%eax),%eax /* we have the xptr on the stack */
566 push %edx /* save regs */
568 call builtin_monitorexit
570 pop %edx /* restore regs */
574 add FrameSize(%edx),%eax /* %eax = frame size */
575 add $4,%eax /* we have the xptr on the stack */
577 mov IntSave(%edx),%ecx /* %ecx = saved int register count*/
599 shl $3,%ecx /* multiply by 8 bytes */
603 mov FltSave(%edx),%ecx /* %ecx = saved flt register count */
630 pop %eax /* restore exception pointer */
632 mov FrameSize(%edx),%ecx /* %ecx = frame size */
633 add %ecx,%esp /* unwind stack */
635 pop %ecx /* the new xpc is return address */
638 jmp asm_handle_exception_loop
641 /********************* function asm_check_clinit *******************************
643 * Does null check and calls monitorenter or throws an exception *
645 *******************************************************************************/
648 mov offclassinit(%eax),%ecx /* get initialized flag */
652 sub $16,%esp /* build stack frame (4 * 4 bytes) */
654 call builtin_asm_get_stackframeinfo
664 call class_init /* call class_init function */
672 test %eax,%eax /* we had an exception */
673 je L_initializererror
676 mov (%esp),%eax /* get return address */
677 sub $12,%eax /* asm_putstatic call code size */
678 movb $0xeb,(%eax) /* jmp rel8 */
679 movb $10,1(%eax) /* 8-bit offset */
683 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
684 call builtin_asm_get_exceptionptrptr
686 mov (%ecx),%eax /* get the exception pointer */
687 movl $0,(%ecx) /* clear the exception pointer */
689 lea _exceptionptr,%ecx
690 mov (%ecx),%eax /* get the exception pointer */
691 movl $0,(%ecx) /* clear the exception pointer */
694 pop %ecx /* delete return address */
695 sub $2,%ecx /* faulting address is return adress - 2 */
697 jmp asm_handle_exception
700 /********************* function asm_builtin_monitorenter ***********************
702 * Does null check and calls monitorenter or throws an exception *
704 *******************************************************************************/
706 asm_builtin_monitorenter:
708 je nb_monitorenter /* if (null) throw exception */
709 jmp builtin_monitorenter /* else call builtin_monitorenter */
712 push string_java_lang_NullPointerException
716 pop %ecx /* delete return address */
717 sub $2,%ecx /* faulting address is return adress - 2 */
718 jmp asm_handle_exception
721 /********************* function asm_builtin_monitorexit ************************
723 * Does null check and calls monitorexit or throws an exception *
725 *******************************************************************************/
727 asm_builtin_monitorexit:
730 je nb_monitorexit /* if (null) throw exception */
731 push %ecx /* save registers which could be used */
734 call builtin_monitorexit /* else call builtin_monitorenter */
736 pop %edx /* restore registers which could be used */
741 push string_java_lang_NullPointerException
745 pop %ecx /* delete return address */
746 sub $2,%ecx /* faulting address is return adress - 2 */
747 jmp asm_handle_exception
750 /************************ function asm_builtin_ldiv ****************************
752 * Does null check and calls ldiv or throws an exception *
754 *******************************************************************************/
759 test %eax,%eax /* if (null) throw exception */
765 push string_java_lang_ArithmeticException_message
766 push string_java_lang_ArithmeticException
767 call new_exception_message
770 pop %ecx /* delete return address */
771 sub $2,%ecx /* faulting address is return adress - 2 */
772 jmp asm_handle_exception
775 /************************ function asm_builtin_lrem ****************************
777 * Does null check and calls lrem or throws an exception *
779 *******************************************************************************/
784 test %eax,%eax /* if (null) throw exception */
790 push string_java_lang_ArithmeticException_message
791 push string_java_lang_ArithmeticException
792 call new_exception_message
795 pop %ecx /* delete return address */
796 sub $2,%ecx /* faulting address is return adress - 2 */
797 jmp asm_handle_exception
800 /************************ function asm_builtin_x2x *****************************
802 * Wrapper functions for corner cases *
804 *******************************************************************************/
835 /******************* function asm_builtin_checkarraycast ***********************
837 * Does the cast check and eventually throws an exception *
839 *******************************************************************************/
841 asm_builtin_checkarraycast:
842 sub $8,%esp /* build stack frame (2 * 4 bytes) */
844 mov 12(%esp),%eax /* 8 (frame) + 4 (return) */
845 mov %eax,(%esp) /* save object pointer */
850 call builtin_checkarraycast /* builtin_checkarraycast */
852 test %eax,%eax /* if (false) throw exception */
855 mov 12(%esp),%eax /* return object pointer */
860 push string_java_lang_ClassCastException
866 pop %ecx /* delete return address */
867 sub $2,%ecx /* faulting address is return adress - 2 */
868 jmp asm_handle_exception
871 /******************* function asm_builtin_newarray *****************************
873 * Does the cast check and eventually throws an exception *
875 *******************************************************************************/
877 asm_builtin_newarray:
878 sub $8,%esp /* build stack frame (2 * 4 bytes) */
886 call builtin_newarray
892 /******************* function asm_builtin_aastore ******************************
894 * Does the cast check and eventually throws an exception *
896 *******************************************************************************/
899 sub $12,%esp /* build stack frame (3 * 4 bytes) */
901 mov 16(%esp),%eax /* 12 (frame) + 4 (return) */
902 test %eax,%eax /* if null pointer throw exception */
905 mov offarraysize(%eax),%edx /* load size */
906 mov 24(%esp),%ecx /* index */
907 cmp %edx,%ecx /* do bound check */
908 jae nb_aastore_bound /* if out of bounds throw exception */
910 shl $2,%ecx /* index * 4 */
911 add %eax,%ecx /* add index * 4 to arrayref */
913 mov %ecx,8(%esp) /* save store position */
915 mov 16(%esp),%eax /* 12 (frame) + 4 (return) */
918 mov 32(%esp),%eax /* object is second argument */
921 call builtin_canstore /* builtin_canstore(arrayref,object) */
923 test %eax,%eax /* if (false) throw exception */
928 mov %eax,offobjarrdata(%ecx) /* store objectptr in array */
934 push string_java_lang_NullPointerException
939 pop %ecx /* delete return address */
940 sub $2,%ecx /* faulting address is return adress - 2 */
941 jmp asm_handle_exception
944 push %ecx /* itmp2 contains array index */
945 push string_java_lang_ArrayIndexOutOfBoundsException
946 call new_exception_int
950 pop %ecx /* delete return address */
951 sub $2,%ecx /* faulting address is return adress - 2 */
952 jmp asm_handle_exception
955 push string_java_lang_ArrayStoreException
960 pop %ecx /* delete return address */
961 sub $2,%ecx /* faulting address is return adress - 2 */
962 jmp asm_handle_exception
965 /******************* function asm_builtin_arrayinstanceof **********************
967 * Does the instanceof check of arrays *
969 *******************************************************************************/
971 asm_builtin_arrayinstanceof:
972 sub $8,%esp /* build stack frame (2 * 4 bytes) */
980 call builtin_arrayinstanceof
986 /******************* function asm_initialize_thread_stack **********************
988 * initialized a thread stack *
989 * (to)->restorePoint = asm_initialize_thread_stack((u1*)(func), (to)->stackEnd)*
991 *******************************************************************************/
993 asm_initialize_thread_stack:
994 mov 8(%esp),%eax /* (to)->stackEnd */
995 sub $36,%eax /* 4 bytes * 8 regs + 4 bytes func */
1007 mov 4(%esp),%edx /* save (u1*) (func) */
1010 ret /* return restorepoint in %eax */
1013 /******************* function asm_perform_threadswitch *************************
1015 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1017 * performs a threadswitch *
1019 *******************************************************************************/
1021 asm_perform_threadswitch:
1033 mov 36(%esp),%eax /* save current return address */
1036 mov 40(%esp),%eax /* first argument **from */
1039 mov 48(%esp),%eax /* third argument **stackTop */
1042 mov 44(%esp),%eax /* second argument **to */
1043 mov 0(%eax),%esp /* load new stack pointer */
1049 /* skip stack pointer */
1054 add $32,%esp /* leave return address on stack */
1058 /********************* function asm_switchstackandcall *************************
1060 * int asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
1063 * Switches to a new stack, calls a function and switches back. *
1064 * a0 new stack pointer *
1065 * a1 function pointer *
1066 * a2 pointer to variable where stack top should be stored *
1067 * a3 pointer to user data, is passed to the function *
1069 *******************************************************************************/
1071 asm_switchstackandcall:
1072 mov 4(%esp),%edx /* first argument *stack */
1073 sub $8,%edx /* allocate new stack */
1075 mov (%esp),%eax /* save return address on new stack */
1078 mov %esp,4(%edx) /* save old stack pointer on new stack */
1080 mov 12(%esp),%eax /* third argument **stacktopsave */
1081 mov %esp,(%eax) /* save old stack pointer to variable */
1083 mov 8(%esp),%eax /* load function pointer */
1084 mov 16(%esp),%ecx /* fourth argument *p */
1086 mov %edx,%esp /* switch to new stack */
1089 mov %ecx,0(%esp) /* pass pointer */
1090 call *%eax /* and call function */
1093 mov (%esp),%edx /* load return address */
1094 mov 4(%esp),%esp /* switch to old stack */
1099 Java_java_lang_VMSecurityManager_currentClassLoader:
1100 lea builtin_asm_getclassloader,%eax
1101 push %eax /*store collector function pointer*/
1102 jmp getClassContext_begin
1103 Java_java_lang_VMSecurityManager_getClassContext:
1104 lea builtin_asm_createclasscontextarray,%eax
1105 push %eax /*store collector function pointer*/
1106 getClassContext_begin: /*start the real work*/
1110 sub $68,%esp /*64 memory location without overwriting return adress and collector function adress*/
1111 mov %esp,%ebx /*end of allocated memory block for classpointers is the adress of the working data block +4 */
1112 push $0 /*%esp+32 was native*/
1113 push %eax /*%esp+24 blkbegin*/
1114 push %eax /*%esp+20 currentpos*/
1115 push %ebx /*%esp+16 blkend*/
1117 call builtin_asm_get_threadrootmethod
1118 push %eax /*%esp+12*/
1119 movl 104(%esp),%eax /*(stack contains: threadRootMethod,blkend,blkpos,blkbegin,was native, data(64kB),collector,ret,env,class,frame stack info of stub, we want the frame stack info of thestub*/
1122 push %edx /*esp+8*/ /*position of return address of native stub*/
1123 call builtin_asm_get_stackframeinfo
1124 movl (%eax),%eax /*comment ??*/
1125 push 0(%eax) /*esp+4*/ /*address of frame info block*/
1132 call i386_native_stub_debug
1135 push %edx /*esp+0*/ /*return adress out of native stub*/
1136 call codegen_findmethod /*find calling java method, this one is still to be skipped (==SecurityManager.getClassContext (or .currentClassLoader)*/
1140 movl MethodPointer(%eax),%eax
1142 call temporaryGetClassContextHelper
1144 call traverseStackInfo
1149 movl MethodPointer(%eax),%ebx
1150 movl offclassmethodinfo(%ebx),%ecx
1155 mov 8(%esp),%ebx /*pos of return adress */
1156 add FrameSize(%eax),%ebx
1157 add $4,%ebx /*adress of new return adress (out of Securitymanager.*/
1161 /* by now we have skipped this method call*/
1163 getClassContext_next:
1166 movl %eax,(%esp) /*return adress*/
1168 call codegen_findmethod
1172 add FrameSize(%eax),%ebx
1174 mov %ebx,8(%esp) /*store adress of next return adress*/
1175 getClassContext_nextRetStored:
1177 mov MethodPointer(%eax),%ecx /*get struct methodinfo*/
1180 je getClassContext_nativeCall
1181 /*save class pointer*/
1183 getClassContext_saveClassPointer:
1184 movl 20(%esp),%ebx /*get temporary memory adress in stack*/
1185 movl offclassmethodinfo(%ecx),%edx /* get class pointer of method*/
1186 movl %edx,(%ebx) /*save */
1187 sub $4,%ebx /*calculate next position */
1188 movl %ebx,20(%esp) /* check if the new adress would overwrite our working data */
1190 je getClassContext_incStack
1191 getClassContext_checkLeave:
1193 cmp 12(%esp),%ecx /*check if we reached the toplevel method of our thread*/
1194 je getClassContext_leave /*yes ->leave*/
1198 call temporaryGetClassContextHelper
1202 jmp getClassContext_next /*continue*/
1205 getClassContext_nativeCall:
1207 movl 4(%esp),%eax /*get top most element on stackframe help information stack*/
1216 je getClassContext_checkLeave
1217 jmp getClassContext_saveClassPointer
1219 getClassContext_incStack:
1220 /*make another 64 in our temporary storage free and store the workingdata */
1222 subl $40,%esp /*should be 32*/
1234 jmp getClassContext_checkLeave /* continue */
1236 getClassContext_leave:
1239 call temporaryGetClassContextHelper*/
1241 /*call collector function with begin/end of temporary classarray*/
1250 /* free stack memory of this function*/
1256 asm_throw_and_handle_hardware_nullpointer_exception:
1257 sub $20,%esp /*build stack frame*/
1258 mov %ecx,16(%esp) /*save eip of problem */
1260 movl $0,12(%esp) /*internal function -> no function description */
1261 call builtin_asm_get_stackframeinfo
1269 mov string_java_lang_NullPointerException,%eax
1279 jmp asm_handle_exception
1280 ret /*should never be reached */
1282 asm_throw_and_handle_hardware_arithmetic_exception:
1283 sub $24,%esp /*build stack frame*/
1284 mov %ecx,20(%esp) /*save eip of problem */
1286 movl $0,16(%esp) /*internal function -> no function description */
1287 call builtin_asm_get_stackframeinfo
1295 mov string_java_lang_ArithmeticException,%eax
1297 mov string_java_lang_ArithmeticException_message,%eax
1300 call new_exception_message
1309 jmp asm_handle_exception
1310 ret /*should never be reached */
1313 /*optimize a littlebit */
1317 call i386_native_stub_debug
1321 mov offclassinit(%eax),%ecx /* get initialized flag */
1323 jnz L_builtin_new_noinit
1325 sub $16,%esp /* build stack frame (4 * 4 bytes) */
1330 call builtin_asm_get_stackframeinfo
1347 jmp L_builtin_new_patch
1350 L_builtin_new_noinit:
1355 /*jmp L_builtin_new_patch*/
1357 L_builtin_new_patch:
1358 /*add patching code here */
1359 lea builtin_new,%edx
1361 mov %edx,-6(%ecx) /*patch calling instruction, t directly call builtin_new the next time*/
1369 push %ebp /*(%ebp-4)*/
1372 push %edi /*(%ebp-8)*/
1373 push %esi /*(%ebp-12)*/
1374 push %ebx /*(%ebp-16)*/
1375 call builtin_asm_get_stackframeinfo
1377 pushl 0(%eax) /*(%ebp-20)*/
1379 call builtin_asm_get_threadrootmethod
1380 pushl %eax /*(%ebp-24)*/
1383 asm_get_stackTraceLoop:
1384 call codegen_findmethod
1387 pushl $1 /*no indent*/
1392 get_stackTrace_line:
1393 movl LineNumberTableSize(%esi),%ecx
1394 test %ecx,%ecx /* skip if empty line table */
1395 je get_stackTrace_noLineInfo
1397 movl LineNumberTableStart(%esi),%ebx
1399 get_stackTrace_lineLoop:
1400 cmp %edx,LinePC(%ebx)
1401 jg get_stackTrace_nextLineInfo
1403 pushl LineLine(%ebx)
1404 jmp get_stackTrace_cont
1406 get_stackTrace_nextLineInfo:
1407 lea LineEntrySize(%ebx),%ebx
1411 jne get_stackTrace_lineLoop
1413 get_stackTrace_noLineInfo:
1417 get_stackTrace_cont:
1419 pushl MethodPointer(%esi)
1420 pushl $0 /*8(%ebp)*/ /*exception ptr*/
1421 call builtin_trace_exception
1424 movl MethodPointer(%esi),%eax
1427 je get_stackTrace_nat
1430 je get_stackTrace_leave
1432 mov FrameSize(%esi),%eax
1436 jmp asm_get_stackTraceLoop
1442 je get_stackTrace_leave
1449 jmp asm_get_stackTraceLoop
1451 get_stackTrace_leave:
1457 call builtin_stacktrace_copy
1466 asm_getclassvalues_atomic:
1468 mov 4(%esp),%ecx /* super */
1469 mov 8(%esp),%edx /* sub */
1471 mov offbaseval(%ecx),%eax
1472 mov offdiffval(%ecx),%ecx
1473 mov offbaseval(%edx),%edx
1476 mov 16(%esp),%ebx /* out */
1477 mov %eax,offcast_super_baseval(%ebx)
1478 mov %ecx,offcast_super_diffval(%ebx)
1479 mov %edx,offcast_sub_baseval(%ebx)
1485 asm_criticalsections:
1486 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
1489 .long _crit_restart1
1492 .long _crit_restart2
1497 * These are local overrides for various environment variables in Emacs.
1498 * Please do not remove this and leave it at the end of the file, where
1499 * Emacs will automagically detect them.
1500 * ---------------------------------------------------------------------
1503 * indent-tabs-mode: t