home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / kaffe-0.5p4-src.tgz / tar.out / contrib / kaffe / kaffevm / jit / machine.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  3KB  |  114 lines

  1. /* machine.h
  2.  *
  3.  * Copyright (c) 1996 Systems Architecture Research Centre,
  4.  *           City University, London, UK.
  5.  *
  6.  * See the file "license.terms" for information on usage and redistribution
  7.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  8.  *
  9.  * Written by Tim Wilkinson <tim@sarc.city.ac.uk>, June 1996.
  10.  */
  11.  
  12. #ifndef __machine_h
  13. #define __machine_h
  14.  
  15. /* -------------------------------------------------------------------- */
  16.  
  17. /* Instructions */
  18. #define    define_insn(code)    break;                    \
  19.                 case code :
  20.  
  21. /* Stack */
  22. #define    stackval(_p)        code[(_p)].stackdepth
  23. #define    push(_i)        stackno -= (_i)
  24. #define    pop(_i)            stackno += (_i)
  25.  
  26. /* PC */
  27. #define    getpc(_p)        base[pc+1+(_p)]
  28. #define    getcode(_p)        base[(_p)]
  29. #define    adjustpc(_p)        npc = pc + (_p)
  30.  
  31. /* -------------------------------------------------------------------- */
  32. /* Constants */
  33.  
  34. #define    constants()        (meth->constants)
  35. #define    constant(idx)                        \
  36.         (slot_alloctmp(cnst),                \
  37.         move_int_const(cnst,                \
  38.         (constants()->tags[idx] == CONSTANT_Chararray ?    \
  39.             makeStringObject(idx, constants()) :    \
  40.             &constants()->data[idx])->v.tint),    \
  41.         cnst)
  42. #define    constant_long(idx)                    \
  43.         (slot_alloc2tmp(cnst),                \
  44.         move_long_const(cnst, constants()->data[idx].v.tlong),\
  45.         cnst)
  46.  
  47. /* -------------------------------------------------------------------- */
  48. /* Methods */
  49.  
  50. #define    get_method_info(cnst, idx)                \
  51.     getMethodSignatureClass(idx, cnst, &cinfo)
  52.  
  53. #define    method_name()                        \
  54.             (slot_alloctmp(cnst),            \
  55.             move_ref_const(cnst, cinfo.mtag),    \
  56.             cnst)
  57. #define    method_tag()    (cinfo.mtag)
  58. #define    method_hash()    (cinfo.offset)
  59. #define    method_idx()    (cinfo.idx)
  60. #define    get_dispatch_table(mtable)                \
  61.             move_ref_const(mtable, cinfo.dtable)
  62.  
  63. #define    method_nargs()        (cinfo.in)
  64. #define    method_dtable_offset    (OBJECT_DTABLE)
  65. #define    method_mtable_offset    (DTABLE_MTABLEOFFSET)
  66. #define    method_returntype()    (cinfo.rettype)
  67. #define    method_arg(_a)        (cinfo.type[(_a)])
  68.  
  69. /* -------------------------------------------------------------------- */
  70. /* Fields */
  71.  
  72. #define    get_field_info(cnst, idx)                \
  73.         getField(idx, false, cnst, &flinfo)
  74.  
  75. #define    get_static_field_info(cnst, idx)            \
  76.         getField(idx, true, cnst, &flinfo)
  77.  
  78. #define    field_data()        (OBJECT_DATA)
  79. #define    field_statics()        ((uintp)flinfo.class->staticFields)
  80. #define    field_size()        (flinfo.size)
  81. #define    field_offset()        (flinfo.offset * 4)
  82. #define    field_isref()        (flinfo.isref)
  83.  
  84. /* -------------------------------------------------------------------- */
  85. /* Classes */
  86.  
  87. #define    get_class_info(cnst, idx)                \
  88.         getClass(idx, cnst, &crinfo)
  89.  
  90. #define    class_object()                        \
  91.             (slot_alloctmp(cnst),            \
  92.             move_ref_const(cnst, crinfo.class),    \
  93.             cnst)
  94.  
  95. /* -------------------------------------------------------------------- */
  96. /* Objects */
  97.  
  98. #define    object_array_offset    (OBJECT_DATA)
  99. #define    object_array_length    (OBJECT_SIZE)
  100. #define    object_colour()        (OBJECT_IDX)
  101. #define    object_white()        (COLOUR_WHITE)
  102.  
  103. /* -------------------------------------------------------------------- */
  104. /* Switches */
  105.  
  106. #define    switchpair_size        8
  107. #define    switchpair_addr        4
  108. #define    switchtable_shift    2
  109.  
  110. struct _methods;
  111. void translate(struct _methods*);
  112.  
  113. #endif
  114.