ArchVariant.cpp revision 5d5b94c8d14b166af580d5dd5906db4f9527d6ca
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 * Determine the initial instruction set to be used for this trace.
19 * Later components may decide to change this.
20 */
21JitInstructionSetType dvmCompilerInstructionSet(void)
22{
23    return DALVIK_JIT_THUMB2;
24}
25
26/* Architecture-specific initializations and checks go here */
27bool dvmCompilerArchVariantInit(void)
28{
29    /* First, declare dvmCompiler_TEMPLATE_XXX for each template */
30#define JIT_TEMPLATE(X) extern void dvmCompiler_TEMPLATE_##X();
31#include "../../../template/armv5te-vfp/TemplateOpList.h"
32#undef JIT_TEMPLATE
33
34    int i = 0;
35    extern void dvmCompilerTemplateStart(void);
36
37    /*
38     * Then, populate the templateEntryOffsets array with the offsets from the
39     * the dvmCompilerTemplateStart symbol for each template.
40     */
41#define JIT_TEMPLATE(X) templateEntryOffsets[i++] = \
42    (intptr_t) dvmCompiler_TEMPLATE_##X - (intptr_t) dvmCompilerTemplateStart;
43#include "../../../template/armv5te-vfp/TemplateOpList.h"
44#undef JIT_TEMPLATE
45
46    /* Target-specific configuration */
47    gDvmJit.jitTableSize = 1 << 12; // 4096
48    gDvmJit.jitTableMask = gDvmJit.jitTableSize - 1;
49    gDvmJit.threshold = 40;
50    gDvmJit.codeCacheSize = 1024*1024;
51
52#if defined(WITH_SELF_VERIFICATION)
53    /* Force into blocking */
54    gDvmJit.blockingMode = true;
55    gDvm.nativeDebuggerActive = true;
56#endif
57
58    /* Codegen-specific assumptions */
59    assert(offsetof(ClassObject, vtable) < 128 &&
60           (offsetof(ClassObject, vtable) & 0x3) == 0);
61    assert(offsetof(ArrayObject, length) < 128 &&
62           (offsetof(ArrayObject, length) & 0x3) == 0);
63    assert(offsetof(ArrayObject, contents) < 256);
64
65    /* Up to 5 args are pushed on top of FP - sizeofStackSaveArea */
66    assert(sizeof(StackSaveArea) < 236);
67
68    /*
69     * EA is calculated by doing "Rn + imm5 << 2". Make sure that the last
70     * offset from the struct is less than 128.
71     */
72    if ((offsetof(Thread, jitToInterpEntries) +
73         sizeof(struct JitToInterpEntries)) >= 128) {
74        LOGE("Thread.jitToInterpEntries size overflow");
75        dvmAbort();
76    }
77
78    /* FIXME - comment out the following to enable method-based JIT */
79    gDvmJit.disableOpt |= (1 << kMethodJit);
80
81    // Make sure all threads have current values
82    dvmJitUpdateThreadStateAll();
83
84    return true;
85}
86
87int dvmCompilerTargetOptHint(int key)
88{
89    int res;
90    switch (key) {
91        case kMaxHoistDistance:
92            res = 7;
93            break;
94        default:
95            LOGE("Unknown target optimization hint key: %d",key);
96            res = 0;
97    }
98    return res;
99}
100
101void dvmCompilerGenMemBarrier(CompilationUnit *cUnit, int barrierKind)
102{
103#if ANDROID_SMP != 0
104    ArmLIR *dmb = newLIR1(cUnit, kThumb2Dmb, barrierKind);
105    dmb->defMask = ENCODE_ALL;
106#endif
107}
108