Commit a56a7097 authored by Liu Yu's avatar Liu Yu Committed by V8 LUCI CQ

[loong64][mips][turbofan] Handle class constructor

Port commit e127f584

Bug: chromium:1260623

Change-Id: I1462126391189f328bb5d8a8fbfb00f3bce642a8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3299283
Auto-Submit: Liu yu <liuyu@loongson.cn>
Reviewed-by: 's avatarZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Cr-Commit-Position: refs/heads/main@{#78054}
parent dadd34d9
......@@ -2301,7 +2301,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);
Label class_constructor;
__ Ld_d(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
......
......@@ -2244,7 +2244,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);
Label class_constructor;
__ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
......
......@@ -2297,7 +2297,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);
Label class_constructor;
__ Ld(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
......
......@@ -3745,6 +3745,23 @@ void MacroAssembler::AssertFunction(Register object) {
}
}
void MacroAssembler::AssertCallableFunction(Register object) {
if (FLAG_debug_code) {
BlockTrampolinePoolScope block_trampoline_pool(this);
STATIC_ASSERT(kSmiTag == 0);
SmiTst(object, t8);
Check(ne, AbortReason::kOperandIsASmiAndNotAFunction, t8,
Operand(zero_reg));
Push(object);
LoadMap(object, object);
GetInstanceTypeRange(object, object, FIRST_CALLABLE_JS_FUNCTION_TYPE, t8);
Check(ls, AbortReason::kOperandIsNotACallableFunction, t8,
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);
......
......@@ -1024,6 +1024,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);
......
......@@ -5084,6 +5084,23 @@ void MacroAssembler::AssertFunction(Register object) {
}
}
void MacroAssembler::AssertCallableFunction(Register object) {
if (FLAG_debug_code) {
BlockTrampolinePoolScope block_trampoline_pool(this);
STATIC_ASSERT(kSmiTag == 0);
SmiTst(object, t8);
Check(ne, AbortReason::kOperandIsASmiAndNotAFunction, t8,
Operand(zero_reg));
push(object);
LoadMap(object, object);
GetInstanceTypeRange(object, object, FIRST_CALLABLE_JS_FUNCTION_TYPE, t8);
Check(ls, AbortReason::kOperandIsNotACallableFunction, t8,
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);
......
......@@ -1132,6 +1132,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);
......
......@@ -5633,6 +5633,23 @@ void MacroAssembler::AssertFunction(Register object) {
}
}
void MacroAssembler::AssertCallableFunction(Register object) {
if (FLAG_debug_code) {
BlockTrampolinePoolScope block_trampoline_pool(this);
STATIC_ASSERT(kSmiTag == 0);
SmiTst(object, t8);
Check(ne, AbortReason::kOperandIsASmiAndNotAFunction, t8,
Operand(zero_reg));
push(object);
LoadMap(object, object);
GetInstanceTypeRange(object, object, FIRST_CALLABLE_JS_FUNCTION_TYPE, t8);
Check(ls, AbortReason::kOperandIsNotACallableFunction, t8,
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);
......
......@@ -1211,6 +1211,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);
......
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