• 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/armv5te-vfp/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/armv5te-vfp/TemplateOpList.h"
45 #undef JIT_TEMPLATE
46 
47     /* Target-specific configuration */
48     gDvmJit.jitTableSize = 1 << 12; // 4096
49     gDvmJit.jitTableMask = gDvmJit.jitTableSize - 1;
50     gDvmJit.threshold = 40;
51     gDvmJit.codeCacheSize = 1024*1024;
52 
53 #if defined(WITH_SELF_VERIFICATION)
54     /* Force into blocking */
55     gDvmJit.blockingMode = true;
56     gDvm.nativeDebuggerActive = true;
57 #endif
58 
59     /* Codegen-specific assumptions */
60     assert(OFFSETOF_MEMBER(ClassObject, vtable) < 128 &&
61            (OFFSETOF_MEMBER(ClassObject, vtable) & 0x3) == 0);
62     assert(OFFSETOF_MEMBER(ArrayObject, length) < 128 &&
63            (OFFSETOF_MEMBER(ArrayObject, length) & 0x3) == 0);
64     assert(OFFSETOF_MEMBER(ArrayObject, contents) < 256);
65 
66     /* Up to 5 args are pushed on top of FP - sizeofStackSaveArea */
67     assert(sizeof(StackSaveArea) < 236);
68 
69     /*
70      * EA is calculated by doing "Rn + imm5 << 2". Make sure that the last
71      * offset from the struct is less than 128.
72      */
73     if ((offsetof(Thread, jitToInterpEntries) +
74          sizeof(struct JitToInterpEntries)) >= 128) {
75         ALOGE("Thread.jitToInterpEntries size overflow");
76         dvmAbort();
77     }
78 
79     /* FIXME - comment out the following to enable method-based JIT */
80     gDvmJit.disableOpt |= (1 << kMethodJit);
81 
82     // Make sure all threads have current values
83     dvmJitUpdateThreadStateAll();
84 
85     return true;
86 }
87 
dvmCompilerTargetOptHint(int key)88 int dvmCompilerTargetOptHint(int key)
89 {
90     int res;
91     switch (key) {
92         case kMaxHoistDistance:
93             res = 7;
94             break;
95         default:
96             ALOGE("Unknown target optimization hint key: %d",key);
97             res = 0;
98     }
99     return res;
100 }
101 
dvmCompilerGenMemBarrier(CompilationUnit * cUnit,int barrierKind)102 void dvmCompilerGenMemBarrier(CompilationUnit *cUnit, int barrierKind)
103 {
104 #if ANDROID_SMP != 0
105     ArmLIR *dmb = newLIR1(cUnit, kThumb2Dmb, barrierKind);
106     dmb->defMask = ENCODE_ALL;
107 #endif
108 }
109