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