Mercurial > hg > graal-jvmci-8
comparison graal/GraalCompiler/src/com/sun/c1x/ir/StoreIndexed.java @ 2509:16b9a8b5ad39
Renamings Runtime=>GraalRuntime and Compiler=>GraalCompiler
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 27 Apr 2011 11:50:44 +0200 |
parents | graal/Compiler/src/com/sun/c1x/ir/StoreIndexed.java@9ec15d6914ca |
children | fa3bda50cbfd |
comparison
equal
deleted
inserted
replaced
2508:fea94949e0a2 | 2509:16b9a8b5ad39 |
---|---|
1 /* | |
2 * Copyright (c) 2009, 2011, 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 package com.sun.c1x.ir; | |
24 | |
25 import static com.sun.c1x.ir.Value.Flag.*; | |
26 | |
27 import com.sun.c1x.debug.*; | |
28 import com.sun.c1x.value.*; | |
29 import com.sun.cri.ci.*; | |
30 | |
31 /** | |
32 * The {@code StoreIndexed} instruction represents a write to an array element. | |
33 * | |
34 * @author Ben L. Titzer | |
35 */ | |
36 public final class StoreIndexed extends AccessIndexed { | |
37 | |
38 /** | |
39 * The value to store. | |
40 */ | |
41 Value value; | |
42 | |
43 /** | |
44 * Creates a new StoreIndexed instruction. | |
45 * @param array the instruction producing the array | |
46 * @param index the instruction producing the index | |
47 * @param length the instruction producing the length | |
48 * @param elementType the element type | |
49 * @param value the value to store into the array | |
50 * @param stateBefore the state before executing this instruction | |
51 */ | |
52 public StoreIndexed(Value array, Value index, Value length, CiKind elementType, Value value, FrameState stateBefore) { | |
53 super(CiKind.Void, array, index, length, elementType, stateBefore); | |
54 this.value = value; | |
55 setFlag(Flag.LiveStore); | |
56 if (elementType != CiKind.Object) { | |
57 setFlag(Flag.NoWriteBarrier); | |
58 } | |
59 } | |
60 | |
61 /** | |
62 * Gets the instruction that produces the value that is to be stored into the array. | |
63 * @return the value to write into the array | |
64 */ | |
65 public Value value() { | |
66 return value; | |
67 } | |
68 | |
69 /** | |
70 * Checks if this instruction needs a write barrier. | |
71 * @return {@code true} if this instruction needs a write barrier | |
72 */ | |
73 public boolean needsWriteBarrier() { | |
74 return !checkFlag(Flag.NoWriteBarrier); | |
75 } | |
76 | |
77 /** | |
78 * Checks if this instruction needs a store check. | |
79 * @return {@code true} if this instruction needs a store check | |
80 */ | |
81 public boolean needsStoreCheck() { | |
82 return !checkFlag(Flag.NoStoreCheck); | |
83 } | |
84 | |
85 public void eliminateStoreCheck() { | |
86 clearRuntimeCheck(NoStoreCheck); | |
87 } | |
88 | |
89 /** | |
90 * Checks whether this instruction can cause a trap. | |
91 * @return {@code true} if this instruction can cause a trap | |
92 */ | |
93 @Override | |
94 public boolean canTrap() { | |
95 return super.canTrap() || needsStoreCheck(); | |
96 } | |
97 | |
98 @Override | |
99 public void inputValuesDo(ValueClosure closure) { | |
100 super.inputValuesDo(closure); | |
101 value = closure.apply(value); | |
102 } | |
103 | |
104 @Override | |
105 public void accept(ValueVisitor v) { | |
106 v.visitStoreIndexed(this); | |
107 } | |
108 | |
109 @Override | |
110 public void print(LogStream out) { | |
111 out.print(array()).print('[').print(index()).print("] := ").print(value()).print(" (").print(kind.typeChar).print(')'); | |
112 } | |
113 } |