mirror of
https://github.com/openharmony/ark_js_runtime.git
synced 2026-07-21 07:05:22 -04:00
fixed for rewrite patch id for runtime call
Signed-off-by: getingke <getingke@huawei.com> Change-Id: Ie4a76fb481a548d356450b79c55ed5d3c28b86b0
This commit is contained in:
@@ -30,6 +30,7 @@ InvokeJSFunctionEntry:
|
||||
// construct the frame
|
||||
mov w19, #0x1 // optimized entry frame type
|
||||
stp x19, x1, [sp, #-16]!
|
||||
str x1, [sp, #-8]! // callsiteSp
|
||||
|
||||
mov x29, sp
|
||||
mov w19, w2
|
||||
@@ -67,6 +68,7 @@ InvokeJSFunctionEntry:
|
||||
add w19, w19, #2 // 2: prevFp and frameType
|
||||
lsl w8, w19, #3
|
||||
add sp, sp, x8
|
||||
add sp, sp, #8 // callsiteSp
|
||||
|
||||
ldr x19, [sp, #16]
|
||||
ldp x29, x30, [sp], #32
|
||||
@@ -86,7 +88,6 @@ InvokeJSFunctionEntry:
|
||||
// sp + 8: patch_id
|
||||
// sp: runtime_id
|
||||
|
||||
|
||||
// Output:
|
||||
// sp - 8 : x30
|
||||
// sp - 16: x29 <---------current x29 & current sp
|
||||
|
||||
@@ -29,9 +29,11 @@ InvokeJSFunctionEntry:
|
||||
pushq %rbp
|
||||
movq %rsp, %rbp // set frame pointer
|
||||
pushq $1 // optimized entry frame type
|
||||
pushq $1 // callsite sp
|
||||
pushq %rsi // prev managed fp
|
||||
|
||||
// callee save
|
||||
pushq %rax
|
||||
pushq %rbx
|
||||
pushq %rdi
|
||||
|
||||
@@ -69,62 +71,62 @@ InvokeJSFunctionEntry:
|
||||
|
||||
popq %rdi // callee restore
|
||||
popq %rbx
|
||||
addq $8, %rsp
|
||||
|
||||
popq %rsi // pop rsi
|
||||
popq %rbp // skip frame type
|
||||
addq $16, %rsp
|
||||
popq %rbp
|
||||
|
||||
// movq %rsi, 2056(%rdi) // restore thread->leaveFp
|
||||
movq %rsi, 2056(%rdi) // restore thread->leaveFp
|
||||
ret
|
||||
|
||||
// uint64_t CallRuntimeTrampoline(uintptr_t glue, uint64_t runtime_id, uint64_t patch_id, uint32_t argc, ...);
|
||||
// webkit_jscc calling convention
|
||||
// %rax - glue
|
||||
// rbp - runtime_id
|
||||
// rbp + 8 - patch_id
|
||||
// rbp + 16 - argc
|
||||
// rbp + 24 - arg0
|
||||
|
||||
// current sp - 8: type ^
|
||||
// current sp - 16: patchId |
|
||||
// current sp - 24: callsiteSp leave frame
|
||||
// V
|
||||
// rsp + 24 - arg0
|
||||
// rsp + 16 - argc
|
||||
// rsp + 8 - patch_id
|
||||
// rsp - runtime_id
|
||||
// return address
|
||||
// rbp
|
||||
// rbp - 8: type ^
|
||||
// rbp - 16: patchId |
|
||||
// rbp - 24: callsiteSp leave frame
|
||||
// V
|
||||
.global CallRuntimeTrampoline
|
||||
.type CallRuntimeTrampoline, %function
|
||||
CallRuntimeTrampoline:
|
||||
pushq %rbp
|
||||
movq %rsp, %rbp // set frame pointer
|
||||
// movq %rbp, 2056(%rax) // save to thread->leaveFp
|
||||
movq %rbp, 2056(%rax) // save to thread->leaveFp
|
||||
pushq $3 // leave frame type
|
||||
subq $24, %rsp // increase the leave frame size
|
||||
subq $16, %rsp // increase the leave frame size
|
||||
|
||||
// callee save
|
||||
pushq %r10
|
||||
pushq %r11
|
||||
pushq %rdx
|
||||
pushq %rax
|
||||
|
||||
// construct leave frame
|
||||
movq %rsp, %r10
|
||||
addq $24, %r10 // 24 : callee register size
|
||||
movq %rbp, %rdx
|
||||
addq $16, %rdx // 16 : for rbp & return address
|
||||
|
||||
movq 8(%rdx), %r11 // get patch pointer id
|
||||
movq %r11, (%r10) // save patch pointer id
|
||||
movq %rdx, 8(%r10) // save callsite sp
|
||||
movq 8(%rdx), %r10 // get patch pointer id
|
||||
movq %r10, 32(%rsp) // save patch pointer id
|
||||
movq %rdx, 24(%rsp) // save callsite sp
|
||||
|
||||
// load runtime trampoline address
|
||||
movq (%rdx), %r10 // runtime id
|
||||
movq 2072(%rax, %r10, 8), %r11
|
||||
movq 2072(%rax, %r10, 8), %r10
|
||||
movq %rax, %rdi // glue
|
||||
movl 16(%rdx), %esi // argc
|
||||
addq $24, %rdx // argV
|
||||
call *%r11
|
||||
call *%r10
|
||||
|
||||
addq $8, %rsp
|
||||
popq %rdx
|
||||
popq %r11
|
||||
popq %r10
|
||||
|
||||
addq $32, %rsp
|
||||
addq $24, %rsp
|
||||
popq %rbp
|
||||
ret
|
||||
@@ -173,7 +173,12 @@ void LLVMAssembler::RewritePatchPointIdOfStatePoint(LLVMValueRef instruction, ui
|
||||
attrName, sizeof(attrName) - 1, patchId.c_str(), patchId.size());
|
||||
LLVMAddCallSiteAttribute(instruction, LLVMAttributeFunctionIndex, attr);
|
||||
callInsNum++;
|
||||
RewritePatchPointIdStoredOnThread(instruction, id);
|
||||
if (LLVMWebKitJSCallConv == LLVMGetInstructionCallConv(instruction)) {
|
||||
// 2 : 2 means patch id arguments order
|
||||
LLVMSetOperand(instruction, 2, LLVMConstInt(LLVMInt64Type(), id, 0));
|
||||
} else {
|
||||
RewritePatchPointIdStoredOnThread(instruction, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -477,7 +477,7 @@ void LLVMIRBuilder::VisitRuntimeCall(GateRef gate, const std::vector<GateRef> &i
|
||||
int index = circuit_->GetBitField(inList[1]);
|
||||
params[1] = LLVMConstInt(LLVMInt64Type(), index - FAST_STUB_MAXCOUNT, 0);
|
||||
params[2] = LLVMConstInt(LLVMInt64Type(), 2882400000, 0); // 2882400000: default statepoint ID
|
||||
params[3] = LLVMConstInt(LLVMInt32Type(), inList.size() - paraStartIndex, 0);
|
||||
params[3] = LLVMConstInt(LLVMInt32Type(), inList.size() - paraStartIndex - 1, 0);
|
||||
for (size_t paraIdx = paraStartIndex; paraIdx < inList.size(); ++paraIdx) {
|
||||
GateRef gateTmp = inList[paraIdx];
|
||||
params[paraIdx + 1] = gateToLLVMMaps_[gateTmp];
|
||||
|
||||
Executable → Regular
+5
@@ -287,6 +287,11 @@ void OptimizedLeaveFrameHandler::Iterate(const RootVisitor &v0, const RootRangeV
|
||||
ChunkMap<DerivedDataKey, uintptr_t> *derivedPointers, bool isVerifying) const
|
||||
{
|
||||
OptLeaveFrame *frame = OptLeaveFrame::GetFrameFromSp(sp_);
|
||||
if (frame->argc > 0) {
|
||||
uintptr_t start = ToUintPtr(&frame->argc + 1);// argv
|
||||
uintptr_t end = ToUintPtr(&frame->argc + 1 + frame->argc);
|
||||
v1(Root::ROOT_FRAME, ObjectSlot(start), ObjectSlot(end));
|
||||
}
|
||||
std::set<uintptr_t> slotAddrs;
|
||||
bool ret = kungfu::LLVMStackMapParser::GetInstance().CollectStackMapSlots(
|
||||
frame, slotAddrs, derivedPointers, isVerifying);
|
||||
|
||||
Reference in New Issue
Block a user