modify annotation of InterpretedFrame

Signed-off-by: guobingbing <guobingbing3@huawei.com>
Change-Id: I1deb88080eb89e27252629d8501005d49fe76adf
This commit is contained in:
guobingbing 2022-05-12 10:22:18 +08:00
parent 491482c043
commit a066f70986
7 changed files with 34 additions and 26 deletions

View File

@ -31,17 +31,17 @@
// |----------------------------------| |
// | newTarget [maybe not exist] | |
// |----------------------------------| |
// | callTarget [deleted] | |
// |----------------------------------| |
// | ...... | |
// |----------------------------------| |
// | Vregs [not exist in native] | |
// +----------------------------------+--------+ interpreter frame
// | base.frameType | ^ |
// |----------------------------------| | |
// | base.prev(pre stack pointer) | | |
// | base.prev(prev stack pointer) | | |
// |----------------------------------| | |
// | numActualArgs [deleted] | | |
// | pc(bytecode addr) | | |
// |----------------------------------| | |
// | sp(current stack pointer) | | |
// |----------------------------------| | |
// | env | | |
// |----------------------------------| | |
@ -49,13 +49,9 @@
// |----------------------------------|InterpretedFrame |
// | profileTypeInfo | | |
// |----------------------------------| | |
// | constantpool | | |
// | function | | |
// |----------------------------------| | |
// | method [changed to function] | | |
// |----------------------------------| | |
// | sp(current stack point) | | |
// |----------------------------------| | |
// | pc(bytecode addr) | v v
// | constpool | v v
// +----------------------------------+--------+----------+
// Optimized Leave Frame(alias OptimizedLeaveFrame) layout
@ -164,7 +160,11 @@
// +----------------------------------+--------+ foo's frame
// | base.frameType | ^ |
// |----------------------------------| | |
// | base.prev(pre stack pointer) | | |
// | base.prev(prev stack pointer) | | |
// |----------------------------------| | |
// | pc(bytecode addr) | | |
// +----------------------------------| | |
// | sp(current stack pointer) | | |
// |----------------------------------| | |
// | env | | |
// |----------------------------------| | |
@ -172,13 +172,9 @@
// |----------------------------------| | |
// | profileTypeInfo |InterpretedFrame |
// |----------------------------------| | |
// | constantpool | | |
// |----------------------------------| | |
// | function | | |
// |----------------------------------| | |
// | sp(current stack point) | | |
// |----------------------------------| | |
// | pc(bytecode addr) | v v
// | constpool | v v
// +----------------------------------+--------+----------+
// | ............. |
// +--------------------------+---------------------------+

View File

@ -203,7 +203,7 @@ JSTaggedValue FrameHandler::GetFunction() const
if (IsAsmInterpretedFrame()) {
auto *frame = AsmInterpretedFrame::GetFrameFromSp(sp_);
return frame->function;
} else {
} else {
auto *frame = BuiltinFrame::GetFrameFromSp(sp_);
return frame->function;
}
@ -316,10 +316,11 @@ ARK_INLINE void FrameHandler::InterpretedFrameIterate(const JSTaggedType *sp,
end = ToUintPtr(GetInterpretedEntryFrameStart(prevSp));
} else {
LOG_ECMA(FATAL) << "frame type error!";
UNREACHABLE();
}
v1(Root::ROOT_FRAME, ObjectSlot(start), ObjectSlot(end));
v0(Root::ROOT_FRAME, ObjectSlot(ToUintPtr(&frame->function)));
// pc == nullptr, init InterpretedFrame & native InterpretedFrame.
if (frame->pc != nullptr) {
v0(Root::ROOT_FRAME, ObjectSlot(ToUintPtr(&frame->acc)));
v0(Root::ROOT_FRAME, ObjectSlot(ToUintPtr(&frame->constpool)));

View File

@ -54,6 +54,8 @@ EcmaRuntimeCallInfo EcmaInterpreter::NewRuntimeCallInfo(
}
#endif
} else {
ASSERT(FrameHandler::GetFrameType(sp) == FrameType::INTERPRETER_FRAME ||
FrameHandler::GetFrameType(sp) == FrameType::INTERPRETER_FAST_NEW_FRAME);
newSp = sp - InterpretedFrame::NumOfMembers(); // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
}
if (UNLIKELY(thread->DoStackOverflowCheck(newSp - numArgs - RESERVED_CALL_ARGCOUNT))) {

View File

@ -256,15 +256,15 @@ JSTaggedValue JSFunction::Call(EcmaRuntimeCallInfo *info)
JSThread *thread = info->GetThread();
// 1. ReturnIfAbrupt(F).
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
JSHandle<JSTaggedValue> funcValue = info->GetFunction();
JSHandle<JSTaggedValue> func = info->GetFunction();
// 2. If argumentsList was not passed, let argumentsList be a new empty List.
// 3. If IsCallable(F) is false, throw a TypeError exception.
if (!funcValue->IsCallable()) {
if (!func->IsCallable()) {
THROW_TYPE_ERROR_AND_RETURN(thread, "Callable is false", JSTaggedValue::Exception());
}
JSHandle<JSFunction> func = JSHandle<JSFunction>::Cast(funcValue);
if (!func->IsBuiltinsConstructor() && func->IsClassConstructor()) {
auto *hclass = func->GetTaggedObject()->GetClass();
if (!hclass->IsBuiltinsCtor() && hclass->IsClassConstructor()) {
THROW_TYPE_ERROR_AND_RETURN(thread, "class constructor cannot call", JSTaggedValue::Exception());
}
return EcmaInterpreter::Execute(info);

View File

@ -712,7 +712,6 @@ JSTaggedValue JSObject::GetProperty(JSThread *thread, ObjectOperator *op)
JSHandle<JSTaggedValue> holder = op->GetHolder();
if (holder->IsJSProxy()) {
if (op->IsElement()) {
JSHandle<JSTaggedValue> key(thread, JSTaggedValue(op->GetElementIndex()));
return JSProxy::GetProperty(thread, JSHandle<JSProxy>::Cast(holder), op->GetKey(), receiver)
.GetValue()
.GetTaggedValue();

View File

@ -704,7 +704,8 @@ JSHandle<JSObject> ObjectFactory::NewJSError(const ErrorType &errorType, const J
return obj;
}
// current frame may be entry frame, in this case sp = the prev frame (interpreter frame).
// current frame may be entry frame, exception happened in JSFunction::Call and JSFunction::Construct,
// in this case sp = the prev frame (interpreter frame).
FrameHandler frameHandler(thread_);
if (frameHandler.IsInterpretedEntryFrame()) {
thread_->SetCurrentSPFrame(frameHandler.GetPrevInterpretedFrame());

View File

@ -57,5 +57,14 @@ print(result2);
const result3 = addThirtySeven(5, 10); // 37 + 5 = 42, (the second argument is ignored)
print(result3);
// TestCase: builtins bind function.
function foo(a, b) {
return a + b;
}
var bfoo = foo.bind(undefined, 1);
bfoo(2);
var array = [1];
array.forEach(bfoo);