From 451b9a7be7ea13cd9208a3166440acd113136f82 Mon Sep 17 00:00:00 2001 From: Ishin Pavel Date: Tue, 25 Oct 2022 11:49:49 +0300 Subject: [PATCH] Check on Exception after call Signed-off-by: Ishin Pavel --- runtime/builtins/builtins_array.cpp | 6 +++--- runtime/builtins/builtins_typedarray.cpp | 2 +- runtime/js_proxy.cpp | 25 ++++++++++++------------ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/runtime/builtins/builtins_array.cpp b/runtime/builtins/builtins_array.cpp index e3bdb9ee5..c57ac6c20 100644 --- a/runtime/builtins/builtins_array.cpp +++ b/runtime/builtins/builtins_array.cpp @@ -1026,8 +1026,8 @@ JSTaggedValue BuiltinsArray::Filter(EcmaRuntimeCallInfo *argv) arguments->MakeArgv(kValue, key, thisObjVal); JSTaggedValue callResult = JSFunction::Call(thread, callbackFnHandle, thisArgHandle, 3, arguments->GetArgv()); // 3: three args - bool boolResult = callResult.ToBoolean(); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); + bool boolResult = callResult.ToBoolean(); if (boolResult) { toIndexHandle.Update(JSTaggedValue(toIndex)); JSObject::CreateDataPropertyOrThrow(thread, newArrayHandle, toIndexHandle, kValue); @@ -1150,8 +1150,8 @@ JSTaggedValue BuiltinsArray::FindIndex(EcmaRuntimeCallInfo *argv) arguments->MakeArgv(kValue, key, thisObjVal); JSTaggedValue callResult = JSFunction::Call(thread, callbackFnHandle, thisArgHandle, 3, arguments->GetArgv()); // 3: three args - bool boolResult = callResult.ToBoolean(); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); + bool boolResult = callResult.ToBoolean(); if (boolResult) { return GetTaggedDouble(k); } @@ -2322,8 +2322,8 @@ JSTaggedValue BuiltinsArray::Some(EcmaRuntimeCallInfo *argv) arguments->MakeArgv(kValue, key, thisObjVal); JSTaggedValue callResult = JSFunction::Call(thread, callbackFnHandle, thisArgHandle, 3, arguments->GetArgv()); // 3: three args - bool boolResult = callResult.ToBoolean(); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); + bool boolResult = callResult.ToBoolean(); if (boolResult) { return GetTaggedBoolean(true); } diff --git a/runtime/builtins/builtins_typedarray.cpp b/runtime/builtins/builtins_typedarray.cpp index 8479cf25b..e0bde4cc7 100644 --- a/runtime/builtins/builtins_typedarray.cpp +++ b/runtime/builtins/builtins_typedarray.cpp @@ -569,8 +569,8 @@ JSTaggedValue BuiltinsTypedArray::Filter(EcmaRuntimeCallInfo *argv) arguments->MakeArgv(kValue, tKey, thisHandle); JSTaggedValue callResult = JSFunction::Call(thread, callbackFnHandle, thisArgHandle, 3, arguments->GetArgv()); // 3: three args - bool testResult = callResult.ToBoolean(); RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread); + bool testResult = callResult.ToBoolean(); if (testResult) { kept->Set(thread, captured, kValue); captured++; diff --git a/runtime/js_proxy.cpp b/runtime/js_proxy.cpp index f70d83b25..9b48817a4 100644 --- a/runtime/js_proxy.cpp +++ b/runtime/js_proxy.cpp @@ -143,6 +143,7 @@ bool JSProxy::SetPrototype(JSThread *thread, const JSHandle &proxy, con // 9. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target, V»)). // If booleanTrapResult is false, return false + RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false); bool booleanTrapResult = trapResult.ToBoolean(); if (!booleanTrapResult) { return false; @@ -198,11 +199,11 @@ bool JSProxy::IsExtensible(JSThread *thread, const JSHandle &proxy) InternalCallParams *arguments = thread->GetInternalCallParams(); arguments->MakeArgv(targetHandle); JSTaggedValue trapResult = JSFunction::Call(thread, trap, handlerTag, 1, arguments->GetArgv()); - - bool booleanTrapResult = trapResult.ToBoolean(); // 9. ReturnIfAbrupt(booleanTrapResult). RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false); + bool booleanTrapResult = trapResult.ToBoolean(); + // 10. Let targetResult be target.[[IsExtensible]](). // 11. ReturnIfAbrupt(targetResult). // 12. If SameValue(booleanTrapResult, targetResult) is false, throw a TypeError exception. @@ -245,10 +246,10 @@ bool JSProxy::PreventExtensions(JSThread *thread, const JSHandle &proxy InternalCallParams *arguments = thread->GetInternalCallParams(); arguments->MakeArgv(targetHandle); JSTaggedValue trapResult = JSFunction::Call(thread, trap, handlerTag, 1, arguments->GetArgv()); - - bool booleanTrapResult = trapResult.ToBoolean(); // 9. ReturnIfAbrupt(booleanTrapResult). RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false); + + bool booleanTrapResult = trapResult.ToBoolean(); // 10. If booleanTrapResult is true, then // a. Let targetIsExtensible be target.[[IsExtensible]](). // b. ReturnIfAbrupt(targetIsExtensible). @@ -393,10 +394,10 @@ bool JSProxy::DefineOwnProperty(JSThread *thread, const JSHandle &proxy arguments->MakeArgv(targetHandle, propKey, descObj); JSTaggedValue trapResult = JSFunction::Call(thread, trap, handlerTag, 3, arguments->GetArgv()); // 3: target, key and desc - - bool booleanTrapResult = trapResult.ToBoolean(); // 11. ReturnIfAbrupt(booleanTrapResult). RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false); + + bool booleanTrapResult = trapResult.ToBoolean(); if (!booleanTrapResult) { return false; } @@ -479,11 +480,11 @@ bool JSProxy::HasProperty(JSThread *thread, const JSHandle &proxy, cons arguments->MakeArgv(targetHandle, propKey); JSTaggedValue trapResult = JSFunction::Call(thread, trap, handlerTag, 2, arguments->GetArgv()); // 2: target and key - - bool booleanTrapResult = trapResult.ToBoolean(); // 10. ReturnIfAbrupt(booleanTrapResult). RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false); + bool booleanTrapResult = trapResult.ToBoolean(); + // 11. If booleanTrapResult is false, then if (!booleanTrapResult) { // a. Let targetDesc be target.[[GetOwnProperty]](P). @@ -606,10 +607,10 @@ bool JSProxy::SetProperty(JSThread *thread, const JSHandle &proxy, cons arguments->MakeArgv(targetHandle, propKey, value, receiver); JSTaggedValue trapResult = JSFunction::Call(thread, trap, handlerTag, 4, arguments->GetArgv()); // 4: «target, P, V, Receiver» - - bool booleanTrapResult = trapResult.ToBoolean(); // 11. ReturnIfAbrupt(booleanTrapResult). RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false); + + bool booleanTrapResult = trapResult.ToBoolean(); if (!booleanTrapResult) { return false; } @@ -662,10 +663,10 @@ bool JSProxy::DeleteProperty(JSThread *thread, const JSHandle &proxy, c arguments->MakeArgv(targetHandle, key); JSTaggedValue trapResult = JSFunction::Call(thread, trap, handlerTag, 2, arguments->GetArgv()); // 2: target and key - - bool booleanTrapResult = trapResult.ToBoolean(); // 11. ReturnIfAbrupt(booleanTrapResult). RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, false); + + bool booleanTrapResult = trapResult.ToBoolean(); if (!booleanTrapResult) { return false; } -- Gitee