test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java
author kvn
Tue, 29 Oct 2019 15:35:06 -0700
changeset 58851 f1e6442241ca
parent 47216 71c04702a3d5
permissions -rw-r--r--
8233035: Update JVMCI Reviewed-by: dlong
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     1
/*
58851
f1e6442241ca 8233035: Update JVMCI
kvn
parents: 47216
diff changeset
     2
 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     4
 *
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     8
 *
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    13
 * accompanied this code).
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    14
 *
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    18
 *
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    21
 * questions.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    22
 */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    23
38027
8a5693d27400 8153439: do not install an empty SpeculationLog in an nmethod
dnsimon
parents: 35844
diff changeset
    24
package jdk.vm.ci.code.test;
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    25
40060
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
    26
import jdk.vm.ci.code.CallingConvention;
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    27
import jdk.vm.ci.code.CodeCacheProvider;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    28
import jdk.vm.ci.code.DebugInfo;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    29
import jdk.vm.ci.code.Register;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    30
import jdk.vm.ci.code.StackSlot;
40060
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
    31
import jdk.vm.ci.code.ValueKindFactory;
35844
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
    32
import jdk.vm.ci.code.site.Call;
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    33
import jdk.vm.ci.code.site.ConstantReference;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    34
import jdk.vm.ci.code.site.DataPatch;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    35
import jdk.vm.ci.code.site.DataSectionReference;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    36
import jdk.vm.ci.code.site.Infopoint;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    37
import jdk.vm.ci.code.site.InfopointReason;
35844
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
    38
import jdk.vm.ci.code.site.Mark;
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    39
import jdk.vm.ci.code.site.Reference;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    40
import jdk.vm.ci.code.site.Site;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    41
import jdk.vm.ci.hotspot.HotSpotCompiledCode;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    42
import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    43
import jdk.vm.ci.hotspot.HotSpotCompiledNmethod;
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    44
import jdk.vm.ci.hotspot.HotSpotConstant;
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    45
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
40060
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
    46
import jdk.vm.ci.meta.AllocatableValue;
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    47
import jdk.vm.ci.meta.Assumptions.Assumption;
35844
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
    48
import jdk.vm.ci.meta.InvokeTarget;
38692
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
    49
import jdk.vm.ci.meta.JavaKind;
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    50
import jdk.vm.ci.meta.PlatformKind;
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    51
import jdk.vm.ci.meta.ResolvedJavaMethod;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39441
diff changeset
    52
import jdk.vm.ci.meta.VMConstant;
38692
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
    53
import jdk.vm.ci.meta.ValueKind;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39441
diff changeset
    54
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39441
diff changeset
    55
import java.nio.ByteBuffer;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39441
diff changeset
    56
import java.nio.ByteOrder;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39441
diff changeset
    57
import java.util.ArrayList;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 39441
diff changeset
    58
import java.util.Arrays;
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    59
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    60
/**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    61
 * Simple assembler used by the code installation tests.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    62
 */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    63
