247 _offset(-1),
248 _freq(freq),
249 _can_be_reused(can_be_reused)
250 {
251 assert(type != T_METADATA, "wrong constructor");
252 _v._value = value;
253 }
254 Constant(Metadata* metadata, bool can_be_reused = true) :
255 _type(T_METADATA),
256 _offset(-1),
257 _freq(0.0f),
258 _can_be_reused(can_be_reused)
259 {
260 _v._metadata = metadata;
261 }
262
263 bool operator==(const Constant& other);
264
265 BasicType type() const { return _type; }
266
267 jlong get_jlong() const { return _v._value.j; }
268 jfloat get_jfloat() const { return _v._value.f; }
269 jdouble get_jdouble() const { return _v._value.d; }
270 jobject get_jobject() const { return _v._value.l; }
271
272 Metadata* get_metadata() const { return _v._metadata; }
273
274 int offset() const { return _offset; }
275 void set_offset(int offset) { _offset = offset; }
276
277 float freq() const { return _freq; }
278 void inc_freq(float freq) { _freq += freq; }
279
280 bool can_be_reused() const { return _can_be_reused; }
281 };
282
283 // Constant table.
284 class ConstantTable {
285 private:
286 GrowableArray<Constant> _constants; // Constants of this table.
303 {}
304
305 int size() const { assert(_size != -1, "not calculated yet"); return _size; }
306
307 int calculate_table_base_offset() const; // AD specific
308 void set_table_base_offset(int x) { assert(_table_base_offset == -1 || x == _table_base_offset, "can't change"); _table_base_offset = x; }
309 int table_base_offset() const { assert(_table_base_offset != -1, "not set yet"); return _table_base_offset; }
310
311 void emit(CodeBuffer& cb);
312
313 // Returns the offset of the last entry (the top) of the constant table.
314 int top_offset() const { assert(_constants.top().offset() != -1, "not bound yet"); return _constants.top().offset(); }
315
316 void calculate_offsets_and_size();
317 int find_offset(Constant& con) const;
318
319 void add(Constant& con);
320 Constant add(MachConstantNode* n, BasicType type, jvalue value);
321 Constant add(Metadata* metadata);
322 Constant add(MachConstantNode* n, MachOper* oper);
323 Constant add(MachConstantNode* n, jfloat f) {
324 jvalue value; value.f = f;
325 return add(n, T_FLOAT, value);
326 }
327 Constant add(MachConstantNode* n, jdouble d) {
328 jvalue value; value.d = d;
329 return add(n, T_DOUBLE, value);
330 }
331
332 // Jump-table
333 Constant add_jump_table(MachConstantNode* n);
334 void fill_jump_table(CodeBuffer& cb, MachConstantNode* n, GrowableArray<Label*> labels) const;
335 };
336
337 private:
338 // Fixed parameters to this compilation.
339 const int _compile_id;
340 const bool _save_argument_registers; // save/restore arg regs for trampolines
341 const bool _subsume_loads; // Load can be matched as part of a larger op.
342 const bool _do_escape_analysis; // Do escape analysis.
|
247 _offset(-1),
248 _freq(freq),
249 _can_be_reused(can_be_reused)
250 {
251 assert(type != T_METADATA, "wrong constructor");
252 _v._value = value;
253 }
254 Constant(Metadata* metadata, bool can_be_reused = true) :
255 _type(T_METADATA),
256 _offset(-1),
257 _freq(0.0f),
258 _can_be_reused(can_be_reused)
259 {
260 _v._metadata = metadata;
261 }
262
263 bool operator==(const Constant& other);
264
265 BasicType type() const { return _type; }
266
267 jint get_jint() const { return _v._value.i; }
268 jlong get_jlong() const { return _v._value.j; }
269 jfloat get_jfloat() const { return _v._value.f; }
270 jdouble get_jdouble() const { return _v._value.d; }
271 jobject get_jobject() const { return _v._value.l; }
272
273 Metadata* get_metadata() const { return _v._metadata; }
274
275 int offset() const { return _offset; }
276 void set_offset(int offset) { _offset = offset; }
277
278 float freq() const { return _freq; }
279 void inc_freq(float freq) { _freq += freq; }
280
281 bool can_be_reused() const { return _can_be_reused; }
282 };
283
284 // Constant table.
285 class ConstantTable {
286 private:
287 GrowableArray<Constant> _constants; // Constants of this table.
304 {}
305
306 int size() const { assert(_size != -1, "not calculated yet"); return _size; }
307
308 int calculate_table_base_offset() const; // AD specific
309 void set_table_base_offset(int x) { assert(_table_base_offset == -1 || x == _table_base_offset, "can't change"); _table_base_offset = x; }
310 int table_base_offset() const { assert(_table_base_offset != -1, "not set yet"); return _table_base_offset; }
311
312 void emit(CodeBuffer& cb);
313
314 // Returns the offset of the last entry (the top) of the constant table.
315 int top_offset() const { assert(_constants.top().offset() != -1, "not bound yet"); return _constants.top().offset(); }
316
317 void calculate_offsets_and_size();
318 int find_offset(Constant& con) const;
319
320 void add(Constant& con);
321 Constant add(MachConstantNode* n, BasicType type, jvalue value);
322 Constant add(Metadata* metadata);
323 Constant add(MachConstantNode* n, MachOper* oper);
324 Constant add(MachConstantNode* n, jint i) {
325 jvalue value; value.i = i;
326 return add(n, T_INT, value);
327 }
328 Constant add(MachConstantNode* n, jlong j) {
329 jvalue value; value.j = j;
330 return add(n, T_LONG, value);
331 }
332 Constant add(MachConstantNode* n, jfloat f) {
333 jvalue value; value.f = f;
334 return add(n, T_FLOAT, value);
335 }
336 Constant add(MachConstantNode* n, jdouble d) {
337 jvalue value; value.d = d;
338 return add(n, T_DOUBLE, value);
339 }
340
341 // Jump-table
342 Constant add_jump_table(MachConstantNode* n);
343 void fill_jump_table(CodeBuffer& cb, MachConstantNode* n, GrowableArray<Label*> labels) const;
344 };
345
346 private:
347 // Fixed parameters to this compilation.
348 const int _compile_id;
349 const bool _save_argument_registers; // save/restore arg regs for trampolines
350 const bool _subsume_loads; // Load can be matched as part of a larger op.
351 const bool _do_escape_analysis; // Do escape analysis.
|