1/** 2 * Copyright (c) 2021-2024 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#include "asm_defines.h" 18#include "shorty_values.h" 19 20// void InterpreterToCompiledCodeBridgeDyn(const BytecodeInstruction* insn, const Frame *iframe, const void* entrypoint, ManagedThread* thread) 21.global InterpreterToCompiledCodeBridgeDyn 22.type InterpreterToCompiledCodeBridgeDyn, %function 23InterpreterToCompiledCodeBridgeDyn: 24 CFI_STARTPROC 25 CFI_DEF_CFA(sp, 0) 26 push {r1, lr} 27 CFI_ADJUST_CFA_OFFSET(8) 28 CFI_REL_OFFSET(lr, 4) 29 30 sub sp, sp, #12 31 CFI_ADJUST_CFA_OFFSET(12) 32 33 stm sp, {THREAD_REG, fp} 34 CFI_REL_OFFSET(fp, 4) 35 CFI_REL_OFFSET(THREAD_REG, 0) 36 37 add fp, sp, #12 38 CFI_DEF_CFA_REGISTER(fp) 39 CFI_ADJUST_CFA_OFFSET(-12) 40 41 mov THREAD_REG, r3 42 mov r3, #INTERPRETER_TO_COMPILED_CODE_BRIDGE 43 str r3, [sp, #8] 44 push {r4, r5, r6, r7, r8} 45 // sp must be 8 byte aligned 46 CFI_REL_OFFSET(r8, -((3 + 1) * 4)) 47 CFI_REL_OFFSET(r7, -((3 + 2) * 4)) 48 CFI_REL_OFFSET(r6, -((3 + 3) * 4)) 49 CFI_REL_OFFSET(r5, -((3 + 4) * 4)) 50 CFI_REL_OFFSET(r4, -((3 + 5) * 4)) 51 52 // setup regs as follow 53 // r0 - acc, r1 - num args, r2-r3 - function object as int64_t 54 // r4 - insn, r5 - iframe.vregs, r6, r7, r8 - temp, lr - entrypoint 55 mov r4, r0 56 add r5, r1, #FRAME_VREGS_OFFSET 57 mov lr, r2 58 ldr r0, [r1, #FRAME_ACC_OFFSET] 59 60 ldrb r6, [r4], #1 // read opcode and advance insn_ptr 61 62 // The file contains code which checks opcode and jumps 63 // to the corresponding handler. 64 // At the end each handler jumps to .Linvoke_from_bridge label. 65 // The file is autogenerated from runtime/templates/bridge_dispatch.S.erb 66 // Handlers are distinguished by format and located in the corresponding files with name: 67 // handle_call_<format>.S 68 // If you get a compilation error that there is no such file it seems 69 // new call format was introduced and you have to implement the corresponding handler. 70#include "bridge_dispatch_dyn_arm.S" 71 72.Linvoke: 73 blx lr 74 75 // Signal handler of the sampling profiler use stack space below sp, 76 // so change it carefully only after registers restoration 77 sub sp, fp, #32 78 pop {r4, r5, r6, r7, r8, THREAD_REG, fp} 79 CFI_RESTORE(r4) 80 CFI_RESTORE(r5) 81 CFI_RESTORE(r6) 82 CFI_RESTORE(r7) 83 CFI_RESTORE(r8) 84 CFI_RESTORE(THREAD_REG) 85 CFI_RESTORE(r11) 86 CFI_DEF_CFA(sp, 12) 87 ldr lr, [sp, #8] 88 CFI_RESTORE(lr) 89 add sp, sp, #12 90 CFI_ADJUST_CFA_OFFSET(-12) 91 bx lr 92 CFI_ENDPROC 93 94 95 96// void InvokeCompiledCodeWithArgArrayDyn( 97// const coretypes::TaggedValue* values, x0 98// uint32_t num_args, x1 99// const Frame *iframe, x2 100// const Method*, x3 101// ManagedThread* thread) x4 102.global InvokeCompiledCodeWithArgArrayDyn 103.type InvokeCompiledCodeWithArgArrayDyn, %function 104InvokeCompiledCodeWithArgArrayDyn: 105 // TODO(audovichenko): Implement the function 106 bx lr 107