annotate src/share/vm/code/vtableStubs.hpp @ 1972:f95d63e2154a

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