blob: 854b13ed6dbf6487ce243e64dd7cd9db864e8dba [file] [log] [blame]
Ben Chengba4fc8b2009-06-01 13:00:29 -07001/*
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 * Jit control
18 */
19#ifndef _DALVIK_INTERP_JIT
20#define _DALVIK_INTERP_JIT
21
22#include "InterpDefs.h"
23
24#define JIT_PROF_SIZE 512
Ben Cheng1efc9c52009-06-08 18:25:27 -070025
26#define JIT_MAX_TRACE_LEN 100
27
Ben Chengba4fc8b2009-06-01 13:00:29 -070028/*
29 * JitTable hash function.
30 */
31static inline u4 dvmJitHash( const u2* p ) {
32 /*
33 * TODO - Might make sense to keep "maxTableEntries - 1" as its own
34 * variable for speed reasons.
35 */
36 return ((((u4)p>>12)^(u4)p)>>1) & (gDvmJit.maxTableEntries-1);
37}
38
39/*
40 * Entries in the JIT's address lookup hash table.
41 * with assembly hash function in mterp.
42 * TODO: rework this structure now that the profile counts have
43 * moved into their own table.
44 */
45typedef struct JitEntry {
46 u2 unused; /* was execution count */
47 u2 chain; /* Index of next in chain */
48 const u2* dPC; /* Dalvik code address */
49 void* codeAddress; /* Code address of native translation */
50} JitEntry;
51
52int dvmJitStartup(void);
53void dvmJitShutdown(void);
54int dvmCheckJit(const u2* pc, Thread* self, InterpState* interpState);
55void* dvmJitGetCodeAddr(const u2* dPC);
56void dvmJitSetCodeAddr(const u2* dPC, void *nPC);
57bool dvmJitCheckTraceRequest(Thread* self, InterpState* interpState);
58void* dvmJitChain(void* tgtAddr, u4* branchAddr);
59void dvmJitStopTranslationRequests();
60void dvmJitStats();
61
62#endif /*_DALVIK_INTERP_JIT*/