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_APUT_OBJECT.S 18 * 19 * Code: 32-bit array put operation. Provides an "scale" variable 20 * specify a scale value which depends on the width of the array 21 * elements. Provides a "mov" variable which determines the type of 22 * mov performed also dependent on the type of the array element. 23 * Provides a "value" register to specify the source of the mov 24 * 25 * For: aput-boolean, aput-byte, aput-char, aput-object, aput-short 26 * 27 * Description: Perform an array put operation from the value register; 28 * store the value register at the identified index of a 29 * given array. vBB[vCC] <- vAA 30 * 31 * Format: AA|op CC|BB (23x) 32 * 33 * Syntax: op vAA, vBB, vCC 34 */ 35 36 FETCH_BB 1, %eax # %eax<- BB 37 FETCH_CC 1, %edx # %edx<- CC 38 GET_VREG %eax # %eax<- vBB 39 GET_VREG %edx # %edx<- vCC 40 cmp $$0, %eax # check for null array object 41 je common_errNullObject # handle null array object 42 cmp offArrayObject_length(%eax), %edx # compare index to arrayObj->length 43 jnc common_errArrayIndex # handle index >= length, bail 44 GET_VREG rINST # rINST<- vAA 45 lea (%eax, %edx, 4), %edx # %edx<- &vBB[vCC] 46 cmp $$0, rINST # check for null reference 47 je .L${opcode}_skip_check # reference is null so skip type check 48 jmp .L${opcode}_finish 49 %break 50 51 .L${opcode}_finish: 52 movl %edx, sReg0 # save &vBB[vCC] 53 movl %eax, sReg1 # save object head 54 movl offObject_clazz(rINST), %edx # %edx<- obj->clazz 55 movl %edx, -8(%esp) # push parameter obj->clazz 56 movl offObject_clazz(%eax), %eax # %eax<- arrayObj->clazz 57 movl %eax, -4(%esp) # push parameter arrayObj->clazz 58 lea -8(%esp), %esp 59 call dvmCanPutArrayElement # test object type vs. array type 60 # call: ClassObject* elemClass, ClassObject* arrayClass) 61 # return: bool 62 lea 8(%esp), %esp 63 testl %eax, %eax # check for invalid array value 64 je common_errArrayStore # handle invalid array value 65 movl sReg0, %edx # restore &vBB[vCC] 66 movl rINST, offArrayObject_contents(%edx) 67 movl rGLUE, %eax 68 FFETCH_ADV 2, %ecx # %ecx<- next instruction hi; fetch, advance 69 movl offGlue_cardTable(%eax), %eax # get card table base 70 movl sReg1, %edx # restore object head 71 shrl $$GC_CARD_SHIFT, %edx # object head to card number 72 movb %al, (%eax, %edx) # mark card using object head 73 FGETOP_JMP 2, %ecx # jump to next instruction; getop, jmp 74 .L${opcode}_skip_check: 75 FFETCH_ADV 2, %eax # %eax<- next instruction hi; fetch, advance 76 movl rINST, offArrayObject_contents(%edx) 77 FGETOP_JMP 2, %eax # jump to next instruction; getop, jmp 78