src/share/vm/opto/compile.hpp

changeset 3310
6729bbc1fcd6
parent 3138
f6f3bb0ee072
child 3631
b40ac3579043
     1.1 --- a/src/share/vm/opto/compile.hpp	Mon Nov 14 18:38:03 2011 -0800
     1.2 +++ b/src/share/vm/opto/compile.hpp	Wed Nov 16 01:39:50 2011 -0800
     1.3 @@ -150,14 +150,16 @@
     1.4      BasicType _type;
     1.5      jvalue    _value;
     1.6      int       _offset;         // offset of this constant (in bytes) relative to the constant table base.
     1.7 +    float     _freq;
     1.8      bool      _can_be_reused;  // true (default) if the value can be shared with other users.
     1.9  
    1.10    public:
    1.11 -    Constant() : _type(T_ILLEGAL), _offset(-1), _can_be_reused(true) { _value.l = 0; }
    1.12 -    Constant(BasicType type, jvalue value, bool can_be_reused = true) :
    1.13 +    Constant() : _type(T_ILLEGAL), _offset(-1), _freq(0.0f), _can_be_reused(true) { _value.l = 0; }
    1.14 +    Constant(BasicType type, jvalue value, float freq = 0.0f, bool can_be_reused = true) :
    1.15        _type(type),
    1.16        _value(value),
    1.17        _offset(-1),
    1.18 +      _freq(freq),
    1.19        _can_be_reused(can_be_reused)
    1.20      {}
    1.21  
    1.22 @@ -173,6 +175,9 @@
    1.23      int         offset()  const    { return _offset; }
    1.24      void    set_offset(int offset) {        _offset = offset; }
    1.25  
    1.26 +    float       freq()    const    { return _freq;         }
    1.27 +    void    inc_freq(float freq)   {        _freq += freq; }
    1.28 +
    1.29      bool    can_be_reused() const  { return _can_be_reused; }
    1.30    };
    1.31  
    1.32 @@ -182,41 +187,51 @@
    1.33      GrowableArray<Constant> _constants;          // Constants of this table.
    1.34      int                     _size;               // Size in bytes the emitted constant table takes (including padding).
    1.35      int                     _table_base_offset;  // Offset of the table base that gets added to the constant offsets.
    1.36 +    int                     _nof_jump_tables;    // Number of jump-tables in this constant table.
    1.37 +
    1.38 +    static int qsort_comparator(Constant* a, Constant* b);
    1.39 +
    1.40 +    // We use negative frequencies to keep the order of the
    1.41 +    // jump-tables in which they were added.  Otherwise we get into
    1.42 +    // trouble with relocation.
    1.43 +    float next_jump_table_freq() { return -1.0f * (++_nof_jump_tables); }
    1.44  
    1.45    public:
    1.46      ConstantTable() :
    1.47        _size(-1),
    1.48 -      _table_base_offset(-1)  // We can use -1 here since the constant table is always bigger than 2 bytes (-(size / 2), see MachConstantBaseNode::emit).
    1.49 +      _table_base_offset(-1),  // We can use -1 here since the constant table is always bigger than 2 bytes (-(size / 2), see MachConstantBaseNode::emit).
    1.50 +      _nof_jump_tables(0)
    1.51      {}
    1.52  
    1.53 -    int size() const { assert(_size != -1, "size not yet calculated"); return _size; }
    1.54 +    int size() const { assert(_size != -1, "not calculated yet"); return _size; }
    1.55  
    1.56 -    void set_table_base_offset(int x)  { assert(_table_base_offset == -1, "set only once");                        _table_base_offset = x; }
    1.57 -    int      table_base_offset() const { assert(_table_base_offset != -1, "table base offset not yet set"); return _table_base_offset; }
    1.58 +    int calculate_table_base_offset() const;  // AD specific
    1.59 +    void set_table_base_offset(int x)  { assert(_table_base_offset == -1 || x == _table_base_offset, "can't change"); _table_base_offset = x; }
    1.60 +    int      table_base_offset() const { assert(_table_base_offset != -1, "not set yet");                      return _table_base_offset; }
    1.61  
    1.62      void emit(CodeBuffer& cb);
    1.63  
    1.64      // Returns the offset of the last entry (the top) of the constant table.
    1.65 -    int  top_offset() const { assert(_constants.top().offset() != -1, "constant not yet bound"); return _constants.top().offset(); }
    1.66 +    int  top_offset() const { assert(_constants.top().offset() != -1, "not bound yet"); return _constants.top().offset(); }
    1.67  
    1.68      void calculate_offsets_and_size();
    1.69      int  find_offset(Constant& con) const;
    1.70  
    1.71      void     add(Constant& con);
    1.72 -    Constant add(BasicType type, jvalue value);
    1.73 -    Constant add(MachOper* oper);
    1.74 -    Constant add(jfloat f) {
    1.75 +    Constant add(MachConstantNode* n, BasicType type, jvalue value);
    1.76 +    Constant add(MachConstantNode* n, MachOper* oper);
    1.77 +    Constant add(MachConstantNode* n, jfloat f) {
    1.78        jvalue value; value.f = f;
    1.79 -      return add(T_FLOAT, value);
    1.80 +      return add(n, T_FLOAT, value);
    1.81      }
    1.82 -    Constant add(jdouble d) {
    1.83 +    Constant add(MachConstantNode* n, jdouble d) {
    1.84        jvalue value; value.d = d;
    1.85 -      return add(T_DOUBLE, value);
    1.86 +      return add(n, T_DOUBLE, value);
    1.87      }
    1.88  
    1.89 -    // Jump table
    1.90 -    Constant allocate_jump_table(MachConstantNode* n);
    1.91 -    void         fill_jump_table(CodeBuffer& cb, MachConstantNode* n, GrowableArray<Label*> labels) const;
    1.92 +    // Jump-table
    1.93 +    Constant  add_jump_table(MachConstantNode* n);
    1.94 +    void     fill_jump_table(CodeBuffer& cb, MachConstantNode* n, GrowableArray<Label*> labels) const;
    1.95    };
    1.96  
    1.97   private:

mercurial