src/share/vm/code/location.hpp

Mon, 19 Aug 2019 10:11:31 +0200

author
neugens
date
Mon, 19 Aug 2019 10:11:31 +0200
changeset 9861
a248d0be1309
parent 2314
f95d63e2154a
child 6876
710a3c8b516e
permissions
-rw-r--r--

8229401: Fix JFR code cache test failures
8223689: Add JFR Thread Sampling Support
8223690: Add JFR BiasedLock Event Support
8223691: Add JFR G1 Region Type Change Event Support
8223692: Add JFR G1 Heap Summary Event Support
Summary: Backport JFR from JDK11, additional fixes
Reviewed-by: neugens, apetushkov
Contributed-by: denghui.ddh@alibaba-inc.com

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_CODE_LOCATION_HPP
stefank@2314 26 #define SHARE_VM_CODE_LOCATION_HPP
stefank@2314 27
stefank@2314 28 #include "asm/assembler.hpp"
stefank@2314 29 #include "code/vmreg.hpp"
stefank@2314 30 #include "memory/allocation.hpp"
stefank@2314 31
duke@435 32 // A Location describes a concrete machine variable location
duke@435 33 // (such as integer or floating point register or a stack-held
duke@435 34 // variable). Used when generating debug-information for nmethods.
duke@435 35 //
duke@435 36 // Encoding:
duke@435 37 //
kvn@766 38 // bits (use low bits for best compression):
kvn@766 39 // Type: [3..0]
kvn@766 40 // Where: [4]
kvn@766 41 // Offset: [31..5]
duke@435 42
duke@435 43 class Location VALUE_OBJ_CLASS_SPEC {
duke@435 44 friend class VMStructs;
duke@435 45 public:
duke@435 46 enum Where {
duke@435 47 on_stack,
duke@435 48 in_register
duke@435 49 };
duke@435 50
duke@435 51 enum Type {
kvn@766 52 invalid, // Invalid location
duke@435 53 normal, // Ints, floats, double halves
duke@435 54 oop, // Oop (please GC me!)
duke@435 55 int_in_long, // Integer held in long register
duke@435 56 lng, // Long held in one register
duke@435 57 float_in_dbl, // Float held in double register
duke@435 58 dbl, // Double held in one register
duke@435 59 addr, // JSR return address
kvn@766 60 narrowoop // Narrow Oop (please GC me!)
duke@435 61 };
duke@435 62
duke@435 63
duke@435 64 private:
duke@435 65 enum {
kvn@766 66 TYPE_MASK = (juint) 0x0F,
kvn@766 67 TYPE_SHIFT = 0,
kvn@766 68 WHERE_MASK = (juint) 0x10,
kvn@766 69 WHERE_SHIFT = 4,
kvn@766 70 OFFSET_MASK = (juint) 0xFFFFFFE0,
kvn@766 71 OFFSET_SHIFT = 5
duke@435 72 };
duke@435 73
kvn@766 74 juint _value;
duke@435 75
duke@435 76 // Create a bit-packed Location
duke@435 77 Location(Where where_, Type type_, unsigned offset_) {
duke@435 78 set(where_, type_, offset_);
duke@435 79 assert( where () == where_ , "" );
duke@435 80 assert( type () == type_ , "" );
duke@435 81 assert( offset() == offset_, "" );
duke@435 82 }
duke@435 83
duke@435 84 inline void set(Where where_, Type type_, unsigned offset_) {
kvn@766 85 _value = (juint) ((where_ << WHERE_SHIFT) |
kvn@766 86 (type_ << TYPE_SHIFT) |
kvn@766 87 ((offset_ << OFFSET_SHIFT) & OFFSET_MASK));
duke@435 88 }
duke@435 89
duke@435 90 public:
duke@435 91
duke@435 92 // Stack location Factory. Offset is 4-byte aligned; remove low bits
duke@435 93 static Location new_stk_loc( Type t, int offset ) { return Location(on_stack,t,offset>>LogBytesPerInt); }
duke@435 94 // Register location Factory
duke@435 95 static Location new_reg_loc( Type t, VMReg reg ) { return Location(in_register, t, reg->value()); }
duke@435 96 // Default constructor
kvn@766 97 Location() { set(on_stack,invalid,0); }
duke@435 98
duke@435 99 // Bit field accessors
duke@435 100 Where where() const { return (Where) ((_value & WHERE_MASK) >> WHERE_SHIFT);}
duke@435 101 Type type() const { return (Type) ((_value & TYPE_MASK) >> TYPE_SHIFT); }
duke@435 102 unsigned offset() const { return (unsigned) ((_value & OFFSET_MASK) >> OFFSET_SHIFT); }
duke@435 103
duke@435 104 // Accessors
duke@435 105 bool is_register() const { return where() == in_register; }
duke@435 106 bool is_stack() const { return where() == on_stack; }
duke@435 107
duke@435 108 int stack_offset() const { assert(where() == on_stack, "wrong Where"); return offset()<<LogBytesPerInt; }
duke@435 109 int register_number() const { assert(where() == in_register, "wrong Where"); return offset() ; }
duke@435 110
duke@435 111 VMReg reg() const { assert(where() == in_register, "wrong Where"); return VMRegImpl::as_VMReg(offset()) ; }
duke@435 112
duke@435 113 // Printing
duke@435 114 void print_on(outputStream* st) const;
duke@435 115
duke@435 116 // Serialization of debugging information
duke@435 117 Location(DebugInfoReadStream* stream);
duke@435 118 void write_on(DebugInfoWriteStream* stream);
duke@435 119
duke@435 120 // check
duke@435 121 static bool legal_offset_in_bytes(int offset_in_bytes);
duke@435 122 };
stefank@2314 123
stefank@2314 124 #endif // SHARE_VM_CODE_LOCATION_HPP

mercurial