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_AGET.S 18 * 19 * Code: Generic 32-bit array "get" operation. Provides a "scale" variable 20 * to 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 * 24 * For: aget, aget-boolean, aget-byte, aget-char, aget-object, sget, aget-short 25 * 26 * Description: Perform an array get operation at the identified index 27 * of a given array; load the array value into the value 28 * register. vAA <- vBB[vCC]. 29 * 30 * Format: AA|op CC|BB (23x) 31 * 32 * Syntax: op vAA, vBB, vCC 33 */ 34 35%default { "mov":"l","scale":"4"} 36 37 FETCH_BB 1, %ecx # %ecx<- BB 38 FETCH_CC 1, %edx # %edx<- CC 39 GET_VREG %ecx # %ecx<- vBB 40 GET_VREG %edx # %edx<- vCC 41 cmp $$0, %ecx # check for null array object 42 je common_errNullObject # handle null array object 43 cmp offArrayObject_length(%ecx), %edx # compare index to arrayObj->length 44 jnc common_errArrayIndex # handle index >= length, bail 45 lea (%ecx, %edx, $scale), %ecx # %ecx<- &vBB[vCC] 46 # trying: lea (%ecx, %edx, scale), %ecx 47 # to reduce code size 48 FFETCH_ADV 2, %eax # %eax<- next instruction hi; fetch, advance 49 mov$mov offArrayObject_contents(%ecx), %edx # %edx<- vBB[vCC] 50 # doing this and the previous instr 51 # with one instr was not faster 52 SET_VREG %edx rINST # vAA<- %edx; value 53 FGETOP_JMP 2, %eax # jump to next instruction; getop, jmp