Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/StackInterval.java @ 23394:964f28c04d7b default tip
Don't fill the code cache with nmethods from CTW
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Fri, 05 Feb 2016 22:48:36 -0800 |
parents | ae8a63a7aa9e |
children |
rev | line source |
---|---|
19028
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
1 /* |
19037
cc2b817de0b5
StackSlotAllocation: fix style/formating issues.
Josef Eisl <josef.eisl@jku.at>
parents:
19031
diff
changeset
|
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
19028
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
4 * |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
8 * |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
14 * |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
18 * |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
21 * questions. |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
22 */ |
19031
beb7c10b7747
Move StackSlotAllocators into a package.
Josef Eisl <josef.eisl@jku.at>
parents:
19028
diff
changeset
|
23 package com.oracle.graal.lir.stackslotalloc; |
19028
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
24 |
22843
ae8a63a7aa9e
Update jvmci import: Move VirtualStackSlot from JVMCI to Graal and remove referenceMapIndex.
Roland Schatz <roland.schatz@oracle.com>
parents:
22790
diff
changeset
|
25 import com.oracle.graal.lir.VirtualStackSlot; |
ae8a63a7aa9e
Update jvmci import: Move VirtualStackSlot from JVMCI to Graal and remove referenceMapIndex.
Roland Schatz <roland.schatz@oracle.com>
parents:
22790
diff
changeset
|
26 |
22790
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22646
diff
changeset
|
27 import jdk.vm.ci.code.StackSlot; |
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22646
diff
changeset
|
28 import jdk.vm.ci.meta.LIRKind; |
19028
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
29 |
19078
5447a27a6fd7
Make StackUsePosList and StackInterval final.
Josef Eisl <josef.eisl@jku.at>
parents:
19037
diff
changeset
|
30 public final class StackInterval { |
19028
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
31 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
32 private static final int INVALID_START = Integer.MAX_VALUE; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
33 private static final int INVALID_END = Integer.MIN_VALUE; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
34 private final VirtualStackSlot operand; |
21197
50a21b1fe8b7
StackSlotAllocation: add support for hints.
Josef Eisl <josef.eisl@jku.at>
parents:
19083
diff
changeset
|
35 private StackInterval hint; |
19028
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
36 private final LIRKind kind; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
37 private int from = INVALID_START; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
38 private int to = INVALID_END; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
39 private StackSlot location; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
40 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
41 public StackInterval(VirtualStackSlot operand, LIRKind kind) { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
42 this.operand = operand; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
43 this.kind = kind; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
44 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
45 |
19083
09292c24d555
LSStackSlotAllocator: hide inner class.
Josef Eisl <josef.eisl@jku.at>
parents:
19081
diff
changeset
|
46 public boolean verify(int maxOpId) { |
09292c24d555
LSStackSlotAllocator: hide inner class.
Josef Eisl <josef.eisl@jku.at>
parents:
19081
diff
changeset
|
47 // maxOpId + 1 is the last position in the last block (i.e. the "write position") |
09292c24d555
LSStackSlotAllocator: hide inner class.
Josef Eisl <josef.eisl@jku.at>
parents:
19081
diff
changeset
|
48 assert 0 <= from && from <= to && to <= maxOpId + 1 : String.format("from %d, to %d, maxOpId %d", from, to, maxOpId); |
19028
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
49 return true; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
50 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
51 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
52 public VirtualStackSlot getOperand() { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
53 return operand; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
54 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
55 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
56 public void addTo(int opId) { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
57 if (opId >= to) { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
58 to = opId; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
59 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
60 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
61 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
62 protected void addFrom(int opId) { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
63 if (from > opId) { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
64 from = opId; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
65 // set opId also as to if it has not yet been set |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
66 if (to == INVALID_END) { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
67 to = opId; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
68 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
69 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
70 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
71 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
72 public LIRKind kind() { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
73 return kind; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
74 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
75 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
76 public StackSlot location() { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
77 return location; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
78 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
79 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
80 public void setLocation(StackSlot location) { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
81 this.location = location; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
82 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
83 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
84 public int from() { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
85 return from; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
86 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
87 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
88 public int to() { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
89 return to; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
90 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
91 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
92 public void fixFrom() { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
93 if (from == INVALID_START) { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
94 from = 0; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
95 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
96 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
97 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
98 public boolean isFixed() { |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
99 return from == 0; |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
100 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
101 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
102 @Override |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
103 public String toString() { |
21263
4154f4842bf0
Add missing null check
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
21197
diff
changeset
|
104 return String.format("SI[%d-%d] k=%s o=%s l=%s h=%s", from, to, kind, operand, location, hint != null ? hint.getOperand() : "null"); |
21197
50a21b1fe8b7
StackSlotAllocation: add support for hints.
Josef Eisl <josef.eisl@jku.at>
parents:
19083
diff
changeset
|
105 } |
50a21b1fe8b7
StackSlotAllocation: add support for hints.
Josef Eisl <josef.eisl@jku.at>
parents:
19083
diff
changeset
|
106 |
50a21b1fe8b7
StackSlotAllocation: add support for hints.
Josef Eisl <josef.eisl@jku.at>
parents:
19083
diff
changeset
|
107 public void setLocationHint(StackInterval locationHint) { |
50a21b1fe8b7
StackSlotAllocation: add support for hints.
Josef Eisl <josef.eisl@jku.at>
parents:
19083
diff
changeset
|
108 hint = locationHint; |
50a21b1fe8b7
StackSlotAllocation: add support for hints.
Josef Eisl <josef.eisl@jku.at>
parents:
19083
diff
changeset
|
109 } |
50a21b1fe8b7
StackSlotAllocation: add support for hints.
Josef Eisl <josef.eisl@jku.at>
parents:
19083
diff
changeset
|
110 |
50a21b1fe8b7
StackSlotAllocation: add support for hints.
Josef Eisl <josef.eisl@jku.at>
parents:
19083
diff
changeset
|
111 public StackInterval locationHint() { |
50a21b1fe8b7
StackSlotAllocation: add support for hints.
Josef Eisl <josef.eisl@jku.at>
parents:
19083
diff
changeset
|
112 return hint; |
19028
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
113 } |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
114 |
f59fc4850df5
StackSlotAllocator: add linear scan stack slot allocator.
Josef Eisl <josef.eisl@jku.at>
parents:
diff
changeset
|
115 } |