blob: 4b6ab6b1741d819be4f09b0b65ac1a40f1c26fb3 [file] [log] [blame]
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
The Android Open Source Project99409882009-03-18 22:20:24 -070016
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080017/*
18 * DEX optimization declarations.
19 */
20#ifndef _DALVIK_DEXOPTIMIZE
21#define _DALVIK_DEXOPTIMIZE
22
23/*
24 * Global DEX optimizer control. Determines the circumstances in which we
25 * try to rewrite instructions in the DEX file.
26 */
27typedef enum DexOptimizerMode {
28 OPTIMIZE_MODE_UNKNOWN = 0,
29 OPTIMIZE_MODE_NONE, /* never optimize */
30 OPTIMIZE_MODE_VERIFIED, /* only optimize verified classes (default) */
31 OPTIMIZE_MODE_ALL /* optimize all classes */
32} DexOptimizerMode;
33
34/* some additional bit flags for dexopt */
35enum DexoptFlags {
36 DEXOPT_GEN_REGISTER_MAPS = 1, /* generate register maps during verify */
37};
38
39/*
40 * Given the full path to a DEX or Jar file, and (if appropriate) the name
41 * within the Jar, open the optimized version from the cache.
42 *
43 * If "*pNewFile" is set, a new file has been created with only a stub
44 * "opt" header, and the caller is expected to fill in the blanks.
45 *
46 * Returns the file descriptor, locked and seeked past the "opt" header.
47 */
48int dvmOpenCachedDexFile(const char* fileName, const char* cachedFile,
49 u4 modWhen, u4 crc, bool isBootstrap, bool* pNewFile, bool createIfMissing);
50
51/*
52 * Unlock the specified file descriptor. Use in conjunction with
53 * dvmOpenCachedDexFile().
54 *
55 * Returns true on success.
56 */
57bool dvmUnlockCachedDexFile(int fd);
58
59/*
60 * Verify the contents of the "opt" header, and check the DEX file's
61 * dependencies on its source zip (if available).
62 */
63bool dvmCheckOptHeaderAndDependencies(int fd, bool sourceAvail, u4 modWhen,
64 u4 crc, bool expectVerify, bool expectOpt);
65
66/*
67 * Optimize a DEX file. The file must start with the "opt" header, followed
68 * by the plain DEX data. It must be mmap()able.
69 *
70 * "fileName" is only used for debug output.
71 */
72bool dvmOptimizeDexFile(int fd, off_t dexOffset, long dexLen,
73 const char* fileName, u4 modWhen, u4 crc, bool isBootstrap);
74
75/*
76 * Continue the optimization process on the other side of a fork/exec.
77 */
78bool dvmContinueOptimization(int fd, off_t dexOffset, long dexLength,
79 const char* fileName, u4 modWhen, u4 crc, bool isBootstrap);
80
81/*
82 * Abbreviated resolution functions, for use by optimization and verification
83 * code.
84 */
85ClassObject* dvmOptResolveClass(ClassObject* referrer, u4 classIdx);
86Method* dvmOptResolveMethod(ClassObject* referrer, u4 methodIdx,
87 MethodType methodType);
88Method* dvmOptResolveInterfaceMethod(ClassObject* referrer, u4 methodIdx);
89InstField* dvmOptResolveInstField(ClassObject* referrer, u4 ifieldIdx);
90StaticField* dvmOptResolveStaticField(ClassObject* referrer, u4 sfieldIdx);
91
92#endif /*_DALVIK_DEXOPTIMIZE*/