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