1 /*
2  * Copyright (c) 2001, 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.interpreter;
26 
27 import java.util.*;
28 import sun.jvm.hotspot.oops.*;
29 import sun.jvm.hotspot.utilities.*;
30 
31 class OopMapForCacheEntry extends GenerateOopMap {
32   private OopMapCacheEntry entry;
33   private int              bci;
34   private int              stackTop;
35 
OopMapForCacheEntry(Method method, int bci, OopMapCacheEntry entry)36   OopMapForCacheEntry(Method method, int bci, OopMapCacheEntry entry) {
37     super(method);
38     this.entry = entry;
39     this.bci = bci;
40     this.stackTop = -1;
41   }
42 
reportResults()43   public boolean reportResults() { return false; }
44 
possibleGCPoint(BytecodeStream bcs)45   public boolean possibleGCPoint(BytecodeStream bcs) {
46     return false; // We are not reporting any result. We call resultForBasicblock directly
47   }
48 
fillStackmapProlog(int nof_gc_points)49   public void fillStackmapProlog(int nof_gc_points) {
50     // Do nothing
51   }
52 
fillStackmapEpilog()53   public void fillStackmapEpilog() {
54     // Do nothing
55   }
56 
fillStackmapForOpcodes(BytecodeStream bcs, CellTypeStateList vars, CellTypeStateList stack, int stackTop)57   public void fillStackmapForOpcodes(BytecodeStream bcs,
58                                      CellTypeStateList vars,
59                                      CellTypeStateList stack,
60                                      int stackTop) {
61     // Only interested in one specific bci
62     if (bcs.bci() == bci) {
63       entry.setMask(vars, stack, stackTop);
64       this.stackTop = stackTop;
65     }
66   }
67 
fillInitVars(List initVars)68   public void fillInitVars(List/*<Integer>*/ initVars) {
69     // Do nothing
70   }
71 
computeMap()72   public void computeMap() {
73     if (Assert.ASSERTS_ENABLED) {
74       Assert.that(!method().isNative(), "cannot compute oop map for native methods");
75     }
76     // First check if it is a method where the stackmap is always empty
77     if (method().getCodeSize() == 0 || method().getMaxLocals() + method().getMaxStack() == 0) {
78       entry.setEmptyMask();
79     } else {
80       super.computeMap();
81       resultForBasicblock(bci);
82     }
83   }
84 
size()85   public int size() {
86     if (Assert.ASSERTS_ENABLED) {
87       Assert.that(stackTop != -1, "computeMap must be called first");
88     }
89     return (int) ((method().isStatic() ? 0 : 1) + method().getMaxLocals() + stackTop);
90   }
91 }
92