duke@435: /* stefank@2314: * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_RUNTIME_STACKVALUE_HPP stefank@2314: #define SHARE_VM_RUNTIME_STACKVALUE_HPP stefank@2314: stefank@2314: #include "code/location.hpp" stefank@2314: #include "runtime/handles.hpp" stefank@2314: #include "utilities/top.hpp" stefank@2314: duke@435: class StackValue : public ResourceObj { duke@435: private: duke@435: BasicType _type; duke@435: intptr_t _i; // Blank java stack slot value duke@435: Handle _o; // Java stack slot value interpreted as a Handle duke@435: public: duke@435: duke@435: StackValue(intptr_t value) { duke@435: _type = T_INT; duke@435: _i = value; duke@435: } duke@435: kvn@1253: StackValue(Handle value, intptr_t scalar_replaced = 0) { duke@435: _type = T_OBJECT; kvn@1253: _i = scalar_replaced; duke@435: _o = value; kvn@1253: assert(_i == 0 || _o.is_null(), "not null object should not be marked as scalar replaced"); duke@435: } duke@435: duke@435: StackValue() { duke@435: _type = T_CONFLICT; duke@435: _i = 0; duke@435: } duke@435: duke@435: // Only used during deopt- preserve object type. duke@435: StackValue(intptr_t o, BasicType t) { duke@435: assert(t == T_OBJECT, "should not be used"); duke@435: _type = t; duke@435: _i = o; duke@435: } duke@435: duke@435: Handle get_obj() const { duke@435: assert(type() == T_OBJECT, "type check"); duke@435: return _o; duke@435: } duke@435: kvn@1253: bool obj_is_scalar_replaced() const { kvn@1253: assert(type() == T_OBJECT, "type check"); kvn@1253: return _i != 0; kvn@1253: } kvn@1253: duke@435: void set_obj(Handle value) { duke@435: assert(type() == T_OBJECT, "type check"); duke@435: _o = value; duke@435: } duke@435: duke@435: intptr_t get_int() const { duke@435: assert(type() == T_INT, "type check"); duke@435: return _i; duke@435: } duke@435: duke@435: // For special case in deopt. duke@435: intptr_t get_int(BasicType t) const { duke@435: assert(t == T_OBJECT && type() == T_OBJECT, "type check"); duke@435: return _i; duke@435: } duke@435: duke@435: void set_int(intptr_t value) { duke@435: assert(type() == T_INT, "type check"); duke@435: _i = value; duke@435: } duke@435: duke@435: BasicType type() const { return _type; } duke@435: duke@435: bool equal(StackValue *value) { duke@435: if (_type != value->_type) return false; duke@435: if (_type == T_OBJECT) duke@435: return (_o == value->_o); duke@435: else { duke@435: assert(_type == T_INT, "sanity check"); duke@435: // [phh] compare only low addressed portions of intptr_t slots duke@435: return (*(int *)&_i == *(int *)&value->_i); duke@435: } duke@435: } duke@435: duke@435: static StackValue* create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv); duke@435: static BasicLock* resolve_monitor_lock(const frame* fr, Location location); duke@435: duke@435: #ifndef PRODUCT duke@435: public: duke@435: // Printing duke@435: void print_on(outputStream* st) const; duke@435: #endif duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_RUNTIME_STACKVALUE_HPP