Home | History | Annotate | Download | only in x86_64
      1 /*
      2  * Copyright (C) 2012 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 #include <math.h>
     18 
     19 #include "entrypoints/jni/jni_entrypoints.h"
     20 #include "entrypoints/quick/quick_alloc_entrypoints.h"
     21 #include "entrypoints/quick/quick_default_externs.h"
     22 #if !defined(__APPLE__)
     23 #include "entrypoints/quick/quick_default_init_entrypoints.h"
     24 #endif
     25 #include "entrypoints/quick/quick_entrypoints.h"
     26 #include "entrypoints/math_entrypoints.h"
     27 #include "entrypoints/runtime_asm_entrypoints.h"
     28 #include "interpreter/interpreter.h"
     29 
     30 namespace art {
     31 
     32 // Cast entrypoints.
     33 extern "C" size_t art_quick_instance_of(mirror::Object* obj, mirror::Class* ref_class);
     34 
     35 // Read barrier entrypoints.
     36 // art_quick_read_barrier_mark_regX uses an non-standard calling
     37 // convention: it expects its input in register X and returns its
     38 // result in that same register, and saves and restores all
     39 // caller-save registers.
     40 extern "C" mirror::Object* art_quick_read_barrier_mark_reg00(mirror::Object*);
     41 extern "C" mirror::Object* art_quick_read_barrier_mark_reg01(mirror::Object*);
     42 extern "C" mirror::Object* art_quick_read_barrier_mark_reg02(mirror::Object*);
     43 extern "C" mirror::Object* art_quick_read_barrier_mark_reg03(mirror::Object*);
     44 extern "C" mirror::Object* art_quick_read_barrier_mark_reg05(mirror::Object*);
     45 extern "C" mirror::Object* art_quick_read_barrier_mark_reg06(mirror::Object*);
     46 extern "C" mirror::Object* art_quick_read_barrier_mark_reg07(mirror::Object*);
     47 extern "C" mirror::Object* art_quick_read_barrier_mark_reg08(mirror::Object*);
     48 extern "C" mirror::Object* art_quick_read_barrier_mark_reg09(mirror::Object*);
     49 extern "C" mirror::Object* art_quick_read_barrier_mark_reg10(mirror::Object*);
     50 extern "C" mirror::Object* art_quick_read_barrier_mark_reg11(mirror::Object*);
     51 extern "C" mirror::Object* art_quick_read_barrier_mark_reg12(mirror::Object*);
     52 extern "C" mirror::Object* art_quick_read_barrier_mark_reg13(mirror::Object*);
     53 extern "C" mirror::Object* art_quick_read_barrier_mark_reg14(mirror::Object*);
     54 extern "C" mirror::Object* art_quick_read_barrier_mark_reg15(mirror::Object*);
     55 extern "C" mirror::Object* art_quick_read_barrier_slow(mirror::Object*, mirror::Object*, uint32_t);
     56 extern "C" mirror::Object* art_quick_read_barrier_for_root_slow(GcRoot<mirror::Object>*);
     57 
     58 void UpdateReadBarrierEntrypoints(QuickEntryPoints* qpoints, bool is_active) {
     59   qpoints->pReadBarrierMarkReg00 = is_active ? art_quick_read_barrier_mark_reg00 : nullptr;
     60   qpoints->pReadBarrierMarkReg01 = is_active ? art_quick_read_barrier_mark_reg01 : nullptr;
     61   qpoints->pReadBarrierMarkReg02 = is_active ? art_quick_read_barrier_mark_reg02 : nullptr;
     62   qpoints->pReadBarrierMarkReg03 = is_active ? art_quick_read_barrier_mark_reg03 : nullptr;
     63   qpoints->pReadBarrierMarkReg05 = is_active ? art_quick_read_barrier_mark_reg05 : nullptr;
     64   qpoints->pReadBarrierMarkReg06 = is_active ? art_quick_read_barrier_mark_reg06 : nullptr;
     65   qpoints->pReadBarrierMarkReg07 = is_active ? art_quick_read_barrier_mark_reg07 : nullptr;
     66   qpoints->pReadBarrierMarkReg08 = is_active ? art_quick_read_barrier_mark_reg08 : nullptr;
     67   qpoints->pReadBarrierMarkReg09 = is_active ? art_quick_read_barrier_mark_reg09 : nullptr;
     68   qpoints->pReadBarrierMarkReg10 = is_active ? art_quick_read_barrier_mark_reg10 : nullptr;
     69   qpoints->pReadBarrierMarkReg11 = is_active ? art_quick_read_barrier_mark_reg11 : nullptr;
     70   qpoints->pReadBarrierMarkReg12 = is_active ? art_quick_read_barrier_mark_reg12 : nullptr;
     71   qpoints->pReadBarrierMarkReg13 = is_active ? art_quick_read_barrier_mark_reg13 : nullptr;
     72   qpoints->pReadBarrierMarkReg14 = is_active ? art_quick_read_barrier_mark_reg14 : nullptr;
     73   qpoints->pReadBarrierMarkReg15 = is_active ? art_quick_read_barrier_mark_reg15 : nullptr;
     74 }
     75 
     76 void InitEntryPoints(JniEntryPoints* jpoints, QuickEntryPoints* qpoints) {
     77 #if defined(__APPLE__)
     78   UNUSED(jpoints, qpoints);
     79   UNIMPLEMENTED(FATAL);
     80 #else
     81   DefaultInitEntryPoints(jpoints, qpoints);
     82 
     83   // Cast
     84   qpoints->pInstanceofNonTrivial = art_quick_instance_of;
     85   qpoints->pCheckInstanceOf = art_quick_check_instance_of;
     86 
     87   // More math.
     88   qpoints->pCos = cos;
     89   qpoints->pSin = sin;
     90   qpoints->pAcos = acos;
     91   qpoints->pAsin = asin;
     92   qpoints->pAtan = atan;
     93   qpoints->pAtan2 = atan2;
     94   qpoints->pCbrt = cbrt;
     95   qpoints->pCosh = cosh;
     96   qpoints->pExp = exp;
     97   qpoints->pExpm1 = expm1;
     98   qpoints->pHypot = hypot;
     99   qpoints->pLog = log;
    100   qpoints->pLog10 = log10;
    101   qpoints->pNextAfter = nextafter;
    102   qpoints->pSinh = sinh;
    103   qpoints->pTan = tan;
    104   qpoints->pTanh = tanh;
    105 
    106   // Math
    107   qpoints->pD2l = art_d2l;
    108   qpoints->pF2l = art_f2l;
    109   qpoints->pLdiv = art_quick_ldiv;
    110   qpoints->pLmod = art_quick_lmod;
    111   qpoints->pLmul = art_quick_lmul;
    112   qpoints->pShlLong = art_quick_lshl;
    113   qpoints->pShrLong = art_quick_lshr;
    114   qpoints->pUshrLong = art_quick_lushr;
    115 
    116   // Intrinsics
    117   qpoints->pStringCompareTo = art_quick_string_compareto;
    118   qpoints->pMemcpy = art_quick_memcpy;
    119 
    120   // Read barrier.
    121   qpoints->pReadBarrierJni = ReadBarrierJni;
    122   UpdateReadBarrierEntrypoints(qpoints, /*is_active*/ false);
    123   qpoints->pReadBarrierMarkReg04 = nullptr;  // Cannot use register 4 (RSP) to pass arguments.
    124   // x86-64 has only 16 core registers.
    125   qpoints->pReadBarrierMarkReg16 = nullptr;
    126   qpoints->pReadBarrierMarkReg17 = nullptr;
    127   qpoints->pReadBarrierMarkReg18 = nullptr;
    128   qpoints->pReadBarrierMarkReg19 = nullptr;
    129   qpoints->pReadBarrierMarkReg20 = nullptr;
    130   qpoints->pReadBarrierMarkReg21 = nullptr;
    131   qpoints->pReadBarrierMarkReg22 = nullptr;
    132   qpoints->pReadBarrierMarkReg23 = nullptr;
    133   qpoints->pReadBarrierMarkReg24 = nullptr;
    134   qpoints->pReadBarrierMarkReg25 = nullptr;
    135   qpoints->pReadBarrierMarkReg26 = nullptr;
    136   qpoints->pReadBarrierMarkReg27 = nullptr;
    137   qpoints->pReadBarrierMarkReg28 = nullptr;
    138   qpoints->pReadBarrierMarkReg29 = nullptr;
    139   qpoints->pReadBarrierSlow = art_quick_read_barrier_slow;
    140   qpoints->pReadBarrierForRootSlow = art_quick_read_barrier_for_root_slow;
    141 #endif  // __APPLE__
    142 };
    143 
    144 }  // namespace art
    145