< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/ObjectValue.java

Print this page

 1 /*
 2  * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved.
 3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  *
 5  * This code is free software; you can redistribute it and/or modify it
 6  * under the terms of the GNU General Public License version 2 only, as
 7  * published by the Free Software Foundation.
 8  *
 9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  *
23  */
24 
25 package sun.jvm.hotspot.code;
26 
27 import java.io.*;
28 import java.util.*;
29 
30 import sun.jvm.hotspot.debugger.*;
31 import sun.jvm.hotspot.utilities.*;
32 
33 /** An ObjectValue describes an object eliminated by escape analysis. */
34 
35 public class ObjectValue extends ScopeValue {
36   protected final int      id;
37   private boolean          isRoot;
38   private ScopeValue       klass;

39   private List<ScopeValue> fieldsValue;
40 
41   // Field "boolean visited" is not implemented here since
42   // it is used only a during debug info creation.
43 
44   public ObjectValue(int id) {
45     this.id = id;
46     klass   = null;

47     fieldsValue = new ArrayList<>();
48   }
49 
50   public boolean isObject() { return true; }
51   public int id() { return id; }
52   public ScopeValue getKlass() { return klass; }

53   public List<ScopeValue> getFieldsValue() { return fieldsValue; }
54   public ScopeValue getFieldAt(int i) { return fieldsValue.get(i); }
55   public int fieldsSize() { return fieldsValue.size(); }
56 
57   // Field "value" is always NULL here since it is used
58   // only during deoptimization of a compiled frame
59   // pointing to reallocated object.
60   public OopHandle getValue() { return null; }
61 
62   /** Serialization of debugging information */
63 
64   void readObject(DebugInfoReadStream stream) {
65     isRoot = stream.readBoolean();
66     klass = readFrom(stream);
67     Assert.that(klass.isConstantOop(), "should be constant klass oop: " + klass);

68     int length = stream.readInt();
69     for (int i = 0; i < length; i++) {
70       ScopeValue val = readFrom(stream);
71       fieldsValue.add(val);
72     }
73   }
74 
75   // Printing
76 
77   public void print() {
78     printOn(System.out);
79   }
80 
81   public void printOn(PrintStream tty) {
82     tty.print("scalarObj[" + id + "]");
83   }
84 
85   void printFieldsOn(PrintStream tty) {
86     if (fieldsValue.size() > 0) {
87       fieldsValue.get(0).printOn(tty);

 1 /*
 2  * Copyright (c) 2009, 2026, Oracle and/or its affiliates. All rights reserved.
 3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  *
 5  * This code is free software; you can redistribute it and/or modify it
 6  * under the terms of the GNU General Public License version 2 only, as
 7  * published by the Free Software Foundation.
 8  *
 9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  *
23  */
24 
25 package sun.jvm.hotspot.code;
26 
27 import java.io.*;
28 import java.util.*;
29 
30 import sun.jvm.hotspot.debugger.*;
31 import sun.jvm.hotspot.utilities.*;
32 
33 /** An ObjectValue describes an object eliminated by escape analysis. */
34 
35 public class ObjectValue extends ScopeValue {
36   protected final int      id;
37   private boolean          isRoot;
38   private ScopeValue       klass;
39   private ScopeValue       properties;
40   private List<ScopeValue> fieldsValue;
41 
42   // Field "boolean visited" is not implemented here since
43   // it is used only a during debug info creation.
44 
45   public ObjectValue(int id) {
46     this.id = id;
47     klass   = null;
48     properties = null;
49     fieldsValue = new ArrayList<>();
50   }
51 
52   public boolean isObject() { return true; }
53   public int id() { return id; }
54   public ScopeValue getKlass() { return klass; }
55   public ScopeValue getProperties() { return properties; }
56   public List<ScopeValue> getFieldsValue() { return fieldsValue; }
57   public ScopeValue getFieldAt(int i) { return fieldsValue.get(i); }
58   public int fieldsSize() { return fieldsValue.size(); }
59 
60   // Field "value" is always NULL here since it is used
61   // only during deoptimization of a compiled frame
62   // pointing to reallocated object.
63   public OopHandle getValue() { return null; }
64 
65   /** Serialization of debugging information */
66 
67   void readObject(DebugInfoReadStream stream) {
68     isRoot = stream.readBoolean();
69     klass = readFrom(stream);
70     Assert.that(klass.isConstantOop(), "should be constant klass oop: " + klass);
71     properties = readFrom(stream);
72     int length = stream.readInt();
73     for (int i = 0; i < length; i++) {
74       ScopeValue val = readFrom(stream);
75       fieldsValue.add(val);
76     }
77   }
78 
79   // Printing
80 
81   public void print() {
82     printOn(System.out);
83   }
84 
85   public void printOn(PrintStream tty) {
86     tty.print("scalarObj[" + id + "]");
87   }
88 
89   void printFieldsOn(PrintStream tty) {
90     if (fieldsValue.size() > 0) {
91       fieldsValue.get(0).printOn(tty);
< prev index next >