annotate graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCompare.java @ 17058:97d0508b7cf1

Truffle: entries in change log.
author Chris Seaton <chris.seaton@oracle.com>
date Sat, 06 Sep 2014 17:20:11 +0100
parents 7c47610015a9
children c2270ad35f57
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
1 /*
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
4 *
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
8 *
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
13 * accompanied this code).
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
14 *
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
18 *
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
21 * questions.
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
22 */
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.hotspot.amd64;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
24
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
25 import static com.oracle.graal.api.code.ValueUtil.*;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
26 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
27
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
28 import com.oracle.graal.api.meta.*;
16353
7c47610015a9 Support direct memory compare of uncompressed metadata references if they fit in 32 bit.
Roland Schatz <roland.schatz@oracle.com>
parents: 16116
diff changeset
29 import com.oracle.graal.asm.*;
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.asm.amd64.*;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.compiler.common.*;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.hotspot.data.*;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
33 import com.oracle.graal.hotspot.meta.*;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.lir.*;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.lir.amd64.*;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
36 import com.oracle.graal.lir.amd64.AMD64Move.MemOp;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
37 import com.oracle.graal.lir.asm.*;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
38
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
39 public class AMD64HotSpotCompare {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
40
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
41 @Opcode("CMP")
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
42 public static class HotSpotCompareConstantOp extends AMD64LIRInstruction {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
43
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
44 @Use({REG}) protected AllocatableValue x;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
45 protected Constant y;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
46
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
47 public HotSpotCompareConstantOp(AllocatableValue x, Constant y) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
48 this.x = x;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
49 this.y = y;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
50 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
51
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
52 @Override
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
53 public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
54 assert isRegister(x);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
55 if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(y)) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
56 // compressed null
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
57 masm.testl(asRegister(x), asRegister(x));
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
58 } else if (y instanceof HotSpotObjectConstant) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
59 if (HotSpotObjectConstant.isCompressed(y)) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
60 // compressed oop
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
61 crb.recordInlineDataInCode(new OopData(0, HotSpotObjectConstant.asObject(y), true));
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
62 masm.cmpl(asRegister(x), 0xDEADDEAD);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
63 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
64 // uncompressed oop
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
65 AMD64Address patch = (AMD64Address) crb.recordDataReferenceInCode(new OopData(8, HotSpotObjectConstant.asObject(y), false));
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
66 masm.cmpq(asRegister(x), patch);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
67 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
68 } else if (y instanceof HotSpotMetaspaceConstant) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
69 if (y.getKind() == Kind.Int) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
70 // compressed metaspace pointer
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
71 crb.recordInlineDataInCode(new MetaspaceData(0, y.asInt(), HotSpotMetaspaceConstant.getMetaspaceObject(y), true));
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
72 masm.cmpl(asRegister(x), y.asInt());
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
73 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
74 // uncompressed metaspace pointer
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
75 AMD64Address patch = (AMD64Address) crb.recordDataReferenceInCode(new MetaspaceData(8, y.asLong(), HotSpotObjectConstant.asObject(y), false));
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
76 masm.cmpq(asRegister(x), patch);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
77 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
78 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
79 throw GraalInternalError.shouldNotReachHere();
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
80 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
81 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
82 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
83
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
84 @Opcode("CMP")
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
85 public static class HotSpotCompareMemoryConstantOp extends MemOp {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
86
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
87 protected Constant y;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
88
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
89 public HotSpotCompareMemoryConstantOp(Kind kind, AMD64AddressValue x, Constant y, LIRFrameState state) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
90 super(kind, x, state);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
91 this.y = y;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
92 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
93
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
94 @Override
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
95 protected void emitMemAccess(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
96 if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(y)) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
97 // compressed null
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
98 masm.cmpl(address.toAddress(), 0);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
99 } else if (y instanceof HotSpotObjectConstant) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
100 if (HotSpotObjectConstant.isCompressed(y) && crb.target.inlineObjects) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
101 // compressed oop
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
102 crb.recordInlineDataInCode(new OopData(0, HotSpotObjectConstant.asObject(y), true));
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
103 masm.cmpl(address.toAddress(), 0xDEADDEAD);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
104 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
105 // uncompressed oop
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
106 throw GraalInternalError.shouldNotReachHere();
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
107 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
108 } else if (y instanceof HotSpotMetaspaceConstant) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
109 if (y.getKind() == Kind.Int) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
110 // compressed metaspace pointer
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
111 crb.recordInlineDataInCode(new MetaspaceData(0, y.asInt(), HotSpotMetaspaceConstant.getMetaspaceObject(y), true));
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
112 masm.cmpl(address.toAddress(), y.asInt());
16353
7c47610015a9 Support direct memory compare of uncompressed metadata references if they fit in 32 bit.
Roland Schatz <roland.schatz@oracle.com>
parents: 16116
diff changeset
113 } else if (y.getKind() == Kind.Long && NumUtil.is32bit(y.asLong())) {
7c47610015a9 Support direct memory compare of uncompressed metadata references if they fit in 32 bit.
Roland Schatz <roland.schatz@oracle.com>
parents: 16116
diff changeset
114 // uncompressed metaspace pointer
7c47610015a9 Support direct memory compare of uncompressed metadata references if they fit in 32 bit.
Roland Schatz <roland.schatz@oracle.com>
parents: 16116
diff changeset
115 crb.recordInlineDataInCode(new MetaspaceData(0, y.asLong(), HotSpotMetaspaceConstant.getMetaspaceObject(y), false));
7c47610015a9 Support direct memory compare of uncompressed metadata references if they fit in 32 bit.
Roland Schatz <roland.schatz@oracle.com>
parents: 16116
diff changeset
116 masm.cmpq(address.toAddress(), (int) y.asLong());
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
117 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
118 throw GraalInternalError.shouldNotReachHere();
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
119 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
120 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
121 throw GraalInternalError.shouldNotReachHere();
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
122 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
123 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
124 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
125
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
126 }