annotate src/share/vm/code/icBuffer.hpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents f95d63e2154a
children b31471cdc53e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
2 * Copyright (c) 1997, 2012, 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: 1552
diff changeset
25 #ifndef SHARE_VM_CODE_ICBUFFER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_CODE_ICBUFFER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "code/stubs.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "interpreter/bytecodes.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32 //
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // For CompiledIC's:
a61af66fc99e Initial load
duke
parents:
diff changeset
34 //
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // In cases where we do not have MT-safe state transformation,
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // we go to a transition state, using ICStubs. At a safepoint,
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // the inline caches are transferred from the transitional code:
a61af66fc99e Initial load
duke
parents:
diff changeset
38 //
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // instruction_address --> 01 set xxx_oop, Ginline_cache_klass
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // 23 jump_to Gtemp, yyyy
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // 4 nop
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class ICStub: public Stub {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
45 int _size; // total size of the stub incl. code
a61af66fc99e Initial load
duke
parents:
diff changeset
46 address _ic_site; // points at call instruction of owning ic-buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
47 /* stub code follows here */
a61af66fc99e Initial load
duke
parents:
diff changeset
48 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
49 friend class ICStubInterface;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // This will be called only by ICStubInterface
a61af66fc99e Initial load
duke
parents:
diff changeset
51 void initialize(int size) { _size = size; _ic_site = NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
52 void finalize(); // called when a method is removed
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // General info
a61af66fc99e Initial load
duke
parents:
diff changeset
55 int size() const { return _size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 static int code_size_to_size(int code_size) { return round_to(sizeof(ICStub), CodeEntryAlignment) + code_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Creation
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
60 void set_stub(CompiledIC *ic, void* cached_value, address dest_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Code info
a61af66fc99e Initial load
duke
parents:
diff changeset
63 address code_begin() const { return (address)this + round_to(sizeof(ICStub), CodeEntryAlignment); }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 address code_end() const { return (address)this + size(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Call site info
a61af66fc99e Initial load
duke
parents:
diff changeset
67 address ic_site() const { return _ic_site; }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 void clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
69 bool is_empty() const { return _ic_site == NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // stub info
a61af66fc99e Initial load
duke
parents:
diff changeset
72 address destination() const; // destination of jump instruction
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
73 void* cached_value() const; // cached_value for stub
0
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
76 void verify() PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 void print() PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
80 friend ICStub* ICStub_from_destination_address(address destination_address);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 };
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // ICStub Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
84 inline ICStub* ICStub_from_destination_address(address destination_address) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 ICStub* stub = (ICStub*) (destination_address - round_to(sizeof(ICStub), CodeEntryAlignment));
a61af66fc99e Initial load
duke
parents:
diff changeset
86 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
87 stub->verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
88 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
89 return stub;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 class InlineCacheBuffer: public AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // friends
a61af66fc99e Initial load
duke
parents:
diff changeset
95 friend class ICStub;
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 static int ic_stub_code_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 static StubQueue* _buffer;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 static ICStub* _next_stub;
a61af66fc99e Initial load
duke
parents:
diff changeset
101
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
102 static CompiledICHolder* _pending_released;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
103 static int _pending_count;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
104
0
a61af66fc99e Initial load
duke
parents:
diff changeset
105 static StubQueue* buffer() { return _buffer; }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 static void set_next_stub(ICStub* next_stub) { _next_stub = next_stub; }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 static ICStub* get_next_stub() { return _next_stub; }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 static void init_next_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 static ICStub* new_ic_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // Machine-dependent implementation of ICBuffer
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
115 static void assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
116 static address ic_buffer_entry_point (address code_begin);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
117 static void* ic_buffer_cached_value (address code_begin);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // Initialization; must be called before first usage
a61af66fc99e Initial load
duke
parents:
diff changeset
122 static void initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // Access
a61af66fc99e Initial load
duke
parents:
diff changeset
125 static bool contains(address instruction_address);
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // removes the ICStubs after backpatching
a61af66fc99e Initial load
duke
parents:
diff changeset
128 static void update_inline_caches();
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // for debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
131 static bool is_empty();
a61af66fc99e Initial load
duke
parents:
diff changeset
132
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
133 static void release_pending_icholders();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
134 static void queue_for_release(CompiledICHolder* icholder);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
135 static int pending_icholder_count() { return _pending_count; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 // New interface
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
138 static void create_transition_stub(CompiledIC *ic, void* cached_value, address entry);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
139 static address ic_destination_for(CompiledIC *ic);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
140 static void* cached_value_for(CompiledIC *ic);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
141 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
142
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
143 #endif // SHARE_VM_CODE_ICBUFFER_HPP