public abstract class TestAssembler {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    64
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    65
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    66
     * Emit the method prologue code (e.g. building the new stack frame).
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    67
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    68
    public abstract void emitPrologue();
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    69
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    70
    /**
35844
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
    71
     * Emit the method epilogue code (e.g. the deopt handler).
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
    72
     */
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
    73
    public abstract void emitEpilogue();
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
    74
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
    75
    /**
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    76
     * Emit code to grow the stack frame.
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
    77
     *
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    78
     * @param size the size in bytes that the stack should grow
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    79
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    80
    public abstract void emitGrowStack(int size);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    81
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    82
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    83
     * Get the register containing the first 32-bit integer argument.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    84
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    85
    public abstract Register emitIntArg0();
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    86
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    87
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    88
     * Get the register containing the second 32-bit integer argument.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    89
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    90
    public abstract Register emitIntArg1();
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    91
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    92
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    93
     * Emit code to add two 32-bit integer registers. May reuse one of the argument registers.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    94
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    95
    public abstract Register emitIntAdd(Register a, Register b);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    96
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    97
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    98
     * Emit code to load a constant 32-bit integer to a register.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
    99
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   100
    public abstract Register emitLoadInt(int value);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   101
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   102
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   103
     * Emit code to load a constant 64-bit integer to a register.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   104
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   105
    public abstract Register emitLoadLong(long value);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   106
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   107
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   108
     * Emit code to load a constant single-precision float to a register.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   109
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   110
    public abstract Register emitLoadFloat(float value);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   111
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   112
    /**
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   113
     * Emit code to load a constant oop or metaspace pointer to a register. The pointer may be wide
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   114
     * or narrow, depending on {@link HotSpotConstant#isCompressed() c.isCompressed()}.
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   115
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   116
    public abstract Register emitLoadPointer(HotSpotConstant c);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   117
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   118
    /**
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   119
     * Emit code to load a wide pointer from the {@link HotSpotCompiledCode#dataSection} to a
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   120
     * register.
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   121
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   122
    public abstract Register emitLoadPointer(DataSectionReference ref);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   123
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   124
    /**
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   125
     * Emit code to load a narrow pointer from the {@link HotSpotCompiledCode#dataSection} to a
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   126
     * register.
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   127
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   128
    public abstract Register emitLoadNarrowPointer(DataSectionReference ref);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   129
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   130
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   131
     * Emit code to load a (wide) pointer from a memory location to a register.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   132
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   133
    public abstract Register emitLoadPointer(Register base, int offset);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   134
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   135
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   136
     * Emit code to store a 32-bit integer from a register to a new stack slot.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   137
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   138
    public abstract StackSlot emitIntToStack(Register a);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   139
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   140
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   141
     * Emit code to store a 64-bit integer from a register to a new stack slot.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   142
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   143
    public abstract StackSlot emitLongToStack(Register a);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   144
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   145
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   146
     * Emit code to store a single-precision float from a register to a new stack slot.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   147
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   148
    public abstract StackSlot emitFloatToStack(Register a);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   149
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   150
    /**
40060
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   151
     * Emit code to store a double-precision float from a register to a new stack slot.
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   152
     */
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   153
    public abstract StackSlot emitDoubleToStack(Register a);
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   154
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   155
    /**
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   156
     * Emit code to store a wide pointer from a register to a new stack slot.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   157
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   158
    public abstract StackSlot emitPointerToStack(Register a);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   159
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   160
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   161
     * Emit code to store a narrow pointer from a register to a new stack slot.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   162
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   163
    public abstract StackSlot emitNarrowPointerToStack(Register a);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   164
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   165
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   166
     * Emit code to uncompress a narrow pointer. The input pointer is guaranteed to be non-null.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   167
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   168
    public abstract Register emitUncompressPointer(Register compressed, long base, int shift);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   169
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   170
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   171
     * Emit code to return from a function, returning a 32-bit integer.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   172
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   173
    public abstract void emitIntRet(Register a);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   174
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   175
    /**
40060
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   176
     * Emit code to return from a function, returning a single precision float.
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   177
     */
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   178
    public abstract void emitFloatRet(Register a);
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   179
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   180
    /**
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   181
     * Emit code to return from a function, returning a wide oop pointer.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   182
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   183
    public abstract void emitPointerRet(Register a);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   184
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   185
    /**
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   186
     * Emit code that traps, forcing a deoptimization.
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   187
     */
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   188
    public abstract void emitTrap(DebugInfo info);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   189
38692
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   190
    public final ValueKind<?> narrowOopKind;
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   191
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   192
    protected final Buffer code;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   193
    protected final Buffer data;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   194
    private final ArrayList<Site> sites;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   195
    private final ArrayList<DataPatch> dataPatches;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   196
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   197
    protected final CodeCacheProvider codeCache;
39423
0f8dc3693499 8159167: [JVMCI] fix HotSpotVMConfig startup performance
rschatz
parents: 38692
diff changeset
   198
    protected final TestHotSpotVMConfig config;
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   199
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   200
    private final Register[] registers;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   201
    private int nextRegister;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   202
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   203
    protected int frameSize;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   204
    private int stackAlignment;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   205
    private int curStackSlot;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   206
35823
59a847ec6ee3 8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents: 35591
diff changeset
   207
    private StackSlot deoptRescue;
59a847ec6ee3 8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents: 35591
diff changeset
   208
58851
f1e6442241ca 8233035: Update JVMCI
kvn
parents: 47216
diff changeset
   209
    public ValueKindFactory<TestValueKind> valueKindFactory = new ValueKindFactory<>() {
40060
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   210
        public TestValueKind getValueKind(JavaKind javaKind) {
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   211
            return (TestValueKind) TestAssembler.this.getValueKind(javaKind);
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   212
        }
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   213
    };
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   214
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   215
    static class TestValueKind extends ValueKind<TestValueKind> {
38692
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   216
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   217
        TestValueKind(PlatformKind kind) {
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   218
            super(kind);
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   219
        }
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   220
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   221
        @Override
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   222
        public TestValueKind changeType(PlatformKind kind) {
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   223
            return new TestValueKind(kind);
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   224
        }
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   225
    }
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   226
39423
0f8dc3693499 8159167: [JVMCI] fix HotSpotVMConfig startup performance
rschatz
parents: 38692
diff changeset
   227
    protected TestAssembler(CodeCacheProvider codeCache, TestHotSpotVMConfig config, int initialFrameSize, int stackAlignment, PlatformKind narrowOopKind, Register... registers) {
38692
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   228
        this.narrowOopKind = new TestValueKind(narrowOopKind);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   229
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   230
        this.code = new Buffer();
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   231
        this.data = new Buffer();
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   232
        this.sites = new ArrayList<>();
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   233
        this.dataPatches = new ArrayList<>();
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   234
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   235
        this.codeCache = codeCache;
39423
0f8dc3693499 8159167: [JVMCI] fix HotSpotVMConfig startup performance
rschatz
parents: 38692
diff changeset
   236
        this.config = config;
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   237
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   238
        this.registers = registers;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   239
        this.nextRegister = 0;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   240
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   241
        this.frameSize = initialFrameSize;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   242
        this.stackAlignment = stackAlignment;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   243
        this.curStackSlot = initialFrameSize;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   244
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   245
38692
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   246
    public ValueKind<?> getValueKind(JavaKind kind) {
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   247
        return new TestValueKind(codeCache.getTarget().arch.getPlatformKind(kind));
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   248
    }
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   249
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   250
    protected Register newRegister() {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   251
        return registers[nextRegister++];
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   252
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   253
38692
54a84b7f3721 8156942: [JVMCI] replace LIRKind with abstract base class
rschatz
parents: 38027
diff changeset
   254
    protected StackSlot newStackSlot(PlatformKind kind) {
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   255
        growFrame(kind.getSizeInBytes());
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   256
        return StackSlot.get(new TestValueKind(kind), -curStackSlot, true);
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   257
    }
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   258
43478
72039e58b2a8 8171173: EXCEPTION_ACCESS_VIOLATION running VirtualObjectDebugInfoTest.java
never
parents: 40060
diff changeset
   259
    public int getOffset(StackSlot slot) {
72039e58b2a8 8171173: EXCEPTION_ACCESS_VIOLATION running VirtualObjectDebugInfoTest.java
never
parents: 40060
diff changeset
   260
        return slot.getOffset(frameSize);
72039e58b2a8 8171173: EXCEPTION_ACCESS_VIOLATION running VirtualObjectDebugInfoTest.java
never
parents: 40060
diff changeset
   261
    }
72039e58b2a8 8171173: EXCEPTION_ACCESS_VIOLATION running VirtualObjectDebugInfoTest.java
never
parents: 40060
diff changeset
   262
39441
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   263
    protected void growFrame(int sizeInBytes) {
7464b1552bf7 8158850: [JVMCI] be more precise when enforcing OopMapValue encoding limitations
never
parents: 39423
diff changeset
   264
        curStackSlot += sizeInBytes;
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   265
        if (curStackSlot > frameSize) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   266
            int newFrameSize = curStackSlot;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   267
            if (newFrameSize % stackAlignment != 0) {
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   268
                newFrameSize += stackAlignment - (newFrameSize % stackAlignment);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   269
            }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   270
            emitGrowStack(newFrameSize - frameSize);
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   271
            frameSize = newFrameSize;
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   272
        }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   273
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   274
35823
59a847ec6ee3 8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents: 35591
diff changeset
   275
    protected void setDeoptRescueSlot(StackSlot deoptRescue) {
59a847ec6ee3 8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents: 35591
diff changeset
   276
        this.deoptRescue = deoptRescue;
59a847ec6ee3 8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents: 35591
diff changeset
   277
    }
59a847ec6ee3 8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents: 35591
diff changeset
   278
35844
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   279
    protected void recordCall(InvokeTarget target, int size, boolean direct, DebugInfo debugInfo) {
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   280
        sites.add(new Call(target, code.position(), size, direct, debugInfo));
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   281
    }
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   282
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   283
    protected void recordMark(Object id) {
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   284
        sites.add(new Mark(code.position(), id));
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   285
    }
8a1952516600 8148741: compiler/jvmci/code/SimpleDebugInfoTest.java fails in 'frame::sender_for_compiled_frame'
rschatz
parents: 35823
diff changeset
   286
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   287
    protected void recordImplicitException(DebugInfo info) {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   288
        sites.add(new Infopoint(code.position(), info, InfopointReason.IMPLICIT_EXCEPTION));
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   289
    }
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   290
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   291
    protected void recordDataPatchInCode(Reference ref) {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   292
        sites.add(new DataPatch(code.position(), ref));
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   293
    }
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   294
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   295
    protected void recordDataPatchInData(Reference ref) {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   296
        dataPatches.add(new DataPatch(data.position(), ref));
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   297
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   298
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   299
    public DataSectionReference emitDataItem(HotSpotConstant c) {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   300
        DataSectionReference ref = new DataSectionReference();
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   301
        ref.setOffset(data.position());
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   302
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   303
        recordDataPatchInData(new ConstantReference((VMConstant) c));
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   304
        if (c.isCompressed()) {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   305
            data.emitInt(0xDEADDEAD);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   306
        } else {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   307
            data.emitLong(0xDEADDEADDEADDEADL);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   308
        }
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   309
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   310
        return ref;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   311
    }
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   312
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   313
    public HotSpotCompiledCode finish(HotSpotResolvedJavaMethod method) {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   314
        int id = method.allocateCompileId(0);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   315
        byte[] finishedCode = code.finish();
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   316
        Site[] finishedSites = sites.toArray(new Site[0]);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   317
        byte[] finishedData = data.finish();
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   318
        DataPatch[] finishedDataPatches = dataPatches.toArray(new DataPatch[0]);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   319
        return new HotSpotCompiledNmethod(method.getName(), finishedCode, finishedCode.length, finishedSites, new Assumption[0], new ResolvedJavaMethod[]{method}, new Comment[0], finishedData, 16,
35823
59a847ec6ee3 8146608: [JVMCI] DebugInfo Tests on DeoptimizeALot runs fails in assert(_pc == *pc_addr || pc == *pc_addr) frame::patch_pc() /frame_x86.cpp:285
rschatz
parents: 35591
diff changeset
   320
                        finishedDataPatches, false, frameSize, deoptRescue, method, 0, id, 0L, false);
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   321
    }
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   322
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   323
    protected static class Buffer {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   324
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   325
        private ByteBuffer data = ByteBuffer.allocate(32).order(ByteOrder.nativeOrder());
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   326
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   327
        private void ensureSize(int length) {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   328
            if (length >= data.limit()) {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   329
                byte[] newBuf = Arrays.copyOf(data.array(), length * 4);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   330
                ByteBuffer newData = ByteBuffer.wrap(newBuf);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   331
                newData.order(data.order());
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   332
                newData.position(data.position());
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   333
                data = newData;
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   334
            }
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   335
        }
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   336
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   337
        public int position() {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   338
            return data.position();
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   339
        }
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   340
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   341
        public void emitByte(int b) {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   342
            ensureSize(data.position() + 1);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   343
            data.put((byte) (b & 0xFF));
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   344
        }
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   345
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   346
        public void emitShort(int b) {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   347
            ensureSize(data.position() + 2);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   348
            data.putShort((short) b);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   349
        }
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   350
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   351
        public void emitInt(int b) {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   352
            ensureSize(data.position() + 4);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   353
            data.putInt(b);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   354
        }
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   355
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   356
        public void emitLong(long b) {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   357
            ensureSize(data.position() + 8);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   358
            data.putLong(b);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   359
        }
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   360
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   361
        public void emitFloat(float f) {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   362
            ensureSize(data.position() + 4);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   363
            data.putFloat(f);
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   364
        }
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   365
40060
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   366
        public void emitDouble(double f) {
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   367
            ensureSize(data.position() + 8);
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   368
            data.putDouble(f);
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   369
        }
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   370
35591
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   371
        public void align(int alignment) {
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   372
            int pos = data.position();
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   373
            int misaligned = pos % alignment;
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   374
            if (misaligned != 0) {
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   375
                pos += alignment - misaligned;
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   376
                data.position(pos);
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   377
            }
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   378
        }
35ab7c6816e9 8146244: compiler/jvmci/code/DataPatchTest.java crashes: SIGSEGV in (getConstClass)getConstClass
rschatz
parents: 35582
diff changeset
   379
35582
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   380
        private byte[] finish() {
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   381
            return Arrays.copyOf(data.array(), data.position());
c32a0cc19877 8147599: [JVMCI] simplify code installation interface
rschatz
parents: 35137
diff changeset
   382
        }
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   383
    }
40060
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   384
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   385
    /**
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   386
     * Loads a primitive into the Allocatable <code>av</code>. Implementors may only implement
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   387
     * primitive types.
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   388
     */
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   389
    public abstract void emitLoad(AllocatableValue av, Object prim);
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   390
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   391
    /**
58851
f1e6442241ca 8233035: Update JVMCI
kvn
parents: 47216
diff changeset
   392
     * Emit a call to a fixed address <code>addr</code>.
40060
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   393
     */
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   394
    public abstract void emitCall(long addr);
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   395
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   396
    /**
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   397
     * Emit code which is necessary to call a method with {@link CallingConvention} <code>cc</code>
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   398
     * and arguments <coe>prim</code>.
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   399
     */
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   400
    public abstract void emitCallPrologue(CallingConvention cc, Object... prim);
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   401
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   402
    /**
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   403
     * Emit code which is necessary after calling a method with CallingConvention <code>cc</code>.
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   404
     */
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   405
    public abstract void emitCallEpilogue(CallingConvention cc);
0e7ca474ea35 8159368: [JVMCI] SPARCHotSpotRegisterConfig.callingConvention gives incorrect calling convention for native calls containing fp args
sanzinger
parents: 40059
diff changeset
   406
35137
c8f8f6de68a7 8144704: [JVMCI] add tests for simple code installation
rschatz
parents:
diff changeset
   407
}