annotate src/cpu/x86/vm/c1_FpuStackSim_x86.cpp @ 20504:6948da6d7c13

8052172: Evacuation failure handling in G1 does not evacuate all objects if -XX:-G1DeferredRSUpdate is set Summary: Remove -XX:-G1DeferredRSUpdate functionality as it is racy. During evacuation failure handling, threads where evacuation failure handling occurred may try to add remembered sets to regions which remembered sets are currently being scanned. The iterator to handle the remembered set scan does not support addition of entries during scan and so may skip valid references. Reviewed-by: iveresov, brutisso, mgerdin
author tschatzl
date Tue, 30 Sep 2014 09:44:36 +0200
parents f95d63e2154a
children
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) 2005, 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 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "c1/c1_FpuStackSim.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "c1/c1_FrameMap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "utilities/array.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "utilities/ostream.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 //--------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // FpuStackSim
a61af66fc99e Initial load
duke
parents:
diff changeset
33 //--------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // This class maps the FPU registers to their stack locations; it computes
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // the offsets between individual registers and simulates the FPU stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 const int EMPTY = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 int FpuStackSim::regs_at(int i) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 assert(i >= 0 && i < FrameMap::nof_fpu_regs, "out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
42 return _regs[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
43 }
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 void FpuStackSim::set_regs_at(int i, int val) {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 assert(i >= 0 && i < FrameMap::nof_fpu_regs, "out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _regs[i] = val;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 void FpuStackSim::dec_stack_size() {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 _stack_size--;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 assert(_stack_size >= 0, "FPU stack underflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 void FpuStackSim::inc_stack_size() {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 _stack_size++;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 assert(_stack_size <= FrameMap::nof_fpu_regs, "FPU stack overflow");
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 FpuStackSim::FpuStackSim(Compilation* compilation)
a61af66fc99e Initial load
duke
parents:
diff changeset
61 : _compilation(compilation)
a61af66fc99e Initial load
duke
parents:
diff changeset
62 {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 _stack_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 set_regs_at(i, EMPTY);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 void FpuStackSim::pop() {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 if (TraceFPUStack) { tty->print("FPU-pop "); print(); tty->cr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 set_regs_at(tos_index(), EMPTY);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 dec_stack_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 void FpuStackSim::pop(int rnr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 if (TraceFPUStack) { tty->print("FPU-pop %d", rnr); print(); tty->cr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 assert(regs_at(tos_index()) == rnr, "rnr is not on TOS");
a61af66fc99e Initial load
duke
parents:
diff changeset
79 set_regs_at(tos_index(), EMPTY);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 dec_stack_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 void FpuStackSim::push(int rnr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 if (TraceFPUStack) { tty->print("FPU-push %d", rnr); print(); tty->cr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 assert(regs_at(stack_size()) == EMPTY, "should be empty");
a61af66fc99e Initial load
duke
parents:
diff changeset
87 set_regs_at(stack_size(), rnr);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 inc_stack_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 void FpuStackSim::swap(int offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 if (TraceFPUStack) { tty->print("FPU-swap %d", offset); print(); tty->cr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
94 int t = regs_at(tos_index() - offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 set_regs_at(tos_index() - offset, regs_at(tos_index()));
a61af66fc99e Initial load
duke
parents:
diff changeset
96 set_regs_at(tos_index(), t);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 int FpuStackSim::offset_from_tos(int rnr) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 for (int i = tos_index(); i >= 0; i--) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if (regs_at(i) == rnr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 return tos_index() - i;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 assert(false, "FpuStackSim: register not found");
a61af66fc99e Initial load
duke
parents:
diff changeset
107 BAILOUT_("FpuStackSim: register not found", 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 int FpuStackSim::get_slot(int tos_offset) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 return regs_at(tos_index() - tos_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 void FpuStackSim::set_slot(int tos_offset, int rnr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 set_regs_at(tos_index() - tos_offset, rnr);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 void FpuStackSim::rename(int old_rnr, int new_rnr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 if (TraceFPUStack) { tty->print("FPU-rename %d %d", old_rnr, new_rnr); print(); tty->cr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 if (old_rnr == new_rnr)
a61af66fc99e Initial load
duke
parents:
diff changeset
122 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 bool found = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 for (int i = 0; i < stack_size(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 assert(regs_at(i) != new_rnr, "should not see old occurrences of new_rnr on the stack");
a61af66fc99e Initial load
duke
parents:
diff changeset
126 if (regs_at(i) == old_rnr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 set_regs_at(i, new_rnr);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 found = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131 assert(found, "should have found at least one instance of old_rnr");
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 bool FpuStackSim::contains(int rnr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 for (int i = 0; i < stack_size(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 if (regs_at(i) == rnr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 bool FpuStackSim::is_empty() {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
146 if (stack_size() == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 assert(regs_at(i) == EMPTY, "must be empty");
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
152 return stack_size() == 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 bool FpuStackSim::slot_is_empty(int tos_offset) {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 return (regs_at(tos_index() - tos_offset) == EMPTY);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 void FpuStackSim::clear() {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 if (TraceFPUStack) { tty->print("FPU-clear"); print(); tty->cr(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 for (int i = tos_index(); i >= 0; i--) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 set_regs_at(i, EMPTY);
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166 _stack_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 intArray* FpuStackSim::write_state() {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 intArray* res = new intArray(1 + FrameMap::nof_fpu_regs);
a61af66fc99e Initial load
duke
parents:
diff changeset
172 (*res)[0] = stack_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
173 for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 (*res)[1 + i] = regs_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 void FpuStackSim::read_state(intArray* fpu_stack_state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 _stack_size = (*fpu_stack_state)[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
182 for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 set_regs_at(i, (*fpu_stack_state)[1 + i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
189 void FpuStackSim::print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 tty->print(" N=%d[", stack_size());\
a61af66fc99e Initial load
duke
parents:
diff changeset
191 for (int i = 0; i < stack_size(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 int reg = regs_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 if (reg != EMPTY) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 tty->print("%d", reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 tty->print("_");
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198 };
a61af66fc99e Initial load
duke
parents:
diff changeset
199 tty->print(" ]");
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 #endif