• Home
  • Raw
  • Download

Lines Matching full:-

2  * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
7 * http://www.apache.org/licenses/LICENSE-2.0
22 #include "ecmascript/stubs/runtime_stubs-inl.h"
27 explicit FrameWriter(Deoptimizier *deoptimizier) : thread_(deoptimizier->GetThread()) in FrameWriter()
29 JSTaggedType *prevSp = const_cast<JSTaggedType *>(thread_->GetCurrentSPFrame()); in FrameWriter()
35 *(--top_) = value; in PushValue()
40 *(--top_) = value; in PushRawValue()
45 return !thread_->DoStackOverflowCheck(top_ - size); in Reserve()
77 ASSERT(index < static_cast<size_t>(start_ - top_)); in ReviseValueByIndex()
92 JSRuntimeOptions options = thread_->GetEcmaVM()->GetJSOptions(); in Deoptimizier()
136 // +--------------------------+ ---------------
140 // |--------------------------| |
142 // +--------------------------+ ---------------
144 // |--------------------------| |
146 // |--------------------------| OptimizedJSFunction FrameType:OPTIMIZED_JS_FUNCTIO…
148 // |--------------------------| |
149 // | call-target | |
150 // |--------------------------| |
152 // |--------------------------| |
154 // +--------------------------+ ---------------
156 // |--------------------------| |
158 // |--------------------------| __llvm_deoptimize FrameType:OPTIMIZED_FRAME
160 // |--------------------------| |
163 // +--------------------------+ ---------------
165 // |--------------------------| |
167 // |--------------------------| DeoptHandlerAsm FrameType:ASM_BRIDGE_FRAME
169 // |--------------------------| |
171 // |--------------------------| |
173 // +--------------------------+ ---------------
178 // |--------------------------| ---------------
182 // +----------------------------------+---------+
186 // |----------------------------------| |
188 // +----------------------------------+---------+
190 // |----------------------------------| |
192 // |----------------------------------| ASM_INTERPRETER_BRIDGE_FRAME
194 // |----------------------------------| |
196 // +----------------------------------+---------+
198 // |----------------------------------|
199 // | argv[n-1] |
200 // |----------------------------------|
202 // |----------------------------------|
204 // |----------------------------------|
206 // |----------------------------------|
208 // |----------------------------------|
210 // +----------------------------------+--------+
214 // |----------------------------------| |
216 // |----------------------------------| |
218 // |----------------------------------| AsmInterpretedFrame 0
220 // |----------------------------------| |
222 // |----------------------------------| |
224 // |----------------------------------| |
226 // |----------------------------------| |
227 // | call-target | v
228 // +----------------------------------+--------+
229 // | argv[n-1] |
230 // |----------------------------------|
232 // |----------------------------------|
234 // |----------------------------------|
236 // |----------------------------------|
238 // |----------------------------------|
240 // +----------------------------------+--------+
244 // |----------------------------------| |
246 // |----------------------------------| |
248 // |----------------------------------| AsmInterpretedFrame 1
250 // |----------------------------------| |
252 // |----------------------------------| |
254 // |----------------------------------| |
256 // |----------------------------------| |
257 // | call-target | v
258 // +----------------------------------+--------+
262 // +----------------------------------+--------+
268 frame->GetFuncCalleeRegAndOffset(it, calleeRegInfo); in AssistCollectDeoptBundleVec()
272 auto preFrameSp = frame->ComputePrevFrameSp(it); in AssistCollectDeoptBundleVec()
273 frameArgc_ = frame->GetArgc(preFrameSp); in AssistCollectDeoptBundleVec()
274 frameArgvs_ = frame->GetArgv(preFrameSp); in AssistCollectDeoptBundleVec()
276 stackContext_.returnAddr_ = frame->GetReturnAddr(); in AssistCollectDeoptBundleVec()
277 stackContext_.callerFp_ = reinterpret_cast<uintptr_t>(frame->GetPrevFrameFp()); in AssistCollectDeoptBundleVec()
282 JSTaggedType *lastLeave = const_cast<JSTaggedType *>(thread_->GetLastLeaveFrame()); in CollectDeoptBundleVec()
291 frame->GetDeoptBundleInfo(it, deoptBundle); in CollectDeoptBundleVec()
298 frame->GetDeoptBundleInfo(it, deoptBundle); in CollectDeoptBundleVec()
305 sp -= TYPE_GLUE_SLOT; in CollectDeoptBundleVec()
306 calleeRegAddr_ = sp - numCalleeRegs_; in CollectDeoptBundleVec()
325 Method *method = callTarget->GetCallTarget(); in GetMethod()
349 declaredNumArgs = static_cast<int32_t>(method->GetNumArgsWithCallField()); in CollectVirtualRegisters()
352 actualNumArgs = static_cast<int32_t>(method->GetNumArgsWithCallField()); in CollectVirtualRegisters()
353 declaredNumArgs = static_cast<int32_t>(method->GetNumArgsWithCallField()); in CollectVirtualRegisters()
356 int32_t callFieldNumVregs = static_cast<int32_t>(method->GetNumVregsWithCallField()); in CollectVirtualRegisters()
365 frameWriter->PushValue(value.GetRawData()); in CollectVirtualRegisters()
368 static_cast<int32_t>(method->GetNumRevervedArgs()) - 1; in CollectVirtualRegisters()
369 if (!frameWriter->Reserve(static_cast<size_t>(virtualIndex))) { in CollectVirtualRegisters()
372 for (int32_t i = static_cast<int32_t>(declaredNumArgs - 1); i >= 0; i--) { in CollectVirtualRegisters()
378 frameWriter->PushValue(value.GetRawData()); in CollectVirtualRegisters()
379 virtualIndex--; in CollectVirtualRegisters()
383 if (method->HaveThisWithCallField()) { in CollectVirtualRegisters()
386 frameWriter->PushValue(value.GetRawData()); in CollectVirtualRegisters()
387 virtualIndex--; in CollectVirtualRegisters()
389 if (method->HaveNewTargetWithCallField()) { in CollectVirtualRegisters()
392 frameWriter->PushValue(value.GetRawData()); in CollectVirtualRegisters()
393 virtualIndex--; in CollectVirtualRegisters()
395 if (method->HaveFuncWithCallField()) { in CollectVirtualRegisters()
398 frameWriter->PushValue(value.GetRawData()); in CollectVirtualRegisters()
399 virtualIndex--; in CollectVirtualRegisters()
403 for (int32_t i = virtualIndex; i >= 0; i--) { in CollectVirtualRegisters()
405 frameWriter->PushValue(value.GetRawData()); in CollectVirtualRegisters()
406 virtualIndex--; in CollectVirtualRegisters()
408 … // revise correct a0 - aN virtual regs , for example: ldobjbyname key; sta a2; update value to a2 in CollectVirtualRegisters()
409 // +--------------------------+ ^ in CollectVirtualRegisters()
411 // +--------------------------+ | in CollectVirtualRegisters()
413 // +--------------------------+ | in CollectVirtualRegisters()
415 // +--------------------------+ revise correct vreg in CollectVirtualRegisters()
417 // +--------------------------+ | in CollectVirtualRegisters()
419 // |--------------------------| v in CollectVirtualRegisters()
420 // | v0 - vN | in CollectVirtualRegisters()
421 // sp --> |--------------------------| in CollectVirtualRegisters()
423 static_cast<int32_t>(method->GetNumRevervedArgs()); in CollectVirtualRegisters()
428 frameWriter->ReviseValueByIndex(value.GetRawData(), i); in CollectVirtualRegisters()
436 if (thread_->IsPGOProfilerEnable()) { in Dump()
438 auto profileTypeInfo = function->GetProfileTypeInfo(); in Dump()
448 const uint8_t *pc = GetMethod(callTarget)->GetBytecodeArray() + pc_.at(depth); in Dump()
464 return "DeoptType-" + std::to_string(static_cast<uint8_t>(type)); in DisplayItems()
468 // |--------------------------| --------------> start(n)
474 // |---------------------------
476 // +--------------------------+ --------------> end(n)
477 // | outputcounts | outputcounts = end(n) - start(n)
478 // |--------------------------| --------------> start(n-1)
484 // |-------------------------------------------
486 // +--------------------------+ --------------> end(n-1)
487 // | outputcounts | outputcounts = end(n-1) - start(n-1)
488 // |--------------------------| --------------> start(n-1)
490 // +--------------------------+ ---------------
495 // |--------------------------| ---------------
501 for (int32_t curDepth = static_cast<int32_t>(inlineDepth_); curDepth >= 0; curDepth--) { in ConstructAsmInterpretFrame()
509 const uint8_t *resumePc = method->GetBytecodeArray() + pc_.at(curDepth); in ConstructAsmInterpretFrame()
512 statePtr->function = callTarget; in ConstructAsmInterpretFrame()
513 statePtr->acc = acc; in ConstructAsmInterpretFrame()
514 statePtr->env = GetDeoptValue(curDepth, static_cast<int32_t>(SpecVregIndex::ENV_INDEX)); in ConstructAsmInterpretFrame()
515 statePtr->callSize = GetCallSize(curDepth, resumePc); in ConstructAsmInterpretFrame()
516 statePtr->fp = 0; // need update in ConstructAsmInterpretFrame()
517 statePtr->thisObj = thisObj; in ConstructAsmInterpretFrame()
518 statePtr->pc = resumePc; in ConstructAsmInterpretFrame()
519 // -uintptr_t skip lr in ConstructAsmInterpretFrame()
521 …statePtr->base.prev = reinterpret_cast<JSTaggedType *>(stackContext_.callFrameTop_ - sizeof(uintpt… in ConstructAsmInterpretFrame()
523 statePtr->base.prev = 0; // need update in ConstructAsmInterpretFrame()
526 statePtr->base.type = FrameType::ASM_INTERPRETER_FRAME; in ConstructAsmInterpretFrame()
530 auto outputCount = start - end; in ConstructAsmInterpretFrame()
545 if (jsFunc->GetMachineCode().IsMachineCodeObject()) { in ResetJitHotness()
546 JSTaggedValue profileTypeInfoVal = jsFunc->GetProfileTypeInfo(); in ResetJitHotness()
549 profileTypeInfo->SetJitHotnessCnt(0); in ResetJitHotness()
552 uint16_t threshold = profileTypeInfo->GetJitHotnessThreshold(); in ResetJitHotness()
554 profileTypeInfo->SetJitHotnessThreshold(threshold); in ResetJitHotness()
555 …ProfileTypeInfoCell::Cast(jsFunc->GetRawProfileTypeInfo())->SetMachineCode(thread_, JSTaggedValue:… in ResetJitHotness()
556 Method *method = Method::Cast(jsFunc->GetMethod().GetTaggedObject()); in ResetJitHotness()
557 …LOG_JIT(DEBUG) << "reset jit hotness for func: " << method->GetMethodName() << ", threshold:" << t… in ResetJitHotness()
564 if (func->GetMachineCode().IsMachineCodeObject()) { in ClearCompiledCodeStatusWhenDeopt()
565 Jit::GetInstance()->GetJitDfx()->SetJitDeoptCount(); in ClearCompiledCodeStatusWhenDeopt()
567 if (func->IsCompiledCode()) { in ClearCompiledCodeStatusWhenDeopt()
568 bool isFastCall = func->IsCompiledFastCall(); // get this flag before clear it in ClearCompiledCodeStatusWhenDeopt()
570 … isFastCall ? thread_->GetRTInterface(kungfu::RuntimeStubCSigns::ID_FastCallToAsmInterBridge) in ClearCompiledCodeStatusWhenDeopt()
571 … : thread_->GetRTInterface(kungfu::RuntimeStubCSigns::ID_AOTCallToAsmInterBridge); in ClearCompiledCodeStatusWhenDeopt()
572 func->SetCodeEntry(entry); in ClearCompiledCodeStatusWhenDeopt()
573 method->ClearAOTStatusWhenDeopt(entry); in ClearCompiledCodeStatusWhenDeopt()
574 func->ClearCompiledCodeFlags(); in ClearCompiledCodeStatusWhenDeopt()
585 if (func->GetMachineCode().IsMachineCodeObject()) { in UpdateAndDumpDeoptInfo()
586 MachineCode *machineCode = MachineCode::Cast(func->GetMachineCode().GetTaggedObject()); in UpdateAndDumpDeoptInfo()
588 machineCode->GetOSROffset() != MachineCode::INVALID_OSR_OFFSET) { in UpdateAndDumpDeoptInfo()
589 machineCode->SetOsrDeoptFlag(true); in UpdateAndDumpDeoptInfo()
597 uint8_t deoptThreshold = method->GetDeoptThreshold(); in UpdateAndDumpDeoptInfo()
599 method->SetDeoptType(type); in UpdateAndDumpDeoptInfo()
600 method->SetDeoptThreshold(--deoptThreshold); in UpdateAndDumpDeoptInfo()
623 return -((-index << shift) | depth); in EncodeDeoptVregIndex()
640 return -((-id) >> shift); in DecodeVregIndex()
645 size_t mask = (1 << shift) - 1; in DecodeDeoptDepth()
649 return (-id) & mask; in DecodeDeoptDepth()