vframeArray.hpp revision 1472
c869993e79c1eafbec61a56bf6cea848fe754c71xy/*
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
c869993e79c1eafbec61a56bf6cea848fe754c71xy * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * This code is free software; you can redistribute it and/or modify it
c869993e79c1eafbec61a56bf6cea848fe754c71xy * under the terms of the GNU General Public License version 2 only, as
c869993e79c1eafbec61a56bf6cea848fe754c71xy * published by the Free Software Foundation.
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer *
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * This code is distributed in the hope that it will be useful, but WITHOUT
c869993e79c1eafbec61a56bf6cea848fe754c71xy * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c869993e79c1eafbec61a56bf6cea848fe754c71xy * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
c869993e79c1eafbec61a56bf6cea848fe754c71xy * version 2 for more details (a copy is included in the LICENSE file that
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * accompanied this code).
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * You should have received a copy of the GNU General Public License version
c869993e79c1eafbec61a56bf6cea848fe754c71xy * 2 along with this work; if not, write to the Free Software Foundation,
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c869993e79c1eafbec61a56bf6cea848fe754c71xy *
c869993e79c1eafbec61a56bf6cea848fe754c71xy * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c869993e79c1eafbec61a56bf6cea848fe754c71xy * or visit www.oracle.com if you need additional information or have any
c869993e79c1eafbec61a56bf6cea848fe754c71xy * questions.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng *
08a0f9b044f01fb540a861b94b63d77dd3d576eechenlu chen - Sun Microsystems - Beijing China */
08a0f9b044f01fb540a861b94b63d77dd3d576eechenlu chen - Sun Microsystems - Beijing China
08a0f9b044f01fb540a861b94b63d77dd3d576eechenlu chen - Sun Microsystems - Beijing China// A vframeArray is an array used for momentarily storing off stack Java method activations
08a0f9b044f01fb540a861b94b63d77dd3d576eechenlu chen - Sun Microsystems - Beijing China// during deoptimization. Essentially it is an array of vframes where each vframe
08a0f9b044f01fb540a861b94b63d77dd3d576eechenlu chen - Sun Microsystems - Beijing China// data is stored off stack. This structure will never exist across a safepoint so
13485e69b5429e6c7d27301fb3c0deee0e93768aGarrett D'Amore// there is no need to gc any oops that are stored in the structure.
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xyclass LocalsClosure;
c869993e79c1eafbec61a56bf6cea848fe754c71xyclass ExpressionStackClosure;
c869993e79c1eafbec61a56bf6cea848fe754c71xyclass MonitorStackClosure;
c869993e79c1eafbec61a56bf6cea848fe754c71xyclass MonitorArrayElement;
c869993e79c1eafbec61a56bf6cea848fe754c71xyclass StackValueCollection;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy// A vframeArrayElement is an element of a vframeArray. Each element
c869993e79c1eafbec61a56bf6cea848fe754c71xy// represent an interpreter frame which will eventually be created.
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xyclass vframeArrayElement : public _ValueObj {
c869993e79c1eafbec61a56bf6cea848fe754c71xy private:
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy frame _frame; // the interpreter frame we will unpack into
c869993e79c1eafbec61a56bf6cea848fe754c71xy int _bci; // raw bci for this vframe
c869993e79c1eafbec61a56bf6cea848fe754c71xy bool _reexecute; // whether sould we reexecute this bytecode
c869993e79c1eafbec61a56bf6cea848fe754c71xy methodOop _method; // the method for this vframe
c869993e79c1eafbec61a56bf6cea848fe754c71xy MonitorChunk* _monitors; // active monitors for this vframe
c869993e79c1eafbec61a56bf6cea848fe754c71xy StackValueCollection* _locals;
c869993e79c1eafbec61a56bf6cea848fe754c71xy StackValueCollection* _expressions;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng public:
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy frame* iframe(void) { return &_frame; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy int bci(void) const;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy int raw_bci(void) const { return _bci; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy bool should_reexecute(void) const { return _reexecute; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy methodOop method(void) const { return _method; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy MonitorChunk* monitors(void) const { return _monitors; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy void free_monitors(JavaThread* jt);
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo
c869993e79c1eafbec61a56bf6cea848fe754c71xy StackValueCollection* locals(void) const { return _locals; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy StackValueCollection* expressions(void) const { return _expressions; }
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl void fill_in(compiledVFrame* vf);
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl // Formerly part of deoptimizedVFrame
75eba5b6d79ed4d2ce3daf7b2806306b6b69a938Robert Mustacchi
75eba5b6d79ed4d2ce3daf7b2806306b6b69a938Robert Mustacchi
c869993e79c1eafbec61a56bf6cea848fe754c71xy // Returns the on stack word size for this frame
c869993e79c1eafbec61a56bf6cea848fe754c71xy // callee_parameters is the number of callee locals residing inside this frame
c869993e79c1eafbec61a56bf6cea848fe754c71xy int on_stack_size(int callee_parameters,
c869993e79c1eafbec61a56bf6cea848fe754c71xy int callee_locals,
c869993e79c1eafbec61a56bf6cea848fe754c71xy bool is_top_frame,
c869993e79c1eafbec61a56bf6cea848fe754c71xy int popframe_extra_stack_expression_els) const;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy // Unpacks the element to skeletal interpreter frame
c869993e79c1eafbec61a56bf6cea848fe754c71xy void unpack_on_stack(int callee_parameters,
c869993e79c1eafbec61a56bf6cea848fe754c71xy int callee_locals,
c869993e79c1eafbec61a56bf6cea848fe754c71xy frame* caller,
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China bool is_top_frame,
cf8dcc9bbabedca41ecfee13dec8172104e99968zhefeng xu - Sun Microsystems - Beijing China int exec_mode);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China#ifndef PRODUCT
ac7f5757903d7806e03e59f71c10eec36e0deadechenlu chen - Sun Microsystems - Beijing China void print(outputStream* st);
c869993e79c1eafbec61a56bf6cea848fe754c71xy#endif /* PRODUCT */
c869993e79c1eafbec61a56bf6cea848fe754c71xy};
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy// this can be a ResourceObj if we don't save the last one...
c869993e79c1eafbec61a56bf6cea848fe754c71xy// but it does make debugging easier even if we can't look
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China// at the data in each vframeElement
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing Chinaclass vframeArray: public CHeapObj {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng private:
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng
c869993e79c1eafbec61a56bf6cea848fe754c71xy // Here is what a vframeArray looks like in memory
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo /*
c869993e79c1eafbec61a56bf6cea848fe754c71xy fixed part
c869993e79c1eafbec61a56bf6cea848fe754c71xy description of the original frame
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China _frames - number of vframes in this array
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China adapter info
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China callee register save area
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China variable part
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China vframeArrayElement [ 0 ]
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China ...
80a11ad227f9c82cd6e7cf5c8913a37f00b7af0echenlu chen - Sun Microsystems - Beijing China vframeArrayElement [_frames - 1]
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy */
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy JavaThread* _owner_thread;
c869993e79c1eafbec61a56bf6cea848fe754c71xy vframeArray* _next;
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng frame _original; // the original frame of the deoptee
c869993e79c1eafbec61a56bf6cea848fe754c71xy frame _caller; // caller of root frame in vframeArray
c869993e79c1eafbec61a56bf6cea848fe754c71xy frame _sender;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy Deoptimization::UnrollBlock* _unroll_block;
c869993e79c1eafbec61a56bf6cea848fe754c71xy int _frame_size;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy int _frames; // number of javavframes in the array (does not count any adapter)
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy intptr_t _callee_registers[RegisterMap::reg_count];
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic unsigned char _valid[RegisterMap::reg_count];
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy vframeArrayElement _elements[1]; // First variable section.
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy void fill_in_element(int index, compiledVFrame* vf);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy bool is_location_valid(int i) const { return _valid[i] != 0; }
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng void set_location_valid(int i, bool valid) { _valid[i] = valid; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy public:
c869993e79c1eafbec61a56bf6cea848fe754c71xy
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China
c869993e79c1eafbec61a56bf6cea848fe754c71xy // Tells whether index is within bounds.
c869993e79c1eafbec61a56bf6cea848fe754c71xy bool is_within_bounds(int index) const { return 0 <= index && index < frames(); }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy // Accessores for instance variable
c869993e79c1eafbec61a56bf6cea848fe754c71xy int frames() const { return _frames; }
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic
c869993e79c1eafbec61a56bf6cea848fe754c71xy static vframeArray* allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
c869993e79c1eafbec61a56bf6cea848fe754c71xy RegisterMap* reg_map, frame sender, frame caller, frame self);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy vframeArrayElement* element(int index) { assert(is_within_bounds(index), "Bad index"); return &_elements[index]; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng // Allocates a new vframe in the array and fills the array with vframe information in chunk
c869993e79c1eafbec61a56bf6cea848fe754c71xy void fill_in(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk, const RegisterMap *reg_map);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy // Returns the owner of this vframeArray
3f7e60a636ef887af87fadf9ab6289c672532dd9zhefeng xu - Sun Microsystems - Beijing China JavaThread* owner_thread() const { return _owner_thread; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy // Accessors for next
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo vframeArray* next() const { return _next; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy void set_next(vframeArray* value) { _next = value; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
69b2d733deffed6bf9baf89d901afd9c81b484edGuoqing Zhu // Accessors for sp
6ca163a136944eea4423498926e09cef9889312cvitezslav batrla - Sun Microsystems - Prague Czech Republic intptr_t* sp() const { return _original.sp(); }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo intptr_t* unextended_sp() const { return _original.unextended_sp(); }
d11274aa6f1c1462c11e04d3da70b7453f6f0ebdPaul Guo
c869993e79c1eafbec61a56bf6cea848fe754c71xy address original_pc() const { return _original.pc(); }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy frame original() const { return _original; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy frame caller() const { return _caller; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy frame sender() const { return _sender; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy // Accessors for unroll block
c869993e79c1eafbec61a56bf6cea848fe754c71xy Deoptimization::UnrollBlock* unroll_block() const { return _unroll_block; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy void set_unroll_block(Deoptimization::UnrollBlock* block) { _unroll_block = block; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy // Returns the size of the frame that got deoptimized
c869993e79c1eafbec61a56bf6cea848fe754c71xy int frame_size() const { return _frame_size; }
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy // Unpack the array on the stack passed in stack interval
c869993e79c1eafbec61a56bf6cea848fe754c71xy void unpack_to_stack(frame &unpack_frame, int exec_mode);
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy // Deallocates monitor chunks allocated during deoptimization.
c869993e79c1eafbec61a56bf6cea848fe754c71xy // This should be called when the array is not used anymore.
b8d0a37778010a5166d34bb0d192cf6b1b2f7becchenlu chen - Sun Microsystems - Beijing China void deallocate_monitor_chunks();
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy
8bb4b220fdb894543e41a5f9037898cf3c3f312bgl // Accessor for register map
c869993e79c1eafbec61a56bf6cea848fe754c71xy address register_location(int i) const;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy void print_on_2(outputStream* st) PRODUCT_RETURN;
c869993e79c1eafbec61a56bf6cea848fe754c71xy void print_value_on(outputStream* st) const PRODUCT_RETURN;
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy#ifndef PRODUCT
c869993e79c1eafbec61a56bf6cea848fe754c71xy // Comparing
c869993e79c1eafbec61a56bf6cea848fe754c71xy bool structural_compare(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk);
c869993e79c1eafbec61a56bf6cea848fe754c71xy#endif
c869993e79c1eafbec61a56bf6cea848fe754c71xy
c869993e79c1eafbec61a56bf6cea848fe754c71xy};
c869993e79c1eafbec61a56bf6cea848fe754c71xy