1a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham 2a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham/* 3a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * Copyright (C) 2008 The Android Open Source Project 4a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * 5a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * Licensed under the Apache License, Version 2.0 (the "License"); 6a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * you may not use this file except in compliance with the License. 7a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * You may obtain a copy of the License at 8a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * 9a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * http://www.apache.org/licenses/LICENSE-2.0 10a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * 11a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * Unless required by applicable law or agreed to in writing, software 12a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * distributed under the License is distributed on an "AS IS" BASIS, 13a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * See the License for the specific language governing permissions and 15a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * limitations under the License. 16a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham */ 17a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham/* 18a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * Interpreter entry point. 19a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham */ 20a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham 21a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham#define ASSIST_DEBUGGER 1 22a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham 23a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham .text 24a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham .align 2 25a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham .global dvmMterpStdRun 26a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham .ent dvmMterpStdRun 27a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham .frame sp, STACK_SIZE, ra 28a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham/* 29a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * On entry: 30a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * r0 Thread* self 31a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * 32a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * The return comes via a call to dvmMterpStdBail(). 33a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham */ 34a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham 35a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu GandhamdvmMterpStdRun: 36a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham .set noreorder 37a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham .cpload t9 38a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham .set reorder 39a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham/* Save to the stack. Frame size = STACK_SIZE */ 40a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham STACK_STORE_FULL() 41a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham/* This directive will make sure all subsequent jal restore gp at a known offset */ 42a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham .cprestore STACK_OFFSET_GP 43a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham 44a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham addu fp, sp, STACK_SIZE # Move Frame Pointer to the base of frame 45a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham /* save stack pointer, add magic word for debuggerd */ 46a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham sw sp, offThread_bailPtr(a0) # Save SP 47a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham 48a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham /* set up "named" registers, figure out entry point */ 49a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham move rSELF, a0 # set rSELF 50a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham LOAD_PC_FROM_SELF() 51a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham LOAD_FP_FROM_SELF() 52a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham lw rIBASE, offThread_curHandlerTable(rSELF) 53a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham 54a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham#if defined(WITH_JIT) 55a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham.LentryInstr: 56a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham /* Entry is always a possible trace start */ 57a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham lw a0, offThread_pJitProfTable(rSELF) 58a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham FETCH_INST() # load rINST from rPC 59a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham sw zero, offThread_inJitCodeCache(rSELF) 60a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham#if !defined(WITH_SELF_VERIFICATION) 61a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham bnez a0, common_updateProfile # profiling is enabled 62a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham#else 63a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham lw a2, offThread_shadowSpace(rSELF) # to find out the jit exit state 64a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham beqz a0, 1f # profiling is disabled 65a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham lw a3, offShadowSpace_jitExitState(a2) # jit exit state 66a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham li t0, kSVSTraceSelect 67a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham bne a3, t0, 2f 68a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham li a2, kJitTSelectRequestHot # ask for trace selection 69a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham b common_selectTrace # go build the trace 70a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham2: 71a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham li a4, kSVSNoProfile 72a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham beq a3, a4, 1f # don't profile the next instruction? 73a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham b common_updateProfile # collect profiles 74a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham#endif 75a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham1: 76a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham GET_INST_OPCODE(t0) # extract opcode from rINST 77a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham GOTO_OPCODE(t0) # jump to next instruction 78a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham#else 79a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham /* start executing the instruction at rPC */ 80a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham FETCH_INST() # load rINST from rPC 81a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham GET_INST_OPCODE(t0) # extract opcode from rINST 82a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham GOTO_OPCODE(t0) # jump to next instruction 83a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham#endif 84a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham 85a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham.Lbad_arg: 86a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham la a0, .LstrBadEntryPoint 87a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham #a1 holds value of entryPoint 88a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham JAL(printf) 89a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham JAL(dvmAbort) 90a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham 91a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham .end dvmMterpStdRun 92a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham 93a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham .global dvmMterpStdBail 94a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham .ent dvmMterpStdBail 95a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham 96a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham/* Restore the stack pointer and all the registers stored at sp from the save 97a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * point established on entry. Return to whoever called dvmMterpStdRun. 98a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * 99a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * On entry: 100a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham * a0 Thread* self 101a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham */ 102a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu GandhamdvmMterpStdBail: 103a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham lw sp, offThread_bailPtr(a0) # Restore sp 104a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham STACK_LOAD_FULL() 105a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham jr ra 106a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham 107a8b91c52fd8a90b784835dfe1f8898035266c4ddRaghu Gandham .end dvmMterpStdBail 108