annotate graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotForeignCallsProvider.java @ 15104:ed29f7ff71eb

add DeoptimizationStub
author twisti
date Mon, 14 Apr 2014 17:21:49 -1000
parents 8b23db5f4164
children 96bb07a5d667
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
1 /*
15104
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 14046
diff changeset
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
4 *
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
8 *
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
13 * accompanied this code).
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
14 *
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
18 *
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
21 * questions.
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
22 */
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.hotspot.amd64;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
24
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 import static com.oracle.graal.amd64.AMD64.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26 import static com.oracle.graal.api.code.CallingConvention.Type.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27 import static com.oracle.graal.api.meta.LocationIdentity.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28 import static com.oracle.graal.api.meta.Value.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29 import static com.oracle.graal.hotspot.HotSpotBackend.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
30 import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.RegisterEffect.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 import static com.oracle.graal.hotspot.HotSpotForeignCallLinkage.Transition.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 import static com.oracle.graal.hotspot.replacements.AESCryptSubstitutions.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 import static com.oracle.graal.hotspot.replacements.CRC32Substitutions.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 import static com.oracle.graal.hotspot.replacements.CipherBlockChainingSubstitutions.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37 import com.oracle.graal.api.code.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38 import com.oracle.graal.api.meta.*;
13112
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
39 import com.oracle.graal.graph.*;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 import com.oracle.graal.hotspot.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 import com.oracle.graal.hotspot.meta.*;
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
43 public class AMD64HotSpotForeignCallsProvider extends HotSpotHostForeignCallsProvider {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
44
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
45 private final Value[] nativeABICallerSaveRegisters;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
47 public AMD64HotSpotForeignCallsProvider(HotSpotGraalRuntime runtime, MetaAccessProvider metaAccess, CodeCacheProvider codeCache, Value[] nativeABICallerSaveRegisters) {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
48 super(runtime, metaAccess, codeCache);
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
49 this.nativeABICallerSaveRegisters = nativeABICallerSaveRegisters;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 }
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 @Override
12463
3661954321aa removed more uses of HotSpotGraalRuntime.getHostProviders() (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12456
diff changeset
53 public void initialize(HotSpotProviders providers, HotSpotVMConfig config) {
15104
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 14046
diff changeset
54 TargetDescription target = providers.getCodeCache().getTarget();
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 14046
diff changeset
55 Kind word = target.wordKind;
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
56
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
57 // The calling convention for the exception handler stub is (only?) defined in
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
58 // TemplateInterpreterGenerator::generate_throw_exception()
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59 // in templateInterpreter_x86_64.cpp around line 1923
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60 RegisterValue exception = rax.asValue(Kind.Object);
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61 RegisterValue exceptionPc = rdx.asValue(word);
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62 CallingConvention exceptionCc = new CallingConvention(0, ILLEGAL, exception, exceptionPc);
13301
126ef8e8aa59 Separate foreign calls into LEAF and LEAF_NOFP.
Roland Schatz <roland.schatz@oracle.com>
parents: 13112
diff changeset
63 register(new HotSpotForeignCallLinkage(EXCEPTION_HANDLER, 0L, PRESERVES_REGISTERS, LEAF_NOFP, null, exceptionCc, NOT_REEXECUTABLE, ANY_LOCATION));
126ef8e8aa59 Separate foreign calls into LEAF and LEAF_NOFP.
Roland Schatz <roland.schatz@oracle.com>
parents: 13112
diff changeset
64 register(new HotSpotForeignCallLinkage(EXCEPTION_HANDLER_IN_CALLER, JUMP_ADDRESS, PRESERVES_REGISTERS, LEAF_NOFP, exceptionCc, null, NOT_REEXECUTABLE, ANY_LOCATION));
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65
15104
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 14046
diff changeset
66 link(new AMD64DeoptimizationStub(providers, target, registerStubCall(UNCOMMON_TRAP_HANDLER, REEXECUTABLE, LEAF, NO_LOCATIONS)));
ed29f7ff71eb add DeoptimizationStub
twisti
parents: 14046
diff changeset
67
13112
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
68 // When the java.ext.dirs property is modified then the crypto classes might not be found.
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
69 // If that's the case we ignore the ClassNotFoundException and continue since we cannot
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
70 // replace a non-existing method anyway.
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
71 try {
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
72 // These stubs do callee saving
14046
8b23db5f4164 fix field access and casts in method substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13301
diff changeset
73 registerForeignCall(ENCRYPT_BLOCK, config.aescryptEncryptBlockStub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, NamedLocationIdentity.getArrayLocation(Kind.Byte));
8b23db5f4164 fix field access and casts in method substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13301
diff changeset
74 registerForeignCall(DECRYPT_BLOCK, config.aescryptDecryptBlockStub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, NamedLocationIdentity.getArrayLocation(Kind.Byte));
13112
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
75 } catch (GraalInternalError e) {
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
76 if (!(e.getCause() instanceof ClassNotFoundException)) {
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
77 throw e;
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
78 }
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
79 }
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
80 try {
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
81 // These stubs do callee saving
14046
8b23db5f4164 fix field access and casts in method substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13301
diff changeset
82 registerForeignCall(ENCRYPT, config.cipherBlockChainingEncryptAESCryptStub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, NamedLocationIdentity.getArrayLocation(Kind.Byte));
8b23db5f4164 fix field access and casts in method substitutions
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13301
diff changeset
83 registerForeignCall(DECRYPT, config.cipherBlockChainingDecryptAESCryptStub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, NamedLocationIdentity.getArrayLocation(Kind.Byte));
13112
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
84 } catch (GraalInternalError e) {
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
85 if (!(e.getCause() instanceof ClassNotFoundException)) {
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
86 throw e;
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
87 }
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
88 }
d737287f5b32 ignore ClassNotFoundException when trying to register foreign calls to crypto methods
twisti
parents: 12463
diff changeset
89
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
90 // These stubs do callee saving
13301
126ef8e8aa59 Separate foreign calls into LEAF and LEAF_NOFP.
Roland Schatz <roland.schatz@oracle.com>
parents: 13112
diff changeset
91 registerForeignCall(UPDATE_BYTES_CRC32, config.updateBytesCRC32Stub, NativeCall, PRESERVES_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, ANY_LOCATION);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
92
12463
3661954321aa removed more uses of HotSpotGraalRuntime.getHostProviders() (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12456
diff changeset
93 super.initialize(providers, config);
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
94 }
12456
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
95
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
96 @Override
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
97 public Value[] getNativeABICallerSaveRegisters() {
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
98 return nativeABICallerSaveRegisters;
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
99 }
f87c68d79f07 improved support for co-existing, multiple backends (GRAAL-363)
Doug Simon <doug.simon@oracle.com>
parents: 12431
diff changeset
100
12429
5124eeec1a7b split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
101 }