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
00035
00036
00037
00038 enum PrimitiveGroup {
00039 NormalPrimitive,
00040
00041 IntComparisonPrimitive,
00042 IntArithmeticPrimitive,
00043
00044 FloatComparisonPrimitive,
00045 FloatArithmeticPrimitive,
00046
00047 ObjArrayPrimitive,
00048 ByteArrayPrimitive,
00049 DoubleByteArrayPrimitive,
00050
00051 BlockPrimitive
00052 };
00053
00054 class InterpretedPrim_Cache: public ValueObj {
00055 private:
00056 u_char* hp() const { return (u_char*)this; }
00057 public:
00058 symbolOop name() const;
00059 int number_of_parameters() const;
00060 primitive_desc* pdesc() const;
00061 bool has_receiver() const;
00062 bool has_failure_code() const;
00063 };
00064
00065
00066
00067
00068
00069 class primitive_desc {
00070 public:
00071 char* _name;
00072 fntype _fn;
00073 int _flags;
00074 char** _types;
00075
00076
00077 char** _errors;
00078
00079 public:
00080
00081 char* name() const { return _name; }
00082
00083
00084 fntype fn() const { return _fn; }
00085
00086
00087 int number_of_parameters() const { return get_unsigned_bitfield(_flags, 0, 8); }
00088
00089
00090 PrimitiveGroup group() const { return (PrimitiveGroup) get_unsigned_bitfield(_flags, 8, 8); }
00091 bool is_special_prim() const { return group() != NormalPrimitive; }
00092 bool can_scavenge() const { return isSet(_flags, 16); }
00093 bool can_perform_NLR() const { return isSet(_flags, 17); }
00094 bool can_fail() const { return isSet(_flags, 18); }
00095
00096
00097 bool can_invoke_delta() const { return can_perform_NLR(); }
00098 bool can_be_constant_folded() const { return isSet(_flags, 19); }
00099 bool has_receiver() const { return isSet(_flags, 20); }
00100 bool is_internal() const { return isSet(_flags, 21); }
00101 bool needs_delta_fp_code() const { return !isSet(_flags, 22); }
00102 bool can_walk_stack() const;
00103
00104
00105 symbolOop selector() const;
00106
00107
00108 oop eval(oop* parameters);
00109
00110
00111
00112 char* parameter_type(int index) const;
00113 char* return_type() const;
00114
00115 #ifdef DELTA_COMPILER
00116
00117
00118 public:
00119 Expr* parameter_klass(int index, PReg* p, Node* n) const;
00120 Expr* return_klass(PReg* p, Node* n) const;
00121
00122 Expr* convertToKlass(char* type, PReg* p, Node* n) const;
00123 #endif
00124
00125 public:
00126
00127 char* error(int index) const { return _errors[index]; }
00128
00129
00130 int compare(char* str, int len);
00131
00132
00133 void print();
00134 void verify();
00135 void error(char* msg);
00136 };
00137
00138
00139 class primitives : AllStatic {
00140 public:
00141 static void print_table();
00142
00143 static primitive_desc* lookup(symbolOop selector) { return lookup((char*) selector->bytes(), selector->length()); }
00144 static primitive_desc* lookup(fntype fn);
00145
00146 static void lookup_and_patch();
00147
00148
00149 static void clear_counters();
00150 static void print_counters();
00151
00152 static void initialize();
00153
00154 private:
00155 static primitive_desc* lookup(char* selector, int len);
00156 static primitive_desc* lookup(char* selector) { return lookup(selector, strlen(selector)); }
00157 static primitive_desc* verified_lookup(char* selector);
00158
00159
00160 static primitive_desc* _new0;
00161 static primitive_desc* _new1;
00162 static primitive_desc* _new2;
00163 static primitive_desc* _new3;
00164 static primitive_desc* _new4;
00165 static primitive_desc* _new5;
00166 static primitive_desc* _new6;
00167 static primitive_desc* _new7;
00168 static primitive_desc* _new8;
00169 static primitive_desc* _new9;
00170
00171 static primitive_desc* _equal;
00172 static primitive_desc* _not_equal;
00173
00174 static primitive_desc* _block_allocate;
00175 static primitive_desc* _block_allocate0;
00176 static primitive_desc* _block_allocate1;
00177 static primitive_desc* _block_allocate2;
00178
00179 static primitive_desc* _context_allocate;
00180 static primitive_desc* _context_allocate0;
00181 static primitive_desc* _context_allocate1;
00182 static primitive_desc* _context_allocate2;
00183
00184 public:
00185 static primitive_desc* new0() { return _new0; }
00186 static primitive_desc* new1() { return _new1; }
00187 static primitive_desc* new2() { return _new2; }
00188 static primitive_desc* new3() { return _new3; }
00189 static primitive_desc* new4() { return _new4; }
00190 static primitive_desc* new5() { return _new5; }
00191 static primitive_desc* new6() { return _new6; }
00192 static primitive_desc* new7() { return _new7; }
00193 static primitive_desc* new8() { return _new8; }
00194 static primitive_desc* new9() { return _new9; }
00195
00196 static primitive_desc* equal() { return _equal; }
00197 static primitive_desc* not_equal() { return _not_equal; }
00198
00199 static primitive_desc* block_allocate() { return _block_allocate; }
00200 static primitive_desc* block_allocate0() { return _block_allocate0; }
00201 static primitive_desc* block_allocate1() { return _block_allocate1; }
00202 static primitive_desc* block_allocate2() { return _block_allocate2; }
00203
00204 static primitive_desc* context_allocate() { return _context_allocate; }
00205 static primitive_desc* context_allocate0() { return _context_allocate0; }
00206 static primitive_desc* context_allocate1() { return _context_allocate1; }
00207 static primitive_desc* context_allocate2() { return _context_allocate2; }
00208 };