hotspot/src/jdk.vm.compiler/share/classes/org.graalvm.compiler.hotspot.amd64/src/org/graalvm/compiler/hotspot/amd64/AMD64HotSpotMove.java
author iveresov
Tue, 10 Jan 2017 21:39:20 +0300
changeset 43435 01521491ec10
parent 42649 28238583a459
permissions -rw-r--r--
8172310: [AOT] Fix unverified entry point Summary: Fix AOT code for the unverified entry point Reviewed-by: kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42649
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
     1
/*
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
     4
 *
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
     7
 * published by the Free Software Foundation.
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
     8
 *
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    13
 * accompanied this code).
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    14
 *
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    18
 *
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    21
 * questions.
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    22
 */
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    23
package org.graalvm.compiler.hotspot.amd64;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    24
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    25
import static org.graalvm.compiler.core.common.GraalOptions.GeneratePIC;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    26
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.HINT;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    27
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.ILLEGAL;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    28
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.REG;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    29
import static org.graalvm.compiler.lir.LIRInstruction.OperandFlag.STACK;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    30
import static jdk.vm.ci.code.ValueUtil.asRegister;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    31
import static jdk.vm.ci.code.ValueUtil.isRegister;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    32
import static jdk.vm.ci.code.ValueUtil.isStackSlot;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    33
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    34
import org.graalvm.compiler.asm.Label;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    35
import org.graalvm.compiler.asm.amd64.AMD64Address;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    36
import org.graalvm.compiler.asm.amd64.AMD64Assembler.ConditionFlag;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    37
import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    38
import org.graalvm.compiler.debug.GraalError;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    39
import org.graalvm.compiler.hotspot.CompressEncoding;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    40
import org.graalvm.compiler.hotspot.GraalHotSpotVMConfig;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    41
import org.graalvm.compiler.lir.LIRInstructionClass;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    42
import org.graalvm.compiler.lir.StandardOp.LoadConstantOp;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    43
import org.graalvm.compiler.lir.amd64.AMD64LIRInstruction;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    44
import org.graalvm.compiler.lir.amd64.AMD64Move;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    45
import org.graalvm.compiler.lir.asm.CompilationResultBuilder;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    46
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    47
import jdk.vm.ci.amd64.AMD64Kind;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    48
import jdk.vm.ci.code.Register;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    49
import jdk.vm.ci.hotspot.HotSpotMetaspaceConstant;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    50
import jdk.vm.ci.hotspot.HotSpotObjectConstant;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    51
import jdk.vm.ci.meta.AllocatableValue;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    52
import jdk.vm.ci.meta.Constant;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    53
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    54
public class AMD64HotSpotMove {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    55
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    56
    public static final class HotSpotLoadObjectConstantOp extends AMD64LIRInstruction implements LoadConstantOp {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    57
        public static final LIRInstructionClass<HotSpotLoadObjectConstantOp> TYPE = LIRInstructionClass.create(HotSpotLoadObjectConstantOp.class);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    58
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    59
        @Def({REG, STACK}) private AllocatableValue result;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    60
        private final HotSpotObjectConstant input;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    61
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    62
        public HotSpotLoadObjectConstantOp(AllocatableValue result, HotSpotObjectConstant input) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    63
            super(TYPE);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    64
            this.result = result;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    65
            this.input = input;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    66
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    67
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    68
        @Override
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    69
        public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    70
            if (GeneratePIC.getValue()) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    71
                throw GraalError.shouldNotReachHere("Object constant load should not be happening directly");
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    72
            }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    73
            boolean compressed = input.isCompressed();
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    74
            if (crb.target.inlineObjects) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    75
                crb.recordInlineDataInCode(input);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    76
                if (isRegister(result)) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    77
                    if (compressed) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    78
                        masm.movl(asRegister(result), 0xDEADDEAD);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    79
                    } else {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    80
                        masm.movq(asRegister(result), 0xDEADDEADDEADDEADL);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    81
                    }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    82
                } else {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    83
                    assert isStackSlot(result);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    84
                    if (compressed) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    85
                        masm.movl((AMD64Address) crb.asAddress(result), 0xDEADDEAD);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    86
                    } else {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    87
                        throw GraalError.shouldNotReachHere("Cannot store 64-bit constants to memory");
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    88
                    }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    89
                }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    90
            } else {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    91
                if (isRegister(result)) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    92
                    AMD64Address address = (AMD64Address) crb.recordDataReferenceInCode(input, compressed ? 4 : 8);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    93
                    if (compressed) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    94
                        masm.movl(asRegister(result), address);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    95
                    } else {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    96
                        masm.movq(asRegister(result), address);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    97
                    }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    98
                } else {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
    99
                    throw GraalError.shouldNotReachHere("Cannot directly store data patch to memory");
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   100
                }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   101
            }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   102
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   103
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   104
        @Override
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   105
        public Constant getConstant() {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   106
            return input;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   107
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   108
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   109
        @Override
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   110
        public AllocatableValue getResult() {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   111
            return result;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   112
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   113
    }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   114
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   115
    public static final class BaseMove extends AMD64LIRInstruction {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   116
        public static final LIRInstructionClass<BaseMove> TYPE = LIRInstructionClass.create(BaseMove.class);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   117
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   118
        @Def({REG, HINT}) protected AllocatableValue result;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   119
        private final GraalHotSpotVMConfig config;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   120
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   121
        public BaseMove(AllocatableValue result, GraalHotSpotVMConfig config) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   122
            super(TYPE);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   123
            this.result = result;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   124
            this.config = config;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   125
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   126
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   127
        @Override
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   128
        public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   129
            masm.movq(asRegister(result), masm.getPlaceholder(-1));
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   130
            crb.recordMark(config.MARKID_NARROW_KLASS_BASE_ADDRESS);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   131
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   132
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   133
    }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   134
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   135
    public static final class HotSpotLoadMetaspaceConstantOp extends AMD64LIRInstruction implements LoadConstantOp {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   136
        public static final LIRInstructionClass<HotSpotLoadMetaspaceConstantOp> TYPE = LIRInstructionClass.create(HotSpotLoadMetaspaceConstantOp.class);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   137
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   138
        @Def({REG, STACK}) private AllocatableValue result;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   139
        private final HotSpotMetaspaceConstant input;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   140
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   141
        public HotSpotLoadMetaspaceConstantOp(AllocatableValue result, HotSpotMetaspaceConstant input) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   142
            super(TYPE);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   143
            this.result = result;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   144
            this.input = input;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   145
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   146
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   147
        @Override
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   148
        public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   149
            if (GeneratePIC.getValue()) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   150
                throw GraalError.shouldNotReachHere("Metaspace constant load should not be happening directly");
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   151
            }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   152
            boolean compressed = input.isCompressed();
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   153
            if (isRegister(result)) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   154
                if (compressed) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   155
                    crb.recordInlineDataInCode(input);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   156
                    masm.movl(asRegister(result), 0xDEADDEAD);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   157
                } else {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   158
                    crb.recordInlineDataInCode(input);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   159
                    masm.movq(asRegister(result), 0xDEADDEADDEADDEADL);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   160
                }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   161
            } else {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   162
                assert isStackSlot(result);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   163
                if (compressed) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   164
                    crb.recordInlineDataInCode(input);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   165
                    masm.movl((AMD64Address) crb.asAddress(result), 0xDEADDEAD);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   166
                } else {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   167
                    throw GraalError.shouldNotReachHere("Cannot store 64-bit constants to memory");
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   168
                }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   169
            }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   170
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   171
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   172
        @Override
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   173
        public Constant getConstant() {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   174
            return input;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   175
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   176
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   177
        @Override
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   178
        public AllocatableValue getResult() {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   179
            return result;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   180
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   181
    }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   182
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   183
    public static final class CompressPointer extends AMD64LIRInstruction {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   184
        public static final LIRInstructionClass<CompressPointer> TYPE = LIRInstructionClass.create(CompressPointer.class);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   185
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   186
        private final CompressEncoding encoding;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   187
        private final boolean nonNull;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   188
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   189
        @Def({REG, HINT}) protected AllocatableValue result;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   190
        @Use({REG}) protected AllocatableValue input;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   191
        @Alive({REG, ILLEGAL}) protected AllocatableValue baseRegister;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   192
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   193
        public CompressPointer(AllocatableValue result, AllocatableValue input, AllocatableValue baseRegister, CompressEncoding encoding, boolean nonNull) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   194
            super(TYPE);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   195
            this.result = result;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   196
            this.input = input;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   197
            this.baseRegister = baseRegister;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   198
            this.encoding = encoding;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   199
            this.nonNull = nonNull;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   200
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   201
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   202
        @Override
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   203
        public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   204
            AMD64Move.move(AMD64Kind.QWORD, crb, masm, result, input);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   205
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   206
            Register resReg = asRegister(result);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   207
            if (encoding.base != 0 || GeneratePIC.getValue()) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   208
                Register baseReg = asRegister(baseRegister);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   209
                if (!nonNull) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   210
                    masm.testq(resReg, resReg);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   211
                    masm.cmovq(ConditionFlag.Equal, resReg, baseReg);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   212
                }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   213
                masm.subq(resReg, baseReg);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   214
            }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   215
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   216
            if (encoding.shift != 0) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   217
                masm.shrq(resReg, encoding.shift);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   218
            }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   219
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   220
    }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   221
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   222
    public static final class UncompressPointer extends AMD64LIRInstruction {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   223
        public static final LIRInstructionClass<UncompressPointer> TYPE = LIRInstructionClass.create(UncompressPointer.class);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   224
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   225
        private final CompressEncoding encoding;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   226
        private final boolean nonNull;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   227
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   228
        @Def({REG, HINT}) protected AllocatableValue result;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   229
        @Use({REG}) protected AllocatableValue input;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   230
        @Alive({REG, ILLEGAL}) protected AllocatableValue baseRegister;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   231
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   232
        public UncompressPointer(AllocatableValue result, AllocatableValue input, AllocatableValue baseRegister, CompressEncoding encoding, boolean nonNull) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   233
            super(TYPE);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   234
            this.result = result;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   235
            this.input = input;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   236
            this.baseRegister = baseRegister;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   237
            this.encoding = encoding;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   238
            this.nonNull = nonNull;
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   239
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   240
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   241
        @Override
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   242
        public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   243
            AMD64Move.move(AMD64Kind.DWORD, crb, masm, result, input);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   244
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   245
            Register resReg = asRegister(result);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   246
            if (encoding.shift != 0) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   247
                masm.shlq(resReg, encoding.shift);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   248
            }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   249
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   250
            if (encoding.base != 0 || GeneratePIC.getValue()) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   251
                if (nonNull) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   252
                    masm.addq(resReg, asRegister(baseRegister));
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   253
                } else {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   254
                    if (encoding.shift == 0) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   255
                        // if encoding.shift != 0, the flags are already set by the shlq
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   256
                        masm.testq(resReg, resReg);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   257
                    }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   258
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   259
                    Label done = new Label();
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   260
                    masm.jccb(ConditionFlag.Equal, done);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   261
                    masm.addq(resReg, asRegister(baseRegister));
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   262
                    masm.bind(done);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   263
                }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   264
            }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   265
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   266
    }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   267
