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 1039 2004-04-26 16:50:00Z twisti $
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
67 /********************* exported functions and variables ***********************/
69 .globl asm_calljavafunction
70 .globl asm_calljavafunction2
71 .globl asm_calljavafunction2long
72 .globl asm_calljavafunction2double
74 .globl asm_call_jit_compiler
75 .globl asm_handle_builtin_exception
76 .globl asm_handle_nat_exception
77 .globl asm_handle_exception
78 .globl asm_check_clinit
79 .globl asm_builtin_checkcast
80 .globl asm_builtin_checkarraycast
81 .globl asm_builtin_newarray
82 .globl asm_builtin_anewarray
83 .globl asm_builtin_newarray_array
84 .globl asm_builtin_aastore
85 .globl asm_builtin_monitorenter
86 .globl asm_builtin_monitorexit
87 .globl asm_builtin_ldiv
88 .globl asm_builtin_lrem
89 .globl asm_builtin_f2i
90 .globl asm_builtin_f2l
91 .globl asm_builtin_d2i
92 .globl asm_builtin_d2l
93 .globl asm_builtin_arrayinstanceof
94 .globl asm_perform_threadswitch
95 .globl asm_initialize_thread_stack
96 .globl asm_switchstackandcall
97 .globl asm_getcallingmethod
98 .globl Java_java_lang_VMSecurityManager_getClassContext
99 .globl Java_java_lang_VMSecurityManager_currentClassLoader
100 .globl asm_builtin_new
101 .globl asm_get_stackTrace
104 /*************************** imported functions *******************************/
107 .globl builtin_monitorexit
108 .globl builtin_throw_exception
109 .globl builtin_trace_exception
110 .globl class_java_lang_Object
112 .globl builtin_asm_createclasscontextarray
113 .globl builtin_asm_getclassloader
114 .globl callgetexceptionptrptr
115 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
121 /********************* function asm_calljavafunction ***************************
123 * This function calls a Java-method (which possibly needs compilation) *
124 * with up to 4 address parameters. *
126 * This functions calls the JIT-compiler which eventually translates the *
127 * method into machine code. *
130 * javaobject_header *asm_calljavamethod (methodinfo *m, *
131 * void *arg1, void *arg2, void *arg3, void *arg4); *
133 *******************************************************************************/
136 .ascii "calljavafunction\0\0"
139 .long 0 /* catch type all */
140 .long calljava_xhandler /* handler pc */
141 .long calljava_xhandler /* end pc */
142 .long asm_calljavafunction /* start pc */
143 .long 1 /* extable size */
144 .long 0 /* line number table start */
145 .long 0 /* line number table size */
146 .long 0 /* fltsave */
147 .long 0 /* intsave */
150 .long 32 /* frame size */
151 .long 0 /* method pointer (pointer to name) */
153 asm_calljavafunction:
154 push %ebp /* allocate stack space */
157 push %ebx /* save registers */
161 sub $32,%esp /* pass the remaining parameters */
164 mov %edx,28(%esp) /* convert parms to 8 byte */
180 mov 8(%ebp),%eax /* move function pointer to %eax */
182 lea asm_call_jit_compiler,%edx
183 call *%edx /* call JIT compiler */
187 pop %edi /* restore registers */
194 push %eax /* pass exception pointer */
195 call builtin_throw_exception
199 pop %edi /* restore registers */
206 /********************* function asm_calljavafunction ***************************
208 * This function calls a Java-method (which possibly needs compilation) *
209 * with up to 4 address parameters. *
211 * This functions calls the JIT-compiler which eventually translates the *
212 * method into machine code. *
215 * javaobject_header *asm_calljavafunction2(methodinfo *m, *
216 * u4 count, u4 size, void *callblock); *
218 *******************************************************************************/
221 .ascii "calljavafunction2\0\0"
224 .long 0 /* catch type all */
225 .long calljava_xhandler2 /* handler pc */
226 .long calljava_xhandler2 /* end pc */
227 .long asm_calljavafunction2 /* start pc */
228 .long 1 /* extable size */
229 .long 0 /* line number table start */
230 .long 0 /* line number table size */
231 .long 0 /* fltsave */
232 .long 0 /* intsave */
235 .long 32 /* frame size */
236 .long 0 /* method pointer (pointer to name) */
238 asm_calljavafunction2:
239 asm_calljavafunction2double:
240 asm_calljavafunction2long:
242 mov %esp,%ebp /* save stackptr */
244 push %ebx /* save registers */
248 mov 20(%ebp),%eax /* pointer to arg block */
249 mov 12(%ebp),%ecx /* arg count */
250 test %ecx,%ecx /* maybe we have no args */
251 jle calljava_copydone
253 mov %ecx,%edx /* calculate stack size */
255 mov %edx,%esi /* save in callee saved register */
256 sub %esi,%esp /* stack frame for arguments */
260 mov offjniitem(%eax),%edx
262 mov offjniitem+4(%eax),%edx
265 sub $1,%ecx /* are there any args left? */
267 jle calljava_copydone
269 add $sizejniblock,%eax /* goto next argument block */
270 add $8,%edi /* increase sp to next argument */
271 jmp calljava_copyloop
274 mov 8(%ebp),%eax /* move function pointer to %eax */
276 lea asm_call_jit_compiler,%edx
277 call *%edx /* call JIT compiler */
280 add %esi,%esp /* remove arg stack frame */
281 pop %edi /* restore registers */
288 push %eax /* pass exception pointer */
289 call builtin_throw_exception
292 add %esi,%esp /* remove arg stack frame */
293 pop %edi /* restore registers */
300 /****************** function asm_call_jit_compiler *****************************
302 * invokes the compiler for untranslated JavaVM methods. *
304 * Register R0 contains a pointer to the method info structure (prepared *
305 * by createcompilerstub). Using the return address in R26 and the *
306 * offset in the LDA instruction or using the value in methodptr R28 the *
307 * patching address for storing the method address can be computed: *
309 * method address was either loaded using *
311 * i386_mov_imm_reg(a, REG_ITMP2) ; invokestatic/special *
312 * i386_call_reg(REG_ITMP2) *
316 * i386_mov_membase_reg(REG_SP, 0, REG_ITMP1) ; invokevirtual/interface *
317 * i386_mov_membase_reg(REG_ITMP1, OFFSET(, vftbl), REG_ITMP2) *
318 * i386_mov_membase_reg(REG_ITMP2, OFFSET(vftbl, table[0]) + \ *
319 * sizeof(methodptr) * m->vftblindex, REG_ITMP1) *
320 * i386_call_reg(REG_ITMP1) *
322 * in the static case the method pointer can be computed using the *
323 * return address and the lda function following the jmp instruction *
325 *******************************************************************************/
327 asm_call_jit_compiler:
328 push %ebx /* save register */
331 mov 8(%esp),%ebp /* get return address (2 push) */
332 mov -1(%ebp),%bl /* get function code */
333 cmp $0xd1,%bl /* called with `call *REG_ITMP2' (%ecx)? */
334 jne L_not_static_special
336 sub $6,%ebp /* calculate address of immediate */
337 jmp L_call_jit_compile
339 L_not_static_special:
340 cmp $0xd0,%bl /* called with `call *REG_ITMP1' (%eax) */
341 jne L_not_virtual_interface
343 sub $6,%ebp /* calculate address of offset */
344 mov (%ebp),%ebp /* get offset */
345 add %ecx,%ebp /* add base address to get method address */
346 jmp L_call_jit_compile
348 L_not_virtual_interface: /* a call from asm_calljavafunction */
352 push %ebp /* save address for method pointer */
354 push %eax /* push methodpointer on stack */
358 pop %ebp /* restore address for method pointer */
359 test %ebp,%ebp /* is address == 0 (asm_calljavafunction) */
362 mov %eax,(%ebp) /* and now save the new pointer */
365 pop %ebp /* restore registers */
368 jmp *%eax /* ...and now call the new method */
371 /********************* function asm_handle_exception ***************************
373 * This function handles an exception. It does not use the usual calling *
374 * conventions. The exception pointer is passed in REG_ITMP1 and the *
375 * pc from the exception raising position is passed in REG_ITMP2. It searches *
376 * the local exception table for a handler. If no one is found, it unwinds *
377 * stacks and continues searching the callers. *
379 * void asm_handle_exception (exceptionptr, exceptionpc); *
381 *******************************************************************************/
383 asm_handle_nat_exception:
384 add $4,%esp /* clear return address of native stub */
386 asm_handle_exception:
390 push %eax /* exception pointer */
391 push %ecx /* excepiton pc */
393 call asm_get_stackTrace
399 asm_handle_exception_loop:
403 push %eax /* save exception pointer */
404 push %ecx /* save exception pc */
406 call findmethod /* get the data segment ptr */
410 mov -8(%ebp),%ecx /* could be changed in findmethod */
412 push %edx /* save data segment pointer */
419 mov %eax,(%esp) /* exception pointer */
420 mov MethodPointer(%edx),%eax /* method pointer */
422 mov %ecx,8(%esp) /* exception pc */
423 movl $0,12(%esp) /* line number */
424 movl $1,16(%esp) /* set no unwind flag */
425 call builtin_trace_exception
427 mov -12(%ebp),%esi /* %esi = data segment pointer */
428 mov ExTableSize(%esi),%ecx /* %ecx = exception table size */
429 test %ecx,%ecx /* if empty table skip */
432 lea ExTableStart(%esi),%edi /* %edi = start of exception table*/
433 mov -4(%ebp),%eax /* get xptr */
436 mov -8(%ebp),%edx /* get xpc */
438 mov ExStartPC(%edi),%ebx /* %ebx = exception start pc */
439 cmp %edx,%ebx /* %ebx = (startpc <= xpc) */
440 jg ex_table_cont /* if (false) continue */
441 mov ExEndPC(%edi),%ebx /* %ebx = exception end pc */
442 cmp %ebx,%edx /* %ebx = (xpc < endpc) */
443 jge ex_table_cont /* if (false) continue */
444 mov ExCatchType(%edi),%ebx /* arg1 = exception catch type */
445 test %ebx,%ebx /* NULL catches everything */
449 cmpl $0,offclassloaded(%ebx) /* check if class is loaded */
452 push %eax /* save not callee saved regs */
455 push %ebx /* exception class is argument */
463 cmpl $0,offclasslinked(%ebx)
466 push %eax /* save not callee saved regs */
469 push %ebx /* exception class is argument */
478 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
479 push %eax /* save not callee saved regs */
486 mov offobjvftbl(%eax),%esi /* %esi = vftblptr(xptr) */
487 mov offclassvftbl(%ebx),%ebx /* %ebx = vftblptr(catchtype) class (not obj) */
488 mov offbaseval(%esi),%esi /* %esi = baseval(xptr) */
489 mov offbaseval(%ebx),%edx /* %edx = baseval(catchtype) */
490 mov offdiffval(%ebx),%ebx /* %ebx = diffval(catchtype) */
491 sub %edx,%esi /* %esi = baseval(xptr) - baseval(catchtype) */
493 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
494 push %eax /* save not callee saved regs */
501 cmp %ebx,%esi /* xptr is instanceof catchtype */
505 mov ExHandlerPC(%edi),%edx
507 pop %edi /* restore registers */
510 add $8,%esp /* suck %ecx, %edx */
511 pop %eax /* restore xptr */
514 jmp *%edx /* jump to exception handler */
517 lea ExEntrySize(%edi),%edi
526 pop %edx /* restore data segment pointer */
531 push %eax /* save exception pointer */
534 mov IsSync(%edx),%eax /* %eax = SyncOffset */
535 test %eax,%eax /* if zero no monitorexit */
539 mov -4(%eax),%eax /* we have the xptr on the stack */
540 push %edx /* save regs */
542 call builtin_monitorexit
544 pop %edx /* restore regs */
548 add FrameSize(%edx),%eax /* %eax = frame size */
549 add $4,%eax /* we have the xptr on the stack */
551 mov IntSave(%edx),%ecx /* %ecx = saved int register count*/
573 shl $3,%ecx /* multiply by 8 bytes */
577 mov FltSave(%edx),%ecx /* %ecx = saved flt register count */
604 pop %eax /* restore exception pointer */
606 mov FrameSize(%edx),%ecx /* %ecx = frame size */
607 add %ecx,%esp /* unwind stack */
609 pop %ecx /* the new xpc is return address */
612 jmp asm_handle_exception_loop
615 /********************* function asm_check_clinit *******************************
617 * Does null check and calls monitorenter or throws an exception *
619 *******************************************************************************/
622 mov offclassinit(%eax),%ecx /* get initialized flag */
626 sub $16,%esp /* build stack frame (4 * 4 bytes) */
628 call builtin_asm_get_stackframeinfo
638 call class_init /* call class_init function */
646 test %eax,%eax /* we had an exception */
647 je L_initializererror
650 mov (%esp),%eax /* get return address */
651 sub $12,%eax /* asm_putstatic call code size */
652 movb $0xeb,(%eax) /* jmp rel8 */
653 movb $10,1(%eax) /* 8-bit offset */
657 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
658 call builtin_asm_get_exceptionptrptr
660 mov (%ecx),%eax /* get the exception pointer */
661 movl $0,(%ecx) /* clear the exception pointer */
663 lea _exceptionptr,%ecx
664 mov (%ecx),%eax /* get the exception pointer */
665 movl $0,(%ecx) /* clear the exception pointer */
668 pop %ecx /* delete return address */
669 sub $2,%ecx /* faulting address is return adress - 2 */
671 jmp asm_handle_exception
674 /********************* function asm_builtin_monitorenter ***********************
676 * Does null check and calls monitorenter or throws an exception *
678 *******************************************************************************/
680 asm_builtin_monitorenter:
682 je nb_monitorenter /* if (null) throw exception */
683 jmp builtin_monitorenter /* else call builtin_monitorenter */
686 push string_java_lang_NullPointerException
690 pop %ecx /* delete return address */
691 sub $2,%ecx /* faulting address is return adress - 2 */
692 jmp asm_handle_exception
695 /********************* function asm_builtin_monitorexit ************************
697 * Does null check and calls monitorexit or throws an exception *
699 *******************************************************************************/
701 asm_builtin_monitorexit:
704 je nb_monitorexit /* if (null) throw exception */
705 push %ecx /* save registers which could be used */
708 call builtin_monitorexit /* else call builtin_monitorenter */
710 pop %edx /* restore registers which could be used */
715 push string_java_lang_NullPointerException
719 pop %ecx /* delete return address */
720 sub $2,%ecx /* faulting address is return adress - 2 */
721 jmp asm_handle_exception
724 /************************ function asm_builtin_ldiv ****************************
726 * Does null check and calls ldiv or throws an exception *
728 *******************************************************************************/
733 test %eax,%eax /* if (null) throw exception */
739 push string_java_lang_ArithmeticException_message
740 push string_java_lang_ArithmeticException
741 call new_exception_message
744 pop %ecx /* delete return address */
745 sub $2,%ecx /* faulting address is return adress - 2 */
746 jmp asm_handle_exception
749 /************************ function asm_builtin_lrem ****************************
751 * Does null check and calls lrem or throws an exception *
753 *******************************************************************************/
758 test %eax,%eax /* if (null) throw exception */
764 push string_java_lang_ArithmeticException_message
765 push string_java_lang_ArithmeticException
766 call new_exception_message
769 pop %ecx /* delete return address */
770 sub $2,%ecx /* faulting address is return adress - 2 */
771 jmp asm_handle_exception
774 /************************ function asm_builtin_x2x *****************************
776 * Wrapper functions for corner cases *
778 *******************************************************************************/
809 /******************* function asm_builtin_checkarraycast ***********************
811 * Does the cast check and eventually throws an exception *
813 *******************************************************************************/
815 asm_builtin_checkarraycast:
816 sub $8,%esp /* build stack frame (2 * 4 bytes) */
818 mov 12(%esp),%eax /* 8 (frame) + 4 (return) */
819 mov %eax,(%esp) /* save object pointer */
824 call builtin_checkarraycast /* builtin_checkarraycast */
826 test %eax,%eax /* if (false) throw exception */
829 mov 12(%esp),%eax /* return object pointer */
834 push string_java_lang_ClassCastException
840 pop %ecx /* delete return address */
841 sub $2,%ecx /* faulting address is return adress - 2 */
842 jmp asm_handle_exception
845 /******************* function asm_builtin_newarray *****************************
847 * Does the cast check and eventually throws an exception *
849 *******************************************************************************/
851 asm_builtin_newarray:
852 sub $8,%esp /* build stack frame (2 * 4 bytes) */
860 call builtin_newarray
866 /******************* function asm_builtin_aastore ******************************
868 * Does the cast check and eventually throws an exception *
870 *******************************************************************************/
873 sub $12,%esp /* build stack frame (3 * 4 bytes) */
875 mov 16(%esp),%eax /* 12 (frame) + 4 (return) */
876 test %eax,%eax /* if null pointer throw exception */
879 mov offarraysize(%eax),%edx /* load size */
880 mov 24(%esp),%ecx /* index */
881 cmp %edx,%ecx /* do bound check */
882 jae nb_aastore_bound /* if out of bounds throw exception */
884 shl $2,%ecx /* index * 4 */
885 add %eax,%ecx /* add index * 4 to arrayref */
887 mov %ecx,8(%esp) /* save store position */
889 mov 16(%esp),%eax /* 12 (frame) + 4 (return) */
892 mov 32(%esp),%eax /* object is second argument */
895 call builtin_canstore /* builtin_canstore(arrayref,object) */
897 test %eax,%eax /* if (false) throw exception */
902 mov %eax,offobjarrdata(%ecx) /* store objectptr in array */
908 push string_java_lang_NullPointerException
913 pop %ecx /* delete return address */
914 sub $2,%ecx /* faulting address is return adress - 2 */
915 jmp asm_handle_exception
918 push %ecx /* itmp2 contains array index */
919 push string_java_lang_ArrayIndexOutOfBoundsException
920 call new_exception_int
924 pop %ecx /* delete return address */
925 sub $2,%ecx /* faulting address is return adress - 2 */
926 jmp asm_handle_exception
929 push string_java_lang_ArrayStoreException
934 pop %ecx /* delete return address */
935 sub $2,%ecx /* faulting address is return adress - 2 */
936 jmp asm_handle_exception
939 /******************* function asm_builtin_arrayinstanceof **********************
941 * Does the instanceof check of arrays *
943 *******************************************************************************/
945 asm_builtin_arrayinstanceof:
946 sub $8,%esp /* build stack frame (2 * 4 bytes) */
954 call builtin_arrayinstanceof
960 /******************* function asm_initialize_thread_stack **********************
962 * initialized a thread stack *
963 * (to)->restorePoint = asm_initialize_thread_stack((u1*)(func), (to)->stackEnd)*
965 *******************************************************************************/
967 asm_initialize_thread_stack:
968 mov 8(%esp),%eax /* (to)->stackEnd */
969 sub $36,%eax /* 4 bytes * 8 regs + 4 bytes func */
981 mov 4(%esp),%edx /* save (u1*) (func) */
984 ret /* return restorepoint in %eax */
987 /******************* function asm_perform_threadswitch *************************
989 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
991 * performs a threadswitch *
993 *******************************************************************************/
995 asm_perform_threadswitch:
1007 mov 36(%esp),%eax /* save current return address */
1010 mov 40(%esp),%eax /* first argument **from */
1013 mov 48(%esp),%eax /* third argument **stackTop */
1016 mov 44(%esp),%eax /* second argument **to */
1017 mov 0(%eax),%esp /* load new stack pointer */
1023 /* skip stack pointer */
1028 add $32,%esp /* leave return address on stack */
1032 /********************* function asm_switchstackandcall *************************
1034 * int asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
1037 * Switches to a new stack, calls a function and switches back. *
1038 * a0 new stack pointer *
1039 * a1 function pointer *
1040 * a2 pointer to variable where stack top should be stored *
1041 * a3 pointer to user data, is passed to the function *
1043 *******************************************************************************/
1045 asm_switchstackandcall:
1046 mov 4(%esp),%edx /* first argument *stack */
1047 sub $8,%edx /* allocate new stack */
1049 mov (%esp),%eax /* save return address on new stack */
1052 mov %esp,4(%edx) /* save old stack pointer on new stack */
1054 mov 12(%esp),%eax /* third argument **stacktopsave */
1055 mov %esp,(%eax) /* save old stack pointer to variable */
1057 mov 8(%esp),%eax /* load function pointer */
1058 mov 16(%esp),%ecx /* fourth argument *p */
1060 mov %edx,%esp /* switch to new stack */
1063 mov %ecx,0(%esp) /* pass pointer */
1064 call *%eax /* and call function */
1067 mov (%esp),%edx /* load return address */
1068 mov 4(%esp),%esp /* switch to old stack */
1073 Java_java_lang_VMSecurityManager_currentClassLoader:
1074 lea builtin_asm_getclassloader,%eax
1075 push %eax /*store collector function pointer*/
1076 jmp getClassContext_begin
1077 Java_java_lang_VMSecurityManager_getClassContext:
1078 lea builtin_asm_createclasscontextarray,%eax
1079 push %eax /*store collector function pointer*/
1080 getClassContext_begin: /*start the real work*/
1084 sub $68,%esp /*64 memory location without overwriting return adress and collector function adress*/
1085 mov %esp,%ebx /*end of allocated memory block for classpointers is the adress of the working data block +4 */
1086 push $0 /*%esp+32 was native*/
1087 push %eax /*%esp+24 blkbegin*/
1088 push %eax /*%esp+20 currentpos*/
1089 push %ebx /*%esp+16 blkend*/
1091 call builtin_asm_get_threadrootmethod
1092 push %eax /*%esp+12*/
1093 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*/
1096 push %edx /*esp+8*/ /*position of return address of native stub*/
1097 call builtin_asm_get_stackframeinfo
1098 movl (%eax),%eax /*comment ??*/
1099 push 0(%eax) /*esp+4*/ /*address of frame info block*/
1106 call i386_native_stub_debug
1109 push %edx /*esp+0*/ /*return adress out of native stub*/
1110 call findmethod /*find calling java method, this one is still to be skipped (==SecurityManager.getClassContext (or .currentClassLoader)*/
1114 movl MethodPointer(%eax),%eax
1116 call temporaryGetClassContextHelper
1118 call traverseStackInfo
1123 movl MethodPointer(%eax),%ebx
1124 movl offclassmethodinfo(%ebx),%ecx
1129 mov 8(%esp),%ebx /*pos of return adress */
1130 add FrameSize(%eax),%ebx
1131 add $4,%ebx /*adress of new return adress (out of Securitymanager.*/
1135 /* by now we have skipped this method call*/
1137 getClassContext_next:
1140 movl %eax,(%esp) /*return adress*/
1146 add FrameSize(%eax),%ebx
1148 mov %ebx,8(%esp) /*store adress of next return adress*/
1149 getClassContext_nextRetStored:
1151 mov MethodPointer(%eax),%ecx /*get struct methodinfo*/
1154 je getClassContext_nativeCall
1155 /*save class pointer*/
1157 getClassContext_saveClassPointer:
1158 movl 20(%esp),%ebx /*get temporary memory adress in stack*/
1159 movl offclassmethodinfo(%ecx),%edx /* get class pointer of method*/
1160 movl %edx,(%ebx) /*save */
1161 sub $4,%ebx /*calculate next position */
1162 movl %ebx,20(%esp) /* check if the new adress would overwrite our working data */
1164 je getClassContext_incStack
1165 getClassContext_checkLeave:
1167 cmp 12(%esp),%ecx /*check if we reached the toplevel method of our thread*/
1168 je getClassContext_leave /*yes ->leave*/
1172 call temporaryGetClassContextHelper
1176 jmp getClassContext_next /*continue*/
1179 getClassContext_nativeCall:
1181 movl 4(%esp),%eax /*get top most element on stackframe help information stack*/
1190 je getClassContext_checkLeave
1191 jmp getClassContext_saveClassPointer
1193 getClassContext_incStack:
1194 /*make another 64 in our temporary storage free and store the workingdata */
1196 subl $40,%esp /*should be 32*/
1208 jmp getClassContext_checkLeave /* continue */
1210 getClassContext_leave:
1213 call temporaryGetClassContextHelper*/
1215 /*call collector function with begin/end of temporary classarray*/
1224 /* free stack memory of this function*/
1231 /*optimize a littlebit */
1235 call i386_native_stub_debug
1239 mov offclassinit(%eax),%ecx /* get initialized flag */
1241 jnz L_builtin_new_noinit
1243 sub $16,%esp /* build stack frame (4 * 4 bytes) */
1248 call builtin_asm_get_stackframeinfo
1265 jmp L_builtin_new_patch
1268 L_builtin_new_noinit:
1273 /*jmp L_builtin_new_patch*/
1275 L_builtin_new_patch:
1276 /*add patching code here */
1277 lea builtin_new,%edx
1279 mov %edx,-6(%ecx) /*patch calling instruction, t directly call builtin_new the next time*/
1287 push %ebp /*(%ebp-4)*/
1290 push %edi /*(%ebp-8)*/
1291 push %esi /*(%ebp-12)*/
1292 push %ebx /*(%ebp-16)*/
1293 call builtin_asm_get_stackframeinfo
1295 pushl 0(%eax) /*(%ebp-20)*/
1297 call builtin_asm_get_threadrootmethod
1298 pushl %eax /*(%ebp-24)*/
1301 asm_get_stackTraceLoop:
1305 pushl $1 /*no indent*/
1310 get_stackTrace_line:
1311 movl LineNumberTableSize(%esi),%ecx
1312 test %ecx,%ecx /* skip if empty line table */
1313 je get_stackTrace_noLineInfo
1315 movl LineNumberTableStart(%esi),%ebx
1317 get_stackTrace_lineLoop:
1318 cmp %edx,LinePC(%ebx)
1319 jg get_stackTrace_nextLineInfo
1321 pushl LineLine(%ebx)
1322 jmp get_stackTrace_cont
1324 get_stackTrace_nextLineInfo:
1325 lea LineEntrySize(%ebx),%ebx
1329 jne get_stackTrace_lineLoop
1331 get_stackTrace_noLineInfo:
1335 get_stackTrace_cont:
1337 pushl MethodPointer(%esi)
1338 pushl $0 /*8(%ebp)*/ /*exception ptr*/
1339 call builtin_trace_exception
1342 movl MethodPointer(%esi),%eax
1345 je get_stackTrace_nat
1348 je get_stackTrace_leave
1350 mov FrameSize(%esi),%eax
1354 jmp asm_get_stackTraceLoop
1360 je get_stackTrace_leave
1367 jmp asm_get_stackTraceLoop
1369 get_stackTrace_leave:
1375 call builtin_stacktrace_copy
1385 * These are local overrides for various environment variables in Emacs.
1386 * Please do not remove this and leave it at the end of the file, where
1387 * Emacs will automagically detect them.
1388 * ---------------------------------------------------------------------
1391 * indent-tabs-mode: t