1 /* Copyright (C) 2008 The Android Open Source Project 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /* 17 * File: OP_INVOKE_DIRECT.S 18 * 19 * Code: Call a non-static direct method. Provides an "isrange" variable and 20 * a "routine" variable to specify this is the "range" version of 21 * invoke_direct that allows up to 255 arguments. 22 * 23 * For: invoke-direct, invoke-direct/range 24 * 25 * Description: invoke-direct is used to invoke a non-static direct method; 26 * an instance method that is non-overridable, for example, 27 * either a private instance method or a constructor. 28 * 29 * Format: B|A|op CCCC G|F|E|D (35c) 30 * AA|op BBBB CCCC (3rc) 31 * 32 * Syntax: [B=5] op {vD, vE, vF, vG, vA}, meth@CCCC (35c) 33 * [B=5] op {vD, vE, vF, vG, vA}, type@CCCC (35c) 34 * [B=4] op {vD, vE, vF, vG}, kind@CCCC (35c) 35 * [B=3] op {vD, vE, vF}, kind@CCCC (35c) 36 * [B=2] op {vD, vE}, kind@CCCC (35c) 37 * [B=1] op {vD}, kind@CCCC (35c) 38 * [B=0] op {}, kind@CCCC (35c) 39 * 40 * op {vCCCC .. vNNNN}, meth@BBBB (3rc) (where NNNN = CCCC+AA-1, that 41 * op {vCCCC .. vNNNN}, type@BBBB (3rc) is A determines the count 0..255, 42 * and C determines the first register) 43 */ 44 45 %default { "isrange":"0", "routine":"NoRange" } 46 47 movl rGLUE, %ecx # %ecx<- pMterpGlue 48 movl offGlue_methodClassDex(%ecx), %ecx # %ecx<- pDvmDex 49 FETCH 1, %eax # %eax<- method index 50 movl offDvmDex_pResMethods(%ecx), %ecx # %ecx<- pDvmDex->pResMethods 51 FETCH 2, %edx # %edx<- GFED or CCCC 52 movl (%ecx, %eax, 4), %ecx # %ecx<- resolved method to call 53 .if (!$isrange) 54 andl $$15, %edx # %edx<- D if not range 55 .endif 56 EXPORT_PC # must export for invoke 57 movl %edx, -4(%esp) # save "this" pointer register 58 cmp $$0, %ecx # check if already resolved 59 GET_VREG %edx # %edx<- "this" pointer 60 je .L${opcode}_resolve # handle resolve 61 62 .L${opcode}_finish: 63 cmp $$0, %edx # check for null "this" 64 jne common_invokeMethod${routine} # invoke method common code 65 jmp common_errNullObject 66 %break 67 68 /* 69 * %eax = reference (BBBB or CCCC) 70 * -4(%esp) = "this" register 71 */ 72 73 .L${opcode}_resolve: 74 movl rGLUE, %edx # %edx<- pMterpGlue 75 movl $$METHOD_DIRECT, -8(%esp) # push parameter method type 76 movl offGlue_method(%edx), %edx # %edx<- glue->method 77 movl %eax, -12(%esp) # push parameter reference 78 lea -16(%esp), %esp 79 movl offMethod_clazz(%edx), %edx # %edx<- glue->method->clazz 80 movl %edx, (%esp) # push parameter clazz 81 call dvmResolveMethod # call: (const ClassObject* referrer, 82 # u4 methodIdx, MethodType methodType) 83 # return: Method* 84 lea 16(%esp), %esp 85 cmp $$0, %eax # check for null method return 86 movl -4(%esp), %edx # get "this" pointer register 87 GET_VREG %edx # get "this" pointer 88 je common_exceptionThrown # null pointer; handle exception 89 cmp $$0, %edx # check for null "this" 90 movl %eax, %ecx # %ecx<- method 91 jne common_invokeMethod${routine} # invoke method common code 92 jmp common_errNullObject # handle null object