Modified: trunk/JSTests/test262/expectations.yaml (290295 => 290296)
--- trunk/JSTests/test262/expectations.yaml 2022-02-22 09:47:45 UTC (rev 290295)
+++ trunk/JSTests/test262/expectations.yaml 2022-02-22 10:08:59 UTC (rev 290296)
@@ -828,9 +828,6 @@
test/built-ins/ShadowRealm/WrappedFunction/name-throws-typeerror.js:
default: 'Test262Error: expect a TypeError on name getter throwing Expected a TypeError but got a Error'
strict mode: 'Test262Error: expect a TypeError on name getter throwing Expected a TypeError but got a Error'
-test/built-ins/ShadowRealm/prototype/evaluate/wrapped-function-throws-typeerror-from-caller-realm.js:
- default: 'Test262Error: throws TypeError if arguments are not wrappable Expected a TypeError but got a different error constructor with the same name'
- strict mode: 'Test262Error: throws TypeError if arguments are not wrappable Expected a TypeError but got a different error constructor with the same name'
test/built-ins/Temporal/Duration/compare/calendar-dateadd-called-with-plaindate-instance.js:
default: 'RangeError: Cannot compare a duration of years, months, or weeks without a relativeTo option'
strict mode: 'RangeError: Cannot compare a duration of years, months, or weeks without a relativeTo option'
Modified: trunk/Source/_javascript_Core/ChangeLog (290295 => 290296)
--- trunk/Source/_javascript_Core/ChangeLog 2022-02-22 09:47:45 UTC (rev 290295)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-02-22 10:08:59 UTC (rev 290296)
@@ -1,3 +1,19 @@
+2022-02-22 Yusuke Suzuki <[email protected]>
+
+ [JSC] TypeError from JSRemoteFunction should be generated by JSRemoteFunction's JSGlobalObject
+ https://bugs.webkit.org/show_bug.cgi?id=237013
+
+ Reviewed by Saam Barati.
+
+ Our unwinding converts any errors inside JSRemoteFunction to TypeError. At that time, we should
+ use JSRemoteFunction's JSGlobalObject for this type error.
+
+ * interpreter/Interpreter.cpp:
+ (JSC::UnwindFunctor::UnwindFunctor):
+ (JSC::UnwindFunctor::operator() const):
+ (JSC::sanitizeRemoteFunctionException):
+ (JSC::Interpreter::unwind):
+
2022-02-21 Robin Morisset <[email protected]>
[JSC] Format the output of --reportTotalPhaseTimes=1 more nicely
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (290295 => 290296)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2022-02-22 09:47:45 UTC (rev 290295)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2022-02-22 10:08:59 UTC (rev 290296)
@@ -556,13 +556,13 @@
class UnwindFunctor {
public:
- UnwindFunctor(VM& vm, CallFrame*& callFrame, bool isTermination, JSValue thrownValue, CodeBlock*& codeBlock, CatchInfo& handler, bool& seenRemoteFucnction)
+ UnwindFunctor(VM& vm, CallFrame*& callFrame, bool isTermination, JSValue thrownValue, CodeBlock*& codeBlock, CatchInfo& handler, JSRemoteFunction*& seenRemoteFunction)
: m_vm(vm)
, m_callFrame(callFrame)
, m_isTermination(isTermination)
, m_codeBlock(codeBlock)
, m_handler(handler)
- , m_seenRemoteFunction(seenRemoteFucnction)
+ , m_seenRemoteFunction(seenRemoteFunction)
{
#if ENABLE(WEBASSEMBLY)
if (!m_isTermination) {
@@ -614,7 +614,7 @@
if (!m_callFrame->isWasmFrame() && JSC::isRemoteFunction(m_vm, m_callFrame->jsCallee()) && !m_isTermination) {
// Continue searching for a handler, but mark that a marshalling function was on the stack so that we can
// translate the exception before jumping to the handler.
- const_cast<UnwindFunctor*>(this)->m_seenRemoteFunction = true;
+ m_seenRemoteFunction = jsCast<JSRemoteFunction*>(m_callFrame->jsCallee());
}
notifyDebuggerOfUnwinding(m_vm, m_callFrame);
@@ -666,11 +666,11 @@
bool m_catchableFromWasm { false };
#endif
- bool& m_seenRemoteFunction;
+ JSRemoteFunction*& m_seenRemoteFunction;
};
// Replace an exception which passes across a marshalling boundary with a TypeError for its handler's global object.
-static void sanitizeRemoteFunctionException(VM& vm, CallFrame* handlerCallFrame, Exception* exception)
+static void sanitizeRemoteFunctionException(VM& vm, JSRemoteFunction* remoteFunction, Exception* exception)
{
DeferTermination deferScope(vm);
auto scope = DECLARE_THROW_SCOPE(vm);
@@ -677,7 +677,7 @@
ASSERT(exception);
ASSERT(!vm.isTerminationException(exception));
- JSGlobalObject* globalObject = handlerCallFrame->jsCallee()->globalObject();
+ JSGlobalObject* globalObject = remoteFunction->globalObject();
JSValue exceptionValue = exception->value();
scope.clearException();
@@ -717,12 +717,12 @@
// Calculate an exception handler vPC, unwinding call frames as necessary.
CatchInfo catchInfo;
- bool seenRemoteFunction = false;
+ JSRemoteFunction* seenRemoteFunction = nullptr;
UnwindFunctor functor(vm, callFrame, vm.isTerminationException(exception), exceptionValue, codeBlock, catchInfo, seenRemoteFunction);
StackVisitor::visit<StackVisitor::TerminateIfTopEntryFrameIsEmpty>(callFrame, vm, functor);
if (seenRemoteFunction) {
- sanitizeRemoteFunctionException(vm, callFrame, exception);
+ sanitizeRemoteFunctionException(vm, seenRemoteFunction, exception);
exception = scope.exception(); // clear m_needExceptionCheck
}