Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/NewArrayStubCall.java @ 6495:75f130f2b30f
moved AMD64 specific HotSpot code in com.oracle.graal.hotspot.amd64 project
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 03 Oct 2012 01:18:03 +0200 |
parents | 9892bfd8a48f |
children | 2a0c9f20baa1 |
rev | line source |
---|---|
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot.nodes; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
6495
75f130f2b30f
moved AMD64 specific HotSpot code in com.oracle.graal.hotspot.amd64 project
Doug Simon <doug.simon@oracle.com>
parents:
6490
diff
changeset
|
25 import static com.oracle.graal.hotspot.HotSpotBackend.*; |
6490
9892bfd8a48f
refactored stub names into constants shared between definition and usage sites
Doug Simon <doug.simon@oracle.com>
parents:
6482
diff
changeset
|
26 |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import com.oracle.graal.compiler.gen.*; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.graal.compiler.target.*; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.hotspot.*; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.lir.*; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.nodes.*; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.nodes.type.*; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 /** |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 * Node implementing a call to HotSpot's {@code new_[object|type]_array} stub. |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 */ |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 public class NewArrayStubCall extends FixedWithNextNode implements LIRGenLowerable { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 private static final Stamp defaultStamp = StampFactory.objectNonNull(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 @Input private final ValueNode hub; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 @Input private final ValueNode length; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 private final boolean isObjectArray; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 public NewArrayStubCall(boolean isObjectArray, ValueNode hub, ValueNode length) { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 super(defaultStamp); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 this.isObjectArray = isObjectArray; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 this.hub = hub; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 this.length = length; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 @Override |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 public boolean inferStamp() { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 if (stamp() == defaultStamp && hub.isConstant()) { |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 HotSpotKlassOop klassOop = (HotSpotKlassOop) this.hub.asConstant().asObject(); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 updateStamp(StampFactory.exactNonNull(klassOop.type)); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 return true; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 return false; |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 @Override |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 public void generate(LIRGenerator gen) { |
6482
f0db2c717f6e
modified NewArrayStubCall to use information provided by the (platform independent) backend instead of AMD64 specific nodes for linking the stub call
Doug Simon <doug.simon@oracle.com>
parents:
6458
diff
changeset
|
64 HotSpotBackend backend = (HotSpotBackend) HotSpotGraalRuntime.getInstance().getCompiler().backend; |
6490
9892bfd8a48f
refactored stub names into constants shared between definition and usage sites
Doug Simon <doug.simon@oracle.com>
parents:
6482
diff
changeset
|
65 HotSpotStub stub = backend.getStub(isObjectArray ? NEW_OBJECT_ARRAY_STUB_NAME : NEW_TYPE_ARRAY_STUB_NAME); |
6482
f0db2c717f6e
modified NewArrayStubCall to use information provided by the (platform independent) backend instead of AMD64 specific nodes for linking the stub call
Doug Simon <doug.simon@oracle.com>
parents:
6458
diff
changeset
|
66 Variable result = gen.emitCall(stub.address, stub.cc, true, gen.operand(hub), gen.operand(length)); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 gen.setResult(this, result); |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
68 } |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 |
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 @NodeIntrinsic |
6458
fb66841a0994
made all @NodeIntrinsic annotated methods be native (this is a requirement now enforced during snippet intrinsification)
Doug Simon <doug.simon@oracle.com>
parents:
5760
diff
changeset
|
71 public static native Object call(@ConstantNodeParameter boolean isObjectArray, Object hub, int length); |
5760
87e8baf5447c
added snippets for lowering array creation and initialization (in NewObjectSnippets)
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
72 } |