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_SUPER.S 18 * 19 * Code: Call super method. 20 * 21 * For: invoke-super, invoke-super/range 22 * 23 * Description: invoke-super is used to invoke the closest superclass's virtual 24 * method (as opposed to the one with the same method_id in the 25 * calling class). 26 * 27 * Format: B|A|op CCCC G|F|E|D (35c) 28 * AA|op BBBB CCCC (3rc) 29 * 30 * Syntax: [B=5] op {vD, vE, vF, vG, vA}, meth@CCCC (35c) 31 * [B=5] op {vD, vE, vF, vG, vA}, type@CCCC (35c) 32 * [B=4] op {vD, vE, vF, vG}, kind@CCCC (35c) 33 * [B=3] op {vD, vE, vF}, kind@CCCC (35c) 34 * [B=2] op {vD, vE}, kind@CCCC (35c) 35 * [B=1] op {vD}, kind@CCCC (35c) 36 * [B=0] op {}, kind@CCCC (35c) 37 * 38 * op {vCCCC .. vNNNN}, meth@BBBB (3rc) (where NNNN = CCCC+AA-1, that 39 * op {vCCCC .. vNNNN}, type@BBBB (3rc) is A determines the count 0..255, 40 * and C determines the first register) 41 */ 42 43%default { "isrange":"0", "routine":"NoRange" } 44 45 movl rGLUE, %ecx # %ecx<- pMterpGlue 46 FETCH 2, %eax # %eax<- GFED or CCCC 47 movl offGlue_methodClassDex(%ecx), %ecx # %ecx<- pDvmDex 48 .if (!$isrange) 49 and $$15, %eax # %eax<- D if not range 50 .endif 51 FETCH 1, %edx # %edx<- method index 52 movl offDvmDex_pResMethods(%ecx), %ecx # %ecx<- pDvmDex->pResMethods 53 cmp $$0, (rFP, %eax, 4) # check for null object 54 movl (%ecx, %edx, 4), %ecx # %ecx<- resolved base method 55 je common_errNullObject # handle null object 56 jmp .L${opcode}_continue2 57%break 58 59.L${opcode}_continue2: 60 movl rGLUE, %eax # %eax<- pMterpGlue 61 movl offGlue_method(%eax), %eax # %eax<- glue->method 62 movl offMethod_clazz(%eax), %eax # %eax<- glue->method->clazz 63 EXPORT_PC # must export for invoke 64 cmp $$0, %ecx # check if already resolved 65 jne .L${opcode}_continue 66 jmp .L${opcode}_resolve # handle resolve 67 68 /* 69 * %ecx = resolved base method 70 * %eax = method->clazz 71 */ 72 73.L${opcode}_continue: 74 movl offClassObject_super(%eax), %edx # %edx<- glue->method->clazz->super 75 movzwl offMethod_methodIndex(%ecx), %ecx # %ecx<- baseMethod->methodIndex 76 cmp offClassObject_vtableCount(%edx), %ecx # compare vtableCount with methodIndex 77 EXPORT_PC # must export for invoke 78 jnc .L${opcode}_nsm # handle method not present 79 movl offClassObject_vtable(%edx), %edx # %edx<- glue->method->clazz->super->vtable 80 movl (%edx, %ecx, 4), %ecx # %ecx<- vtable[methodIndex] 81 jmp common_invokeMethod${routine} # invoke method common code 82 83.L${opcode}_resolve: 84 movl %eax, -12(%esp) # push parameter clazz 85 movl %edx, -8(%esp) # push parameter method index 86 movl $$METHOD_VIRTUAL, -4(%esp) # push parameter method type 87 lea -12(%esp), %esp 88 call dvmResolveMethod # call: (const ClassObject* referrer, 89 # u4 methodIdx, MethodType methodType) 90 # return: Method* 91 lea 12(%esp), %esp 92 movl %eax, %ecx # %ecx<- method 93 cmp $$0, %ecx # check for null method return 94 movl -12(%esp), %eax # %eax<- glue->method->clazz 95 jne .L${opcode}_continue 96 jmp common_exceptionThrown # null pointer; handle exception 97 98 /* 99 * Throw a NoSuchMethodError with the method name as the message. 100 * %ecx = resolved base method 101 */ 102 103.L${opcode}_nsm: 104 movl offMethod_name(%ecx), %edx # %edx<- method name 105 jmp common_errNoSuchMethod 106