Mercurial > hg > graal-jvmci-8
annotate jvmci/jdk.vm.ci.meta/src/jdk/vm/ci/meta/LineNumberTable.java @ 24111:8abcd8e1285d
missing checks in HotSpotMemoryAccessProviderImpl can cause VM assertions to fail (JDK-8177673)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 30 Mar 2017 21:18:43 +0200 |
parents | 9bc5db6cdbb0 |
children |
rev | line source |
---|---|
7311
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
22672
1bbd4a7c274b
Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22054
diff
changeset
|
23 package jdk.vm.ci.meta; |
7311
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
25 /** |
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
26 * Maps bytecode indexes to source line numbers. |
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
27 * |
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
28 * @see "https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.12" |
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
29 */ |
23393
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
30 public class LineNumberTable { |
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
31 |
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
32 private final int[] lineNumbers; |
23718
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
33 private final int[] bcis; |
7311
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
35 /** |
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
36 * |
23718
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
37 * @param lineNumbers an array of source line numbers. This array is now owned by this object |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
38 * and should not be mutated by the caller. |
23718
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
39 * @param bcis an array of bytecode indexes the same length at {@code lineNumbers} whose entries |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
40 * are sorted in ascending order. This array is now owned by this object and must not |
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
41 * be mutated by the caller. |
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
42 */ |
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
43 @SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "caller transfers ownership of `lineNumbers` and `bcis`") |
23718
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
44 public LineNumberTable(int[] lineNumbers, int[] bcis) { |
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
45 assert bcis.length == lineNumbers.length; |
23393
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
46 this.lineNumbers = lineNumbers; |
23718
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
47 this.bcis = bcis; |
23393
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
48 } |
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
49 |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
50 /** |
23718
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
51 * Gets a source line number for bytecode index {@code atBci}. |
23700
9e1235406b59
[Findbugs] various warnings reported for JVMCI sources (JDK-8159613)
Doug Simon <doug.simon@oracle.com>
parents:
23393
diff
changeset
|
52 */ |
23393
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
53 public int getLineNumber(int atBci) { |
23718
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
54 for (int i = 0; i < this.bcis.length - 1; i++) { |
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
55 if (this.bcis[i] <= atBci && atBci < this.bcis[i + 1]) { |
23393
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
56 return lineNumbers[i]; |
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
57 } |
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
58 } |
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
59 return lineNumbers[lineNumbers.length - 1]; |
1d4ce2d19e52
clean up and minimize JVMCI (JDK-8156835)
Doug Simon <doug.simon@oracle.com>
parents:
22672
diff
changeset
|
60 } |
23718
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
61 |
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
62 /** |
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
63 * Gets a copy of the array of line numbers that was passed to this object's constructor. |
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
64 */ |
23736
9bc5db6cdbb0
Backport method renames from jdk9.
Roland Schatz <roland.schatz@oracle.com>
parents:
23718
diff
changeset
|
65 public int[] getLineNumbers() { |
23718
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
66 return lineNumbers.clone(); |
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
67 } |
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
68 |
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
69 /** |
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
70 * Gets a copy of the array of bytecode indexes that was passed to this object's constructor. |
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
71 */ |
23736
9bc5db6cdbb0
Backport method renames from jdk9.
Roland Schatz <roland.schatz@oracle.com>
parents:
23718
diff
changeset
|
72 public int[] getBcis() { |
23718
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
73 return bcis.clone(); |
0bd91cd9869d
need to be able to copy internal arrays from LocalVariableTable and LineNumberTable (JDK-8160647)
Doug Simon <doug.simon@oracle.com>
parents:
23700
diff
changeset
|
74 } |
7311
3fda7128589e
Added missing files LineNumberTable.java and LineNumberTableImpl.java.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 } |