comparison graal/Compiler/src/com/sun/c1x/ir/StoreField.java @ 2507:9ec15d6914ca

Pull over of compiler from maxine repository.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 27 Apr 2011 11:43:22 +0200
parents
children
comparison
equal deleted inserted replaced
2506:4a3bf8a5bf41 2507:9ec15d6914ca
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 com.sun.c1x.debug.*;
26 import com.sun.c1x.value.*;
27 import com.sun.cri.ci.*;
28 import com.sun.cri.ri.*;
29
30 /**
31 * The {@code StoreField} instruction represents a write to a static or instance field.
32 *
33 * @author Ben L. Titzer
34 */
35 public final class StoreField extends AccessField {
36
37 /**
38 * The value to store.
39 */
40 Value value;
41
42 /**
43 * Creates a new LoadField instance.
44 * @param object the receiver object
45 * @param field the compiler interface field
46 * @param value the instruction representing the value to store to the field
47 * @param isStatic indicates if the field is static
48 * @param stateBefore the state before the field access
49 * @param isLoaded indicates if the class is loaded
50 */
51 public StoreField(Value object, RiField field, Value value, boolean isStatic, FrameState stateBefore, boolean isLoaded) {
52 super(CiKind.Void, object, field, isStatic, stateBefore, isLoaded);
53 this.value = value;
54 setFlag(Flag.LiveStore);
55 if (value.kind != CiKind.Object) {
56 setFlag(Flag.NoWriteBarrier);
57 }
58 }
59
60 /**
61 * Gets the value that is written to the field.
62 * @return the value
63 */
64 public Value value() {
65 return value;
66 }
67
68 /**
69 * Checks whether this instruction needs a write barrier.
70 * @return {@code true} if this instruction needs a write barrier
71 */
72 public boolean needsWriteBarrier() {
73 return !checkFlag(Flag.NoWriteBarrier);
74 }
75
76 @Override
77 public void inputValuesDo(ValueClosure closure) {
78 super.inputValuesDo(closure);
79 value = closure.apply(value);
80 }
81
82 @Override
83 public void accept(ValueVisitor v) {
84 v.visitStoreField(this);
85 }
86
87 @Override
88 public void print(LogStream out) {
89 out.print(object()).
90 print(".").
91 print(field().name()).
92 print(" := ").
93 print(value()).
94 print(" [type: ").print(CiUtil.format("%h.%n:%t", field(), false)).
95 print(']');
96 }
97 }