OSDN Git Service

Jit: Sapphire tuning - mostly scheduling.
[android-x86/dalvik.git] / vm / compiler / codegen / arm / armv5te / ArchVariant.c
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 /*
18  * This file is included by Codegen-armv5te.c, and implements architecture
19  * variant-specific code.
20  */
21
22 /*
23  * Determine the initial instruction set to be used for this trace.
24  * Later components may decide to change this.
25  */
26 JitInstructionSetType dvmCompilerInstructionSet(void)
27 {
28     return DALVIK_JIT_THUMB;
29 }
30
31 /* Architecture-specific initializations and checks go here */
32 bool dvmCompilerArchVariantInit(void)
33 {
34     /* First, declare dvmCompiler_TEMPLATE_XXX for each template */
35 #define JIT_TEMPLATE(X) extern void dvmCompiler_TEMPLATE_##X();
36 #include "../../../template/armv5te/TemplateOpList.h"
37 #undef JIT_TEMPLATE
38
39     int i = 0;
40     extern void dvmCompilerTemplateStart(void);
41
42     /*
43      * Then, populate the templateEntryOffsets array with the offsets from the
44      * the dvmCompilerTemplateStart symbol for each template.
45      */
46 #define JIT_TEMPLATE(X) templateEntryOffsets[i++] = \
47     (intptr_t) dvmCompiler_TEMPLATE_##X - (intptr_t) dvmCompilerTemplateStart;
48 #include "../../../template/armv5te/TemplateOpList.h"
49 #undef JIT_TEMPLATE
50
51     /* Target-specific configuration */
52     gDvmJit.jitTableSize = 1 << 9; // 512
53     gDvmJit.jitTableMask = gDvmJit.jitTableSize - 1;
54     gDvmJit.threshold = 200;
55     gDvmJit.codeCacheSize = 512*1024;
56
57 #if defined(WITH_SELF_VERIFICATION)
58     /* Force into blocking mode */
59     gDvmJit.blockingMode = true;
60 #endif
61
62     /* Codegen-specific assumptions */
63     assert(offsetof(ClassObject, vtable) < 128 &&
64            (offsetof(ClassObject, vtable) & 0x3) == 0);
65     assert(offsetof(ArrayObject, length) < 128 &&
66            (offsetof(ArrayObject, length) & 0x3) == 0);
67     assert(offsetof(ArrayObject, contents) < 256);
68
69     /* Up to 5 args are pushed on top of FP - sizeofStackSaveArea */
70     assert(sizeof(StackSaveArea) < 236);
71
72     /*
73      * EA is calculated by doing "Rn + imm5 << 2", and there are 5 entry points
74      * that codegen may access, make sure that the offset from the top of the
75      * struct is less than 108.
76      */
77     assert(offsetof(InterpState, jitToInterpEntries) < 108);
78     return true;
79 }
80
81 int dvmCompilerTargetOptHint(int key)
82 {
83     int res;
84     switch (key) {
85         case kMaxHoistDistance:
86             res = 2;
87             break;
88         default:
89             LOGE("Unknown target optimization hint key: %d",key);
90             res = 0;
91     }
92     return res;
93 }