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