Commit 21157d25 authored by Lu Yahan's avatar Lu Yahan Committed by V8 LUCI CQ

[riscv64] [turbofan] Handle class constructor

Port e127f584

Change-Id: Id0eb9205c3e94cb504340110ff6a42bc94a80cc1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3251133
Auto-Submit: Yahan Lu <yahan@iscas.ac.cn>
Reviewed-by: 's avatarji qiu <qiuji@iscas.ac.cn>
Commit-Queue: Yahan Lu <yahan@iscas.ac.cn>
Cr-Commit-Position: refs/heads/main@{#77634}
parent 8f93d342
......@@ -2431,7 +2431,7 @@ void Builtins::Generate_CallFunction(MacroAssembler* masm,
// -- a0 : the number of arguments
// -- a1 : the function to call (checked to be a JSFunction)
// -----------------------------------
__ AssertFunction(a1);
__ AssertCallableFunction(a1);
__ LoadTaggedPointerField(
a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
......
......@@ -4496,21 +4496,21 @@ void MacroAssembler::JumpIfNotSmi(Register value, Label* not_smi_label) {
Branch(not_smi_label, ne, scratch, Operand(zero_reg));
}
void TurboAssembler::AssertNotSmi(Register object) {
void TurboAssembler::AssertNotSmi(Register object, AbortReason reason) {
if (FLAG_debug_code) {
STATIC_ASSERT(kSmiTag == 0);
DCHECK(object != kScratchReg);
andi(kScratchReg, object, kSmiTagMask);
Check(ne, AbortReason::kOperandIsASmi, kScratchReg, Operand(zero_reg));
Check(ne, reason, kScratchReg, Operand(zero_reg));
}
}
void TurboAssembler::AssertSmi(Register object) {
void TurboAssembler::AssertSmi(Register object, AbortReason reason) {
if (FLAG_debug_code) {
STATIC_ASSERT(kSmiTag == 0);
DCHECK(object != kScratchReg);
andi(kScratchReg, object, kSmiTagMask);
Check(eq, AbortReason::kOperandIsASmi, kScratchReg, Operand(zero_reg));
Check(eq, reason, kScratchReg, Operand(zero_reg));
}
}
......@@ -4550,6 +4550,22 @@ void MacroAssembler::AssertFunction(Register object) {
}
}
void MacroAssembler::AssertCallableFunction(Register object) {
if (!FLAG_debug_code) return;
ASM_CODE_COMMENT(this);
STATIC_ASSERT(kSmiTag == 0);
AssertNotSmi(object, AbortReason::kOperandIsASmiAndNotAFunction);
push(object);
LoadMap(object, object);
UseScratchRegisterScope temps(this);
Register range = temps.Acquire();
GetInstanceTypeRange(object, object, FIRST_CALLABLE_JS_FUNCTION_TYPE, range);
Check(Uless_equal, AbortReason::kOperandIsNotACallableFunction, range,
Operand(LAST_CALLABLE_JS_FUNCTION_TYPE -
FIRST_CALLABLE_JS_FUNCTION_TYPE));
pop(object);
}
void MacroAssembler::AssertBoundFunction(Register object) {
if (FLAG_debug_code) {
BlockTrampolinePoolScope block_trampoline_pool(this);
......
......@@ -495,8 +495,10 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void SmiToInt32(Register smi);
// Enabled via --debug-code.
void AssertNotSmi(Register object);
void AssertSmi(Register object);
void AssertNotSmi(Register object,
AbortReason reason = AbortReason::kOperandIsASmi);
void AssertSmi(Register object,
AbortReason reason = AbortReason::kOperandIsASmi);
int CalculateStackPassedDWords(int num_gp_arguments, int num_fp_arguments);
......@@ -1271,6 +1273,10 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
// Abort execution if argument is not a JSFunction, enabled via --debug-code.
void AssertFunction(Register object);
// Abort execution if argument is not a callable JSFunction, enabled via
// --debug-code.
void AssertCallableFunction(Register object);
// Abort execution if argument is not a JSBoundFunction,
// enabled via --debug-code.
void AssertBoundFunction(Register object);
......
......@@ -889,7 +889,7 @@ class Simulator : public SimulatorBase {
template <typename T, typename Func>
inline T CanonicalizeFPUOpFMA(Func fn, T dst, T src1, T src2) {
static_assert(std::is_floating_point<T>::value);
STATIC_ASSERT(std::is_floating_point<T>::value);
auto alu_out = fn(dst, src1, src2);
// if any input or result is NaN, the result is quiet_NaN
if (std::isnan(alu_out) || std::isnan(src1) || std::isnan(src2) ||
......@@ -904,7 +904,7 @@ class Simulator : public SimulatorBase {
template <typename T, typename Func>
inline T CanonicalizeFPUOp3(Func fn) {
static_assert(std::is_floating_point<T>::value);
STATIC_ASSERT(std::is_floating_point<T>::value);
T src1 = std::is_same<float, T>::value ? frs1() : drs1();
T src2 = std::is_same<float, T>::value ? frs2() : drs2();
T src3 = std::is_same<float, T>::value ? frs3() : drs3();
......@@ -922,7 +922,7 @@ class Simulator : public SimulatorBase {
template <typename T, typename Func>
inline T CanonicalizeFPUOp2(Func fn) {
static_assert(std::is_floating_point<T>::value);
STATIC_ASSERT(std::is_floating_point<T>::value);
T src1 = std::is_same<float, T>::value ? frs1() : drs1();
T src2 = std::is_same<float, T>::value ? frs2() : drs2();
auto alu_out = fn(src1, src2);
......@@ -938,7 +938,7 @@ class Simulator : public SimulatorBase {
template <typename T, typename Func>
inline T CanonicalizeFPUOp1(Func fn) {
static_assert(std::is_floating_point<T>::value);
STATIC_ASSERT(std::is_floating_point<T>::value);
T src1 = std::is_same<float, T>::value ? frs1() : drs1();
auto alu_out = fn(src1);
// if any input or result is NaN, the result is quiet_NaN
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment