• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 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  */
16 
17 extern "C" void dvmCompilerTemplateStart(void);
18 
19 /*
20  * Determine the initial instruction set to be used for this trace.
21  * Later components may decide to change this.
22  */
dvmCompilerInstructionSet(void)23 JitInstructionSetType dvmCompilerInstructionSet(void)
24 {
25     return DALVIK_JIT_THUMB2;
26 }
27 
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"
31 #undef JIT_TEMPLATE
32 
33 /* Architecture-specific initializations and checks go here */
dvmCompilerArchVariantInit(void)34 bool dvmCompilerArchVariantInit(void)
35 {
36     int i = 0;
37 
38     /*
39      * Then, populate the templateEntryOffsets array with the offsets from the
40      * the dvmCompilerTemplateStart symbol for each template.
41      */
42 #define JIT_TEMPLATE(X) templateEntryOffsets[i++] = \
43     (intptr_t) dvmCompiler_TEMPLATE_##X - (intptr_t) dvmCompilerTemplateStart;
44 #include "../../../template/armv7-a/TemplateOpList.h"
45 #undef JIT_TEMPLATE
46 
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;
52     }
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;
57     }
58     /* Hard limit for Arm of 2M */
59     assert(gDvmJit.codeCacheSize <= 2 * 1024 * 1024);
60 
61 #if defined(WITH_SELF_VERIFICATION)
62     /* Force into blocking */
63     gDvmJit.blockingMode = true;
64     gDvm.nativeDebuggerActive = true;
65 #endif
66 
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);
73 
74     /* Up to 5 args are pushed on top of FP - sizeofStackSaveArea */
75     assert(sizeof(StackSaveArea) < 236);
76 
77     /*
78      * EA is calculated by doing "Rn + imm5 << 2". Make sure that the last
79      * offset from the struct is less than 128.
80      */
81     if ((offsetof(Thread, jitToInterpEntries) +
82          sizeof(struct JitToInterpEntries)) >= 128) {
83         ALOGE("Thread.jitToInterpEntries size overflow");
84         dvmAbort();
85     }
86 
87     /* FIXME - comment out the following to enable method-based JIT */
88     gDvmJit.disableOpt |= (1 << kMethodJit);
89 
90     // Make sure all threads have current values
91     dvmJitUpdateThreadStateAll();
92 
93     return true;
94 }
95 
dvmCompilerTargetOptHint(int key)96 int dvmCompilerTargetOptHint(int key)
97 {
98     int res;
99     switch (key) {
100         case kMaxHoistDistance:
101             res = 7;
102             break;
103         default:
104             ALOGE("Unknown target optimization hint key: %d",key);
105             res = 0;
106     }
107     return res;
108 }
109 
dvmCompilerGenMemBarrier(CompilationUnit * cUnit,int barrierKind)110 void dvmCompilerGenMemBarrier(CompilationUnit *cUnit, int barrierKind)
111 {
112 #if ANDROID_SMP != 0
113     ArmLIR *dmb = newLIR1(cUnit, kThumb2Dmb, barrierKind);
114     dmb->defMask = ENCODE_ALL;
115 #endif
116 }
117