• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
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#include "arch/asm_support.h"
17
18// DecodedTaggedValue InvokeEntryPointImpl(const uint8_t* gprs, const uint8_t* fprs, const uint8_t* stack, size_t stack_size, ManagedThread* thread);
19.global InvokeHelper
20.type InvokeHelper, %function
21InvokeHelper:
22    CFI_STARTPROC
23    CFI_DEF_CFA(sp, 0)
24
25    // setup regs as follow
26    // x9 - gprs, x10 - fprs, x11 - stack args, x12 - number of stack args, x13 - thread
27    mov x9, x0
28    mov x10, x1
29    mov x11, x2
30    mov x12, x3
31    mov x13, x4
32
33    stp fp, lr, [sp, #-16]!
34    CFI_ADJUST_CFA_OFFSET(2 * 8)
35    CFI_REL_OFFSET(lr, 8)
36    CFI_REL_OFFSET(fp, 0)
37    mov fp, sp
38    CFI_DEF_CFA_REGISTER(fp)
39    str THREAD_REG, [sp, #-16]!
40    CFI_REL_OFFSET(THREAD_REG, -(2 * 8))
41    mov THREAD_REG, x13
42
43    ldp x0, x1, [x9], #16
44    ldp x2, x3, [x9], #16
45    ldp x4, x5, [x9], #16
46    ldp x6, x7, [x9], #16
47    ldp d0, d1, [x10], #16
48    ldp d2, d3, [x10], #16
49    ldp d4, d5, [x10], #16
50    ldp d6, d7, [x10], #16
51
52    sub sp, sp, x12, lsl #3
53    mov x14, sp
541:  cbz x12, .Linvoke
55    ldp x9, x10, [x11], #16
56    stp x9, x10, [x14], #16
57    sub x12, x12, #2
58    b 1b
59
60.Linvoke:
61    ldr lr, [x0, #METHOD_COMPILED_ENTRY_POINT_OFFSET]
62    blr lr
63
64    mov sp, fp
65    ldr THREAD_REG, [sp, #-16]
66    CFI_RESTORE(THREAD_REG)
67    ldp fp, lr, [sp], #16
68    CFI_RESTORE(lr)
69    CFI_RESTORE(fp)
70    CFI_DEF_CFA(sp, 0)
71    ret
72    CFI_ENDPROC
73