/* * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
class CodeBuffer; class Metadata; class MachConstantNode; class MachOper;
class ConstantTable { public: // Constant entry of the constant table. class Constant { private:
BasicType _type; bool _is_array; int _alignment; union {
jvalue _value;
Metadata* _metadata;
GrowableArray<jvalue>* _array;
} _v; int _offset; // offset of this constant (in bytes) relative to the constant table base. float _freq; bool _can_be_reused; // true (default) if the value can be shared with other users.
private:
GrowableArray<Constant> _constants; // Constants of this table. int _size; // Size in bytes the emitted constant table takes (including padding). int _table_base_offset; // Offset of the table base that gets added to the constant offsets. int _nof_jump_tables; // Number of jump-tables in this constant table.
staticint qsort_comparator(Constant* a, Constant* b);
// We use negative frequencies to keep the order of the // jump-tables in which they were added. Otherwise we get into // trouble with relocation. float next_jump_table_freq() { return -1.0f * (++_nof_jump_tables); }
public:
ConstantTable() :
_size(-1),
_table_base_offset(-1), // We can use -1 here since the constant table is always bigger than 2 bytes (-(size / 2), see MachConstantBaseNode::emit).
_nof_jump_tables(0)
{}
int calculate_table_base_offset() const; // AD specific void set_table_base_offset(int x) { assert(_table_base_offset == -1 || x == _table_base_offset, "can't change"); _table_base_offset = x; } int table_base_offset() const { assert(_table_base_offset != -1, "not set yet"); return _table_base_offset; }
bool emit(CodeBuffer& cb) const;
// Returns the offset of the last entry (the top) of the constant table. int top_offset() const { assert(_constants.top().offset() != -1, "not bound yet"); return _constants.top().offset(); }
void calculate_offsets_and_size(); int find_offset(Constant& con) const;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.