0 /*
1 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #ifndef SHARE_VM_CODE_ICBUFFER_HPP
25 #define SHARE_VM_CODE_ICBUFFER_HPP
26
27 #include "asm/codeBuffer.hpp"
28 #include "code/stubs.hpp"
29 #include "interpreter/bytecodes.hpp"
30 #include "memory/allocation.hpp"
31 #include "utilities/align.hpp"
32 #include "utilities/macros.hpp"
33
34 //
35 // For CompiledIC's:
36 //
37 // In cases where we do not have MT-safe state transformation,
38 // we go to a transition state, using ICStubs. At a safepoint,
39 // the inline caches are transferred from the transitional code:
40 //
41 // instruction_address --> 01 set xxx_oop, Ginline_cache_klass
42 // 23 jump_to Gtemp, yyyy
43 // 4 nop
44
45 class ICStub: public Stub {
46 private:
47 int _size; // total size of the stub incl. code
48 address _ic_site; // points at call instruction of owning ic-buffer
49 /* stub code follows here */
50 protected:
|
0 /*
1 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation.
7 *
8 * This code is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #ifndef SHARE_VM_CODE_ICBUFFER_HPP
25 #define SHARE_VM_CODE_ICBUFFER_HPP
26
27 #include "asm/codeBuffer.hpp"
28 #include "code/stubs.hpp"
29 #include "interpreter/bytecodes.hpp"
30 #include "memory/allocation.hpp"
31 #include "runtime/safepointVerifiers.hpp"
32 #include "utilities/align.hpp"
33 #include "utilities/debug.hpp"
34 #include "utilities/macros.hpp"
35
36 //
37 // For CompiledIC's:
38 //
39 // In cases where we do not have MT-safe state transformation,
40 // we go to a transition state, using ICStubs. At a safepoint,
41 // the inline caches are transferred from the transitional code:
42 //
43 // instruction_address --> 01 set xxx_oop, Ginline_cache_klass
44 // 23 jump_to Gtemp, yyyy
45 // 4 nop
46
47 class ICStub: public Stub {
48 private:
49 int _size; // total size of the stub incl. code
50 address _ic_site; // points at call instruction of owning ic-buffer
51 /* stub code follows here */
52 protected:
|
75 address destination() const; // destination of jump instruction
76 void* cached_value() const; // cached_value for stub
77
78 // Debugging
79 void verify() PRODUCT_RETURN;
80 void print() PRODUCT_RETURN;
81
82 // Creation
83 friend ICStub* ICStub_from_destination_address(address destination_address);
84 };
85
86 // ICStub Creation
87 inline ICStub* ICStub_from_destination_address(address destination_address) {
88 ICStub* stub = (ICStub*) (destination_address - align_up(sizeof(ICStub), CodeEntryAlignment));
89 #ifdef ASSERT
90 stub->verify();
91 #endif
92 return stub;
93 }
94
95 class InlineCacheBuffer: public AllStatic {
96 private:
97 // friends
98 friend class ICStub;
99
100 static int ic_stub_code_size();
101
102 static StubQueue* _buffer;
103
104 static CompiledICHolder* _pending_released;
105 static int _pending_count;
106
107 DEBUG_ONLY(static volatile int _needs_refill;)
108
109 static StubQueue* buffer() { return _buffer; }
110
111 static ICStub* new_ic_stub();
112
113 // Machine-dependent implementation of ICBuffer
114 static void assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point);
115 static address ic_buffer_entry_point (address code_begin);
116 static void* ic_buffer_cached_value (address code_begin);
117
118 public:
119
120 // Initialization; must be called before first usage
121 static void initialize();
122
123 // Access
124 static bool contains(address instruction_address);
125
126 // removes the ICStubs after backpatching
|
77 address destination() const; // destination of jump instruction
78 void* cached_value() const; // cached_value for stub
79
80 // Debugging
81 void verify() PRODUCT_RETURN;
82 void print() PRODUCT_RETURN;
83
84 // Creation
85 friend ICStub* ICStub_from_destination_address(address destination_address);
86 };
87
88 // ICStub Creation
89 inline ICStub* ICStub_from_destination_address(address destination_address) {
90 ICStub* stub = (ICStub*) (destination_address - align_up(sizeof(ICStub), CodeEntryAlignment));
91 #ifdef ASSERT
92 stub->verify();
93 #endif
94 return stub;
95 }
96
97 #ifdef ASSERT
98 // The ICRefillVerifier class is a stack allocated RAII object used to
99 // detect if a failed IC transition that required IC stub refilling has
100 // been accidentally missed. It is up to the caller to in that case
101 // refill IC stubs.
102 class ICRefillVerifier: StackObj {
103 bool _refill_requested;
104 bool _refill_remembered;
105
106 public:
107 ICRefillVerifier();
108 ~ICRefillVerifier();
109
110 void request_refill() { _refill_requested = true; }
111 void request_remembered() { _refill_remembered = true; }
112 };
113
114 // The ICRefillVerifierMark is used to set the thread's current
115 // ICRefillVerifier to a provided one. This is useful in particular
116 // when transitioning IC stubs in parallel and refilling from the
117 // master thread invoking the IC stub transitioning code.
118 class ICRefillVerifierMark: StackObj {
119 public:
120 ICRefillVerifierMark(ICRefillVerifier* verifier);
121 ~ICRefillVerifierMark();
122 };
123 #else
124 class ICRefillVerifier: StackObj {
125 public:
126 ICRefillVerifier() {}
127 };
128 class ICRefillVerifierMark: StackObj {
129 public:
130 ICRefillVerifierMark(ICRefillVerifier* verifier) {}
131 };
132 #endif
133
134 class InlineCacheBuffer: public AllStatic {
135 private:
136 // friends
137 friend class ICStub;
138
139 static int ic_stub_code_size();
140
141 static StubQueue* _buffer;
142
143 static CompiledICHolder* _pending_released;
144 static int _pending_count;
145
146 static StubQueue* buffer() { return _buffer; }
147
148 static ICStub* new_ic_stub();
149
150 // Machine-dependent implementation of ICBuffer
151 static void assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point);
152 static address ic_buffer_entry_point (address code_begin);
153 static void* ic_buffer_cached_value (address code_begin);
154
155 public:
156
157 // Initialization; must be called before first usage
158 static void initialize();
159
160 // Access
161 static bool contains(address instruction_address);
162
163 // removes the ICStubs after backpatching
|