Home | History | Annotate | Download | only in x86-atom
      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_NEW_ARRAY.S
     18     *
     19     * Code: Create a new array. Uses no substitutions.
     20     *
     21     * For: new-array
     22     *
     23     * Description: Construct a new array of the indicated type and size.
     24     *              The type must be an array type.
     25     *
     26     * Format: B|A|op CCCC (22c)
     27     *
     28     * Syntax: op vA, vB, type@CCCC
     29     *         op vA, vB, field@CCCC
     30     */
     31 
     32     movl        rGLUE, %eax             # %eax<- pMterpGlue
     33     movl        rINST, %edx             # %edx<- BA
     34     shr         $$4, %edx               # %edx<- B
     35     movl        offGlue_methodClassDex(%eax), %eax # %eax<- glue->pDvmDex
     36     FETCH       1, %ecx                 # %ecx<- CCCC
     37     GET_VREG    %edx                    # %edx<- vB
     38     movl        offDvmDex_pResClasses(%eax), %eax # %eax<- glue->pDvmDex->pResClasses
     39     cmp         $$0, %edx               # check for negative length
     40     movl        (%eax, %ecx, 4), %eax   # %eax<- resolved class
     41     js          common_errNegativeArraySize # handle negative array length
     42     cmp         $$0, %eax               # check for null
     43     EXPORT_PC                           # required for resolve
     44     jne         .L${opcode}_finish      # already resovled so continue
     45     jmp         .L${opcode}_resolve     # need to resolve
     46 %break
     47 
     48    /*
     49     * Resolve class.  (This is an uncommon case.)
     50     *
     51     *  %edx holds array length
     52     *  %ecx holds class ref CCCC
     53     */
     54 
     55 .L${opcode}_resolve:
     56     movl        rGLUE, %eax             # %eax<- pMterpGlue
     57     movl        offGlue_method(%eax), %eax # %eax<- glue->method
     58     movl        %edx, -4(%esp)          # save length
     59     movl        $$0, -8(%esp)           # push parameter false
     60     movl        %ecx, -12(%esp)         # push parameter class ref
     61     movl        offMethod_clazz(%eax), %eax # %eax<- glue->method->clazz
     62     movl        %eax, -16(%esp)         # push parameter clazz
     63     lea         -16(%esp), %esp
     64     call        dvmResolveClass         # call: (const ClassObject* referrer,
     65                                         #       u4 classIdx, bool fromUnverifiedConstant)
     66                                         # return: ClassObject*
     67     cmp         $$0, %eax               # check for failure
     68     lea         16(%esp), %esp
     69     je          common_exceptionThrown  # handle exception
     70     movl        -4(%esp), %edx          # %edx<- length
     71 
     72    /*
     73     * Finish allocation.
     74     *
     75     *  %eax holds class
     76     *  %edx holds array length
     77     */
     78 
     79 .L${opcode}_finish:
     80     movl        %eax, -12(%esp)         # push parameter class
     81     movl        %edx, -8(%esp)          # push parameter length
     82     movl        $$ALLOC_DONT_TRACK, -4(%esp)
     83     lea         -12(%esp), %esp
     84     call        dvmAllocArrayByClass    # call: (ClassObject* arrayClass,
     85                                         # size_t length, int allocFlags)
     86                                         # return: ArrayObject*
     87     and         $$15, rINST             # rINST<- A
     88     cmp         $$0, %eax               # check for allocation failure
     89     lea         12(%esp), %esp
     90     je          common_exceptionThrown  # handle exception
     91     SET_VREG    %eax, rINST             # vA<- pArray
     92     FINISH      2                       # jump to next instruction
     93