Thu, 04 Sep 2014 16:53:27 -0700
8057531: refactor gc argument processing code slightly
Reviewed-by: mgerdin, tschatzl, jmasa
duke@435 | 1 | /* |
stefank@2314 | 2 | * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_RUNTIME_STACKVALUE_HPP |
stefank@2314 | 26 | #define SHARE_VM_RUNTIME_STACKVALUE_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "code/location.hpp" |
stefank@2314 | 29 | #include "runtime/handles.hpp" |
stefank@2314 | 30 | #include "utilities/top.hpp" |
stefank@2314 | 31 | |
duke@435 | 32 | class StackValue : public ResourceObj { |
duke@435 | 33 | private: |
duke@435 | 34 | BasicType _type; |
duke@435 | 35 | intptr_t _i; // Blank java stack slot value |
duke@435 | 36 | Handle _o; // Java stack slot value interpreted as a Handle |
duke@435 | 37 | public: |
duke@435 | 38 | |
duke@435 | 39 | StackValue(intptr_t value) { |
duke@435 | 40 | _type = T_INT; |
duke@435 | 41 | _i = value; |
duke@435 | 42 | } |
duke@435 | 43 | |
kvn@1253 | 44 | StackValue(Handle value, intptr_t scalar_replaced = 0) { |
duke@435 | 45 | _type = T_OBJECT; |
kvn@1253 | 46 | _i = scalar_replaced; |
duke@435 | 47 | _o = value; |
kvn@1253 | 48 | assert(_i == 0 || _o.is_null(), "not null object should not be marked as scalar replaced"); |
duke@435 | 49 | } |
duke@435 | 50 | |
duke@435 | 51 | StackValue() { |
duke@435 | 52 | _type = T_CONFLICT; |
duke@435 | 53 | _i = 0; |
duke@435 | 54 | } |
duke@435 | 55 | |
duke@435 | 56 | // Only used during deopt- preserve object type. |
duke@435 | 57 | StackValue(intptr_t o, BasicType t) { |
duke@435 | 58 | assert(t == T_OBJECT, "should not be used"); |
duke@435 | 59 | _type = t; |
duke@435 | 60 | _i = o; |
duke@435 | 61 | } |
duke@435 | 62 | |
duke@435 | 63 | Handle get_obj() const { |
duke@435 | 64 | assert(type() == T_OBJECT, "type check"); |
duke@435 | 65 | return _o; |
duke@435 | 66 | } |
duke@435 | 67 | |
kvn@1253 | 68 | bool obj_is_scalar_replaced() const { |
kvn@1253 | 69 | assert(type() == T_OBJECT, "type check"); |
kvn@1253 | 70 | return _i != 0; |
kvn@1253 | 71 | } |
kvn@1253 | 72 | |
duke@435 | 73 | void set_obj(Handle value) { |
duke@435 | 74 | assert(type() == T_OBJECT, "type check"); |
duke@435 | 75 | _o = value; |
duke@435 | 76 | } |
duke@435 | 77 | |
duke@435 | 78 | intptr_t get_int() const { |
duke@435 | 79 | assert(type() == T_INT, "type check"); |
duke@435 | 80 | return _i; |
duke@435 | 81 | } |
duke@435 | 82 | |
duke@435 | 83 | // For special case in deopt. |
duke@435 | 84 | intptr_t get_int(BasicType t) const { |
duke@435 | 85 | assert(t == T_OBJECT && type() == T_OBJECT, "type check"); |
duke@435 | 86 | return _i; |
duke@435 | 87 | } |
duke@435 | 88 | |
duke@435 | 89 | void set_int(intptr_t value) { |
duke@435 | 90 | assert(type() == T_INT, "type check"); |
duke@435 | 91 | _i = value; |
duke@435 | 92 | } |
duke@435 | 93 | |
duke@435 | 94 | BasicType type() const { return _type; } |
duke@435 | 95 | |
duke@435 | 96 | bool equal(StackValue *value) { |
duke@435 | 97 | if (_type != value->_type) return false; |
duke@435 | 98 | if (_type == T_OBJECT) |
duke@435 | 99 | return (_o == value->_o); |
duke@435 | 100 | else { |
duke@435 | 101 | assert(_type == T_INT, "sanity check"); |
duke@435 | 102 | // [phh] compare only low addressed portions of intptr_t slots |
duke@435 | 103 | return (*(int *)&_i == *(int *)&value->_i); |
duke@435 | 104 | } |
duke@435 | 105 | } |
duke@435 | 106 | |
duke@435 | 107 | static StackValue* create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv); |
duke@435 | 108 | static BasicLock* resolve_monitor_lock(const frame* fr, Location location); |
duke@435 | 109 | |
duke@435 | 110 | #ifndef PRODUCT |
duke@435 | 111 | public: |
duke@435 | 112 | // Printing |
duke@435 | 113 | void print_on(outputStream* st) const; |
duke@435 | 114 | #endif |
duke@435 | 115 | }; |
stefank@2314 | 116 | |
stefank@2314 | 117 | #endif // SHARE_VM_RUNTIME_STACKVALUE_HPP |