src/share/vm/code/vtableStubs.hpp

Mon, 19 Aug 2019 10:11:31 +0200

author
neugens
date
Mon, 19 Aug 2019 10:11:31 +0200
changeset 9861
a248d0be1309
parent 9185
82f9d3b7e317
child 9203
53eec13fbaa5
permissions
-rw-r--r--

8229401: Fix JFR code cache test failures
8223689: Add JFR Thread Sampling Support
8223690: Add JFR BiasedLock Event Support
8223691: Add JFR G1 Region Type Change Event Support
8223692: Add JFR G1 Heap Summary Event Support
Summary: Backport JFR from JDK11, additional fixes
Reviewed-by: neugens, apetushkov
Contributed-by: denghui.ddh@alibaba-inc.com

duke@435 1 /*
poonam@9185 2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_CODE_VTABLESTUBS_HPP
stefank@2314 26 #define SHARE_VM_CODE_VTABLESTUBS_HPP
stefank@2314 27
stefank@2325 28 #include "code/vmreg.hpp"
stefank@2314 29 #include "memory/allocation.hpp"
stefank@2314 30
duke@435 31 // A VtableStub holds an individual code stub for a pair (vtable index, #args) for either itables or vtables
duke@435 32 // There's a one-to-one relationship between a VtableStub and such a pair.
duke@435 33
duke@435 34 class VtableStub {
duke@435 35 private:
duke@435 36 friend class VtableStubs;
duke@435 37
duke@435 38 static address _chunk; // For allocation
duke@435 39 static address _chunk_end; // For allocation
duke@435 40 static VMReg _receiver_location; // Where to find receiver
duke@435 41
duke@435 42 VtableStub* _next; // Pointer to next entry in hash table
duke@435 43 const short _index; // vtable index
duke@435 44 short _ame_offset; // Where an AbstractMethodError might occur
duke@435 45 short _npe_offset; // Where a NullPointerException might occur
duke@435 46 bool _is_vtable_stub; // True if vtable stub, false, is itable stub
duke@435 47 /* code follows here */ // The vtableStub code
duke@435 48
coleenp@5614 49 void* operator new(size_t size, int code_size) throw();
duke@435 50
duke@435 51 VtableStub(bool is_vtable_stub, int index)
duke@435 52 : _next(NULL), _is_vtable_stub(is_vtable_stub),
duke@435 53 _index(index), _ame_offset(-1), _npe_offset(-1) {}
duke@435 54 VtableStub* next() const { return _next; }
duke@435 55 int index() const { return _index; }
duke@435 56 static VMReg receiver_location() { return _receiver_location; }
duke@435 57 void set_next(VtableStub* n) { _next = n; }
twisti@3969 58
twisti@3969 59 public:
duke@435 60 address code_begin() const { return (address)(this + 1); }
duke@435 61 address code_end() const { return code_begin() + pd_code_size_limit(_is_vtable_stub); }
duke@435 62 address entry_point() const { return code_begin(); }
duke@435 63 static int entry_offset() { return sizeof(class VtableStub); }
duke@435 64
duke@435 65 bool matches(bool is_vtable_stub, int index) const {
duke@435 66 return _index == index && _is_vtable_stub == is_vtable_stub;
duke@435 67 }
duke@435 68 bool contains(address pc) const { return code_begin() <= pc && pc < code_end(); }
duke@435 69
twisti@3969 70 private:
duke@435 71 void set_exception_points(address npe_addr, address ame_addr) {
duke@435 72 _npe_offset = npe_addr - code_begin();
duke@435 73 _ame_offset = ame_addr - code_begin();
duke@435 74 assert(is_abstract_method_error(ame_addr), "offset must be correct");
duke@435 75 assert(is_null_pointer_exception(npe_addr), "offset must be correct");
duke@435 76 assert(!is_abstract_method_error(npe_addr), "offset must be correct");
duke@435 77 assert(!is_null_pointer_exception(ame_addr), "offset must be correct");
duke@435 78 }
duke@435 79
duke@435 80 // platform-dependent routines
duke@435 81 static int pd_code_size_limit(bool is_vtable_stub);
duke@435 82 static int pd_code_alignment();
duke@435 83 // CNC: Removed because vtable stubs are now made with an ideal graph
duke@435 84 // static bool pd_disregard_arg_size();
duke@435 85
duke@435 86 static void align_chunk() {
duke@435 87 uintptr_t off = (uintptr_t)( _chunk + sizeof(VtableStub) ) % pd_code_alignment();
duke@435 88 if (off != 0) _chunk += pd_code_alignment() - off;
duke@435 89 }
duke@435 90
duke@435 91 public:
duke@435 92 // Query
duke@435 93 bool is_itable_stub() { return !_is_vtable_stub; }
duke@435 94 bool is_vtable_stub() { return _is_vtable_stub; }
duke@435 95 bool is_abstract_method_error(address epc) { return epc == code_begin()+_ame_offset; }
duke@435 96 bool is_null_pointer_exception(address epc) { return epc == code_begin()+_npe_offset; }
duke@435 97
bobv@2036 98 void print_on(outputStream* st) const;
bobv@2036 99 void print() const { print_on(tty); }
bobv@2036 100
duke@435 101 };
duke@435 102
duke@435 103
duke@435 104 // VtableStubs creates the code stubs for compiled calls through vtables.
duke@435 105 // There is one stub per (vtable index, args_size) pair, and the stubs are
duke@435 106 // never deallocated. They don't need to be GCed because they contain no oops.
duke@435 107
duke@435 108 class VtableStubs : AllStatic {
duke@435 109 public: // N must be public (some compilers need this for _table)
duke@435 110 enum {
duke@435 111 N = 256, // size of stub table; must be power of two
duke@435 112 mask = N - 1
duke@435 113 };
duke@435 114
duke@435 115 private:
duke@435 116 static VtableStub* _table[N]; // table of existing stubs
duke@435 117 static int _number_of_vtable_stubs; // number of stubs created so far (for statistics)
duke@435 118
duke@435 119 static VtableStub* create_vtable_stub(int vtable_index);
duke@435 120 static VtableStub* create_itable_stub(int vtable_index);
duke@435 121 static VtableStub* lookup (bool is_vtable_stub, int vtable_index);
duke@435 122 static void enter (bool is_vtable_stub, int vtable_index, VtableStub* s);
duke@435 123 static inline uint hash (bool is_vtable_stub, int vtable_index);
drchase@5732 124 static address find_stub (bool is_vtable_stub, int vtable_index);
duke@435 125
duke@435 126 public:
drchase@5732 127 static address find_vtable_stub(int vtable_index) { return find_stub(true, vtable_index); }
drchase@5732 128 static address find_itable_stub(int itable_index) { return find_stub(false, itable_index); }
poonam@9185 129 static VtableStub* entry_point(address pc); // vtable stub entry point for a pc
duke@435 130 static bool contains(address pc); // is pc within any stub?
duke@435 131 static VtableStub* stub_containing(address pc); // stub containing pc or NULL
duke@435 132 static int number_of_vtable_stubs() { return _number_of_vtable_stubs; }
duke@435 133 static void initialize();
sspitsyn@6310 134 static void vtable_stub_do(void f(VtableStub*)); // iterates over all vtable stubs
duke@435 135 };
stefank@2314 136
stefank@2314 137 #endif // SHARE_VM_CODE_VTABLESTUBS_HPP

mercurial