Comment
[cacao.git] / i386 / methodtable.c
1 /* i386/methodtable.c **********************************************************
2
3     Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
4
5     See file COPYRIGHT for information on usage and disclaimer of warranties
6
7     Contains the codegenerator for an i386 processor.
8     This module generates i386 machine code for a sequence of
9     pseudo commands (ICMDs).
10
11     Authors: Christian Thalinger EMAIL: cacao@complang.tuwien.ac.at
12
13     Last Change: $Id: methodtable.c 525 2003-10-22 21:14:23Z twisti $
14
15 *******************************************************************************/
16
17 #include "methodtable.h"
18
19 static mtentry *mtroot = NULL;
20
21
22
23 void addmethod(u1 *start, u1 *end)
24 {
25   /* boehm makes problems with jvm98 db */
26 #if 0
27     mtentry *mte = GCNEW(mtentry, 1);
28 #else
29     mtentry *mte = NEW(mtentry);
30 #endif
31
32 /*      fprintf(stderr, "start=%lx end=%lx\n", start, end); */
33
34     if (mtroot == NULL) {
35 #if 0
36         mtentry *tmp = GCNEW(mtentry, 1);
37 #else
38         mtentry *tmp = NEW(mtentry);
39 #endif
40         tmp->start = (u1 *) asm_calljavamethod;
41         tmp->end = (u1 *) asm_calljavafunction;    /* little hack, but should work */
42         tmp->next = mtroot;
43         mtroot = tmp;
44
45 #if 0
46         tmp = GCNEW(mtentry, 1);
47 #else
48         tmp = NEW(mtentry);
49 #endif
50         tmp->start = (u1 *) asm_calljavafunction;
51         tmp->end = (u1 *) asm_call_jit_compiler;    /* little hack, but should work */
52         tmp->next = mtroot;
53         mtroot = tmp;
54     }
55
56     mte->start = start;
57     mte->end = end;
58     mte->next = mtroot;
59     mtroot = mte;
60 }
61
62
63
64 u1 *findmethod(u1 *pos)
65 {
66     mtentry *mte = mtroot;
67
68 /*      printf("findmethod: start\n"); */
69
70     while (mte != NULL) {
71 /*          printf("%p <= %p <= %p\n", mte->start, pos, mte->end); */
72           
73         if (mte->start <= pos && pos <= mte->end) {
74             return mte->start;
75
76         } else {
77             mte = mte->next;
78         }
79     }
80         
81     return NULL;
82 }
83
84
85
86 void asmprintf(int x)
87 {
88     printf("val=%x\n", x);
89     fflush(stdout);
90 }