Sat, 01 Sep 2012 13:25:18 -0400
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>
1 /*
2 * Copyright (c) 1997, 2012, 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 *
23 */
25 #ifndef SHARE_VM_CODE_ICBUFFER_HPP
26 #define SHARE_VM_CODE_ICBUFFER_HPP
28 #include "code/stubs.hpp"
29 #include "interpreter/bytecodes.hpp"
30 #include "memory/allocation.hpp"
32 //
33 // For CompiledIC's:
34 //
35 // In cases where we do not have MT-safe state transformation,
36 // we go to a transition state, using ICStubs. At a safepoint,
37 // the inline caches are transferred from the transitional code:
38 //
39 // instruction_address --> 01 set xxx_oop, Ginline_cache_klass
40 // 23 jump_to Gtemp, yyyy
41 // 4 nop
43 class ICStub: public Stub {
44 private:
45 int _size; // total size of the stub incl. code
46 address _ic_site; // points at call instruction of owning ic-buffer
47 /* stub code follows here */
48 protected:
49 friend class ICStubInterface;
50 // This will be called only by ICStubInterface
51 void initialize(int size) { _size = size; _ic_site = NULL; }
52 void finalize(); // called when a method is removed
54 // General info
55 int size() const { return _size; }
56 static int code_size_to_size(int code_size) { return round_to(sizeof(ICStub), CodeEntryAlignment) + code_size; }
58 public:
59 // Creation
60 void set_stub(CompiledIC *ic, void* cached_value, address dest_addr);
62 // Code info
63 address code_begin() const { return (address)this + round_to(sizeof(ICStub), CodeEntryAlignment); }
64 address code_end() const { return (address)this + size(); }
66 // Call site info
67 address ic_site() const { return _ic_site; }
68 void clear();
69 bool is_empty() const { return _ic_site == NULL; }
71 // stub info
72 address destination() const; // destination of jump instruction
73 void* cached_value() const; // cached_value for stub
75 // Debugging
76 void verify() PRODUCT_RETURN;
77 void print() PRODUCT_RETURN;
79 // Creation
80 friend ICStub* ICStub_from_destination_address(address destination_address);
81 };
83 // ICStub Creation
84 inline ICStub* ICStub_from_destination_address(address destination_address) {
85 ICStub* stub = (ICStub*) (destination_address - round_to(sizeof(ICStub), CodeEntryAlignment));
86 #ifdef ASSERT
87 stub->verify();
88 #endif
89 return stub;
90 }
92 class InlineCacheBuffer: public AllStatic {
93 private:
94 // friends
95 friend class ICStub;
97 static int ic_stub_code_size();
99 static StubQueue* _buffer;
100 static ICStub* _next_stub;
102 static CompiledICHolder* _pending_released;
103 static int _pending_count;
105 static StubQueue* buffer() { return _buffer; }
106 static void set_next_stub(ICStub* next_stub) { _next_stub = next_stub; }
107 static ICStub* get_next_stub() { return _next_stub; }
109 static void init_next_stub();
111 static ICStub* new_ic_stub();
114 // Machine-dependent implementation of ICBuffer
115 static void assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point);
116 static address ic_buffer_entry_point (address code_begin);
117 static void* ic_buffer_cached_value (address code_begin);
119 public:
121 // Initialization; must be called before first usage
122 static void initialize();
124 // Access
125 static bool contains(address instruction_address);
127 // removes the ICStubs after backpatching
128 static void update_inline_caches();
130 // for debugging
131 static bool is_empty();
133 static void release_pending_icholders();
134 static void queue_for_release(CompiledICHolder* icholder);
135 static int pending_icholder_count() { return _pending_count; }
137 // New interface
138 static void create_transition_stub(CompiledIC *ic, void* cached_value, address entry);
139 static address ic_destination_for(CompiledIC *ic);
140 static void* cached_value_for(CompiledIC *ic);
141 };
143 #endif // SHARE_VM_CODE_ICBUFFER_HPP