annotate src/share/vm/runtime/vframeArray.cpp @ 4678:a03f3fd16b22

Fix reexecute boolean in HotSpot debug information. Introduce "duringCall" flag in FrameState that indicates that the bci of the frame state denotes an invoke that should *not* be reexecuted.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 23 Feb 2012 21:43:59 +0100
parents 3dbcd1013cc8
children 07bcee8b70a4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
2 * Copyright (c) 1997, 2011, 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: 1506
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1506
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: 1506
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: 1814
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
26 #include "classfile/vmSymbols.hpp"
3153
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
27 #include "code/scopeDesc.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
28 #include "interpreter/interpreter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
29 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
30 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
31 #include "memory/universe.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
32 #include "oops/methodDataOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
33 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
34 #include "prims/jvmtiThreadState.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
35 #include "runtime/handles.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
36 #include "runtime/monitorChunk.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
37 #include "runtime/sharedRuntime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
38 #include "runtime/vframe.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
39 #include "runtime/vframeArray.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
40 #include "runtime/vframe_hp.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
41 #include "utilities/events.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
42 #ifdef COMPILER2
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
43 #include "opto/runtime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1814
diff changeset
44 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 int vframeArrayElement:: bci(void) const { return (_bci == SynchronizationEntryBCI ? 0 : _bci); }
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 void vframeArrayElement::free_monitors(JavaThread* jt) {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 if (_monitors != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 MonitorChunk* chunk = _monitors;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 _monitors = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 jt->remove_monitor_chunk(chunk);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 delete chunk;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 void vframeArrayElement::fill_in(compiledVFrame* vf) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Copy the information from the compiled vframe to the
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // interpreter frame we will be creating to replace vf
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 _method = vf->method();
a61af66fc99e Initial load
duke
parents:
diff changeset
64 _bci = vf->raw_bci();
900
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 818
diff changeset
65 _reexecute = vf->should_reexecute();
3153
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
66
0
a61af66fc99e Initial load
duke
parents:
diff changeset
67 int index;
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Get the monitors off-stack
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 GrowableArray<MonitorInfo*>* list = vf->monitors();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 if (list->is_empty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 _monitors = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // Allocate monitor chunk
a61af66fc99e Initial load
duke
parents:
diff changeset
77 _monitors = new MonitorChunk(list->length());
a61af66fc99e Initial load
duke
parents:
diff changeset
78 vf->thread()->add_monitor_chunk(_monitors);
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // Migrate the BasicLocks from the stack to the monitor chunk
a61af66fc99e Initial load
duke
parents:
diff changeset
81 for (index = 0; index < list->length(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 MonitorInfo* monitor = list->at(index);
818
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 0
diff changeset
83 assert(!monitor->owner_is_scalar_replaced(), "object should be reallocated already");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
84 assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased");
a61af66fc99e Initial load
duke
parents:
diff changeset
85 BasicObjectLock* dest = _monitors->at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 dest->set_obj(monitor->owner());
a61af66fc99e Initial load
duke
parents:
diff changeset
87 monitor->lock()->move_to(monitor->owner(), dest->lock());
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // Convert the vframe locals and expressions to off stack
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // values. Because we will not gc all oops can be converted to
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // intptr_t (i.e. a stack slot) and we are fine. This is
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // good since we are inside a HandleMark and the oops in our
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // collection would go away between packing them here and
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // unpacking them in unpack_on_stack.
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // First the locals go off-stack
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // FIXME this seems silly it creates a StackValueCollection
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // in order to get the size to then copy them and
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // convert the types to intptr_t size slots. Seems like it
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // could do it in place... Still uses less memory than the
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // old way though
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 StackValueCollection *locs = vf->locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
107 _locals = new StackValueCollection(locs->size());
a61af66fc99e Initial load
duke
parents:
diff changeset
108 for(index = 0; index < locs->size(); index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 StackValue* value = locs->at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 switch(value->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 case T_OBJECT:
818
b109e761e927 6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents: 0
diff changeset
112 assert(!value->obj_is_scalar_replaced(), "object should be reallocated already");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // preserve object type
a61af66fc99e Initial load
duke
parents:
diff changeset
114 _locals->add( new StackValue((intptr_t) (value->get_obj()()), T_OBJECT ));
a61af66fc99e Initial load
duke
parents:
diff changeset
115 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 case T_CONFLICT:
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // A dead local. Will be initialized to null/zero.
a61af66fc99e Initial load
duke
parents:
diff changeset
118 _locals->add( new StackValue());
a61af66fc99e Initial load
duke
parents:
diff changeset
119 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
121 _locals->add( new StackValue(value->get_int()));
a61af66fc99e Initial load
duke
parents:
diff changeset
122 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
124 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // Now the expressions off-stack
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // Same silliness as above
3153
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
130 bool rethrow_exception = vf->scope()->rethrow_exception();
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
131 if (rethrow_exception) {
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
132 // (tw) Make sure there are only null pointers on the stack, because the stack values do not correspond to the GC map at the bytecode at which the exception is rethrown.
4678
a03f3fd16b22 Fix reexecute boolean in HotSpot debug information. Introduce "duringCall" flag in FrameState that indicates that the bci of the frame state denotes an invoke that should *not* be reexecuted.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4668
diff changeset
133 // TODO: Fix this! Locals map might be wrong too.
3153
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
134 _expressions = new StackValueCollection(vf->method()->max_stack());
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
135 assert(Thread::current()->has_pending_exception(), "just checking");
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
136 for (int i=0; i<vf->method()->max_stack(); ++i) {
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
137 _expressions->add( new StackValue());
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
138 }
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
139 } else {
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
140 StackValueCollection *exprs = vf->expressions();
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
141 _expressions = new StackValueCollection(exprs->size());
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
142 for(index = 0; index < exprs->size(); index++) {
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
143 StackValue* value = exprs->at(index);
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
144 switch(value->type()) {
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
145 case T_OBJECT:
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
146 assert(!value->obj_is_scalar_replaced(), "object should be reallocated already");
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
147 // preserve object type
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
148 _expressions->add( new StackValue((intptr_t) (value->get_obj()()), T_OBJECT ));
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
149 break;
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
150 case T_CONFLICT:
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
151 // A dead stack element. Will be initialized to null/zero.
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
152 // This can occur when the compiler emits a state in which stack
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
153 // elements are known to be dead (because of an imminent exception).
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
154 _expressions->add( new StackValue());
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
155 break;
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
156 case T_INT:
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
157 _expressions->add( new StackValue(value->get_int()));
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
158 break;
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
159 default:
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
160 ShouldNotReachHere();
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
161 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 int unpack_counter = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
167
3369
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 2142
diff changeset
168 void vframeArrayElement::unpack_on_stack(int caller_actual_parameters,
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 2142
diff changeset
169 int callee_parameters,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
170 int callee_locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
171 frame* caller,
a61af66fc99e Initial load
duke
parents:
diff changeset
172 bool is_top_frame,
a61af66fc99e Initial load
duke
parents:
diff changeset
173 int exec_mode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 JavaThread* thread = (JavaThread*) Thread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
175
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // Look at bci and decide on bcp and continuation pc
a61af66fc99e Initial load
duke
parents:
diff changeset
177 address bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // C++ interpreter doesn't need a pc since it will figure out what to do when it
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // begins execution
a61af66fc99e Initial load
duke
parents:
diff changeset
180 address pc;
900
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 818
diff changeset
181 bool use_next_mdp = false; // true if we should use the mdp associated with the next bci
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 818
diff changeset
182 // rather than the one associated with bcp
0
a61af66fc99e Initial load
duke
parents:
diff changeset
183 if (raw_bci() == SynchronizationEntryBCI) {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // We are deoptimizing while hanging in prologue code for synchronized method
a61af66fc99e Initial load
duke
parents:
diff changeset
185 bcp = method()->bcp_from(0); // first byte code
a61af66fc99e Initial load
duke
parents:
diff changeset
186 pc = Interpreter::deopt_entry(vtos, 0); // step = 0 since we don't skip current bytecode
900
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 818
diff changeset
187 } else if (should_reexecute()) { //reexecute this bytecode
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 818
diff changeset
188 assert(is_top_frame, "reexecute allowed only for the top frame");
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 818
diff changeset
189 bcp = method()->bcp_from(bci());
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 818
diff changeset
190 pc = Interpreter::deopt_reexecute_entry(method(), bcp);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
191 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 bcp = method()->bcp_from(bci());
900
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 818
diff changeset
193 pc = Interpreter::deopt_continue_after_entry(method(), bcp, callee_parameters, is_top_frame);
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 818
diff changeset
194 use_next_mdp = true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 assert(Bytecodes::is_defined(*bcp), "must be a valid bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // Monitorenter and pending exceptions:
a61af66fc99e Initial load
duke
parents:
diff changeset
199 //
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // For Compiler2, there should be no pending exception when deoptimizing at monitorenter
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // because there is no safepoint at the null pointer check (it is either handled explicitly
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // or prior to the monitorenter) and asynchronous exceptions are not made "pending" by the
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // runtime interface for the slow case (see JRT_ENTRY_FOR_MONITORENTER). If an asynchronous
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // exception was processed, the bytecode pointer would have to be extended one bytecode beyond
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // the monitorenter to place it in the proper exception range.
a61af66fc99e Initial load
duke
parents:
diff changeset
206 //
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // For Compiler1, deoptimization can occur while throwing a NullPointerException at monitorenter,
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // in which case bcp should point to the monitorenter since it is within the exception's range.
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 assert(*bcp != Bytecodes::_monitorenter || is_top_frame, "a _monitorenter must be a top frame");
1814
fd5d4527cdf5 6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents: 1603
diff changeset
211 assert(thread->deopt_nmethod() != NULL, "nmethod should be known");
fd5d4527cdf5 6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents: 1603
diff changeset
212 guarantee(!(thread->deopt_nmethod()->is_compiled_by_c2() &&
fd5d4527cdf5 6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents: 1603
diff changeset
213 *bcp == Bytecodes::_monitorenter &&
fd5d4527cdf5 6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents: 1603
diff changeset
214 exec_mode == Deoptimization::Unpack_exception),
fd5d4527cdf5 6986270: guarantee(*bcp != Bytecodes::_monitorenter || exec_mode != Deoptimization::Unpack_exception) fails
iveresov
parents: 1603
diff changeset
215 "shouldn't get exception during monitorenter");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
216
a61af66fc99e Initial load
duke
parents:
diff changeset
217 int popframe_preserved_args_size_in_bytes = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
218 int popframe_preserved_args_size_in_words = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
219 if (is_top_frame) {
1255
e3a4305c6bc3 6925249: assert(last_sp < (intptr_t*) interpreter_frame_monitor_begin(),"bad tos")
kvn
parents: 903
diff changeset
220 JvmtiThreadState *state = thread->jvmti_thread_state();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
221 if (JvmtiExport::can_pop_frame() &&
a61af66fc99e Initial load
duke
parents:
diff changeset
222 (thread->has_pending_popframe() || thread->popframe_forcing_deopt_reexecution())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 if (thread->has_pending_popframe()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // Pop top frame after deoptimization
a61af66fc99e Initial load
duke
parents:
diff changeset
225 #ifndef CC_INTERP
a61af66fc99e Initial load
duke
parents:
diff changeset
226 pc = Interpreter::remove_activation_preserving_args_entry();
a61af66fc99e Initial load
duke
parents:
diff changeset
227 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // Do an uncommon trap type entry. c++ interpreter will know
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // to pop frame and preserve the args
a61af66fc99e Initial load
duke
parents:
diff changeset
230 pc = Interpreter::deopt_entry(vtos, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
231 use_next_mdp = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
233 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // Reexecute invoke in top frame
a61af66fc99e Initial load
duke
parents:
diff changeset
235 pc = Interpreter::deopt_entry(vtos, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 use_next_mdp = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 popframe_preserved_args_size_in_bytes = in_bytes(thread->popframe_preserved_args_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // Note: the PopFrame-related extension of the expression stack size is done in
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // Deoptimization::fetch_unroll_info_helper
a61af66fc99e Initial load
duke
parents:
diff changeset
240 popframe_preserved_args_size_in_words = in_words(thread->popframe_preserved_args_size_in_words());
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242 } else if (JvmtiExport::can_force_early_return() && state != NULL && state->is_earlyret_pending()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // Force early return from top frame after deoptimization
a61af66fc99e Initial load
duke
parents:
diff changeset
244 #ifndef CC_INTERP
a61af66fc99e Initial load
duke
parents:
diff changeset
245 pc = Interpreter::remove_activation_early_entry(state->earlyret_tos());
a61af66fc99e Initial load
duke
parents:
diff changeset
246 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // TBD: Need to implement ForceEarlyReturn for CC_INTERP (ia64)
a61af66fc99e Initial load
duke
parents:
diff changeset
248 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
249 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // Possibly override the previous pc computation of the top (youngest) frame
a61af66fc99e Initial load
duke
parents:
diff changeset
251 switch (exec_mode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
252 case Deoptimization::Unpack_deopt:
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // use what we've got
a61af66fc99e Initial load
duke
parents:
diff changeset
254 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 case Deoptimization::Unpack_exception:
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // exception is pending
1295
3cf667df43ef 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1255
diff changeset
257 pc = SharedRuntime::raw_exception_handler_for_return_address(thread, pc);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // [phh] We're going to end up in some handler or other, so it doesn't
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // matter what mdp we point to. See exception_handler_for_exception()
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // in interpreterRuntime.cpp.
a61af66fc99e Initial load
duke
parents:
diff changeset
261 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
262 case Deoptimization::Unpack_uncommon_trap:
a61af66fc99e Initial load
duke
parents:
diff changeset
263 case Deoptimization::Unpack_reexecute:
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // redo last byte code
4678
a03f3fd16b22 Fix reexecute boolean in HotSpot debug information. Introduce "duringCall" flag in FrameState that indicates that the bci of the frame state denotes an invoke that should *not* be reexecuted.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4668
diff changeset
265 assert(should_reexecute(), "");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
266 pc = Interpreter::deopt_entry(vtos, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
267 use_next_mdp = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
268 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
269 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
270 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // Setup the interpreter frame
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 assert(method() != NULL, "method must exist");
a61af66fc99e Initial load
duke
parents:
diff changeset
278 int temps = expressions()->size();
a61af66fc99e Initial load
duke
parents:
diff changeset
279
a61af66fc99e Initial load
duke
parents:
diff changeset
280 int locks = monitors() == NULL ? 0 : monitors()->number_of_monitors();
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 Interpreter::layout_activation(method(),
a61af66fc99e Initial load
duke
parents:
diff changeset
283 temps + callee_parameters,
a61af66fc99e Initial load
duke
parents:
diff changeset
284 popframe_preserved_args_size_in_words,
a61af66fc99e Initial load
duke
parents:
diff changeset
285 locks,
3369
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 2142
diff changeset
286 caller_actual_parameters,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
287 callee_parameters,
a61af66fc99e Initial load
duke
parents:
diff changeset
288 callee_locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
289 caller,
a61af66fc99e Initial load
duke
parents:
diff changeset
290 iframe(),
a61af66fc99e Initial load
duke
parents:
diff changeset
291 is_top_frame);
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // Update the pc in the frame object and overwrite the temporary pc
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // we placed in the skeletal frame now that we finally know the
a61af66fc99e Initial load
duke
parents:
diff changeset
295 // exact interpreter address we should use.
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 _frame.patch_pc(thread, pc);
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 assert (!method()->is_synchronized() || locks > 0, "synchronized methods must have monitors");
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 BasicObjectLock* top = iframe()->interpreter_frame_monitor_begin();
a61af66fc99e Initial load
duke
parents:
diff changeset
302 for (int index = 0; index < locks; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 top = iframe()->previous_monitor_in_interpreter_frame(top);
a61af66fc99e Initial load
duke
parents:
diff changeset
304 BasicObjectLock* src = _monitors->at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
305 top->set_obj(src->obj());
a61af66fc99e Initial load
duke
parents:
diff changeset
306 src->lock()->move_to(src->obj(), top->lock());
a61af66fc99e Initial load
duke
parents:
diff changeset
307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
308 if (ProfileInterpreter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 iframe()->interpreter_frame_set_mdx(0); // clear out the mdp.
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311 iframe()->interpreter_frame_set_bcx((intptr_t)bcp); // cannot use bcp because frame is not initialized yet
a61af66fc99e Initial load
duke
parents:
diff changeset
312 if (ProfileInterpreter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
313 methodDataOop mdo = method()->method_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
314 if (mdo != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
315 int bci = iframe()->interpreter_frame_bci();
a61af66fc99e Initial load
duke
parents:
diff changeset
316 if (use_next_mdp) ++bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
317 address mdp = mdo->bci_to_dp(bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
318 iframe()->interpreter_frame_set_mdp(mdp);
a61af66fc99e Initial load
duke
parents:
diff changeset
319 }
a61af66fc99e Initial load
duke
parents:
diff changeset
320 }
2607
008adfd6d850 Fixed the stateBefore of invokes and monitorenter instructions to include the arguments of the instruction.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2181
diff changeset
321
4668
3dbcd1013cc8 added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents: 3464
diff changeset
322 if (PrintDeoptimizationDetails) {
2607
008adfd6d850 Fixed the stateBefore of invokes and monitorenter instructions to include the arguments of the instruction.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2181
diff changeset
323 tty->print_cr("Expressions size: %d", expressions()->size());
008adfd6d850 Fixed the stateBefore of invokes and monitorenter instructions to include the arguments of the instruction.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2181
diff changeset
324 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326 // Unpack expression stack
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // If this is an intermediate frame (i.e. not top frame) then this
a61af66fc99e Initial load
duke
parents:
diff changeset
328 // only unpacks the part of the expression stack not used by callee
a61af66fc99e Initial load
duke
parents:
diff changeset
329 // as parameters. The callee parameters are unpacked as part of the
a61af66fc99e Initial load
duke
parents:
diff changeset
330 // callee locals.
3153
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
331 for(int i = 0; i < expressions()->size(); i++) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
332 StackValue *value = expressions()->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
333 intptr_t* addr = iframe()->interpreter_frame_expression_stack_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
334 switch(value->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
335 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
336 *addr = value->get_int();
1936
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
337 #ifndef PRODUCT
4668
3dbcd1013cc8 added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents: 3464
diff changeset
338 if (PrintDeoptimizationDetails) {
1936
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
339 tty->print_cr("Reconstructed expression %d (INT): %d", i, (int)(*addr));
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
340 }
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
341 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
342 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
343 case T_OBJECT:
a61af66fc99e Initial load
duke
parents:
diff changeset
344 *addr = value->get_int(T_OBJECT);
1936
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
345 #ifndef PRODUCT
4668
3dbcd1013cc8 added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents: 3464
diff changeset
346 if (PrintDeoptimizationDetails) {
1936
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
347 tty->print("Reconstructed expression %d (OBJECT): ", i);
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
348 oop o = (oop)(*addr);
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
349 if (o == NULL) {
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
350 tty->print_cr("NULL");
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
351 } else {
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
352 tty->print_cr(err_msg("%s", o->blueprint()->name()->as_C_string()));
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
353 }
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
354 }
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
355 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
356 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
357 case T_CONFLICT:
a61af66fc99e Initial load
duke
parents:
diff changeset
358 // A dead stack slot. Initialize to null in case it is an oop.
a61af66fc99e Initial load
duke
parents:
diff changeset
359 *addr = NULL_WORD;
a61af66fc99e Initial load
duke
parents:
diff changeset
360 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
361 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
362 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
363 }
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // Unpack the locals
3153
5ca1332171c8 Fixed an issue in the HotSpot code for rethrowing an exception at deopt (wrong values on the expression stack caused a crash when GC and deopt happened at the same time).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2607
diff changeset
368 for(int i = 0; i < locals()->size(); i++) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
369 StackValue *value = locals()->at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
370 intptr_t* addr = iframe()->interpreter_frame_local_at(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
371 switch(value->type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
372 case T_INT:
a61af66fc99e Initial load
duke
parents:
diff changeset
373 *addr = value->get_int();
1936
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
374 #ifndef PRODUCT
4668
3dbcd1013cc8 added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents: 3464
diff changeset
375 if (PrintDeoptimizationDetails) {
1936
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
376 tty->print_cr("Reconstructed local %d (INT): %d", i, (int)(*addr));
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
377 }
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
378 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
379 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
380 case T_OBJECT:
a61af66fc99e Initial load
duke
parents:
diff changeset
381 *addr = value->get_int(T_OBJECT);
1936
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
382 #ifndef PRODUCT
4668
3dbcd1013cc8 added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents: 3464
diff changeset
383 if (PrintDeoptimizationDetails) {
1936
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
384 tty->print("Reconstructed local %d (OBJECT): ", i);
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
385 oop o = (oop)(*addr);
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
386 if (o == NULL) {
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
387 tty->print_cr("NULL");
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
388 } else {
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
389 tty->print_cr(err_msg("%s", o->blueprint()->name()->as_C_string()));
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
390 }
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
391 }
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1814
diff changeset
392 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
393 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
394 case T_CONFLICT:
a61af66fc99e Initial load
duke
parents:
diff changeset
395 // A dead location. If it is an oop then we need a NULL to prevent GC from following it
a61af66fc99e Initial load
duke
parents:
diff changeset
396 *addr = NULL_WORD;
a61af66fc99e Initial load
duke
parents:
diff changeset
397 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
398 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
399 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
400 }
a61af66fc99e Initial load
duke
parents:
diff changeset
401 }
a61af66fc99e Initial load
duke
parents:
diff changeset
402
a61af66fc99e Initial load
duke
parents:
diff changeset
403 if (is_top_frame && JvmtiExport::can_pop_frame() && thread->popframe_forcing_deopt_reexecution()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
404 // An interpreted frame was popped but it returns to a deoptimized
a61af66fc99e Initial load
duke
parents:
diff changeset
405 // frame. The incoming arguments to the interpreted activation
a61af66fc99e Initial load
duke
parents:
diff changeset
406 // were preserved in thread-local storage by the
a61af66fc99e Initial load
duke
parents:
diff changeset
407 // remove_activation_preserving_args_entry in the interpreter; now
a61af66fc99e Initial load
duke
parents:
diff changeset
408 // we put them back into the just-unpacked interpreter frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
409 // Note that this assumes that the locals arena grows toward lower
a61af66fc99e Initial load
duke
parents:
diff changeset
410 // addresses.
a61af66fc99e Initial load
duke
parents:
diff changeset
411 if (popframe_preserved_args_size_in_words != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
412 void* saved_args = thread->popframe_preserved_args();
a61af66fc99e Initial load
duke
parents:
diff changeset
413 assert(saved_args != NULL, "must have been saved by interpreter");
a61af66fc99e Initial load
duke
parents:
diff changeset
414 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
415 assert(popframe_preserved_args_size_in_words <=
1506
2338d41fbd81 6943304: remove tagged stack interpreter
twisti
parents: 1295
diff changeset
416 iframe()->interpreter_frame_expression_stack_size()*Interpreter::stackElementWords,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
417 "expression stack size should have been extended");
a61af66fc99e Initial load
duke
parents:
diff changeset
418 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
419 int top_element = iframe()->interpreter_frame_expression_stack_size()-1;
a61af66fc99e Initial load
duke
parents:
diff changeset
420 intptr_t* base;
a61af66fc99e Initial load
duke
parents:
diff changeset
421 if (frame::interpreter_frame_expression_stack_direction() < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
422 base = iframe()->interpreter_frame_expression_stack_at(top_element);
a61af66fc99e Initial load
duke
parents:
diff changeset
423 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
424 base = iframe()->interpreter_frame_expression_stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
425 }
1603
d93949c5bdcc 6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents: 1552
diff changeset
426 Copy::conjoint_jbytes(saved_args,
d93949c5bdcc 6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents: 1552
diff changeset
427 base,
d93949c5bdcc 6730276: JDI_REGRESSION tests fail with "Error: count must be non-zero" error on x86
kvn
parents: 1552
diff changeset
428 popframe_preserved_args_size_in_bytes);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
429 thread->popframe_free_preserved_args();
a61af66fc99e Initial load
duke
parents:
diff changeset
430 }
a61af66fc99e Initial load
duke
parents:
diff changeset
431 }
a61af66fc99e Initial load
duke
parents:
diff changeset
432
a61af66fc99e Initial load
duke
parents:
diff changeset
433 #ifndef PRODUCT
4668
3dbcd1013cc8 added flag PrintDeoptimizationDetails
Christian Haeubl <christian.haeubl@oracle.com>
parents: 3464
diff changeset
434 if (PrintDeoptimizationDetails) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
435 ttyLocker ttyl;
a61af66fc99e Initial load
duke
parents:
diff changeset
436 tty->print_cr("[%d Interpreted Frame]", ++unpack_counter);
a61af66fc99e Initial load
duke
parents:
diff changeset
437 iframe()->print_on(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
438 RegisterMap map(thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
439 vframe* f = vframe::new_vframe(iframe(), &map, thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
440 f->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
441 tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
442 // method()->print_codes();
a61af66fc99e Initial load
duke
parents:
diff changeset
443 } else if (TraceDeoptimization) {
a61af66fc99e Initial load
duke
parents:
diff changeset
444 tty->print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
445 method()->print_value();
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
446 Bytecodes::Code code = Bytecodes::java_code_at(method(), bcp);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
447 int bci = method()->bci_from(bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
448 tty->print(" - %s", Bytecodes::name(code));
a61af66fc99e Initial load
duke
parents:
diff changeset
449 tty->print(" @ bci %d ", bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
450 tty->print_cr("sp = " PTR_FORMAT, iframe()->sp());
a61af66fc99e Initial load
duke
parents:
diff changeset
451 }
a61af66fc99e Initial load
duke
parents:
diff changeset
452 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
453
a61af66fc99e Initial load
duke
parents:
diff changeset
454 // The expression stack and locals are in the resource area don't leave
a61af66fc99e Initial load
duke
parents:
diff changeset
455 // a dangling pointer in the vframeArray we leave around for debug
a61af66fc99e Initial load
duke
parents:
diff changeset
456 // purposes
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 _locals = _expressions = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
459
a61af66fc99e Initial load
duke
parents:
diff changeset
460 }
a61af66fc99e Initial load
duke
parents:
diff changeset
461
3369
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 2142
diff changeset
462 int vframeArrayElement::on_stack_size(int caller_actual_parameters,
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 2142
diff changeset
463 int callee_parameters,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
464 int callee_locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
465 bool is_top_frame,
a61af66fc99e Initial load
duke
parents:
diff changeset
466 int popframe_extra_stack_expression_els) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
467 assert(method()->max_locals() == locals()->size(), "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
468 int locks = monitors() == NULL ? 0 : monitors()->number_of_monitors();
a61af66fc99e Initial load
duke
parents:
diff changeset
469 int temps = expressions()->size();
a61af66fc99e Initial load
duke
parents:
diff changeset
470 return Interpreter::size_activation(method(),
a61af66fc99e Initial load
duke
parents:
diff changeset
471 temps + callee_parameters,
a61af66fc99e Initial load
duke
parents:
diff changeset
472 popframe_extra_stack_expression_els,
a61af66fc99e Initial load
duke
parents:
diff changeset
473 locks,
3369
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 2142
diff changeset
474 caller_actual_parameters,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
475 callee_parameters,
a61af66fc99e Initial load
duke
parents:
diff changeset
476 callee_locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
477 is_top_frame);
a61af66fc99e Initial load
duke
parents:
diff changeset
478 }
a61af66fc99e Initial load
duke
parents:
diff changeset
479
a61af66fc99e Initial load
duke
parents:
diff changeset
480
a61af66fc99e Initial load
duke
parents:
diff changeset
481
a61af66fc99e Initial load
duke
parents:
diff changeset
482 vframeArray* vframeArray::allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
a61af66fc99e Initial load
duke
parents:
diff changeset
483 RegisterMap *reg_map, frame sender, frame caller, frame self) {
a61af66fc99e Initial load
duke
parents:
diff changeset
484
a61af66fc99e Initial load
duke
parents:
diff changeset
485 // Allocate the vframeArray
a61af66fc99e Initial load
duke
parents:
diff changeset
486 vframeArray * result = (vframeArray*) AllocateHeap(sizeof(vframeArray) + // fixed part
a61af66fc99e Initial load
duke
parents:
diff changeset
487 sizeof(vframeArrayElement) * (chunk->length() - 1), // variable part
a61af66fc99e Initial load
duke
parents:
diff changeset
488 "vframeArray::allocate");
a61af66fc99e Initial load
duke
parents:
diff changeset
489 result->_frames = chunk->length();
a61af66fc99e Initial load
duke
parents:
diff changeset
490 result->_owner_thread = thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
491 result->_sender = sender;
a61af66fc99e Initial load
duke
parents:
diff changeset
492 result->_caller = caller;
a61af66fc99e Initial load
duke
parents:
diff changeset
493 result->_original = self;
a61af66fc99e Initial load
duke
parents:
diff changeset
494 result->set_unroll_block(NULL); // initialize it
a61af66fc99e Initial load
duke
parents:
diff changeset
495 result->fill_in(thread, frame_size, chunk, reg_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
496 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
497 }
a61af66fc99e Initial load
duke
parents:
diff changeset
498
a61af66fc99e Initial load
duke
parents:
diff changeset
499 void vframeArray::fill_in(JavaThread* thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
500 int frame_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
501 GrowableArray<compiledVFrame*>* chunk,
a61af66fc99e Initial load
duke
parents:
diff changeset
502 const RegisterMap *reg_map) {
a61af66fc99e Initial load
duke
parents:
diff changeset
503 // Set owner first, it is used when adding monitor chunks
a61af66fc99e Initial load
duke
parents:
diff changeset
504
a61af66fc99e Initial load
duke
parents:
diff changeset
505 _frame_size = frame_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
506 for(int i = 0; i < chunk->length(); i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
507 element(i)->fill_in(chunk->at(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
508 }
a61af66fc99e Initial load
duke
parents:
diff changeset
509
a61af66fc99e Initial load
duke
parents:
diff changeset
510 // Copy registers for callee-saved registers
a61af66fc99e Initial load
duke
parents:
diff changeset
511 if (reg_map != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
512 for(int i = 0; i < RegisterMap::reg_count; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
513 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
514 // The register map has one entry for every int (32-bit value), so
a61af66fc99e Initial load
duke
parents:
diff changeset
515 // 64-bit physical registers have two entries in the map, one for
a61af66fc99e Initial load
duke
parents:
diff changeset
516 // each half. Ignore the high halves of 64-bit registers, just like
a61af66fc99e Initial load
duke
parents:
diff changeset
517 // frame::oopmapreg_to_location does.
a61af66fc99e Initial load
duke
parents:
diff changeset
518 //
a61af66fc99e Initial load
duke
parents:
diff changeset
519 // [phh] FIXME: this is a temporary hack! This code *should* work
a61af66fc99e Initial load
duke
parents:
diff changeset
520 // correctly w/o this hack, possibly by changing RegisterMap::pd_location
a61af66fc99e Initial load
duke
parents:
diff changeset
521 // in frame_amd64.cpp and the values of the phantom high half registers
a61af66fc99e Initial load
duke
parents:
diff changeset
522 // in amd64.ad.
a61af66fc99e Initial load
duke
parents:
diff changeset
523 // if (VMReg::Name(i) < SharedInfo::stack0 && is_even(i)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
524 intptr_t* src = (intptr_t*) reg_map->location(VMRegImpl::as_VMReg(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
525 _callee_registers[i] = src != NULL ? *src : NULL_WORD;
a61af66fc99e Initial load
duke
parents:
diff changeset
526 // } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
527 // jint* src = (jint*) reg_map->location(VMReg::Name(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
528 // _callee_registers[i] = src != NULL ? *src : NULL_WORD;
a61af66fc99e Initial load
duke
parents:
diff changeset
529 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
530 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
531 jint* src = (jint*) reg_map->location(VMRegImpl::as_VMReg(i));
a61af66fc99e Initial load
duke
parents:
diff changeset
532 _callee_registers[i] = src != NULL ? *src : NULL_WORD;
a61af66fc99e Initial load
duke
parents:
diff changeset
533 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
534 if (src == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
535 set_location_valid(i, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
536 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
537 set_location_valid(i, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
538 jint* dst = (jint*) register_location(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
539 *dst = *src;
a61af66fc99e Initial load
duke
parents:
diff changeset
540 }
a61af66fc99e Initial load
duke
parents:
diff changeset
541 }
a61af66fc99e Initial load
duke
parents:
diff changeset
542 }
a61af66fc99e Initial load
duke
parents:
diff changeset
543 }
a61af66fc99e Initial load
duke
parents:
diff changeset
544
3369
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 2142
diff changeset
545 void vframeArray::unpack_to_stack(frame &unpack_frame, int exec_mode, int caller_actual_parameters) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
546 // stack picture
a61af66fc99e Initial load
duke
parents:
diff changeset
547 // unpack_frame
a61af66fc99e Initial load
duke
parents:
diff changeset
548 // [new interpreter frames ] (frames are skeletal but walkable)
a61af66fc99e Initial load
duke
parents:
diff changeset
549 // caller_frame
a61af66fc99e Initial load
duke
parents:
diff changeset
550 //
a61af66fc99e Initial load
duke
parents:
diff changeset
551 // This routine fills in the missing data for the skeletal interpreter frames
a61af66fc99e Initial load
duke
parents:
diff changeset
552 // in the above picture.
a61af66fc99e Initial load
duke
parents:
diff changeset
553
a61af66fc99e Initial load
duke
parents:
diff changeset
554 // Find the skeletal interpreter frames to unpack into
a61af66fc99e Initial load
duke
parents:
diff changeset
555 RegisterMap map(JavaThread::current(), false);
a61af66fc99e Initial load
duke
parents:
diff changeset
556 // Get the youngest frame we will unpack (last to be unpacked)
a61af66fc99e Initial load
duke
parents:
diff changeset
557 frame me = unpack_frame.sender(&map);
a61af66fc99e Initial load
duke
parents:
diff changeset
558 int index;
a61af66fc99e Initial load
duke
parents:
diff changeset
559 for (index = 0; index < frames(); index++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
560 *element(index)->iframe() = me;
a61af66fc99e Initial load
duke
parents:
diff changeset
561 // Get the caller frame (possibly skeletal)
a61af66fc99e Initial load
duke
parents:
diff changeset
562 me = me.sender(&map);
a61af66fc99e Initial load
duke
parents:
diff changeset
563 }
a61af66fc99e Initial load
duke
parents:
diff changeset
564
a61af66fc99e Initial load
duke
parents:
diff changeset
565 frame caller_frame = me;
a61af66fc99e Initial load
duke
parents:
diff changeset
566
a61af66fc99e Initial load
duke
parents:
diff changeset
567 // Do the unpacking of interpreter frames; the frame at index 0 represents the top activation, so it has no callee
a61af66fc99e Initial load
duke
parents:
diff changeset
568
a61af66fc99e Initial load
duke
parents:
diff changeset
569 // Unpack the frames from the oldest (frames() -1) to the youngest (0)
a61af66fc99e Initial load
duke
parents:
diff changeset
570
a61af66fc99e Initial load
duke
parents:
diff changeset
571 for (index = frames() - 1; index >= 0 ; index--) {
a61af66fc99e Initial load
duke
parents:
diff changeset
572 int callee_parameters = index == 0 ? 0 : element(index-1)->method()->size_of_parameters();
a61af66fc99e Initial load
duke
parents:
diff changeset
573 int callee_locals = index == 0 ? 0 : element(index-1)->method()->max_locals();
3369
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 2142
diff changeset
574 element(index)->unpack_on_stack(caller_actual_parameters,
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 2142
diff changeset
575 callee_parameters,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
576 callee_locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
577 &caller_frame,
a61af66fc99e Initial load
duke
parents:
diff changeset
578 index == 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
579 exec_mode);
a61af66fc99e Initial load
duke
parents:
diff changeset
580 if (index == frames() - 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
581 Deoptimization::unwind_callee_save_values(element(index)->iframe(), this);
a61af66fc99e Initial load
duke
parents:
diff changeset
582 }
a61af66fc99e Initial load
duke
parents:
diff changeset
583 caller_frame = *element(index)->iframe();
3369
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 2142
diff changeset
584 caller_actual_parameters = callee_parameters;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
585 }
a61af66fc99e Initial load
duke
parents:
diff changeset
586
a61af66fc99e Initial load
duke
parents:
diff changeset
587
a61af66fc99e Initial load
duke
parents:
diff changeset
588 deallocate_monitor_chunks();
a61af66fc99e Initial load
duke
parents:
diff changeset
589 }
a61af66fc99e Initial load
duke
parents:
diff changeset
590
a61af66fc99e Initial load
duke
parents:
diff changeset
591 void vframeArray::deallocate_monitor_chunks() {
a61af66fc99e Initial load
duke
parents:
diff changeset
592 JavaThread* jt = JavaThread::current();
a61af66fc99e Initial load
duke
parents:
diff changeset
593 for (int index = 0; index < frames(); index++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
594 element(index)->free_monitors(jt);
a61af66fc99e Initial load
duke
parents:
diff changeset
595 }
a61af66fc99e Initial load
duke
parents:
diff changeset
596 }
a61af66fc99e Initial load
duke
parents:
diff changeset
597
a61af66fc99e Initial load
duke
parents:
diff changeset
598 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
599
a61af66fc99e Initial load
duke
parents:
diff changeset
600 bool vframeArray::structural_compare(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
601 if (owner_thread() != thread) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
602 int index = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
603 #if 0 // FIXME can't do this comparison
a61af66fc99e Initial load
duke
parents:
diff changeset
604
a61af66fc99e Initial load
duke
parents:
diff changeset
605 // Compare only within vframe array.
a61af66fc99e Initial load
duke
parents:
diff changeset
606 for (deoptimizedVFrame* vf = deoptimizedVFrame::cast(vframe_at(first_index())); vf; vf = vf->deoptimized_sender_or_null()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
607 if (index >= chunk->length() || !vf->structural_compare(chunk->at(index))) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
608 index++;
a61af66fc99e Initial load
duke
parents:
diff changeset
609 }
a61af66fc99e Initial load
duke
parents:
diff changeset
610 if (index != chunk->length()) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
611 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
612
a61af66fc99e Initial load
duke
parents:
diff changeset
613 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
614 }
a61af66fc99e Initial load
duke
parents:
diff changeset
615
a61af66fc99e Initial load
duke
parents:
diff changeset
616 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
617
a61af66fc99e Initial load
duke
parents:
diff changeset
618 address vframeArray::register_location(int i) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
619 assert(0 <= i && i < RegisterMap::reg_count, "index out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
620 return (address) & _callee_registers[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
621 }
a61af66fc99e Initial load
duke
parents:
diff changeset
622
a61af66fc99e Initial load
duke
parents:
diff changeset
623
a61af66fc99e Initial load
duke
parents:
diff changeset
624 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
625
a61af66fc99e Initial load
duke
parents:
diff changeset
626 // Printing
a61af66fc99e Initial load
duke
parents:
diff changeset
627
a61af66fc99e Initial load
duke
parents:
diff changeset
628 // Note: we cannot have print_on as const, as we allocate inside the method
a61af66fc99e Initial load
duke
parents:
diff changeset
629 void vframeArray::print_on_2(outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
630 st->print_cr(" - sp: " INTPTR_FORMAT, sp());
a61af66fc99e Initial load
duke
parents:
diff changeset
631 st->print(" - thread: ");
a61af66fc99e Initial load
duke
parents:
diff changeset
632 Thread::current()->print();
a61af66fc99e Initial load
duke
parents:
diff changeset
633 st->print_cr(" - frame size: %d", frame_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
634 for (int index = 0; index < frames() ; index++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
635 element(index)->print(st);
a61af66fc99e Initial load
duke
parents:
diff changeset
636 }
a61af66fc99e Initial load
duke
parents:
diff changeset
637 }
a61af66fc99e Initial load
duke
parents:
diff changeset
638
a61af66fc99e Initial load
duke
parents:
diff changeset
639 void vframeArrayElement::print(outputStream* st) {
1255
e3a4305c6bc3 6925249: assert(last_sp < (intptr_t*) interpreter_frame_monitor_begin(),"bad tos")
kvn
parents: 903
diff changeset
640 st->print_cr(" - interpreter_frame -> sp: " INTPTR_FORMAT, iframe()->sp());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
641 }
a61af66fc99e Initial load
duke
parents:
diff changeset
642
a61af66fc99e Initial load
duke
parents:
diff changeset
643 void vframeArray::print_value_on(outputStream* st) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
644 st->print_cr("vframeArray [%d] ", frames());
a61af66fc99e Initial load
duke
parents:
diff changeset
645 }
a61af66fc99e Initial load
duke
parents:
diff changeset
646
a61af66fc99e Initial load
duke
parents:
diff changeset
647
a61af66fc99e Initial load
duke
parents:
diff changeset
648 #endif