2 * Copyright (C) 2009 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 extern "C" void dvmCompilerTemplateStart(void);
20 * Determine the initial instruction set to be used for this trace.
21 * Later components may decide to change this.
23 JitInstructionSetType dvmCompilerInstructionSet(void)
25 return DALVIK_JIT_THUMB2;
28 /* First, declare dvmCompiler_TEMPLATE_XXX for each template */
29 #define JIT_TEMPLATE(X) extern "C" void dvmCompiler_TEMPLATE_##X();
30 #include "../../../template/armv7-a/TemplateOpList.h"
33 /* Architecture-specific initializations and checks go here */
34 bool dvmCompilerArchVariantInit(void)
39 * Then, populate the templateEntryOffsets array with the offsets from the
40 * the dvmCompilerTemplateStart symbol for each template.
42 #define JIT_TEMPLATE(X) templateEntryOffsets[i++] = \
43 (intptr_t) dvmCompiler_TEMPLATE_##X - (intptr_t) dvmCompilerTemplateStart;
44 #include "../../../template/armv7-a/TemplateOpList.h"
47 /* Target-specific configuration */
48 gDvmJit.jitTableSize = 1 << 12; // 4096
49 gDvmJit.jitTableMask = gDvmJit.jitTableSize - 1;
50 if (gDvmJit.threshold == 0) {
51 gDvmJit.threshold = 40;
53 if (gDvmJit.codeCacheSize == DEFAULT_CODE_CACHE_SIZE) {
54 gDvmJit.codeCacheSize = 1500 * 1024;
55 } else if ((gDvmJit.codeCacheSize == 0) && (gDvm.executionMode == kExecutionModeJit)) {
56 gDvm.executionMode = kExecutionModeInterpFast;
58 /* Hard limit for Arm of 2M */
59 assert(gDvmJit.codeCacheSize <= 2 * 1024 * 1024);
61 #if defined(WITH_SELF_VERIFICATION)
62 /* Force into blocking */
63 gDvmJit.blockingMode = true;
64 gDvm.nativeDebuggerActive = true;
67 /* Codegen-specific assumptions */
68 assert(OFFSETOF_MEMBER(ClassObject, vtable) < 128 &&
69 (OFFSETOF_MEMBER(ClassObject, vtable) & 0x3) == 0);
70 assert(OFFSETOF_MEMBER(ArrayObject, length) < 128 &&
71 (OFFSETOF_MEMBER(ArrayObject, length) & 0x3) == 0);
72 assert(OFFSETOF_MEMBER(ArrayObject, contents) < 256);
74 /* Up to 5 args are pushed on top of FP - sizeofStackSaveArea */
75 assert(sizeof(StackSaveArea) < 236);
78 * EA is calculated by doing "Rn + imm5 << 2". Make sure that the last
79 * offset from the struct is less than 128.
81 if ((offsetof(Thread, jitToInterpEntries) +
82 sizeof(struct JitToInterpEntries)) >= 128) {
83 ALOGE("Thread.jitToInterpEntries size overflow");
87 /* FIXME - comment out the following to enable method-based JIT */
88 gDvmJit.disableOpt |= (1 << kMethodJit);
90 // Make sure all threads have current values
91 dvmJitUpdateThreadStateAll();
96 int dvmCompilerTargetOptHint(int key)
100 case kMaxHoistDistance:
104 ALOGE("Unknown target optimization hint key: %d",key);
110 void dvmCompilerGenMemBarrier(CompilationUnit *cUnit, int barrierKind)
113 ArmLIR *dmb = newLIR1(cUnit, kThumb2Dmb, barrierKind);
114 dmb->defMask = ENCODE_ALL;