0N/A/*
1879N/A * Copyright (c) 1997, 2010, 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_STACKVALUE_HPP
1879N/A#define SHARE_VM_RUNTIME_STACKVALUE_HPP
1879N/A
1879N/A#include "code/location.hpp"
1879N/A#include "runtime/handles.hpp"
1879N/A#include "utilities/top.hpp"
1879N/A
0N/Aclass StackValue : public ResourceObj {
0N/A private:
0N/A BasicType _type;
0N/A intptr_t _i; // Blank java stack slot value
0N/A Handle _o; // Java stack slot value interpreted as a Handle
0N/A public:
0N/A
0N/A StackValue(intptr_t value) {
0N/A _type = T_INT;
0N/A _i = value;
0N/A }
0N/A
818N/A StackValue(Handle value, intptr_t scalar_replaced = 0) {
0N/A _type = T_OBJECT;
818N/A _i = scalar_replaced;
0N/A _o = value;
818N/A assert(_i == 0 || _o.is_null(), "not null object should not be marked as scalar replaced");
0N/A }
0N/A
0N/A StackValue() {
0N/A _type = T_CONFLICT;
0N/A _i = 0;
0N/A }
0N/A
0N/A // Only used during deopt- preserve object type.
0N/A StackValue(intptr_t o, BasicType t) {
0N/A assert(t == T_OBJECT, "should not be used");
0N/A _type = t;
0N/A _i = o;
0N/A }
0N/A
0N/A Handle get_obj() const {
0N/A assert(type() == T_OBJECT, "type check");
0N/A return _o;
0N/A }
0N/A
818N/A bool obj_is_scalar_replaced() const {
818N/A assert(type() == T_OBJECT, "type check");
818N/A return _i != 0;
818N/A }
818N/A
0N/A void set_obj(Handle value) {
0N/A assert(type() == T_OBJECT, "type check");
0N/A _o = value;
0N/A }
0N/A
0N/A intptr_t get_int() const {
0N/A assert(type() == T_INT, "type check");
0N/A return _i;
0N/A }
0N/A
0N/A // For special case in deopt.
0N/A intptr_t get_int(BasicType t) const {
0N/A assert(t == T_OBJECT && type() == T_OBJECT, "type check");
0N/A return _i;
0N/A }
0N/A
0N/A void set_int(intptr_t value) {
0N/A assert(type() == T_INT, "type check");
0N/A _i = value;
0N/A }
0N/A
0N/A BasicType type() const { return _type; }
0N/A
0N/A bool equal(StackValue *value) {
0N/A if (_type != value->_type) return false;
0N/A if (_type == T_OBJECT)
0N/A return (_o == value->_o);
0N/A else {
0N/A assert(_type == T_INT, "sanity check");
0N/A // [phh] compare only low addressed portions of intptr_t slots
0N/A return (*(int *)&_i == *(int *)&value->_i);
0N/A }
0N/A }
0N/A
0N/A static StackValue* create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv);
0N/A static BasicLock* resolve_monitor_lock(const frame* fr, Location location);
0N/A
0N/A#ifndef PRODUCT
0N/A public:
0N/A // Printing
0N/A void print_on(outputStream* st) const;
0N/A#endif
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_RUNTIME_STACKVALUE_HPP