annotate src/share/vm/code/icBuffer.hpp @ 10408:836a62f43af9

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Wed, 19 Jun 2013 10:45:56 +0200
parents b9a918201d47
children d8041d695d19
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
6796
b31471cdc53e 7200163: add CodeComments functionality to assember stubs
kvn
parents: 6725
diff changeset
28 #include "asm/codeBuffer.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "code/stubs.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "interpreter/bytecodes.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 //
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // For CompiledIC's:
a61af66fc99e Initial load
duke
parents:
diff changeset
35 //
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // In cases where we do not have MT-safe state transformation,
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // we go to a transition state, using ICStubs. At a safepoint,
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // the inline caches are transferred from the transitional code:
a61af66fc99e Initial load
duke
parents:
diff changeset
39 //
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // instruction_address --> 01 set xxx_oop, Ginline_cache_klass
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // 23 jump_to Gtemp, yyyy
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // 4 nop
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 class ICStub: public Stub {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
46 int _size; // total size of the stub incl. code
a61af66fc99e Initial load
duke
parents:
diff changeset
47 address _ic_site; // points at call instruction of owning ic-buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
48 /* stub code follows here */
a61af66fc99e Initial load
duke
parents:
diff changeset
49 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
50 friend class ICStubInterface;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // This will be called only by ICStubInterface
6796
b31471cdc53e 7200163: add CodeComments functionality to assember stubs
kvn
parents: 6725
diff changeset
52 void initialize(int size,
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 6796
diff changeset
53 CodeStrings strings) { _size = size; _ic_site = NULL; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
54 void finalize(); // called when a method is removed
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // General info
a61af66fc99e Initial load
duke
parents:
diff changeset
57 int size() const { return _size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
58 static int code_size_to_size(int code_size) { return round_to(sizeof(ICStub), CodeEntryAlignment) + code_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Creation
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
62 void set_stub(CompiledIC *ic, void* cached_value, address dest_addr);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // Code info
a61af66fc99e Initial load
duke
parents:
diff changeset
65 address code_begin() const { return (address)this + round_to(sizeof(ICStub), CodeEntryAlignment); }
a61af66fc99e Initial load
duke
parents:
diff changeset
66 address code_end() const { return (address)this + size(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // Call site info
a61af66fc99e Initial load
duke
parents:
diff changeset
69 address ic_site() const { return _ic_site; }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 void clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
71 bool is_empty() const { return _ic_site == NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // stub info
a61af66fc99e Initial load
duke
parents:
diff changeset
74 address destination() const; // destination of jump instruction
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
75 void* cached_value() const; // cached_value for stub
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
78 void verify() PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 void print() PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
82 friend ICStub* ICStub_from_destination_address(address destination_address);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 };
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // ICStub Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
86 inline ICStub* ICStub_from_destination_address(address destination_address) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 ICStub* stub = (ICStub*) (destination_address - round_to(sizeof(ICStub), CodeEntryAlignment));
a61af66fc99e Initial load
duke
parents:
diff changeset
88 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
89 stub->verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
90 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
91 return stub;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 class InlineCacheBuffer: public AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // friends
a61af66fc99e Initial load
duke
parents:
diff changeset
97 friend class ICStub;
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 static int ic_stub_code_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 static StubQueue* _buffer;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 static ICStub* _next_stub;
a61af66fc99e Initial load
duke
parents:
diff changeset
103
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
104 static CompiledICHolder* _pending_released;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
105 static int _pending_count;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
106
0
a61af66fc99e Initial load
duke
parents:
diff changeset
107 static StubQueue* buffer() { return _buffer; }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 static void set_next_stub(ICStub* next_stub) { _next_stub = next_stub; }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 static ICStub* get_next_stub() { return _next_stub; }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 static void init_next_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 static ICStub* new_ic_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Machine-dependent implementation of ICBuffer
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
117 static void assemble_ic_buffer_code(address code_begin, void* cached_value, address entry_point);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
118 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
119 static void* ic_buffer_cached_value (address code_begin);
0
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
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Initialization; must be called before first usage
a61af66fc99e Initial load
duke
parents:
diff changeset
124 static void initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // Access
a61af66fc99e Initial load
duke
parents:
diff changeset
127 static bool contains(address instruction_address);
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // removes the ICStubs after backpatching
a61af66fc99e Initial load
duke
parents:
diff changeset
130 static void update_inline_caches();
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 // for debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
133 static bool is_empty();
a61af66fc99e Initial load
duke
parents:
diff changeset
134
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
135 static void release_pending_icholders();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
136 static void queue_for_release(CompiledICHolder* icholder);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
137 static int pending_icholder_count() { return _pending_count; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // New interface
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
140 static void create_transition_stub(CompiledIC *ic, void* cached_value, address entry);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
141 static address ic_destination_for(CompiledIC *ic);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 1972
diff changeset
142 static void* cached_value_for(CompiledIC *ic);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
143 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
144
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
145 #endif // SHARE_VM_CODE_ICBUFFER_HPP