From 504a4d43477313c5567df40ca70e57f7af31d555 Mon Sep 17 00:00:00 2001 From: Tzvetan Mikov Date: Mon, 9 Jan 2023 19:52:24 -0800 Subject: [PATCH] Interpreter: add _RJS suffix to some functions Summary: Some interpreter helpers were missing the _RJS suffix. I discovered this while annotation IR instructions for it. Reviewed By: neildhar Differential Revision: D42297945 fbshipit-source-id: 817587cbfeeb23cd5ad096a48f7069b81f93f85d --- lib/VM/Interpreter-internal.h | 14 +++++---- lib/VM/Interpreter-slowpaths.cpp | 42 ++++++++++++++------------ lib/VM/Interpreter.cpp | 52 +++++++++++++++++--------------- 3 files changed, 58 insertions(+), 50 deletions(-) diff --git a/lib/VM/Interpreter-internal.h b/lib/VM/Interpreter-internal.h index ca5816e6e13..f0cc73b17f5 100644 --- a/lib/VM/Interpreter-internal.h +++ b/lib/VM/Interpreter-internal.h @@ -126,22 +126,24 @@ inline double doDec(double d) { template CallResult -doOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs); +doOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs); template CallResult -doBitOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs); +doBitOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs); template CallResult -doShiftOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs); +doShiftOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs); template -CallResult doIncDecOperSlowPath(Runtime &runtime, Handle<> src); +CallResult doIncDecOperSlowPath_RJS( + Runtime &runtime, + Handle<> src); -CallResult doBitNotSlowPath(Runtime &runtime, Handle<> src); +CallResult doBitNotSlowPath_RJS(Runtime &runtime, Handle<> src); -CallResult doNegateSlowPath(Runtime &runtime, Handle<> src); +CallResult doNegateSlowPath_RJS(Runtime &runtime, Handle<> src); } // namespace vm } // namespace hermes diff --git a/lib/VM/Interpreter-slowpaths.cpp b/lib/VM/Interpreter-slowpaths.cpp index 9af3e502eaa..0c5f098e6f1 100644 --- a/lib/VM/Interpreter-slowpaths.cpp +++ b/lib/VM/Interpreter-slowpaths.cpp @@ -375,7 +375,7 @@ constexpr auto &BigIntOper = BigIntPrimitive::dec; template CallResult -doOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs) { +doOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs) { CallResult res = toPrimitive_RJS(runtime, lhs, PreferredType::NUMBER); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { @@ -398,20 +398,20 @@ doOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs) { } template CallResult -doOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs); +doOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs); template CallResult -doOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs); +doOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs); template CallResult -doOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs); +doOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs); template CallResult -doOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs); +doOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs); template CallResult -doBitOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs) { +doBitOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs) { CallResult res = toPrimitive_RJS(runtime, lhs, PreferredType::NUMBER); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { @@ -435,13 +435,13 @@ doBitOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs) { } template CallResult -doBitOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs); +doBitOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs); template CallResult -doBitOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs); +doBitOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs); template CallResult -doBitOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs); +doBitOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs); namespace { /// ToIntegral maps the \param Oper shift operation (on Number) to the function @@ -463,7 +463,7 @@ inline constexpr auto &ToIntegral = toUInt32_RJS; template CallResult -doShiftOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs) { +doShiftOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs) { CallResult res = toPrimitive_RJS(runtime, std::move(lhs), PreferredType::NUMBER); @@ -492,16 +492,20 @@ doShiftOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs) { } template CallResult -doShiftOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs); +doShiftOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs); template CallResult -doShiftOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs); +doShiftOperSlowPath_RJS(Runtime &runtime, Handle<> lhs, Handle<> rhs); -template CallResult -doShiftOperSlowPath(Runtime &runtime, Handle<> lhs, Handle<> rhs); +template CallResult doShiftOperSlowPath_RJS( + Runtime &runtime, + Handle<> lhs, + Handle<> rhs); template -CallResult doIncDecOperSlowPath(Runtime &runtime, Handle<> src) { +CallResult doIncDecOperSlowPath_RJS( + Runtime &runtime, + Handle<> src) { CallResult res = toPrimitive_RJS(runtime, std::move(src), PreferredType::NUMBER); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { @@ -519,15 +523,15 @@ CallResult doIncDecOperSlowPath(Runtime &runtime, Handle<> src) { return BigIntOper(runtime, runtime.makeHandle(res->getBigInt())); } -template CallResult doIncDecOperSlowPath( +template CallResult doIncDecOperSlowPath_RJS( Runtime &runtime, Handle<> src); -template CallResult doIncDecOperSlowPath( +template CallResult doIncDecOperSlowPath_RJS( Runtime &runtime, Handle<> src); -CallResult doBitNotSlowPath(Runtime &runtime, Handle<> src) { +CallResult doBitNotSlowPath_RJS(Runtime &runtime, Handle<> src) { // Try converting src to a numeric. auto numRes = toNumeric_RJS(runtime, src); if (LLVM_UNLIKELY(numRes == ExecutionStatus::EXCEPTION)) @@ -543,7 +547,7 @@ CallResult doBitNotSlowPath(Runtime &runtime, Handle<> src) { return BigIntPrimitive::unaryNOT(runtime, bigint); } -CallResult doNegateSlowPath(Runtime &runtime, Handle<> src) { +CallResult doNegateSlowPath_RJS(Runtime &runtime, Handle<> src) { // Try converting src to a numeric. auto numRes = toNumeric_RJS(runtime, src); if (LLVM_UNLIKELY(numRes == ExecutionStatus::EXCEPTION)) diff --git a/lib/VM/Interpreter.cpp b/lib/VM/Interpreter.cpp index e10c3a5bd55..22ac01f6ea8 100644 --- a/lib/VM/Interpreter.cpp +++ b/lib/VM/Interpreter.cpp @@ -1164,7 +1164,7 @@ CallResult Interpreter::interpretFunction( } \ } \ CAPTURE_IP( \ - res = doOperSlowPath( \ + res = doOperSlowPath_RJS( \ runtime, Handle<>(&O2REG(name)), Handle<>(&O3REG(name)))); \ if (res == ExecutionStatus::EXCEPTION) \ goto exception; \ @@ -1174,25 +1174,25 @@ CallResult Interpreter::interpretFunction( DISPATCH; \ } -#define INCDECOP(name) \ - CASE(name) { \ - if (LLVM_LIKELY(O2REG(name).isNumber())) { \ - O1REG(name) = \ - HermesValue::encodeDoubleValue(do##name(O2REG(name).getNumber())); \ - gcScope.flushToSmallCount(KEEP_HANDLES); \ - ip = NEXTINST(name); \ - DISPATCH; \ - } \ - CAPTURE_IP( \ - res = \ - doIncDecOperSlowPath(runtime, Handle<>(&O2REG(name)))); \ - if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { \ - goto exception; \ - } \ - O1REG(name) = *res; \ - gcScope.flushToSmallCount(KEEP_HANDLES); \ - ip = NEXTINST(name); \ - DISPATCH; \ +#define INCDECOP(name) \ + CASE(name) { \ + if (LLVM_LIKELY(O2REG(name).isNumber())) { \ + O1REG(name) = \ + HermesValue::encodeDoubleValue(do##name(O2REG(name).getNumber())); \ + gcScope.flushToSmallCount(KEEP_HANDLES); \ + ip = NEXTINST(name); \ + DISPATCH; \ + } \ + CAPTURE_IP( \ + res = doIncDecOperSlowPath_RJS( \ + runtime, Handle<>(&O2REG(name)))); \ + if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { \ + goto exception; \ + } \ + O1REG(name) = *res; \ + gcScope.flushToSmallCount(KEEP_HANDLES); \ + ip = NEXTINST(name); \ + DISPATCH; \ } /// Implement a shift instruction with a fast path where both @@ -1210,7 +1210,7 @@ CallResult Interpreter::interpretFunction( DISPATCH; \ } \ CAPTURE_IP( \ - res = doShiftOperSlowPath( \ + res = doShiftOperSlowPath_RJS( \ runtime, Handle<>(&O2REG(name)), Handle<>(&O3REG(name)))); \ if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { \ goto exception; \ @@ -1235,7 +1235,7 @@ CallResult Interpreter::interpretFunction( DISPATCH; \ } \ CAPTURE_IP( \ - res = doBitOperSlowPath( \ + res = doBitOperSlowPath_RJS( \ runtime, Handle<>(&O2REG(name)), Handle<>(&O3REG(name)))); \ if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { \ goto exception; \ @@ -2813,7 +2813,8 @@ CallResult Interpreter::interpretFunction( ip = NEXTINST(BitNot); DISPATCH; } - CAPTURE_IP(res = doBitNotSlowPath(runtime, Handle<>(&O2REG(BitNot)))); + CAPTURE_IP( + res = doBitNotSlowPath_RJS(runtime, Handle<>(&O2REG(BitNot)))); if (res == ExecutionStatus::EXCEPTION) { goto exception; } @@ -3096,7 +3097,8 @@ CallResult Interpreter::interpretFunction( ip = NEXTINST(Negate); DISPATCH; } - CAPTURE_IP(res = doNegateSlowPath(runtime, Handle<>(&O2REG(Negate)))); + CAPTURE_IP( + res = doNegateSlowPath_RJS(runtime, Handle<>(&O2REG(Negate)))); if (res == ExecutionStatus::EXCEPTION) goto exception; O1REG(Negate) = *res; @@ -3118,7 +3120,7 @@ CallResult Interpreter::interpretFunction( DISPATCH; } CAPTURE_IP( - res = doOperSlowPath( + res = doOperSlowPath_RJS( runtime, Handle<>(&O2REG(Mod)), Handle<>(&O3REG(Mod)))); if (LLVM_UNLIKELY(res == ExecutionStatus::EXCEPTION)) { goto exception;