00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifdef DELTA_COMPILER
00035
00036 class jumpTableEntry;
00037 class jumpTable;
00038
00039 class jumpTableID : ValueObj {
00040 u_short _major;
00041 u_short _minor;
00042 friend class jumpTable;
00043
00044 enum { max_value = nthMask(16) };
00045
00046 public:
00047 jumpTableID() : _major(max_value), _minor(max_value) {}
00048 jumpTableID(u_short major) : _major(major), _minor(max_value) {}
00049 jumpTableID(u_short major, u_short minor) : _major(major), _minor(minor) {}
00050 bool has_minor() const { return _minor != max_value; }
00051 bool is_block() const { return _minor > 0; }
00052 bool is_valid() const { return _major != max_value; }
00053 u_short major() const { return _major; }
00054 u_short minor() const { return _minor; }
00055 jumpTableID sub(u_short minor) const { return jumpTableID(_major, minor); }
00056 };
00057
00058
00059 class jumpTable : public ValueObj {
00060 protected:
00061 int firstFree;
00062 static char* allocate_jump_entries(int size);
00063 static jumpTableEntry* jump_entry_for_at(char* entries, int index);
00064 jumpTableEntry* major_at(u_short index);
00065 public:
00066 char* entries;
00067 int length;
00068 int usedIDs;
00069
00070 public:
00071 jumpTable();
00072 ~jumpTable();
00073
00074 void init();
00075
00076
00077 jumpTableID allocate(int number_of_entries);
00078
00079
00080 jumpTableEntry* at(jumpTableID id);
00081
00082 int newID();
00083 int peekID();
00084
00085 void freeID(int index);
00086
00087 void verify();
00088 void print();
00089
00090
00091 static char* compile_new_block(blockClosureOop blk);
00092 static nmethod* compile_block(blockClosureOop blk);
00093
00094 friend class jumpTableEntry;
00095 };
00096
00097
00098
00099
00100
00101 class jumpTableEntry : public ValueObj {
00102 private:
00103 char* jump_inst_addr() const { assert(oop(this)->is_smi(), "misaligned"); return (char*) this; }
00104 char* state_addr() const { return ((char*) this) + sizeof(char) + sizeof(int); }
00105 char state() const { return *state_addr(); }
00106 void fill_entry(char instr, char* dest, char state);
00107 void initialize_as_unused(int index);
00108 void initialize_as_link(char* link);
00109 void initialize_nmethod_stub(char* dest);
00110 void initialize_block_closure_stub();
00111 inline jumpTableEntry* previous_stub() const;
00112 inline jumpTableEntry* next_stub() const;
00113 jumpTableEntry* parent_entry(int& index) const;
00114 void report_verify_error(char* message);
00115 public:
00116
00117 bool is_nmethod_stub() const;
00118 bool is_block_closure_stub() const;
00119 bool is_link() const;
00120 bool is_unused() const;
00121
00122
00123 char* entry_point() const { return jump_inst_addr(); }
00124
00125
00126 char** destination_addr() const;
00127 char* destination() const;
00128 void set_destination(char* dest);
00129
00130
00131 char* link() const;
00132
00133
00134 int next_free() const;
00135
00136
00137 nmethod* method() const;
00138
00139
00140 bool block_has_nmethod() const;
00141 nmethod* block_nmethod() const;
00142 methodOop block_method() const;
00143
00144
00145 nmethod* parent_nmethod(int& index) const;
00146
00147
00148 void print();
00149 void verify();
00150
00151
00152 static int size() { return 8; }
00153
00154 friend class jumpTable;
00155 };
00156
00157 #endif