annotate graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCompare.java @ 18262:f7d45e2426d4

converted HotSpotObjectConstant to an interface
author Doug Simon <doug.simon@oracle.com>
date Wed, 05 Nov 2014 21:07:59 +0100
parents 9619ba4daf4c
children 7acff34abbf7
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 /*
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 16353
diff changeset
2 * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
15910
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.meta.*;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
33 import com.oracle.graal.lir.*;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.lir.amd64.*;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.lir.amd64.AMD64Move.MemOp;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
36 import com.oracle.graal.lir.asm.*;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
37
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
38 public class AMD64HotSpotCompare {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
39
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
40 @Opcode("CMP")
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
41 public static class HotSpotCompareConstantOp extends AMD64LIRInstruction {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
42
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
43 @Use({REG}) protected AllocatableValue x;
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
44 protected JavaConstant y;
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
45
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
46 public HotSpotCompareConstantOp(AllocatableValue x, JavaConstant y) {
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
47 this.x = x;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
48 this.y = y;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
49 }
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 @Override
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
52 public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
53 assert isRegister(x);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
54 if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(y)) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
55 // compressed null
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
56 masm.testl(asRegister(x), asRegister(x));
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
57 } else if (y instanceof HotSpotObjectConstant) {
18262
f7d45e2426d4 converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
58 if (HotSpotObjectConstantImpl.isCompressed(y)) {
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
59 // compressed oop
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 16353
diff changeset
60 crb.recordInlineDataInCode(y);
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
61 masm.cmpl(asRegister(x), 0xDEADDEAD);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
62 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
63 // uncompressed oop
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 16353
diff changeset
64 AMD64Address patch = (AMD64Address) crb.recordDataReferenceInCode(y, 8);
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
65 masm.cmpq(asRegister(x), patch);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
66 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
67 } else if (y instanceof HotSpotMetaspaceConstant) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
68 if (y.getKind() == Kind.Int) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
69 // compressed metaspace pointer
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 16353
diff changeset
70 crb.recordInlineDataInCode(y);
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
71 masm.cmpl(asRegister(x), y.asInt());
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
72 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
73 // uncompressed metaspace pointer
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 16353
diff changeset
74 AMD64Address patch = (AMD64Address) crb.recordDataReferenceInCode(y, 8);
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
75 masm.cmpq(asRegister(x), patch);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
76 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
77 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
78 throw GraalInternalError.shouldNotReachHere();
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
79 }
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 @Opcode("CMP")
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
84 public static class HotSpotCompareMemoryConstantOp extends MemOp {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
85
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
86 protected JavaConstant y;
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
87
18187
9619ba4daf4c Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents: 18176
diff changeset
88 public HotSpotCompareMemoryConstantOp(Kind kind, AMD64AddressValue x, JavaConstant y, LIRFrameState state) {
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
89 super(kind, x, state);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
90 this.y = y;
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
91 }
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 @Override
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
94 protected void emitMemAccess(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
95 if (HotSpotCompressedNullConstant.COMPRESSED_NULL.equals(y)) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
96 // compressed null
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
97 masm.cmpl(address.toAddress(), 0);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
98 } else if (y instanceof HotSpotObjectConstant) {
18262
f7d45e2426d4 converted HotSpotObjectConstant to an interface
Doug Simon <doug.simon@oracle.com>
parents: 18187
diff changeset
99 if (HotSpotObjectConstantImpl.isCompressed(y) && crb.target.inlineObjects) {
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
100 // compressed oop
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 16353
diff changeset
101 crb.recordInlineDataInCode(y);
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
102 masm.cmpl(address.toAddress(), 0xDEADDEAD);
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
103 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
104 // uncompressed oop
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
105 throw GraalInternalError.shouldNotReachHere();
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
106 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
107 } else if (y instanceof HotSpotMetaspaceConstant) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
108 if (y.getKind() == Kind.Int) {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
109 // compressed metaspace pointer
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 16353
diff changeset
110 crb.recordInlineDataInCode(y);
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
111 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
112 } 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
113 // uncompressed metaspace pointer
18176
c2270ad35f57 Better construction of data section and data patches.
Roland Schatz <roland.schatz@oracle.com>
parents: 16353
diff changeset
114 crb.recordInlineDataInCode(y);
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
115 masm.cmpq(address.toAddress(), (int) y.asLong());
15910
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
116 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
117 throw GraalInternalError.shouldNotReachHere();
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
118 }
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
119 } else {
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
120 throw GraalInternalError.shouldNotReachHere();
79a0d9065849 Support direct comparison of compressed pointers.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
121 }
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 }