Comment
[cacao.git] / x86_64 / methodtable.c
1 /* x86_64/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 x86_64 processor.
8     This module generates x86_64 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 414 2003-08-23 23:45:58Z 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 /*  #ifdef USE_BOEHM */
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 /*  #ifdef USE_BOEHM */
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 /*  #ifdef USE_BOEHM */
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     printf("can't find method with rip=%p\n", pos);
82     exit(-1);
83 }
84
85
86
87 void asmprintf(s8 x)
88 {
89     printf("val=%lx\n", x);
90     fflush(stdout);
91 }