< prev index next >

src/hotspot/share/asm/codeBuffer.hpp

Print this page

  1 /*
  2  * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *

192   bool allocates2(address pc) const { return pc >= _start && pc <= _limit; }
193 
194   // checks if two CodeSections are disjoint
195   //
196   // limit is an exclusive address and can be the start of another
197   // section.
198   bool disjoint(CodeSection* cs) const { return cs->_limit <= _start || cs->_start >= _limit; }
199 
200   void    set_end(address pc)       { assert(allocates2(pc), "not in CodeBuffer memory: " INTPTR_FORMAT " <= " INTPTR_FORMAT " <= " INTPTR_FORMAT, p2i(_start), p2i(pc), p2i(_limit)); _end = pc; }
201   void    set_mark(address pc)      { assert(contains2(pc), "not in codeBuffer");
202                                       _mark = pc; }
203   void    set_mark()                { _mark = _end; }
204   void    clear_mark()              { _mark = nullptr; }
205 
206   void    set_locs_end(relocInfo* p) {
207     assert(p <= locs_limit(), "locs data fits in allocated buffer");
208     _locs_end = p;
209   }
210   void    set_locs_point(address pc) {
211     assert(pc >= locs_point(), "relocation addr may not decrease");
212     assert(allocates2(pc),     "relocation addr must be in this section");
213     _locs_point = pc;
214   }
215 
216   void register_skipped(int size) {
217     _skipped_instructions_size += size;
218   }
219 
220   // Code emission
221   void emit_int8(uint8_t x1) {
222     address curr = end();
223     *((uint8_t*)  curr++) = x1;
224     set_end(curr);
225   }
226 
227   template <typename T>
228   void emit_native(T x) { put_native(end(), x); set_end(end() + sizeof x); }
229 
230   void emit_int16(uint16_t x) { emit_native(x); }
231   void emit_int16(uint8_t x1, uint8_t x2) {
232     address curr = end();

  1 /*
  2  * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *

192   bool allocates2(address pc) const { return pc >= _start && pc <= _limit; }
193 
194   // checks if two CodeSections are disjoint
195   //
196   // limit is an exclusive address and can be the start of another
197   // section.
198   bool disjoint(CodeSection* cs) const { return cs->_limit <= _start || cs->_start >= _limit; }
199 
200   void    set_end(address pc)       { assert(allocates2(pc), "not in CodeBuffer memory: " INTPTR_FORMAT " <= " INTPTR_FORMAT " <= " INTPTR_FORMAT, p2i(_start), p2i(pc), p2i(_limit)); _end = pc; }
201   void    set_mark(address pc)      { assert(contains2(pc), "not in codeBuffer");
202                                       _mark = pc; }
203   void    set_mark()                { _mark = _end; }
204   void    clear_mark()              { _mark = nullptr; }
205 
206   void    set_locs_end(relocInfo* p) {
207     assert(p <= locs_limit(), "locs data fits in allocated buffer");
208     _locs_end = p;
209   }
210   void    set_locs_point(address pc) {
211     assert(pc >= locs_point(), "relocation addr may not decrease");
212     assert(allocates2(pc),     "relocation addr " INTPTR_FORMAT " must be in this section from " INTPTR_FORMAT " to " INTPTR_FORMAT, p2i(pc), p2i(_start), p2i(_limit));
213     _locs_point = pc;
214   }
215 
216   void register_skipped(int size) {
217     _skipped_instructions_size += size;
218   }
219 
220   // Code emission
221   void emit_int8(uint8_t x1) {
222     address curr = end();
223     *((uint8_t*)  curr++) = x1;
224     set_end(curr);
225   }
226 
227   template <typename T>
228   void emit_native(T x) { put_native(end(), x); set_end(end() + sizeof x); }
229 
230   void emit_int16(uint16_t x) { emit_native(x); }
231   void emit_int16(uint8_t x1, uint8_t x2) {
232     address curr = end();
< prev index next >