Mercurial > hg > truffle
annotate graal/com.oracle.max.graal.runtime/src/com/oracle/max/graal/runtime/HotSpotXirGenerator.java @ 2874:d90bf514d647
Renamed packages.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 08 Jun 2011 08:59:54 +0200 |
parents | graal/com.oracle.max.graal.runtime/src/com/oracle/graal/runtime/HotSpotXirGenerator.java@0341b6424579 |
children | 224412c24426 |
rev | line source |
---|---|
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
2502
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
2502
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
7 * published by the Free Software Foundation. |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
2502
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
13 * accompanied this code). |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
2502
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
2502
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
3e3e8bd12730
Copyright rebranding. Update checkstyle file.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
2501
diff
changeset
|
21 * questions. |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
2874
d90bf514d647
Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2872
diff
changeset
|
23 package com.oracle.max.graal.runtime; |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
2874
d90bf514d647
Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2872
diff
changeset
|
25 import static com.oracle.max.graal.runtime.TemplateFlag.*; |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 import static com.sun.cri.ci.CiCallingConvention.Type.*; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 import java.lang.reflect.*; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 import java.util.*; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 import java.util.concurrent.*; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 |
2677
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
2659
diff
changeset
|
32 import com.oracle.max.asm.target.amd64.*; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
2659
diff
changeset
|
33 import com.sun.cri.ci.*; |
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
2659
diff
changeset
|
34 import com.sun.cri.ci.CiAddress.*; |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
35 import com.sun.cri.ci.CiRegister.*; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 import com.sun.cri.ri.*; |
2677
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
2659
diff
changeset
|
37 import com.sun.cri.ri.RiType.*; |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
38 import com.sun.cri.xir.*; |
2677
0ea5f12e873a
use com.oracle.max.asm project for assembler
Christian.Wimmer@Oracle.com
parents:
2659
diff
changeset
|
39 import com.sun.cri.xir.CiXirAssembler.*; |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 public class HotSpotXirGenerator implements RiXirGenerator { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
43 // this needs to correspond to c1x_CodeInstaller.hpp |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
44 // @formatter:off |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
45 private static final Integer MARK_VERIFIED_ENTRY = 0x0001; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 private static final Integer MARK_UNVERIFIED_ENTRY = 0x0002; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
47 private static final Integer MARK_OSR_ENTRY = 0x0003; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 private static final Integer MARK_UNWIND_ENTRY = 0x0004; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
49 private static final Integer MARK_EXCEPTION_HANDLER_ENTRY = 0x0005; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 private static final Integer MARK_DEOPT_HANDLER_ENTRY = 0x0006; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 private static final Integer MARK_STATIC_CALL_STUB = 0x1000; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
53 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
54 private static final Integer MARK_INVOKE_INVALID = 0x2000; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 private static final Integer MARK_INVOKEINTERFACE = 0x2001; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
56 private static final Integer MARK_INVOKESTATIC = 0x2002; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 private static final Integer MARK_INVOKESPECIAL = 0x2003; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 private static final Integer MARK_INVOKEVIRTUAL = 0x2004; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 private static final Integer MARK_IMPLICIT_NULL = 0x3000; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 private static final Integer MARK_KLASS_PATCHING = 0x4000; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
63 private static final Integer MARK_DUMMY_OOP_RELOCATION = 0x4001; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 private static final Integer MARK_ACCESS_FIELD_PATCHING = 0x4002; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 // @formatter:on |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
66 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 private final HotSpotVMConfig config; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 private final CiTarget target; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 private final RiRegisterConfig registerConfig; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 private final Compiler compiler; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 private CiXirAssembler globalAsm; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 public HotSpotXirGenerator(HotSpotVMConfig config, CiTarget target, RiRegisterConfig registerConfig, Compiler compiler) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 this.config = config; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 this.target = target; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
77 this.registerConfig = registerConfig; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 this.compiler = compiler; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
80 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
81 private SimpleTemplates prologueTemplates = new SimpleTemplates(STATIC_METHOD) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 asm.restart(CiKind.Void); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 XirOperand framePointer = asm.createRegisterTemp("frame pointer", CiKind.Word, AMD64.rbp); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 XirOperand stackPointer = asm.createRegisterTemp("stack pointer", CiKind.Word, AMD64.rsp); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 XirLabel unverifiedStub = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
90 asm.mark(MARK_OSR_ENTRY); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
91 asm.mark(MARK_UNVERIFIED_ENTRY); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 if (!is(STATIC_METHOD, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 unverifiedStub = asm.createOutOfLineLabel("unverified"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 XirOperand temp = asm.createRegisterTemp("temp (r10)", CiKind.Word, AMD64.r10); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 XirOperand cache = asm.createRegisterTemp("cache (rax)", CiKind.Word, AMD64.rax); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 CiCallingConvention conventions = registerConfig.getCallingConvention(JavaCallee, new CiKind[] {CiKind.Object}, target); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 XirOperand receiver = asm.createRegisterTemp("receiver", CiKind.Word, conventions.locations[0].asRegister()); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 asm.pload(CiKind.Word, temp, receiver, asm.i(config.hubOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 asm.jneq(unverifiedStub, cache, temp); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 asm.align(config.codeEntryAlignment); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 asm.mark(MARK_VERIFIED_ENTRY); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 asm.stackOverflowCheck(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 asm.push(framePointer); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 asm.mov(framePointer, stackPointer); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
109 asm.pushFrame(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
111 // -- out of line ------------------------------------------------------- |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
112 XirOperand thread = asm.createRegisterTemp("thread", CiKind.Word, AMD64.r15); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 XirOperand exceptionOop = asm.createTemp("exception oop", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 XirLabel unwind = asm.createOutOfLineLabel("unwind"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 asm.bindOutOfLine(unwind); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 asm.mark(MARK_UNWIND_ENTRY); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 asm.pload(CiKind.Object, exceptionOop, thread, asm.i(config.threadExceptionOopOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 asm.pstore(CiKind.Object, thread, asm.i(config.threadExceptionOopOffset), asm.createConstant(CiConstant.NULL_OBJECT), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 asm.pstore(CiKind.Long, thread, asm.i(config.threadExceptionPcOffset), asm.l(0), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
123 asm.callRuntime(config.unwindExceptionStub, null, exceptionOop); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
124 asm.shouldNotReachHere(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 asm.mark(MARK_EXCEPTION_HANDLER_ENTRY); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 asm.callRuntime(config.handleExceptionStub, null); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 asm.shouldNotReachHere(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 asm.nop(1); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 asm.mark(MARK_DEOPT_HANDLER_ENTRY); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
132 asm.callRuntime(config.handleDeoptStub, null); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
133 asm.shouldNotReachHere(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
134 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
135 if (!is(STATIC_METHOD, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 asm.bindOutOfLine(unverifiedStub); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 asm.jmpRuntime(config.inlineCacheMissStub); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
139 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 return asm.finishTemplate(is(STATIC_METHOD, flags) ? "static prologue" : "prologue"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
141 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
142 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
143 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
144 private SimpleTemplates epilogueTemplates = new SimpleTemplates(STATIC_METHOD, SYNCHRONIZED) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
145 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
146 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 asm.restart(CiKind.Void); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 XirOperand framePointer = asm.createRegisterTemp("frame pointer", CiKind.Word, AMD64.rbp); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
151 asm.popFrame(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
152 asm.pop(framePointer); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
153 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
154 // TODO safepoint check |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
155 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
156 return asm.finishTemplate("epilogue"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
157 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 private SimpleTemplates safepointTemplates = new SimpleTemplates() { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
162 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
163 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 asm.restart(CiKind.Void); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 // XirOperand temp = asm.createRegister("temp", CiKind.Word, AMD64.rax); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
167 // asm.pload(CiKind.Word, temp, asm.w(config.safepointPollingAddress), true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
168 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
169 return asm.finishTemplate("safepoint"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
170 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
171 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 private SimpleTemplates exceptionObjectTemplates = new SimpleTemplates() { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
174 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
175 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
176 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
177 XirOperand result = asm.restart(CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
178 XirOperand thread = asm.createRegisterTemp("thread", CiKind.Word, AMD64.r15); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 asm.pload(CiKind.Object, result, thread, asm.i(config.threadExceptionOopOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 asm.pstore(CiKind.Object, thread, asm.i(config.threadExceptionOopOffset), asm.o(null), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 asm.pstore(CiKind.Long, thread, asm.i(config.threadExceptionPcOffset), asm.l(0), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
184 return asm.finishTemplate("exception object"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
188 private SimpleTemplates invokeInterfaceTemplates = new SimpleTemplates(NULL_CHECK) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
189 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
190 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 asm.restart(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
193 XirParameter receiver = asm.createInputParameter("receiver", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
194 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
195 XirOperand temp = asm.createRegisterTemp("temp", CiKind.Word, AMD64.rax); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
196 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
197 if (is(NULL_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
198 asm.nop(1); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
199 asm.mark(MARK_IMPLICIT_NULL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
200 asm.pload(CiKind.Word, temp, receiver, true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
201 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
202 asm.mark(MARK_INVOKEINTERFACE); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
203 asm.mov(temp, asm.createConstant(CiConstant.forObject(HotSpotProxy.DUMMY_CONSTANT_OBJ))); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
204 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 return asm.finishTemplate(addr, "invokeinterface"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
206 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 private SimpleTemplates invokeVirtualTemplates = new SimpleTemplates(NULL_CHECK) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
210 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
211 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
212 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
213 asm.restart(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
214 XirParameter receiver = asm.createInputParameter("receiver", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
215 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
216 XirOperand temp = asm.createRegisterTemp("temp", CiKind.Word, AMD64.rax); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
218 if (is(NULL_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
219 asm.nop(1); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 asm.mark(MARK_IMPLICIT_NULL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
221 asm.pload(CiKind.Word, temp, receiver, true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
222 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 asm.mark(MARK_INVOKEVIRTUAL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 asm.mov(temp, asm.createConstant(CiConstant.forObject(HotSpotProxy.DUMMY_CONSTANT_OBJ))); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
226 return asm.finishTemplate(addr, "invokevirtual"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
227 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
228 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
229 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
230 private SimpleTemplates invokeSpecialTemplates = new SimpleTemplates(NULL_CHECK) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
231 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
232 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
233 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
234 asm.restart(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
235 XirParameter receiver = asm.createInputParameter("receiver", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
236 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
237 XirOperand temp = asm.createRegisterTemp("temp", CiKind.Word, AMD64.rax); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
238 XirLabel stub = asm.createOutOfLineLabel("call stub"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
239 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
240 if (is(NULL_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
241 asm.nop(1); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
242 asm.mark(MARK_IMPLICIT_NULL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
243 asm.pload(CiKind.Word, temp, receiver, true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
244 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
245 asm.mark(MARK_INVOKESPECIAL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
246 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
247 // -- out of line ------------------------------------------------------- |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
248 asm.bindOutOfLine(stub); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
249 XirOperand method = asm.createRegisterTemp("method", CiKind.Word, AMD64.rbx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
250 asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
251 asm.mov(method, asm.w(0L)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
252 XirLabel dummy = asm.createOutOfLineLabel("dummy"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
253 asm.jmp(dummy); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
254 asm.bindOutOfLine(dummy); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
255 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
256 return asm.finishTemplate(addr, "invokespecial"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
257 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
258 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
259 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
260 private SimpleTemplates invokeStaticTemplates = new SimpleTemplates() { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
261 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
262 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
263 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
264 asm.restart(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
265 XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
266 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
267 XirLabel stub = asm.createOutOfLineLabel("call stub"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
268 asm.mark(MARK_INVOKESTATIC); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
269 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
270 // -- out of line ------------------------------------------------------- |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
271 asm.bindOutOfLine(stub); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
272 XirOperand method = asm.createRegisterTemp("method", CiKind.Word, AMD64.rbx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
273 asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
274 asm.mov(method, asm.w(0L)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
275 XirLabel dummy = asm.createOutOfLineLabel("dummy"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
276 asm.jmp(dummy); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
277 asm.bindOutOfLine(dummy); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
278 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
279 return asm.finishTemplate(addr, "invokestatic"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
280 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
281 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
282 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
283 private SimpleTemplates monitorEnterTemplates = new SimpleTemplates(NULL_CHECK) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
284 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
285 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
286 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
287 asm.restart(CiKind.Void); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
288 XirParameter object = asm.createInputParameter("object", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
289 XirParameter lock = asm.createInputParameter("lock", CiKind.Word); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
290 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
291 if (is(NULL_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
292 asm.nop(1); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
293 asm.mark(MARK_IMPLICIT_NULL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
294 asm.pload(CiKind.Word, asm.createTemp("temp", CiKind.Word), object, true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
295 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
296 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
297 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
298 // (tw) It is important to use for this runtime call the debug info AFTER the monitor enter. Otherwise the monitor object |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
299 // is not correctly garbage collected. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
300 final boolean useInfoAfter = true; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
301 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
302 if (config.useFastLocking) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
303 useRegisters(asm, AMD64.rax, AMD64.rbx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
304 useRegisters(asm, getGeneralParameterRegister(0)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
305 useRegisters(asm, getGeneralParameterRegister(1)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
306 asm.callRuntime(config.fastMonitorEnterStub, null, useInfoAfter, object, lock); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
307 } else { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
308 asm.reserveOutgoingStack(target.wordSize * 2); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
309 asm.pstore(CiKind.Object, asm.createRegister("rsp", CiKind.Word, AMD64.RSP.asRegister()), asm.i(target.wordSize), object, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
310 asm.pstore(CiKind.Word, asm.createRegister("rsp", CiKind.Word, AMD64.RSP.asRegister()), asm.i(0), lock, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
311 asm.callRuntime(config.monitorEnterStub, null, useInfoAfter); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
312 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
313 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
314 return asm.finishTemplate("monitorEnter"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
315 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
316 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
317 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
318 private CiRegister getGeneralParameterRegister(int index) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
319 return registerConfig.getCallingConventionRegisters(CiCallingConvention.Type.RuntimeCall, RegisterFlag.CPU)[index]; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
320 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
321 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
322 private SimpleTemplates monitorExitTemplates = new SimpleTemplates(NULL_CHECK) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
323 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
324 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
325 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
326 asm.restart(CiKind.Void); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
327 XirParameter object = asm.createInputParameter("object", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
328 XirParameter lock = asm.createInputParameter("lock", CiKind.Word); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
329 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
330 if (config.useFastLocking) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
331 useRegisters(asm, AMD64.rax, AMD64.rbx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
332 useRegisters(asm, getGeneralParameterRegister(0)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
333 useRegisters(asm, getGeneralParameterRegister(1)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
334 asm.callRuntime(config.fastMonitorExitStub, null, object, lock); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
335 } else { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
336 asm.reserveOutgoingStack(target.wordSize); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
337 asm.pstore(CiKind.Word, asm.createRegister("rsp", CiKind.Word, AMD64.RSP.asRegister()), asm.i(0), lock, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
338 asm.callRuntime(config.monitorExitStub, null); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
339 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
340 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
341 return asm.finishTemplate("monitorExit"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
342 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
343 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
344 |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
345 private KindTemplates getFieldTemplates = new KindTemplates(NULL_CHECK) { |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
346 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
347 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
348 protected XirTemplate create(CiXirAssembler asm, long flags, CiKind kind) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
349 XirOperand result = asm.restart(kind); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
350 XirParameter object = asm.createInputParameter("object", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
351 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
352 XirParameter fieldOffset = asm.createConstantInputParameter("fieldOffset", CiKind.Int); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
353 if (is(NULL_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
354 asm.nop(1); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
355 asm.mark(MARK_IMPLICIT_NULL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
356 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
357 asm.pload(kind, result, object, fieldOffset, is(NULL_CHECK, flags)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
358 return asm.finishTemplate("getfield<" + kind + ">"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
359 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
360 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
361 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
362 private KindTemplates writeBarrierTemplate = new KindTemplates() { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
363 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
364 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
365 protected XirTemplate create(CiXirAssembler asm, long flags, CiKind kind) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
366 asm.restart(CiKind.Void); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
367 XirParameter object = asm.createInputParameter("object", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
368 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
369 // Need temp operand, because the write barrier destroys the object pointer. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
370 XirOperand temp = asm.createTemp("temp", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
371 asm.mov(temp, object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
372 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
373 writeBarrier(asm, temp); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
374 return asm.finishTemplate("writeBarrier"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
375 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
376 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
377 |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
378 private KindTemplates putFieldTemplates = new KindTemplates(WRITE_BARRIER, NULL_CHECK) { |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
379 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
380 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
381 protected XirTemplate create(CiXirAssembler asm, long flags, CiKind kind) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
382 asm.restart(CiKind.Void); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
383 XirParameter object = asm.createInputParameter("object", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
384 XirParameter value = asm.createInputParameter("value", kind); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
385 XirParameter fieldOffset = asm.createConstantInputParameter("fieldOffset", CiKind.Int); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
386 if (kind == CiKind.Object) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
387 verifyPointer(asm, value); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
388 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
389 if (is(NULL_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
390 asm.nop(1); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
391 asm.mark(MARK_IMPLICIT_NULL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
392 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
393 asm.pstore(kind, object, fieldOffset, value, is(NULL_CHECK, flags)); |
2544
84a2012f8cd1
Fixes to barriers.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2543
diff
changeset
|
394 if (is(WRITE_BARRIER, flags) && kind == CiKind.Object) { |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
395 XirOperand temp = asm.createTemp("temp", CiKind.Word); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
396 asm.mov(temp, object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
397 writeBarrier(asm, temp); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
398 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
399 return asm.finishTemplate("putfield<" + kind + ">"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
400 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
401 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
402 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
403 private final IndexTemplates newInstanceTemplates = new IndexTemplates() { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
404 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
405 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
406 protected XirTemplate create(CiXirAssembler asm, long flags, int size) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
407 XirOperand result = asm.restart(CiKind.Word); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
408 XirOperand type = asm.createInputParameter("type", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
409 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
410 XirOperand temp1 = asm.createRegisterTemp("temp1", CiKind.Word, AMD64.rcx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
411 XirOperand temp2 = asm.createRegisterTemp("temp2", CiKind.Word, AMD64.rbx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
412 XirOperand temp2i = asm.createRegisterTemp("temp2i", CiKind.Int, AMD64.rbx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
413 useRegisters(asm, AMD64.rsi); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
414 XirLabel tlabFull = asm.createOutOfLineLabel("tlab full"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
415 XirLabel resume = asm.createInlineLabel("resume"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
416 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
417 // check if the class is already initialized |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
418 asm.pload(CiKind.Int, temp2i, type, asm.i(config.klassStateOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
419 asm.jneq(tlabFull, temp2i, asm.i(config.klassStateFullyInitialized)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
420 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
421 XirOperand thread = asm.createRegisterTemp("thread", CiKind.Word, AMD64.r15); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
422 asm.pload(CiKind.Word, result, thread, asm.i(config.threadTlabTopOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
423 asm.add(temp1, result, asm.w(size)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
424 asm.pload(CiKind.Word, temp2, thread, asm.i(config.threadTlabEndOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
425 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
426 asm.jgt(tlabFull, temp1, temp2); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
427 asm.pstore(CiKind.Word, thread, asm.i(config.threadTlabTopOffset), temp1, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
428 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
429 asm.bindInline(resume); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
430 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
431 asm.pload(CiKind.Word, temp1, type, asm.i(config.instanceHeaderPrototypeOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
432 asm.pstore(CiKind.Word, result, temp1, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
433 asm.pstore(CiKind.Object, result, asm.i(config.hubOffset), type, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
434 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
435 if (size > 2 * target.wordSize) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
436 asm.mov(temp1, asm.w(0)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
437 for (int offset = 2 * target.wordSize; offset < size; offset += target.wordSize) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
438 asm.pstore(CiKind.Word, result, asm.i(offset), temp1, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
439 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
440 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
441 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
442 // -- out of line ------------------------------------------------------- |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
443 asm.bindOutOfLine(tlabFull); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
444 XirOperand arg = asm.createRegisterTemp("runtime call argument", CiKind.Object, AMD64.rdx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
445 asm.mov(arg, type); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
446 useRegisters(asm, AMD64.rax); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
447 asm.callRuntime(config.newInstanceStub, result); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
448 asm.jmp(resume); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
449 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
450 return asm.finishTemplate("new instance"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
451 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
452 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
453 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
454 private SimpleTemplates newObjectArrayCloneTemplates = new SimpleTemplates() { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
455 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
456 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
457 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
458 XirOperand result = asm.restart(CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
459 XirParameter lengthParam = asm.createInputParameter("length", CiKind.Int, true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
460 XirParameter src = asm.createInputParameter("src", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
461 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
462 // Set up length and hub. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
463 XirOperand length = asm.createRegisterTemp("length", CiKind.Int, AMD64.rbx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
464 XirOperand hub = asm.createRegisterTemp("hub", CiKind.Object, AMD64.rdx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
465 asm.pload(CiKind.Object, hub, src, asm.i(config.hubOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
466 asm.mov(length, lengthParam); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
467 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
468 useRegisters(asm, AMD64.rsi, AMD64.rcx, AMD64.rdi, AMD64.rax); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
469 asm.callRuntime(config.newObjectArrayStub, result); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
470 return asm.finishTemplate("objectArrayClone"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
471 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
472 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
473 |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
474 private SimpleTemplates newObjectArrayTemplates = new SimpleTemplates() { |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
475 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
476 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
477 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
478 emitNewTypeArray(asm, flags, CiKind.Object, config.useFastNewObjectArray, config.newObjectArrayStub); |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
479 return asm.finishTemplate("newObjectArray"); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
480 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
481 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
482 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
483 private void emitNewTypeArray(CiXirAssembler asm, long flags, CiKind kind, boolean useFast, long slowPathStub) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
484 XirOperand result = asm.restart(CiKind.Word); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
485 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
486 XirParameter lengthParam = asm.createInputParameter("length", CiKind.Int, true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
487 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
488 XirOperand length = asm.createRegisterTemp("length", CiKind.Int, AMD64.rbx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
489 XirOperand hub = asm.createRegisterTemp("hub", CiKind.Object, AMD64.rdx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
490 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
491 // Registers rsi, rcx, rdi, and rax are needed by the runtime call. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
492 // Hub needs to be on rdx, length on rbx. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
493 XirOperand temp1 = asm.createRegisterTemp("temp1", CiKind.Word, AMD64.rcx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
494 XirOperand temp2 = asm.createRegisterTemp("temp2", CiKind.Word, AMD64.rax); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
495 XirOperand temp3 = asm.createRegisterTemp("temp3", CiKind.Word, AMD64.rdi); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
496 XirOperand size = asm.createRegisterTemp("size", CiKind.Int, AMD64.rsi); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
497 |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
498 asm.mov(hub, asm.createConstantInputParameter("hub", CiKind.Object)); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
499 asm.mov(length, lengthParam); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
500 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
501 if (useFast) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
502 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
503 XirLabel slowPath = asm.createOutOfLineLabel("slowPath"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
504 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
505 XirLabel done = asm.createInlineLabel("done"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
506 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
507 // Check for negative array size. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
508 // TODO: Also check for upper bound |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
509 asm.jlt(slowPath, length, asm.i(0)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
510 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
511 final int aligning = target.wordSize; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
512 final int arrayLengthOffset = target.wordSize * 2; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
513 final int arrayElementOffset = config.getArrayOffset(kind); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
514 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
515 // Calculate aligned size |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
516 asm.mov(size, length); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
517 int scale = CiUtil.log2(kind.sizeInBytes(target.wordSize)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
518 if (scale != 0) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
519 asm.shl(size, size, asm.i(scale)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
521 asm.add(size, size, asm.i(arrayElementOffset + aligning - 1)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
522 long mask = 0xFFFFFFFFL; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
523 mask <<= CiUtil.log2(aligning); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
524 asm.and(size, size, asm.i((int) mask)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
525 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
526 // Try tlab allocation |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
527 XirOperand thread = asm.createRegisterTemp("thread", CiKind.Word, AMD64.r15); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
528 asm.pload(CiKind.Word, result, thread, asm.i(config.threadTlabTopOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
529 asm.add(temp1, result, size); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
530 asm.pload(CiKind.Word, temp2, thread, asm.i(config.threadTlabEndOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
531 asm.jgt(slowPath, temp1, temp2); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
532 asm.pstore(CiKind.Word, thread, asm.i(config.threadTlabTopOffset), temp1, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
533 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
534 // Now the new object is in result, store mark word and klass |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
535 asm.pload(CiKind.Word, temp1, hub, asm.i(config.instanceHeaderPrototypeOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
536 asm.pstore(CiKind.Word, result, temp1, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
537 asm.pstore(CiKind.Object, result, asm.i(config.hubOffset), hub, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
538 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
539 // Store array length |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
540 asm.pstore(CiKind.Int, result, asm.i(arrayLengthOffset), length, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
541 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
542 // Initialize with 0 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
543 XirLabel top = asm.createInlineLabel("top"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
544 asm.sub(size, size, asm.i(arrayElementOffset)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
545 asm.shr(size, size, asm.i(Scale.Times8.log2)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
546 asm.jeq(done, size, asm.i(0)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
547 asm.xor(temp3, temp3, temp3); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
548 asm.bindInline(top); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
549 asm.pstore(CiKind.Word, result, size, temp3, arrayElementOffset - target.wordSize, Scale.Times8, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
550 asm.decAndJumpNotZero(top, size); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
551 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
552 asm.bindInline(done); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
553 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
554 // Slow path |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
555 asm.bindOutOfLine(slowPath); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
556 asm.callRuntime(slowPathStub, result); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
557 asm.jmp(done); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
558 } else { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
559 asm.callRuntime(slowPathStub, result); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
560 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
561 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
562 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
563 private KindTemplates newTypeArrayTemplates = new KindTemplates() { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
564 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
565 protected XirTemplate create(CiXirAssembler asm, long flags, CiKind kind) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
566 emitNewTypeArray(asm, flags, kind, config.useFastNewTypeArray, config.newTypeArrayStub); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
567 return asm.finishTemplate("newTypeArray<" + kind.toString() + ">"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
568 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
569 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
570 |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
571 private final IndexTemplates multiNewArrayTemplate = new IndexTemplates() { |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
572 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
573 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
574 protected XirTemplate create(CiXirAssembler asm, long flags, int dimensions) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
575 XirOperand result = asm.restart(CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
576 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
577 XirOperand hub = asm.createRegisterTemp("hub", CiKind.Object, AMD64.rax); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
578 XirOperand rank = asm.createRegisterTemp("rank", CiKind.Int, AMD64.rbx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
579 XirOperand sizes = asm.createRegisterTemp("sizes", CiKind.Long, AMD64.rcx); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
580 XirOperand thread = asm.createRegisterTemp("thread", CiKind.Long, AMD64.r15); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
581 asm.add(sizes, thread, asm.l(config.threadMultiNewArrayStorage)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
582 for (int i = 0; i < dimensions; i++) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
583 XirParameter length = asm.createInputParameter("length" + i, CiKind.Int, true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
584 asm.pstore(CiKind.Int, sizes, asm.i(i * target.sizeInBytes(CiKind.Int)), length, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
585 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
586 |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
587 asm.mov(hub, asm.createConstantInputParameter("hub", CiKind.Object)); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
588 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
589 asm.mov(rank, asm.i(dimensions)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
590 useRegisters(asm, AMD64.rax); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
591 asm.callRuntime(config.newMultiArrayStub, result); |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
592 return asm.finishTemplate("multiNewArray" + dimensions); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
593 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
594 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
595 |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
596 private SimpleTemplates checkCastTemplates = new SimpleTemplates(NULL_CHECK) { |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
597 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
598 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
599 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
600 asm.restart(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
601 XirParameter object = asm.createInputParameter("object", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
602 final XirOperand hub; |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
603 hub = asm.createConstantInputParameter("hub", CiKind.Object); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
604 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
605 XirOperand objHub = asm.createTemp("objHub", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
606 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
607 XirLabel end = asm.createInlineLabel("end"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
608 XirLabel slowPath = asm.createOutOfLineLabel("slow path"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
609 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
610 if (is(NULL_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
611 // null can be cast to anything |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
612 asm.jeq(end, object, asm.o(null)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
613 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
614 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
615 asm.pload(CiKind.Object, objHub, object, asm.i(config.hubOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
616 // if we get an exact match: succeed immediately |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
617 asm.jneq(slowPath, objHub, hub); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
618 asm.bindInline(end); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
619 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
620 // -- out of line ------------------------------------------------------- |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
621 asm.bindOutOfLine(slowPath); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
622 checkSubtype(asm, objHub, objHub, hub); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
623 asm.jneq(end, objHub, asm.o(null)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
624 XirOperand scratch = asm.createRegisterTemp("scratch", CiKind.Object, AMD64.r10); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
625 asm.mov(scratch, object); |
2638
3e47aeb60ab3
Deopt instead of throwing exception for checkcast.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2544
diff
changeset
|
626 |
3e47aeb60ab3
Deopt instead of throwing exception for checkcast.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2544
diff
changeset
|
627 asm.callRuntime(CiRuntimeCall.Deoptimize, null); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
628 asm.shouldNotReachHere(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
629 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
630 return asm.finishTemplate(object, "instanceof"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
631 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
632 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
633 |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
634 private SimpleTemplates instanceOfTemplates = new SimpleTemplates(NULL_CHECK) { |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
635 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
636 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
637 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
638 XirOperand result = asm.restart(CiKind.Boolean); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
639 XirParameter object = asm.createInputParameter("object", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
640 final XirOperand hub; |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
641 hub = asm.createConstantInputParameter("hub", CiKind.Object); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
642 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
643 XirOperand objHub = asm.createTemp("objHub", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
644 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
645 XirLabel end = asm.createInlineLabel("end"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
646 XirLabel slowPath = asm.createOutOfLineLabel("slow path"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
647 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
648 if (is(NULL_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
649 // null isn't "instanceof" anything |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
650 asm.mov(result, asm.b(false)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
651 asm.jeq(end, object, asm.o(null)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
652 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
653 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
654 asm.pload(CiKind.Object, objHub, object, asm.i(config.hubOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
655 // if we get an exact match: succeed immediately |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
656 asm.mov(result, asm.b(true)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
657 asm.jneq(slowPath, objHub, hub); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
658 asm.bindInline(end); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
659 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
660 // -- out of line ------------------------------------------------------- |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
661 asm.bindOutOfLine(slowPath); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
662 checkSubtype(asm, result, objHub, hub); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
663 asm.jmp(end); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
664 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
665 return asm.finishTemplate("instanceof"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
666 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
667 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
668 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
669 private XirOperand genArrayLength(CiXirAssembler asm, XirOperand array, boolean implicitNullException) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
670 XirOperand length = asm.createTemp("length", CiKind.Int); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
671 genArrayLength(asm, length, array, implicitNullException); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
672 return length; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
673 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
674 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
675 private void genArrayLength(CiXirAssembler asm, XirOperand length, XirOperand array, boolean implicitNullException) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
676 if (implicitNullException) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
677 asm.nop(1); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
678 asm.mark(MARK_IMPLICIT_NULL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
679 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
680 asm.pload(CiKind.Int, length, array, asm.i(config.arrayLengthOffset), implicitNullException); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
681 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
682 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
683 private KindTemplates arrayLoadTemplates = new KindTemplates(NULL_CHECK, READ_BARRIER, BOUNDS_CHECK, GIVEN_LENGTH) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
684 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
685 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
686 protected XirTemplate create(CiXirAssembler asm, long flags, CiKind kind) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
687 XirOperand result = asm.restart(kind); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
688 XirParameter array = asm.createInputParameter("array", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
689 XirParameter index = asm.createInputParameter("index", CiKind.Int, true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
690 XirLabel failBoundsCheck = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
691 // if the length is known the array cannot be null |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
692 boolean implicitNullException = is(NULL_CHECK, flags); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
693 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
694 if (is(BOUNDS_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
695 // load the array length and check the index |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
696 failBoundsCheck = asm.createOutOfLineLabel("failBoundsCheck"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
697 XirOperand length; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
698 if (is(GIVEN_LENGTH, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
699 length = asm.createInputParameter("length", CiKind.Int, true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
700 } else { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
701 length = genArrayLength(asm, array, implicitNullException); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
702 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
703 asm.jugteq(failBoundsCheck, index, length); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
704 implicitNullException = false; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
705 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
706 int elemSize = target.sizeInBytes(kind); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
707 if (implicitNullException) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
708 asm.nop(1); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
709 asm.mark(MARK_IMPLICIT_NULL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
710 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
711 asm.pload(kind, result, array, index, config.getArrayOffset(kind), Scale.fromInt(elemSize), implicitNullException); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
712 if (is(BOUNDS_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
713 asm.bindOutOfLine(failBoundsCheck); |
2659
40248577d587
Deoptimize on array store and array bounds exception.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2638
diff
changeset
|
714 asm.callRuntime(CiRuntimeCall.Deoptimize, null); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
715 asm.shouldNotReachHere(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
716 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
717 return asm.finishTemplate("arrayload<" + kind + ">"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
718 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
719 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
720 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
721 private SimpleTemplates getClassTemplates = new SimpleTemplates() { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
722 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
723 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
724 XirOperand result = asm.restart(CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
725 XirOperand object = asm.createInputParameter("object", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
726 if (is(NULL_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
727 asm.nop(1); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
728 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
729 asm.pload(CiKind.Object, result, object, asm.i(config.hubOffset), is(NULL_CHECK, flags)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
730 asm.pload(CiKind.Object, result, result, asm.i(config.classMirrorOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
731 return asm.finishTemplate("currentThread"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
732 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
733 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
734 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
735 private SimpleTemplates currentThreadTemplates = new SimpleTemplates() { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
736 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
737 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
738 XirOperand result = asm.restart(CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
739 XirOperand thread = asm.createRegisterTemp("thread", CiKind.Word, AMD64.r15); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
740 asm.pload(CiKind.Object, result, thread, asm.i(config.threadObjectOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
741 return asm.finishTemplate("currentThread"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
742 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
743 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
744 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
745 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
746 public XirSnippet genCurrentThread(XirSite site) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
747 return new XirSnippet(currentThreadTemplates.get(site)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
748 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
749 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
750 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
751 public XirSnippet genGetClass(XirSite site, XirArgument object) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
752 return new XirSnippet(getClassTemplates.get(site), object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
753 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
754 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
755 private KindTemplates arrayCopyTemplates = new KindTemplates() { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
756 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
757 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
758 protected XirTemplate create(CiXirAssembler asm, long flags, CiKind kind) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
759 asm.restart(CiKind.Void); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
760 XirParameter src = asm.createInputParameter("src", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
761 XirParameter srcPos = asm.createInputParameter("srcPos", CiKind.Int, true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
762 XirParameter dest = asm.createInputParameter("dest", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
763 XirParameter destPos = asm.createInputParameter("destPos", CiKind.Int, true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
764 XirParameter length = asm.createInputParameter("length", CiKind.Int, true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
765 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
766 XirOperand tempSrc = asm.createTemp("tempSrc", CiKind.Word); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
767 XirOperand tempDest = asm.createTemp("tempDest", CiKind.Word); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
768 XirOperand lengthOperand = asm.createRegisterTemp("lengthOperand", CiKind.Int, AMD64.rax); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
769 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
770 XirOperand compHub = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
771 XirOperand valueHub = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
772 XirOperand temp = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
773 XirLabel store = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
774 XirLabel slowStoreCheck = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
775 |
2544
84a2012f8cd1
Fixes to barriers.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2543
diff
changeset
|
776 if (is(STORE_CHECK, flags) && kind == CiKind.Object) { |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
777 valueHub = asm.createRegisterTemp("valueHub", CiKind.Word, AMD64.rdi); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
778 compHub = asm.createRegisterTemp("compHub", CiKind.Word, AMD64.rsi); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
779 temp = asm.createRegisterTemp("temp", CiKind.Word, AMD64.r10); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
780 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
781 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
782 // Calculate the factor for the repeat move instruction. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
783 int elementSize = kind.sizeInBytes(target.wordSize); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
784 int factor; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
785 boolean wordSize; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
786 if (elementSize >= target.wordSize) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
787 assert elementSize % target.wordSize == 0; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
788 wordSize = true; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
789 factor = elementSize / target.wordSize; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
790 } else { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
791 factor = elementSize; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
792 wordSize = false; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
793 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
794 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
795 // Adjust the length if the factor is not 1. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
796 if (factor != 1) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
797 asm.shl(lengthOperand, length, asm.i(CiUtil.log2(factor))); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
798 } else { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
799 asm.mov(lengthOperand, length); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
800 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
801 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
802 // Set the start and the end pointer. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
803 asm.lea(tempSrc, src, srcPos, config.getArrayOffset(kind), Scale.fromInt(elementSize)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
804 asm.lea(tempDest, dest, destPos, config.getArrayOffset(kind), Scale.fromInt(elementSize)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
805 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
806 XirLabel reverse = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
807 XirLabel normal = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
808 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
809 if (is(STORE_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
810 reverse = asm.createInlineLabel("reverse"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
811 asm.jneq(reverse, src, dest); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
812 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
813 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
814 if (!is(STORE_CHECK, flags) && !is(INPUTS_DIFFERENT, flags) && !is(INPUTS_SAME, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
815 normal = asm.createInlineLabel("normal"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
816 asm.jneq(normal, src, dest); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
817 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
818 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
819 if (!is(INPUTS_DIFFERENT, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
820 if (reverse == null) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
821 reverse = asm.createInlineLabel("reverse"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
822 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
823 asm.jlt(reverse, srcPos, destPos); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
824 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
825 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
826 if (!is(STORE_CHECK, flags) && !is(INPUTS_DIFFERENT, flags) && !is(INPUTS_SAME, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
827 asm.bindInline(normal); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
828 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
829 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
830 // Everything set up => repeat mov. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
831 if (wordSize) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
832 asm.repmov(tempSrc, tempDest, lengthOperand); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
833 } else { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
834 asm.repmovb(tempSrc, tempDest, lengthOperand); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
835 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
836 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
837 if (!is(INPUTS_DIFFERENT, flags) || is(STORE_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
838 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
839 XirLabel end = asm.createInlineLabel("end"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
840 asm.jmp(end); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
841 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
842 // Implement reverse copy, because srcPos < destPos and src == dest. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
843 asm.bindInline(reverse); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
844 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
845 if (is(STORE_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
846 asm.pload(CiKind.Object, compHub, dest, asm.i(config.hubOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
847 asm.pload(CiKind.Object, compHub, compHub, asm.i(config.arrayClassElementOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
848 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
849 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
850 CiKind copyKind = wordSize ? CiKind.Object : CiKind.Byte; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
851 XirOperand tempValue = asm.createTemp("tempValue", copyKind); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
852 XirLabel start = asm.createInlineLabel("start"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
853 asm.bindInline(start); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
854 asm.sub(lengthOperand, lengthOperand, asm.i(1)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
855 asm.jlt(end, lengthOperand, asm.i(0)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
856 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
857 Scale scale = wordSize ? Scale.fromInt(target.wordSize) : Scale.Times1; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
858 asm.pload(copyKind, tempValue, tempSrc, lengthOperand, 0, scale, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
859 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
860 if (is(STORE_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
861 slowStoreCheck = asm.createOutOfLineLabel("slowStoreCheck"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
862 store = asm.createInlineLabel("store"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
863 asm.jeq(store, tempValue, asm.o(null)); // first check if value is null |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
864 asm.pload(CiKind.Object, valueHub, tempValue, asm.i(config.hubOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
865 asm.jneq(slowStoreCheck, compHub, valueHub); // then check component hub matches value hub |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
866 asm.bindInline(store); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
867 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
868 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
869 asm.pstore(copyKind, tempDest, lengthOperand, tempValue, 0, scale, false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
870 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
871 asm.jmp(start); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
872 asm.bindInline(end); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
873 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
874 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
875 if (kind == CiKind.Object) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
876 // Do write barriers |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
877 asm.lea(tempDest, dest, destPos, config.getArrayOffset(kind), Scale.fromInt(elementSize)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
878 asm.shr(tempDest, tempDest, asm.i(config.cardtableShift)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
879 asm.pstore(CiKind.Boolean, asm.w(config.cardtableStartAddress), tempDest, asm.b(false), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
880 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
881 XirOperand tempDestEnd = tempSrc; // Reuse src temp |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
882 asm.lea(tempDestEnd, dest, destPos, config.getArrayOffset(kind), Scale.fromInt(elementSize)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
883 asm.add(tempDestEnd, tempDestEnd, length); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
884 asm.shr(tempDestEnd, tempDestEnd, asm.i(config.cardtableShift)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
885 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
886 // Jump to out-of-line write barrier loop if the array is big. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
887 XirLabel writeBarrierLoop = asm.createOutOfLineLabel("writeBarrierLoop"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
888 asm.jneq(writeBarrierLoop, tempDest, tempSrc); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
889 XirLabel back = asm.createInlineLabel("back"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
890 asm.bindInline(back); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
891 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
892 asm.bindOutOfLine(writeBarrierLoop); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
893 asm.pstore(CiKind.Boolean, asm.w(config.cardtableStartAddress), tempDestEnd, asm.b(false), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
894 asm.sub(tempDestEnd, tempDestEnd, asm.i(1)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
895 asm.jneq(writeBarrierLoop, tempDestEnd, tempDest); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
896 asm.jmp(back); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
897 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
898 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
899 if (is(STORE_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
900 assert kind == CiKind.Object; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
901 useRegisters(asm, AMD64.rax); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
902 asm.bindOutOfLine(slowStoreCheck); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
903 checkSubtype(asm, temp, valueHub, compHub); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
904 asm.jneq(store, temp, asm.w(0)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
905 XirOperand scratch = asm.createRegisterTemp("scratch", CiKind.Object, AMD64.r10); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
906 asm.mov(scratch, valueHub); |
2659
40248577d587
Deoptimize on array store and array bounds exception.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2638
diff
changeset
|
907 asm.callRuntime(CiRuntimeCall.Deoptimize, null); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
908 asm.jmp(store); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
909 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
910 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
911 return asm.finishTemplate("arraycopy<" + kind + ">"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
912 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
913 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
914 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
915 private KindTemplates arrayStoreTemplates = new KindTemplates(NULL_CHECK, WRITE_BARRIER, BOUNDS_CHECK, STORE_CHECK, GIVEN_LENGTH) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
916 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
917 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
918 protected XirTemplate create(CiXirAssembler asm, long flags, CiKind kind) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
919 asm.restart(CiKind.Void); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
920 XirParameter array = asm.createInputParameter("array", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
921 XirParameter index = asm.createInputParameter("index", CiKind.Int, true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
922 XirParameter value = asm.createInputParameter("value", kind, kind != CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
923 XirOperand temp = asm.createTemp("temp", CiKind.Word); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
924 XirOperand valueHub = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
925 XirOperand compHub = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
926 XirLabel store = asm.createInlineLabel("store"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
927 XirLabel failBoundsCheck = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
928 XirLabel slowStoreCheck = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
929 // if the length is known the array cannot be null |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
930 boolean implicitNullException = is(NULL_CHECK, flags); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
931 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
932 if (is(BOUNDS_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
933 // load the array length and check the index |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
934 failBoundsCheck = asm.createOutOfLineLabel("failBoundsCheck"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
935 XirOperand length; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
936 if (is(GIVEN_LENGTH, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
937 length = asm.createInputParameter("length", CiKind.Int); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
938 } else { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
939 length = asm.createTemp("length", CiKind.Int); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
940 if (implicitNullException) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
941 asm.nop(1); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
942 asm.mark(MARK_IMPLICIT_NULL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
943 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
944 asm.pload(CiKind.Int, length, array, asm.i(config.arrayLengthOffset), implicitNullException); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
945 implicitNullException = false; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
946 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
947 asm.jugteq(failBoundsCheck, index, length); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
948 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
949 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
950 if (is(STORE_CHECK, flags) && kind == CiKind.Object) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
951 slowStoreCheck = asm.createOutOfLineLabel("slowStoreCheck"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
952 asm.jeq(store, value, asm.o(null)); // first check if value is null |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
953 valueHub = asm.createTemp("valueHub", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
954 compHub = asm.createTemp("compHub", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
955 if (implicitNullException) { |
2543
c58a301eb2d7
Clean up on canTrap.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2509
diff
changeset
|
956 asm.nop(1); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
957 asm.mark(MARK_IMPLICIT_NULL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
958 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
959 asm.pload(CiKind.Object, compHub, array, asm.i(config.hubOffset), implicitNullException); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
960 asm.pload(CiKind.Object, compHub, compHub, asm.i(config.arrayClassElementOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
961 asm.pload(CiKind.Object, valueHub, value, asm.i(config.hubOffset), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
962 asm.jneq(slowStoreCheck, compHub, valueHub); // then check component hub matches value hub |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
963 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
964 implicitNullException = false; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
965 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
966 asm.bindInline(store); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
967 int elemSize = target.sizeInBytes(kind); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
968 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
969 if (implicitNullException) { |
2543
c58a301eb2d7
Clean up on canTrap.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2509
diff
changeset
|
970 asm.nop(1); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
971 asm.mark(MARK_IMPLICIT_NULL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
972 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
973 int disp = config.getArrayOffset(kind); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
974 Scale scale = Scale.fromInt(elemSize); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
975 if (kind == CiKind.Object) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
976 verifyPointer(asm, value); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
977 } |
2544
84a2012f8cd1
Fixes to barriers.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2543
diff
changeset
|
978 if (is(WRITE_BARRIER, flags) && kind == CiKind.Object) { |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
979 asm.lea(temp, array, index, disp, scale); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
980 asm.pstore(kind, temp, value, implicitNullException); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
981 writeBarrier(asm, temp); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
982 } else { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
983 asm.pstore(kind, array, index, value, disp, scale, implicitNullException); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
984 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
985 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
986 // -- out of line ------------------------------------------------------- |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
987 if (is(BOUNDS_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
988 asm.bindOutOfLine(failBoundsCheck); |
2659
40248577d587
Deoptimize on array store and array bounds exception.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2638
diff
changeset
|
989 asm.callRuntime(CiRuntimeCall.Deoptimize, null); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
990 asm.shouldNotReachHere(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
991 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
992 if (is(STORE_CHECK, flags) && kind == CiKind.Object) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
993 useRegisters(asm, AMD64.rax); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
994 asm.bindOutOfLine(slowStoreCheck); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
995 checkSubtype(asm, temp, valueHub, compHub); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
996 asm.jneq(store, temp, asm.w(0)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
997 XirOperand scratch = asm.createRegisterTemp("scratch", CiKind.Object, AMD64.r10); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
998 asm.mov(scratch, valueHub); |
2659
40248577d587
Deoptimize on array store and array bounds exception.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2638
diff
changeset
|
999 asm.callRuntime(CiRuntimeCall.Deoptimize, null); |
40248577d587
Deoptimize on array store and array bounds exception.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2638
diff
changeset
|
1000 asm.shouldNotReachHere(); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1001 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1002 return asm.finishTemplate("arraystore<" + kind + ">"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1003 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1004 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1005 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1006 private SimpleTemplates arrayLengthTemplates = new SimpleTemplates(NULL_CHECK) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1007 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1008 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1009 protected XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1010 XirOperand result = asm.restart(CiKind.Int); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1011 XirParameter object = asm.createInputParameter("object", CiKind.Object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1012 if (is(NULL_CHECK, flags)) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1013 asm.nop(1); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1014 asm.mark(MARK_IMPLICIT_NULL); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1015 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1016 verifyPointer(asm, object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1017 asm.pload(CiKind.Int, result, object, asm.i(config.arrayLengthOffset), true); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1018 return asm.finishTemplate("arrayLength"); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1019 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1020 }; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1021 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1022 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1023 public XirSnippet genPrologue(XirSite site, RiMethod method) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1024 boolean staticMethod = Modifier.isStatic(method.accessFlags()); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1025 return new XirSnippet(staticMethod ? prologueTemplates.get(site, STATIC_METHOD) : prologueTemplates.get(site)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1026 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1027 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1028 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1029 public XirSnippet genEpilogue(XirSite site, RiMethod method) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1030 return new XirSnippet(epilogueTemplates.get(site)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1031 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1032 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1033 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1034 public XirSnippet genSafepoint(XirSite site) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1035 return new XirSnippet(safepointTemplates.get(site)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1036 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1037 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1038 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1039 public XirSnippet genExceptionObject(XirSite site) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1040 return new XirSnippet(exceptionObjectTemplates.get(site)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1041 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1042 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1043 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1044 public XirSnippet genResolveClass(XirSite site, RiType type, Representation rep) { |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1045 throw new CiBailout("Xir ResolveClass not available"); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1046 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1047 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1048 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1049 public XirSnippet genIntrinsic(XirSite site, XirArgument[] arguments, RiMethod method) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1050 return null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1051 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1052 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1053 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1054 public XirSnippet genInvokeInterface(XirSite site, XirArgument receiver, RiMethod method) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1055 return new XirSnippet(invokeInterfaceTemplates.get(site), receiver, XirArgument.forWord(0)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1056 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1057 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1058 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1059 public XirSnippet genInvokeVirtual(XirSite site, XirArgument receiver, RiMethod method) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1060 return new XirSnippet(invokeVirtualTemplates.get(site), receiver, XirArgument.forWord(0)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1061 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1062 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1063 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1064 public XirSnippet genInvokeSpecial(XirSite site, XirArgument receiver, RiMethod method) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1065 return new XirSnippet(invokeSpecialTemplates.get(site), receiver, XirArgument.forWord(0)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1066 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1067 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1068 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1069 public XirSnippet genInvokeStatic(XirSite site, RiMethod method) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1070 return new XirSnippet(invokeStaticTemplates.get(site), XirArgument.forWord(0)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1071 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1072 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1073 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1074 public XirSnippet genMonitorEnter(XirSite site, XirArgument receiver, XirArgument lockAddress) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1075 return new XirSnippet(monitorEnterTemplates.get(site), receiver, lockAddress); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1076 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1077 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1078 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1079 public XirSnippet genMonitorExit(XirSite site, XirArgument receiver, XirArgument lockAddress) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1080 return new XirSnippet(monitorExitTemplates.get(site), receiver, lockAddress); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1081 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1082 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1083 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1084 public XirSnippet genGetField(XirSite site, XirArgument object, RiField field) { |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1085 assert field.isResolved(); |
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1086 return new XirSnippet(getFieldTemplates.get(site, field.kind()), object, XirArgument.forInt(((HotSpotField) field).offset())); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1087 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1088 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1089 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1090 public XirSnippet genWriteBarrier(XirArgument object) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1091 return new XirSnippet(writeBarrierTemplate.get(null, CiKind.Void), object); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1092 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1093 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1094 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1095 public XirSnippet genPutField(XirSite site, XirArgument object, RiField field, XirArgument value) { |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1096 assert field.isResolved(); |
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1097 return new XirSnippet(putFieldTemplates.get(site, field.kind()), object, value, XirArgument.forInt(((HotSpotField) field).offset())); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1098 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1099 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1100 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1101 public XirSnippet genGetStatic(XirSite site, XirArgument object, RiField field) { |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1102 assert field.isResolved(); |
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1103 return new XirSnippet(getFieldTemplates.get(site, field.kind()), object, XirArgument.forInt(((HotSpotField) field).offset())); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1104 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1105 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1106 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1107 public XirSnippet genPutStatic(XirSite site, XirArgument object, RiField field, XirArgument value) { |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1108 assert field.isResolved(); |
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1109 return new XirSnippet(putFieldTemplates.get(site, field.kind()), object, value, XirArgument.forInt(((HotSpotField) field).offset())); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1110 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1111 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1112 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1113 public XirSnippet genNewInstance(XirSite site, RiType type) { |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1114 assert type.isResolved(); |
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1115 int instanceSize = ((HotSpotTypeResolved) type).instanceSize(); |
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1116 return new XirSnippet(newInstanceTemplates.get(site, instanceSize), XirArgument.forObject(type)); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1117 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1118 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1119 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1120 public XirSnippet genNewArray(XirSite site, XirArgument length, CiKind elementKind, RiType componentType, RiType arrayType) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1121 if (elementKind == CiKind.Object) { |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1122 assert arrayType.isResolved(); |
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1123 return new XirSnippet(newObjectArrayTemplates.get(site), length, XirArgument.forObject(arrayType)); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1124 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1125 assert arrayType == null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1126 arrayType = compiler.getVMEntries().getPrimitiveArrayType(elementKind); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1127 return new XirSnippet(newTypeArrayTemplates.get(site, elementKind), length, XirArgument.forObject(arrayType)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1128 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1129 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1130 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1131 public XirSnippet genNewObjectArrayClone(XirSite site, XirArgument newLength, XirArgument referenceArray) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1132 return new XirSnippet(newObjectArrayCloneTemplates.get(site), newLength, referenceArray); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1133 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1134 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1135 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1136 public XirSnippet genNewMultiArray(XirSite site, XirArgument[] lengths, RiType type) { |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1137 assert type.isResolved(); |
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1138 XirArgument[] params = Arrays.copyOf(lengths, lengths.length + 1); |
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1139 params[lengths.length] = XirArgument.forObject(type); |
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1140 return new XirSnippet(multiNewArrayTemplate.get(site, lengths.length), params); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1141 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1142 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1143 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1144 public XirSnippet genCheckCast(XirSite site, XirArgument receiver, XirArgument hub, RiType type) { |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1145 assert type.isResolved(); |
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1146 return new XirSnippet(checkCastTemplates.get(site), receiver, hub); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1147 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1148 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1149 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1150 public XirSnippet genInstanceOf(XirSite site, XirArgument object, XirArgument hub, RiType type) { |
2709
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1151 assert type.isResolved(); |
7b7dbe19fafb
Remove all unresolved cases from HotspotXirGenerator, use more explicit Deopt, Deopt to lastState instead of stateBefore
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
2677
diff
changeset
|
1152 return new XirSnippet(instanceOfTemplates.get(site), object, hub); |
2501
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1153 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1154 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1155 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1156 public XirSnippet genArrayLoad(XirSite site, XirArgument array, XirArgument index, XirArgument length, CiKind elementKind, RiType elementType) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1157 if (length == null || !site.requiresBoundsCheck()) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1158 return new XirSnippet(arrayLoadTemplates.get(site, elementKind), array, index); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1159 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1160 return new XirSnippet(arrayLoadTemplates.get(site, elementKind, GIVEN_LENGTH), array, index, length); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1161 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1162 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1163 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1164 public XirSnippet genArrayStore(XirSite site, XirArgument array, XirArgument index, XirArgument length, XirArgument value, CiKind elementKind, RiType elementType) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1165 if (length == null || !site.requiresBoundsCheck()) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1166 return new XirSnippet(arrayStoreTemplates.get(site, elementKind), array, index, value); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1167 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1168 return new XirSnippet(arrayStoreTemplates.get(site, elementKind, GIVEN_LENGTH), array, index, value, length); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1169 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1170 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1171 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1172 public XirSnippet genArrayCopy(XirSite site, XirArgument src, XirArgument srcPos, XirArgument dest, XirArgument destPos, XirArgument length, RiType elementType, boolean inputsSame, boolean inputsDifferent) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1173 if (elementType == null) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1174 return null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1175 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1176 assert !inputsDifferent || !inputsSame; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1177 XirTemplate template = null; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1178 if (inputsDifferent) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1179 template = arrayCopyTemplates.get(site, elementType.kind(), INPUTS_DIFFERENT); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1180 } else if (inputsSame) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1181 template = arrayCopyTemplates.get(site, elementType.kind(), INPUTS_SAME); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1182 } else { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1183 template = arrayCopyTemplates.get(site, elementType.kind()); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1184 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1185 return new XirSnippet(template, src, srcPos, dest, destPos, length); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1186 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1187 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1188 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1189 public XirSnippet genArrayLength(XirSite site, XirArgument array) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1190 return new XirSnippet(arrayLengthTemplates.get(site), array); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1191 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1192 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1193 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1194 public List<XirTemplate> buildTemplates(CiXirAssembler asm) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1195 this.globalAsm = asm; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1196 List<XirTemplate> templates = new ArrayList<XirTemplate>(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1197 return templates; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1198 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1199 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1200 private void verifyPointer(CiXirAssembler asm, XirOperand pointer) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1201 if (config.verifyPointers) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1202 // The verify pointer stub wants the argument in a fixed register. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1203 XirOperand fixed = asm.createRegisterTemp("fixed", CiKind.Object, AMD64.r13); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1204 asm.push(fixed); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1205 asm.mov(fixed, pointer); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1206 asm.callRuntime(config.verifyPointerStub, null); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1207 asm.pop(fixed); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1208 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1209 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1210 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1211 private void checkSubtype(CiXirAssembler asm, XirOperand result, XirOperand objHub, XirOperand hub) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1212 asm.push(objHub); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1213 asm.push(hub); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1214 asm.callRuntime(config.instanceofStub, null); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1215 asm.pop(result); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1216 asm.pop(result); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1217 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1218 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1219 private void useRegisters(CiXirAssembler asm, CiRegister... registers) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1220 if (registers != null) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1221 for (CiRegister register : registers) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1222 asm.createRegisterTemp("reg", CiKind.Illegal, register); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1223 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1224 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1225 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1226 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1227 private void writeBarrier(CiXirAssembler asm, XirOperand base) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1228 asm.shr(base, base, asm.i(config.cardtableShift)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1229 asm.pstore(CiKind.Boolean, asm.w(config.cardtableStartAddress), base, asm.b(false), false); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1230 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1231 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1232 public boolean is(TemplateFlag check, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1233 return (flags & check.bits()) == check.bits(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1234 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1235 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1236 /** |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1237 * Base class for all the ondemand template generators. It is not normally subclassed directly, but through one of |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1238 * its subclasses (SimpleTemplates, KindTemplates, IndexTemplates). |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1239 * |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1240 * @author Lukas Stadler |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1241 */ |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1242 private abstract class Templates { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1243 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1244 private ConcurrentHashMap<Long, XirTemplate> templates = new ConcurrentHashMap<Long, XirTemplate>(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1245 private final long mask; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1246 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1247 /** |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1248 * Each flag passed to this method will cause templates with and without it to be generated. |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1249 */ |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1250 public Templates(TemplateFlag... flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1251 this.mask = getBits((int) INDEX_MASK, null, flags); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1252 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1253 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1254 protected abstract XirTemplate create(CiXirAssembler asm, long flags); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1255 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1256 protected long getBits(int index, XirSite site, TemplateFlag... flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1257 long bits = index; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1258 if (site != null) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1259 bits |= site.requiresNullCheck() ? NULL_CHECK.bits() : 0; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1260 bits |= site.requiresReadBarrier() ? READ_BARRIER.bits() : 0; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1261 bits |= site.requiresWriteBarrier() ? WRITE_BARRIER.bits() : 0; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1262 bits |= site.requiresArrayStoreCheck() ? STORE_CHECK.bits() : 0; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1263 bits |= site.requiresBoundsCheck() ? BOUNDS_CHECK.bits() : 0; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1264 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1265 if (flags != null) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1266 for (TemplateFlag flag : flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1267 bits |= flag.bits(); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1268 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1269 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1270 return bits; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1271 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1272 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1273 protected XirTemplate getInternal(long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1274 flags = flags & mask; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1275 XirTemplate template = templates.get(flags); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1276 if (template == null) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1277 template = create(HotSpotXirGenerator.this.globalAsm.copy(), flags); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1278 templates.put(flags, template); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1279 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1280 return template; |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1281 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1282 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1283 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1284 private abstract class SimpleTemplates extends Templates { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1285 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1286 public SimpleTemplates(TemplateFlag... flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1287 super(flags); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1288 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1289 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1290 public XirTemplate get(XirSite site, TemplateFlag... flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1291 return getInternal(getBits(0, site, flags)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1292 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1293 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1294 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1295 private abstract class IndexTemplates extends Templates { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1296 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1297 public IndexTemplates(TemplateFlag... flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1298 super(flags); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1299 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1300 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1301 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1302 protected final XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1303 return create(asm, flags & FLAGS_MASK, (int) (flags & INDEX_MASK)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1304 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1305 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1306 protected abstract XirTemplate create(CiXirAssembler asm, long flags, int index); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1307 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1308 public XirTemplate get(XirSite site, int size, TemplateFlag... flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1309 return getInternal(getBits(size, site, flags)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1310 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1311 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1312 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1313 private abstract class KindTemplates extends Templates { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1314 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1315 public KindTemplates(TemplateFlag... flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1316 super(flags); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1317 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1318 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1319 @Override |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1320 protected final XirTemplate create(CiXirAssembler asm, long flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1321 return create(asm, flags & FLAGS_MASK, CiKind.VALUES[(int) (flags & INDEX_MASK)]); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1322 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1323 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1324 protected abstract XirTemplate create(CiXirAssembler asm, long flags, CiKind kind); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1325 |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1326 public XirTemplate get(XirSite site, CiKind kind, TemplateFlag... flags) { |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1327 return getInternal(getBits(kind.ordinal(), site, flags)); |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1328 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1329 } |
6594e6d8bfe7
Rebranding to com.oracle.graal
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1330 } |