2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * Dalvik interpreter public definitions.
20 #ifndef DALVIK_INTERP_INTERP_H_
21 #define DALVIK_INTERP_INTERP_H_
24 * Stash the dalvik PC in the frame. Called during interpretation.
26 INLINE void dvmExportPC(const u2* pc, const u4* fp)
28 SAVEAREA_FROM_FP(fp)->xtra.currentPc = pc;
32 * Extract the Dalvik opcode
34 #define GET_OPCODE(_inst) (_inst & 0xff)
37 * Interpreter entry point. Call here after setting up the interpreted
38 * stack (most code will want to get here via dvmCallMethod().)
40 void dvmInterpret(Thread* thread, const Method* method, JValue* pResult);
43 * Throw an exception for a problem detected by the verifier.
45 * This is called from the handler for the throw-verification-error
46 * instruction. "method" is the method currently being executed.
48 extern "C" void dvmThrowVerificationError(const Method* method,
52 * One-time initialization and shutdown.
54 bool dvmBreakpointStartup(void);
55 void dvmBreakpointShutdown(void);
56 void dvmInitInterpreterState(Thread* self);
59 * Breakpoint implementation.
61 void dvmInitBreakpoints();
62 void dvmAddBreakAddr(Method* method, unsigned int instrOffset);
63 void dvmClearBreakAddr(Method* method, unsigned int instrOffset);
64 bool dvmAddSingleStep(Thread* thread, int size, int depth);
65 void dvmClearSingleStep(Thread* thread);
68 * Recover the opcode that was replaced by a breakpoint.
70 extern "C" u1 dvmGetOriginalOpcode(const u2* addr);
73 * Flush any breakpoints associated with methods in "clazz".
75 void dvmFlushBreakpoints(ClassObject* clazz);
80 extern "C" void dvmCheckBefore(const u2 *dPC, u4 *fp, Thread* self);
81 extern "C" void dvmReportExceptionThrow(Thread* self, Object* exception);
82 extern "C" void dvmReportPreNativeInvoke(const Method* methodToCall, Thread* self, u4* fp);
83 extern "C" void dvmReportPostNativeInvoke(const Method* methodToCall, Thread* self, u4* fp);
84 extern "C" void dvmReportInvoke(Thread* self, const Method* methodToCall);
85 extern "C" void dvmReportReturn(Thread* self);
88 * InterpBreak & subMode control
90 void dvmDisableSubMode(Thread* thread, ExecutionSubModes subMode);
91 extern "C" void dvmEnableSubMode(Thread* thread, ExecutionSubModes subMode);
92 void dvmDisableAllSubMode(ExecutionSubModes subMode);
93 void dvmEnableAllSubMode(ExecutionSubModes subMode);
94 void dvmAddToSuspendCounts(Thread* thread, int delta, int dbgDelta);
95 void dvmCheckInterpStateConsistency();
96 void dvmInitializeInterpBreak(Thread* thread);
99 * Register a callback to occur at the next safe point for a single thread.
100 * If funct is NULL, the previous registration is cancelled.
102 * The callback prototype is:
103 * bool funct(Thread* thread, void* arg)
105 * If funct returns false, the callback will be disarmed. If true,
106 * it will stay in effect.
108 void dvmArmSafePointCallback(Thread* thread, SafePointCallback funct,
112 #ifndef DVM_NO_ASM_INTERP
113 extern void* dvmAsmInstructionStart[];
114 extern void* dvmAsmAltInstructionStart[];
117 #endif // DALVIK_INTERP_INTERP_H_