2 * Copyright (C) 2008 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * Target-specific optimization and run-time hints
22 #include "libdex/DexClass.h"
30 * The class loader will associate with each method a 32-bit info word
31 * (jniArgInfo) to support JNI calls. The high order 4 bits of this word
32 * are the same for all targets, while the lower 28 are used for hints to
33 * allow accelerated JNI bridge transfers.
35 * jniArgInfo (32-bit int) layout:
37 * SRRRHHHH HHHHHHHH HHHHHHHH HHHHHHHH
39 * S - if set, ignore the hints and do things the hard way (scan signature)
40 * R - return-type enumeration
41 * H - target-specific hints (see below for details)
43 * This function produces arm-specific hints - specifically a description
44 * of padding required to keep all 64-bit parameters properly aligned.
48 * LLLL FFFFFFFF FFFFFFFF FFFFFFFF
50 * L - number of double-words of storage required on the stack (0-30 words)
51 * F - pad flag -- if set, write a pad word to the stack before copying
54 * If there are too many arguments to construct valid hints, this function will
55 * return a result with the S bit set.
57 u4 dvmPlatformInvokeHints(const DexProto* proto)
59 const char* sig = dexProtoGetShorty(proto);
60 int padFlags, jniHints;
62 int stackOffset, padMask, hints;
64 stackOffset = padFlags = 0;
67 /* Skip past the return type */
76 if (sigByte == 'D' || sigByte == 'J') {
77 if ((stackOffset & 1) != 0) {
92 if (stackOffset > DALVIK_JNI_COUNT_SHIFT) {
93 /* too big for "fast" version */
94 jniHints = DALVIK_JNI_NO_ARG_INFO;
96 assert((padFlags & (0xffffffff << DALVIK_JNI_COUNT_SHIFT)) == 0);
97 stackOffset -= 2; // r2/r3 holds first two items
100 jniHints |= ((stackOffset+1) / 2) << DALVIK_JNI_COUNT_SHIFT;
101 jniHints |= padFlags;