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.
18 * DEX constant-reduction declarations.
20 #ifndef _DALVIK_REDUCECONSTANTS
21 #define _DALVIK_REDUCECONSTANTS
23 #define DVM_RC_DISABLED 0 /* no reduction, 1:1 map */
24 #define DVM_RC_REDUCING 1 /* normal constants, reduced lookup table */
25 #define DVM_RC_EXPANDING 2 /* reduced constants, expanded on resolve */
26 #define DVM_RC_NO_CACHE 3 /* disable the cache (reduce to zero) */
39 #define kNoIndexMapping ((u2) -1)
42 * Map indices back to the original.
44 typedef struct IndexMap {
45 int origCount; /* original size; describes range of entries in map */
46 int newCount; /* reduced size */
47 u2* mapToNew; /* sparse map, from "orig" to "new" */
48 u2* mapToOld; /* dense map, from "new" back to "orig" */
50 typedef struct IndexMapSet {
51 /* maps for the different sections */
52 IndexMap map[kNumIndexMaps];
54 /* data stream that gets appended to the optimized DEX file */
61 * Constant pool compaction.
63 * The caller is responsible for freeing the returned structure by
64 * calling dvmFreeIndexMap().
66 IndexMapSet* dvmRewriteConstants(struct DvmDex* pDvmDex);
68 /* free an index map set */
69 void dvmFreeIndexMapSet(IndexMapSet* indexMapSet);
71 #endif /*_DALVIK_REDUCECONSTANTS*/