annotate src/share/vm/code/icBuffer.hpp @ 3992:d1bdeef3e3e2

7098282: G1: assert(interval >= 0) failed: Sanity check, referencePolicy.cpp: 76 Summary: There is a race between one thread successfully forwarding and copying the klass mirror for the SoftReference class (including the static master clock) and another thread attempting to use the master clock while attempting to discover a soft reference object. Maintain a shadow copy of the soft reference master clock and use the shadow during reference discovery and reference processing. Reviewed-by: tonyp, brutisso, ysr
author johnc
date Wed, 12 Oct 2011 10:25:51 -0700
parents f95d63e2154a
children da91efe96a93 8c5333c80cfd
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: 1552
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: 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
a61af66fc99e Initial load
duke
parents:
diff changeset
60 void set_stub(CompiledIC *ic, oop cached_value, address dest_addr);
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
a61af66fc99e Initial load
duke
parents:
diff changeset
73 oop cached_oop() const; // cached_oop for stub
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
a61af66fc99e Initial load
duke
parents:
diff changeset
102 static StubQueue* buffer() { return _buffer; }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 static void set_next_stub(ICStub* next_stub) { _next_stub = next_stub; }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 static ICStub* get_next_stub() { return _next_stub; }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 static void init_next_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 static ICStub* new_ic_stub();
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // Machine-dependent implementation of ICBuffer
a61af66fc99e Initial load
duke
parents:
diff changeset
112 static void assemble_ic_buffer_code(address code_begin, oop cached_oop, address entry_point);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 static address ic_buffer_entry_point (address code_begin);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 static oop ic_buffer_cached_oop (address code_begin);
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // Initialization; must be called before first usage
a61af66fc99e Initial load
duke
parents:
diff changeset
119 static void initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // Access
a61af66fc99e Initial load
duke
parents:
diff changeset
122 static bool contains(address instruction_address);
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // removes the ICStubs after backpatching
a61af66fc99e Initial load
duke
parents:
diff changeset
125 static void update_inline_caches();
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // for debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
128 static bool is_empty();
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // New interface
a61af66fc99e Initial load
duke
parents:
diff changeset
132 static void create_transition_stub(CompiledIC *ic, oop cached_oop, address entry);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 static address ic_destination_for(CompiledIC *ic);
a61af66fc99e Initial load
duke
parents:
diff changeset
134 static oop cached_oop_for(CompiledIC *ic);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
136
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
137 #endif // SHARE_VM_CODE_ICBUFFER_HPP