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 1072 2004-05-19 17:20:12Z stefan $
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
102 .globl asm_criticalsections
103 .globl asm_getclassvalues_atomic
105 /*************************** imported functions *******************************/
108 .globl builtin_monitorexit
109 .globl builtin_throw_exception
110 .globl builtin_trace_exception
111 .globl class_java_lang_Object
113 .globl builtin_asm_createclasscontextarray
114 .globl builtin_asm_getclassloader
115 .globl callgetexceptionptrptr
118 /********************* function asm_calljavafunction ***************************
120 * This function calls a Java-method (which possibly needs compilation) *
121 * with up to 4 address parameters. *
123 * This functions calls the JIT-compiler which eventually translates the *
124 * method into machine code. *
127 * javaobject_header *asm_calljavamethod (methodinfo *m, *
128 * void *arg1, void *arg2, void *arg3, void *arg4); *
130 *******************************************************************************/
133 .ascii "calljavafunction\0\0"
136 .long 0 /* catch type all */
137 .long calljava_xhandler /* handler pc */
138 .long calljava_xhandler /* end pc */
139 .long asm_calljavafunction /* start pc */
140 .long 1 /* extable size */
141 .long 0 /* line number table start */
142 .long 0 /* line number table size */
143 .long 0 /* fltsave */
144 .long 0 /* intsave */
147 .long 32 /* frame size */
148 .long 0 /* method pointer (pointer to name) */
150 asm_calljavafunction:
151 push %ebp /* allocate stack space */
154 push %ebx /* save registers */
158 sub $32,%esp /* pass the remaining parameters */
161 mov %edx,28(%esp) /* convert parms to 8 byte */
177 mov 8(%ebp),%eax /* move function pointer to %eax */
179 lea asm_call_jit_compiler,%edx
180 call *%edx /* call JIT compiler */
184 pop %edi /* restore registers */
191 push %eax /* pass exception pointer */
192 call builtin_throw_exception
196 pop %edi /* restore registers */
203 /********************* function asm_calljavafunction ***************************
205 * This function calls a Java-method (which possibly needs compilation) *
206 * with up to 4 address parameters. *
208 * This functions calls the JIT-compiler which eventually translates the *
209 * method into machine code. *
212 * javaobject_header *asm_calljavafunction2(methodinfo *m, *
213 * u4 count, u4 size, void *callblock); *
215 *******************************************************************************/
218 .ascii "calljavafunction2\0\0"
221 .long 0 /* catch type all */
222 .long calljava_xhandler2 /* handler pc */
223 .long calljava_xhandler2 /* end pc */
224 .long asm_calljavafunction2 /* start pc */
225 .long 1 /* extable size */
226 .long 0 /* line number table start */
227 .long 0 /* line number table size */
228 .long 0 /* fltsave */
229 .long 0 /* intsave */
232 .long 32 /* frame size */
233 .long 0 /* method pointer (pointer to name) */
235 asm_calljavafunction2:
236 asm_calljavafunction2double:
237 asm_calljavafunction2long:
239 mov %esp,%ebp /* save stackptr */
241 push %ebx /* save registers */
245 mov 20(%ebp),%eax /* pointer to arg block */
246 mov 12(%ebp),%ecx /* arg count */
247 test %ecx,%ecx /* maybe we have no args */
248 jle calljava_copydone
250 mov %ecx,%edx /* calculate stack size */
252 mov %edx,%esi /* save in callee saved register */
253 sub %esi,%esp /* stack frame for arguments */
257 mov offjniitem(%eax),%edx
259 mov offjniitem+4(%eax),%edx
262 sub $1,%ecx /* are there any args left? */
264 jle calljava_copydone
266 add $sizejniblock,%eax /* goto next argument block */
267 add $8,%edi /* increase sp to next argument */
268 jmp calljava_copyloop
271 mov 8(%ebp),%eax /* move function pointer to %eax */
273 lea asm_call_jit_compiler,%edx
274 call *%edx /* call JIT compiler */
277 add %esi,%esp /* remove arg stack frame */
278 pop %edi /* restore registers */
285 push %eax /* pass exception pointer */
286 call builtin_throw_exception
289 add %esi,%esp /* remove arg stack frame */
290 pop %edi /* restore registers */
297 /****************** function asm_call_jit_compiler *****************************
299 * invokes the compiler for untranslated JavaVM methods. *
301 * Register R0 contains a pointer to the method info structure (prepared *
302 * by createcompilerstub). Using the return address in R26 and the *
303 * offset in the LDA instruction or using the value in methodptr R28 the *
304 * patching address for storing the method address can be computed: *
306 * method address was either loaded using *
308 * i386_mov_imm_reg(a, REG_ITMP2) ; invokestatic/special *
309 * i386_call_reg(REG_ITMP2) *
313 * i386_mov_membase_reg(REG_SP, 0, REG_ITMP1) ; invokevirtual/interface *
314 * i386_mov_membase_reg(REG_ITMP1, OFFSET(, vftbl), REG_ITMP2) *
315 * i386_mov_membase_reg(REG_ITMP2, OFFSET(vftbl, table[0]) + \ *
316 * sizeof(methodptr) * m->vftblindex, REG_ITMP1) *
317 * i386_call_reg(REG_ITMP1) *
319 * in the static case the method pointer can be computed using the *
320 * return address and the lda function following the jmp instruction *
322 *******************************************************************************/
324 asm_call_jit_compiler:
325 push %ebx /* save register */
328 mov 8(%esp),%ebp /* get return address (2 push) */
329 mov -1(%ebp),%bl /* get function code */
330 cmp $0xd1,%bl /* called with `call *REG_ITMP2' (%ecx)? */
331 jne L_not_static_special
333 sub $6,%ebp /* calculate address of immediate */
334 jmp L_call_jit_compile
336 L_not_static_special:
337 cmp $0xd0,%bl /* called with `call *REG_ITMP1' (%eax) */
338 jne L_not_virtual_interface
340 sub $6,%ebp /* calculate address of offset */
341 mov (%ebp),%ebp /* get offset */
342 add %ecx,%ebp /* add base address to get method address */
343 jmp L_call_jit_compile
345 L_not_virtual_interface: /* a call from asm_calljavafunction */
349 push %ebp /* save address for method pointer */
351 push %eax /* push methodpointer on stack */
355 pop %ebp /* restore address for method pointer */
356 test %ebp,%ebp /* is address == 0 (asm_calljavafunction) */
359 mov %eax,(%ebp) /* and now save the new pointer */
362 pop %ebp /* restore registers */
365 jmp *%eax /* ...and now call the new method */
368 /********************* function asm_handle_exception ***************************
370 * This function handles an exception. It does not use the usual calling *
371 * conventions. The exception pointer is passed in REG_ITMP1 and the *
372 * pc from the exception raising position is passed in REG_ITMP2. It searches *
373 * the local exception table for a handler. If no one is found, it unwinds *
374 * stacks and continues searching the callers. *
376 * void asm_handle_exception (exceptionptr, exceptionpc); *
378 *******************************************************************************/
380 asm_handle_nat_exception:
381 add $4,%esp /* clear return address of native stub */
383 asm_handle_exception:
387 push %eax /* exception pointer */
388 push %ecx /* excepiton pc */
390 call asm_get_stackTrace
396 asm_handle_exception_loop:
400 push %eax /* save exception pointer */
401 push %ecx /* save exception pc */
403 call findmethod /* get the data segment ptr */
407 mov -8(%ebp),%ecx /* could be changed in findmethod */
409 push %edx /* save data segment pointer */
416 mov %eax,(%esp) /* exception pointer */
417 mov MethodPointer(%edx),%eax /* method pointer */
419 mov %ecx,8(%esp) /* exception pc */
420 movl $0,12(%esp) /* line number */
421 movl $1,16(%esp) /* set no unwind flag */
422 call builtin_trace_exception
424 mov -12(%ebp),%esi /* %esi = data segment pointer */
425 mov ExTableSize(%esi),%ecx /* %ecx = exception table size */
426 test %ecx,%ecx /* if empty table skip */
429 lea ExTableStart(%esi),%edi /* %edi = start of exception table*/
430 mov -4(%ebp),%eax /* get xptr */
433 mov -8(%ebp),%edx /* get xpc */
435 mov ExStartPC(%edi),%ebx /* %ebx = exception start pc */
436 cmp %edx,%ebx /* %ebx = (startpc <= xpc) */
437 jg ex_table_cont /* if (false) continue */
438 mov ExEndPC(%edi),%ebx /* %ebx = exception end pc */
439 cmp %ebx,%edx /* %ebx = (xpc < endpc) */
440 jge ex_table_cont /* if (false) continue */
441 mov ExCatchType(%edi),%ebx /* arg1 = exception catch type */
442 test %ebx,%ebx /* NULL catches everything */
446 cmpl $0,offclassloaded(%ebx) /* check if class is loaded */
449 push %eax /* save not callee saved regs */
452 push %ebx /* exception class is argument */
460 cmpl $0,offclasslinked(%ebx)
463 push %eax /* save not callee saved regs */
466 push %ebx /* exception class is argument */
475 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
483 mov offobjvftbl(%eax),%esi /* %esi = vftblptr(xptr) */
484 mov offclassvftbl(%ebx),%ebx /* %ebx = vftblptr(catchtype) class (not obj) */
485 mov offbaseval(%esi),%esi /* %esi = baseval(xptr) */
486 mov offbaseval(%ebx),%edx /* %edx = baseval(catchtype) */
487 mov offdiffval(%ebx),%ebx /* %ebx = diffval(catchtype) */
489 sub %edx,%esi /* %esi = baseval(xptr) - baseval(catchtype) */
491 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
495 cmp %ebx,%esi /* xptr is instanceof catchtype */
499 mov ExHandlerPC(%edi),%edx
501 pop %edi /* restore registers */
504 add $8,%esp /* suck %ecx, %edx */
505 pop %eax /* restore xptr */
508 jmp *%edx /* jump to exception handler */
511 lea ExEntrySize(%edi),%edi
520 pop %edx /* restore data segment pointer */
525 push %eax /* save exception pointer */
528 mov IsSync(%edx),%eax /* %eax = SyncOffset */
529 test %eax,%eax /* if zero no monitorexit */
533 mov -4(%eax),%eax /* we have the xptr on the stack */
534 push %edx /* save regs */
536 call builtin_monitorexit
538 pop %edx /* restore regs */
542 add FrameSize(%edx),%eax /* %eax = frame size */
543 add $4,%eax /* we have the xptr on the stack */
545 mov IntSave(%edx),%ecx /* %ecx = saved int register count*/
567 shl $3,%ecx /* multiply by 8 bytes */
571 mov FltSave(%edx),%ecx /* %ecx = saved flt register count */
598 pop %eax /* restore exception pointer */
600 mov FrameSize(%edx),%ecx /* %ecx = frame size */
601 add %ecx,%esp /* unwind stack */
603 pop %ecx /* the new xpc is return address */
606 jmp asm_handle_exception_loop
609 /********************* function asm_check_clinit *******************************
611 * Does null check and calls monitorenter or throws an exception *
613 *******************************************************************************/
616 mov offclassinit(%eax),%ecx /* get initialized flag */
620 sub $16,%esp /* build stack frame (4 * 4 bytes) */
622 call builtin_asm_get_stackframeinfo
632 call class_init /* call class_init function */
640 test %eax,%eax /* we had an exception */
641 je L_initializererror
644 mov (%esp),%eax /* get return address */
645 sub $12,%eax /* asm_putstatic call code size */
646 movb $0xeb,(%eax) /* jmp rel8 */
647 movb $10,1(%eax) /* 8-bit offset */
651 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
652 call builtin_asm_get_exceptionptrptr
654 mov (%ecx),%eax /* get the exception pointer */
655 movl $0,(%ecx) /* clear the exception pointer */
657 lea _exceptionptr,%ecx
658 mov (%ecx),%eax /* get the exception pointer */
659 movl $0,(%ecx) /* clear the exception pointer */
662 pop %ecx /* delete return address */
663 sub $2,%ecx /* faulting address is return adress - 2 */
665 jmp asm_handle_exception
668 /********************* function asm_builtin_monitorenter ***********************
670 * Does null check and calls monitorenter or throws an exception *
672 *******************************************************************************/
674 asm_builtin_monitorenter:
676 je nb_monitorenter /* if (null) throw exception */
677 jmp builtin_monitorenter /* else call builtin_monitorenter */
680 push string_java_lang_NullPointerException
684 pop %ecx /* delete return address */
685 sub $2,%ecx /* faulting address is return adress - 2 */
686 jmp asm_handle_exception
689 /********************* function asm_builtin_monitorexit ************************
691 * Does null check and calls monitorexit or throws an exception *
693 *******************************************************************************/
695 asm_builtin_monitorexit:
698 je nb_monitorexit /* if (null) throw exception */
699 push %ecx /* save registers which could be used */
702 call builtin_monitorexit /* else call builtin_monitorenter */
704 pop %edx /* restore registers which could be used */
709 push string_java_lang_NullPointerException
713 pop %ecx /* delete return address */
714 sub $2,%ecx /* faulting address is return adress - 2 */
715 jmp asm_handle_exception
718 /************************ function asm_builtin_ldiv ****************************
720 * Does null check and calls ldiv or throws an exception *
722 *******************************************************************************/
727 test %eax,%eax /* if (null) throw exception */
733 push string_java_lang_ArithmeticException_message
734 push string_java_lang_ArithmeticException
735 call new_exception_message
738 pop %ecx /* delete return address */
739 sub $2,%ecx /* faulting address is return adress - 2 */
740 jmp asm_handle_exception
743 /************************ function asm_builtin_lrem ****************************
745 * Does null check and calls lrem or throws an exception *
747 *******************************************************************************/
752 test %eax,%eax /* if (null) throw exception */
758 push string_java_lang_ArithmeticException_message
759 push string_java_lang_ArithmeticException
760 call new_exception_message
763 pop %ecx /* delete return address */
764 sub $2,%ecx /* faulting address is return adress - 2 */
765 jmp asm_handle_exception
768 /************************ function asm_builtin_x2x *****************************
770 * Wrapper functions for corner cases *
772 *******************************************************************************/
803 /******************* function asm_builtin_checkarraycast ***********************
805 * Does the cast check and eventually throws an exception *
807 *******************************************************************************/
809 asm_builtin_checkarraycast:
810 sub $8,%esp /* build stack frame (2 * 4 bytes) */
812 mov 12(%esp),%eax /* 8 (frame) + 4 (return) */
813 mov %eax,(%esp) /* save object pointer */
818 call builtin_checkarraycast /* builtin_checkarraycast */
820 test %eax,%eax /* if (false) throw exception */
823 mov 12(%esp),%eax /* return object pointer */
828 push string_java_lang_ClassCastException
834 pop %ecx /* delete return address */
835 sub $2,%ecx /* faulting address is return adress - 2 */
836 jmp asm_handle_exception
839 /******************* function asm_builtin_newarray *****************************
841 * Does the cast check and eventually throws an exception *
843 *******************************************************************************/
845 asm_builtin_newarray:
846 sub $8,%esp /* build stack frame (2 * 4 bytes) */
854 call builtin_newarray
860 /******************* function asm_builtin_aastore ******************************
862 * Does the cast check and eventually throws an exception *
864 *******************************************************************************/
867 sub $12,%esp /* build stack frame (3 * 4 bytes) */
869 mov 16(%esp),%eax /* 12 (frame) + 4 (return) */
870 test %eax,%eax /* if null pointer throw exception */
873 mov offarraysize(%eax),%edx /* load size */
874 mov 24(%esp),%ecx /* index */
875 cmp %edx,%ecx /* do bound check */
876 jae nb_aastore_bound /* if out of bounds throw exception */
878 shl $2,%ecx /* index * 4 */
879 add %eax,%ecx /* add index * 4 to arrayref */
881 mov %ecx,8(%esp) /* save store position */
883 mov 16(%esp),%eax /* 12 (frame) + 4 (return) */
886 mov 32(%esp),%eax /* object is second argument */
889 call builtin_canstore /* builtin_canstore(arrayref,object) */
891 test %eax,%eax /* if (false) throw exception */
896 mov %eax,offobjarrdata(%ecx) /* store objectptr in array */
902 push string_java_lang_NullPointerException
907 pop %ecx /* delete return address */
908 sub $2,%ecx /* faulting address is return adress - 2 */
909 jmp asm_handle_exception
912 push %ecx /* itmp2 contains array index */
913 push string_java_lang_ArrayIndexOutOfBoundsException
914 call new_exception_int
918 pop %ecx /* delete return address */
919 sub $2,%ecx /* faulting address is return adress - 2 */
920 jmp asm_handle_exception
923 push string_java_lang_ArrayStoreException
928 pop %ecx /* delete return address */
929 sub $2,%ecx /* faulting address is return adress - 2 */
930 jmp asm_handle_exception
933 /******************* function asm_builtin_arrayinstanceof **********************
935 * Does the instanceof check of arrays *
937 *******************************************************************************/
939 asm_builtin_arrayinstanceof:
940 sub $8,%esp /* build stack frame (2 * 4 bytes) */
948 call builtin_arrayinstanceof
954 /******************* function asm_initialize_thread_stack **********************
956 * initialized a thread stack *
957 * (to)->restorePoint = asm_initialize_thread_stack((u1*)(func), (to)->stackEnd)*
959 *******************************************************************************/
961 asm_initialize_thread_stack:
962 mov 8(%esp),%eax /* (to)->stackEnd */
963 sub $36,%eax /* 4 bytes * 8 regs + 4 bytes func */
975 mov 4(%esp),%edx /* save (u1*) (func) */
978 ret /* return restorepoint in %eax */
981 /******************* function asm_perform_threadswitch *************************
983 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
985 * performs a threadswitch *
987 *******************************************************************************/
989 asm_perform_threadswitch:
1001 mov 36(%esp),%eax /* save current return address */
1004 mov 40(%esp),%eax /* first argument **from */
1007 mov 48(%esp),%eax /* third argument **stackTop */
1010 mov 44(%esp),%eax /* second argument **to */
1011 mov 0(%eax),%esp /* load new stack pointer */
1017 /* skip stack pointer */
1022 add $32,%esp /* leave return address on stack */
1026 /********************* function asm_switchstackandcall *************************
1028 * int asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
1031 * Switches to a new stack, calls a function and switches back. *
1032 * a0 new stack pointer *
1033 * a1 function pointer *
1034 * a2 pointer to variable where stack top should be stored *
1035 * a3 pointer to user data, is passed to the function *
1037 *******************************************************************************/
1039 asm_switchstackandcall:
1040 mov 4(%esp),%edx /* first argument *stack */
1041 sub $8,%edx /* allocate new stack */
1043 mov (%esp),%eax /* save return address on new stack */
1046 mov %esp,4(%edx) /* save old stack pointer on new stack */
1048 mov 12(%esp),%eax /* third argument **stacktopsave */
1049 mov %esp,(%eax) /* save old stack pointer to variable */
1051 mov 8(%esp),%eax /* load function pointer */
1052 mov 16(%esp),%ecx /* fourth argument *p */
1054 mov %edx,%esp /* switch to new stack */
1057 mov %ecx,0(%esp) /* pass pointer */
1058 call *%eax /* and call function */
1061 mov (%esp),%edx /* load return address */
1062 mov 4(%esp),%esp /* switch to old stack */
1067 Java_java_lang_VMSecurityManager_currentClassLoader:
1068 lea builtin_asm_getclassloader,%eax
1069 push %eax /*store collector function pointer*/
1070 jmp getClassContext_begin
1071 Java_java_lang_VMSecurityManager_getClassContext:
1072 lea builtin_asm_createclasscontextarray,%eax
1073 push %eax /*store collector function pointer*/
1074 getClassContext_begin: /*start the real work*/
1078 sub $68,%esp /*64 memory location without overwriting return adress and collector function adress*/
1079 mov %esp,%ebx /*end of allocated memory block for classpointers is the adress of the working data block +4 */
1080 push $0 /*%esp+32 was native*/
1081 push %eax /*%esp+24 blkbegin*/
1082 push %eax /*%esp+20 currentpos*/
1083 push %ebx /*%esp+16 blkend*/
1085 call builtin_asm_get_threadrootmethod
1086 push %eax /*%esp+12*/
1087 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*/
1090 push %edx /*esp+8*/ /*position of return address of native stub*/
1091 call builtin_asm_get_stackframeinfo
1092 movl (%eax),%eax /*comment ??*/
1093 push 0(%eax) /*esp+4*/ /*address of frame info block*/
1100 call i386_native_stub_debug
1103 push %edx /*esp+0*/ /*return adress out of native stub*/
1104 call findmethod /*find calling java method, this one is still to be skipped (==SecurityManager.getClassContext (or .currentClassLoader)*/
1108 movl MethodPointer(%eax),%eax
1110 call temporaryGetClassContextHelper
1112 call traverseStackInfo
1117 movl MethodPointer(%eax),%ebx
1118 movl offclassmethodinfo(%ebx),%ecx
1123 mov 8(%esp),%ebx /*pos of return adress */
1124 add FrameSize(%eax),%ebx
1125 add $4,%ebx /*adress of new return adress (out of Securitymanager.*/
1129 /* by now we have skipped this method call*/
1131 getClassContext_next:
1134 movl %eax,(%esp) /*return adress*/
1140 add FrameSize(%eax),%ebx
1142 mov %ebx,8(%esp) /*store adress of next return adress*/
1143 getClassContext_nextRetStored:
1145 mov MethodPointer(%eax),%ecx /*get struct methodinfo*/
1148 je getClassContext_nativeCall
1149 /*save class pointer*/
1151 getClassContext_saveClassPointer:
1152 movl 20(%esp),%ebx /*get temporary memory adress in stack*/
1153 movl offclassmethodinfo(%ecx),%edx /* get class pointer of method*/
1154 movl %edx,(%ebx) /*save */
1155 sub $4,%ebx /*calculate next position */
1156 movl %ebx,20(%esp) /* check if the new adress would overwrite our working data */
1158 je getClassContext_incStack
1159 getClassContext_checkLeave:
1161 cmp 12(%esp),%ecx /*check if we reached the toplevel method of our thread*/
1162 je getClassContext_leave /*yes ->leave*/
1166 call temporaryGetClassContextHelper
1170 jmp getClassContext_next /*continue*/
1173 getClassContext_nativeCall:
1175 movl 4(%esp),%eax /*get top most element on stackframe help information stack*/
1184 je getClassContext_checkLeave
1185 jmp getClassContext_saveClassPointer
1187 getClassContext_incStack:
1188 /*make another 64 in our temporary storage free and store the workingdata */
1190 subl $40,%esp /*should be 32*/
1202 jmp getClassContext_checkLeave /* continue */
1204 getClassContext_leave:
1207 call temporaryGetClassContextHelper*/
1209 /*call collector function with begin/end of temporary classarray*/
1218 /* free stack memory of this function*/
1225 /*optimize a littlebit */
1229 call i386_native_stub_debug
1233 mov offclassinit(%eax),%ecx /* get initialized flag */
1235 jnz L_builtin_new_noinit
1237 sub $16,%esp /* build stack frame (4 * 4 bytes) */
1242 call builtin_asm_get_stackframeinfo
1259 jmp L_builtin_new_patch
1262 L_builtin_new_noinit:
1267 /*jmp L_builtin_new_patch*/
1269 L_builtin_new_patch:
1270 /*add patching code here */
1271 lea builtin_new,%edx
1273 mov %edx,-6(%ecx) /*patch calling instruction, t directly call builtin_new the next time*/
1281 push %ebp /*(%ebp-4)*/
1284 push %edi /*(%ebp-8)*/
1285 push %esi /*(%ebp-12)*/
1286 push %ebx /*(%ebp-16)*/
1287 call builtin_asm_get_stackframeinfo
1289 pushl 0(%eax) /*(%ebp-20)*/
1291 call builtin_asm_get_threadrootmethod
1292 pushl %eax /*(%ebp-24)*/
1295 asm_get_stackTraceLoop:
1299 pushl $1 /*no indent*/
1304 get_stackTrace_line:
1305 movl LineNumberTableSize(%esi),%ecx
1306 test %ecx,%ecx /* skip if empty line table */
1307 je get_stackTrace_noLineInfo
1309 movl LineNumberTableStart(%esi),%ebx
1311 get_stackTrace_lineLoop:
1312 cmp %edx,LinePC(%ebx)
1313 jg get_stackTrace_nextLineInfo
1315 pushl LineLine(%ebx)
1316 jmp get_stackTrace_cont
1318 get_stackTrace_nextLineInfo:
1319 lea LineEntrySize(%ebx),%ebx
1323 jne get_stackTrace_lineLoop
1325 get_stackTrace_noLineInfo:
1329 get_stackTrace_cont:
1331 pushl MethodPointer(%esi)
1332 pushl $0 /*8(%ebp)*/ /*exception ptr*/
1333 call builtin_trace_exception
1336 movl MethodPointer(%esi),%eax
1339 je get_stackTrace_nat
1342 je get_stackTrace_leave
1344 mov FrameSize(%esi),%eax
1348 jmp asm_get_stackTraceLoop
1354 je get_stackTrace_leave
1361 jmp asm_get_stackTraceLoop
1363 get_stackTrace_leave:
1369 call builtin_stacktrace_copy
1378 asm_getclassvalues_atomic:
1380 mov 4(%esp),%ecx /* super */
1381 mov 8(%esp),%edx /* sub */
1383 mov offbaseval(%ecx),%eax
1384 mov offdiffval(%ecx),%ecx
1385 mov offbaseval(%edx),%edx
1388 mov 16(%esp),%ebx /* out */
1389 mov %eax,offcast_super_baseval(%ebx)
1390 mov %ecx,offcast_super_diffval(%ebx)
1391 mov %edx,offcast_sub_baseval(%ebx)
1397 asm_criticalsections:
1398 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
1401 .long _crit_restart1
1404 .long _crit_restart2
1409 * These are local overrides for various environment variables in Emacs.
1410 * Please do not remove this and leave it at the end of the file, where
1411 * Emacs will automagically detect them.
1412 * ---------------------------------------------------------------------
1415 * indent-tabs-mode: t