43435
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 42649
diff changeset
   268
    public static void decodeKlassPointer(CompilationResultBuilder crb, AMD64MacroAssembler masm, Register register, Register scratch, AMD64Address address, GraalHotSpotVMConfig config) {
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 42649
diff changeset
   269
        CompressEncoding encoding = config.getKlassEncoding();
42649
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   270
        masm.movl(register, address);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   271
        if (encoding.shift != 0) {
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   272
            assert encoding.alignment == encoding.shift : "Decode algorithm is wrong";
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   273
            masm.shlq(register, encoding.alignment);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   274
        }
43435
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 42649
diff changeset
   275
        if (GeneratePIC.getValue() || encoding.base != 0) {
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 42649
diff changeset
   276
            if (GeneratePIC.getValue()) {
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 42649
diff changeset
   277
                masm.movq(scratch, masm.getPlaceholder(-1));
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 42649
diff changeset
   278
                crb.recordMark(config.MARKID_NARROW_KLASS_BASE_ADDRESS);
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 42649
diff changeset
   279
            } else {
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 42649
diff changeset
   280
                assert encoding.base != 0;
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 42649
diff changeset
   281
                masm.movq(scratch, encoding.base);
01521491ec10 8172310: [AOT] Fix unverified entry point
iveresov
parents: 42649
diff changeset
   282
            }
42649
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   283
            masm.addq(register, scratch);
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   284
        }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   285
    }
28238583a459 8166417: Integrate Graal-core into JDK for AOT compiler
thomaswue
parents:
diff changeset
   286
}