annotate src/share/vm/code/location.hpp @ 10408:836a62f43af9

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Wed, 19 Jun 2013 10:45:56 +0200
parents f95d63e2154a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 331
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 331
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 331
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_CODE_LOCATION_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_CODE_LOCATION_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "asm/assembler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "code/vmreg.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // A Location describes a concrete machine variable location
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // (such as integer or floating point register or a stack-held
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // variable). Used when generating debug-information for nmethods.
a61af66fc99e Initial load
duke
parents:
diff changeset
35 //
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // Encoding:
a61af66fc99e Initial load
duke
parents:
diff changeset
37 //
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
38 // bits (use low bits for best compression):
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
39 // Type: [3..0]
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
40 // Where: [4]
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
41 // Offset: [31..5]
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class Location VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
46 enum Where {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 on_stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
48 in_register
a61af66fc99e Initial load
duke
parents:
diff changeset
49 };
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 enum Type {
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
52 invalid, // Invalid location
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53 normal, // Ints, floats, double halves
a61af66fc99e Initial load
duke
parents:
diff changeset
54 oop, // Oop (please GC me!)
a61af66fc99e Initial load
duke
parents:
diff changeset
55 int_in_long, // Integer held in long register
a61af66fc99e Initial load
duke
parents:
diff changeset
56 lng, // Long held in one register
a61af66fc99e Initial load
duke
parents:
diff changeset
57 float_in_dbl, // Float held in double register
a61af66fc99e Initial load
duke
parents:
diff changeset
58 dbl, // Double held in one register
a61af66fc99e Initial load
duke
parents:
diff changeset
59 addr, // JSR return address
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
60 narrowoop // Narrow Oop (please GC me!)
0
a61af66fc99e Initial load
duke
parents:
diff changeset
61 };
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
65 enum {
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
66 TYPE_MASK = (juint) 0x0F,
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
67 TYPE_SHIFT = 0,
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
68 WHERE_MASK = (juint) 0x10,
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
69 WHERE_SHIFT = 4,
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
70 OFFSET_MASK = (juint) 0xFFFFFFE0,
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
71 OFFSET_SHIFT = 5
0
a61af66fc99e Initial load
duke
parents:
diff changeset
72 };
a61af66fc99e Initial load
duke
parents:
diff changeset
73
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
74 juint _value;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // Create a bit-packed Location
a61af66fc99e Initial load
duke
parents:
diff changeset
77 Location(Where where_, Type type_, unsigned offset_) {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 set(where_, type_, offset_);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 assert( where () == where_ , "" );
a61af66fc99e Initial load
duke
parents:
diff changeset
80 assert( type () == type_ , "" );
a61af66fc99e Initial load
duke
parents:
diff changeset
81 assert( offset() == offset_, "" );
a61af66fc99e Initial load
duke
parents:
diff changeset
82 }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 inline void set(Where where_, Type type_, unsigned offset_) {
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
85 _value = (juint) ((where_ << WHERE_SHIFT) |
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
86 (type_ << TYPE_SHIFT) |
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
87 ((offset_ << OFFSET_SHIFT) & OFFSET_MASK));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // Stack location Factory. Offset is 4-byte aligned; remove low bits
a61af66fc99e Initial load
duke
parents:
diff changeset
93 static Location new_stk_loc( Type t, int offset ) { return Location(on_stack,t,offset>>LogBytesPerInt); }
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // Register location Factory
a61af66fc99e Initial load
duke
parents:
diff changeset
95 static Location new_reg_loc( Type t, VMReg reg ) { return Location(in_register, t, reg->value()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // Default constructor
331
cecd8eb4e0ca 6706829: Compressed Oops: add debug info for narrow oops
kvn
parents: 0
diff changeset
97 Location() { set(on_stack,invalid,0); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // Bit field accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
100 Where where() const { return (Where) ((_value & WHERE_MASK) >> WHERE_SHIFT);}
a61af66fc99e Initial load
duke
parents:
diff changeset
101 Type type() const { return (Type) ((_value & TYPE_MASK) >> TYPE_SHIFT); }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 unsigned offset() const { return (unsigned) ((_value & OFFSET_MASK) >> OFFSET_SHIFT); }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
105 bool is_register() const { return where() == in_register; }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 bool is_stack() const { return where() == on_stack; }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 int stack_offset() const { assert(where() == on_stack, "wrong Where"); return offset()<<LogBytesPerInt; }
a61af66fc99e Initial load
duke
parents:
diff changeset
109 int register_number() const { assert(where() == in_register, "wrong Where"); return offset() ; }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 VMReg reg() const { assert(where() == in_register, "wrong Where"); return VMRegImpl::as_VMReg(offset()) ; }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // Printing
a61af66fc99e Initial load
duke
parents:
diff changeset
114 void print_on(outputStream* st) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Serialization of debugging information
a61af66fc99e Initial load
duke
parents:
diff changeset
117 Location(DebugInfoReadStream* stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 void write_on(DebugInfoWriteStream* stream);
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // check
a61af66fc99e Initial load
duke
parents:
diff changeset
121 static bool legal_offset_in_bytes(int offset_in_bytes);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
123
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
124 #endif // SHARE_VM_CODE_LOCATION_HPP