author | tschatzl |
Wed, 08 Aug 2018 15:31:06 +0200 | |
changeset 51333 | f6641fcf7b7e |
parent 49655 | d6893a76c554 |
child 51618 | 54b344d9dd4e |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49655
d6893a76c554
8199406: Performance drop with Java JDK 1.8.0_162-b32
poonam
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_CODE_VTABLESTUBS_HPP |
26 |
#define SHARE_VM_CODE_VTABLESTUBS_HPP |
|
27 |
||
7408
c04a5c989f26
7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents:
7397
diff
changeset
|
28 |
#include "code/vmreg.hpp" |
7397 | 29 |
#include "memory/allocation.hpp" |
30 |
||
1 | 31 |
// A VtableStub holds an individual code stub for a pair (vtable index, #args) for either itables or vtables |
32 |
// There's a one-to-one relationship between a VtableStub and such a pair. |
|
33 |
||
34 |
class VtableStub { |
|
35 |
private: |
|
36 |
friend class VtableStubs; |
|
37 |
||
38 |
static address _chunk; // For allocation |
|
39 |
static address _chunk_end; // For allocation |
|
40 |
static VMReg _receiver_location; // Where to find receiver |
|
41 |
||
42 |
VtableStub* _next; // Pointer to next entry in hash table |
|
43 |
const short _index; // vtable index |
|
44 |
short _ame_offset; // Where an AbstractMethodError might occur |
|
45 |
short _npe_offset; // Where a NullPointerException might occur |
|
46 |
bool _is_vtable_stub; // True if vtable stub, false, is itable stub |
|
47 |
/* code follows here */ // The vtableStub code |
|
48 |
||
19696
bd5a0131bde1
8021954: VM SIGSEGV during classloading on MacOS; hs_err_pid file produced
coleenp
parents:
13728
diff
changeset
|
49 |
void* operator new(size_t size, int code_size) throw(); |
1 | 50 |
|
51 |
VtableStub(bool is_vtable_stub, int index) |
|
51333
f6641fcf7b7e
8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents:
49655
diff
changeset
|
52 |
: _next(NULL), _index(index), _ame_offset(-1), _npe_offset(-1), |
f6641fcf7b7e
8208670: Compiler changes to allow enabling -Wreorder
tschatzl
parents:
49655
diff
changeset
|
53 |
_is_vtable_stub(is_vtable_stub) {} |
1 | 54 |
VtableStub* next() const { return _next; } |
55 |
int index() const { return _index; } |
|
56 |
static VMReg receiver_location() { return _receiver_location; } |
|
57 |
void set_next(VtableStub* n) { _next = n; } |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7408
diff
changeset
|
58 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7408
diff
changeset
|
59 |
public: |
1 | 60 |
address code_begin() const { return (address)(this + 1); } |
61 |
address code_end() const { return code_begin() + pd_code_size_limit(_is_vtable_stub); } |
|
62 |
address entry_point() const { return code_begin(); } |
|
63 |
static int entry_offset() { return sizeof(class VtableStub); } |
|
64 |
||
65 |
bool matches(bool is_vtable_stub, int index) const { |
|
66 |
return _index == index && _is_vtable_stub == is_vtable_stub; |
|
67 |
} |
|
68 |
bool contains(address pc) const { return code_begin() <= pc && pc < code_end(); } |
|
69 |
||
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
7408
diff
changeset
|
70 |
private: |
1 | 71 |
void set_exception_points(address npe_addr, address ame_addr) { |
72 |
_npe_offset = npe_addr - code_begin(); |
|
73 |
_ame_offset = ame_addr - code_begin(); |
|
74 |
assert(is_abstract_method_error(ame_addr), "offset must be correct"); |
|
75 |
assert(is_null_pointer_exception(npe_addr), "offset must be correct"); |
|
76 |
assert(!is_abstract_method_error(npe_addr), "offset must be correct"); |
|
77 |
assert(!is_null_pointer_exception(ame_addr), "offset must be correct"); |
|
78 |
} |
|
79 |
||
80 |
// platform-dependent routines |
|
81 |
static int pd_code_size_limit(bool is_vtable_stub); |
|
82 |
static int pd_code_alignment(); |
|
83 |
// CNC: Removed because vtable stubs are now made with an ideal graph |
|
84 |
// static bool pd_disregard_arg_size(); |
|
85 |
||
86 |
static void align_chunk() { |
|
87 |
uintptr_t off = (uintptr_t)( _chunk + sizeof(VtableStub) ) % pd_code_alignment(); |
|
88 |
if (off != 0) _chunk += pd_code_alignment() - off; |
|
89 |
} |
|
90 |
||
91 |
public: |
|
92 |
// Query |
|
93 |
bool is_itable_stub() { return !_is_vtable_stub; } |
|
94 |
bool is_vtable_stub() { return _is_vtable_stub; } |
|
95 |
bool is_abstract_method_error(address epc) { return epc == code_begin()+_ame_offset; } |
|
96 |
bool is_null_pointer_exception(address epc) { return epc == code_begin()+_npe_offset; } |
|
97 |
||
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
98 |
void print_on(outputStream* st) const; |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
99 |
void print() const { print_on(tty); } |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
100 |
|
1 | 101 |
}; |
102 |
||
103 |
||
104 |
// VtableStubs creates the code stubs for compiled calls through vtables. |
|
105 |
// There is one stub per (vtable index, args_size) pair, and the stubs are |
|
106 |
// never deallocated. They don't need to be GCed because they contain no oops. |
|
107 |
||
108 |
class VtableStubs : AllStatic { |
|
109 |
public: // N must be public (some compilers need this for _table) |
|
110 |
enum { |
|
111 |
N = 256, // size of stub table; must be power of two |
|
112 |
mask = N - 1 |
|
113 |
}; |
|
114 |
||
115 |
private: |
|
116 |
static VtableStub* _table[N]; // table of existing stubs |
|
117 |
static int _number_of_vtable_stubs; // number of stubs created so far (for statistics) |
|
118 |
||
119 |
static VtableStub* create_vtable_stub(int vtable_index); |
|
120 |
static VtableStub* create_itable_stub(int vtable_index); |
|
121 |
static VtableStub* lookup (bool is_vtable_stub, int vtable_index); |
|
122 |
static void enter (bool is_vtable_stub, int vtable_index, VtableStub* s); |
|
123 |
static inline uint hash (bool is_vtable_stub, int vtable_index); |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19696
diff
changeset
|
124 |
static address find_stub (bool is_vtable_stub, int vtable_index); |
1 | 125 |
|
126 |
public: |
|
20017
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19696
diff
changeset
|
127 |
static address find_vtable_stub(int vtable_index) { return find_stub(true, vtable_index); } |
81eba62e9048
8014013: CallInfo structure no longer accurately reports the result of a LinkResolver operation
drchase
parents:
19696
diff
changeset
|
128 |
static address find_itable_stub(int itable_index) { return find_stub(false, itable_index); } |
49655
d6893a76c554
8199406: Performance drop with Java JDK 1.8.0_162-b32
poonam
parents:
47216
diff
changeset
|
129 |
static VtableStub* entry_point(address pc); // vtable stub entry point for a pc |
1 | 130 |
static bool contains(address pc); // is pc within any stub? |
131 |
static VtableStub* stub_containing(address pc); // stub containing pc or NULL |
|
132 |
static int number_of_vtable_stubs() { return _number_of_vtable_stubs; } |
|
133 |
static void initialize(); |
|
22747
f467c14746f5
8025841: JVMTI: "vtable stub" dynamic code notification is misplaced
sspitsyn
parents:
20017
diff
changeset
|
134 |
static void vtable_stub_do(void f(VtableStub*)); // iterates over all vtable stubs |
1 | 135 |
}; |
7397 | 136 |
|
137 |
#endif // SHARE_VM_CODE_VTABLESTUBS_HPP |