Commit 2471a067 authored by Liu Yu's avatar Liu Yu Committed by Commit Bot

[mips][runtime] Add new instance types for constructor functions

Port: 624030e9

Bug: v8:11256

Change-Id: I48379a716fd5424448fb1fb1051a9d119f73bcdb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2642167
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/master@{#72221}
parent cb020c8e
...@@ -2088,9 +2088,11 @@ void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) { ...@@ -2088,9 +2088,11 @@ void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) {
Label non_callable, non_smi; Label non_callable, non_smi;
__ JumpIfSmi(a1, &non_callable); __ JumpIfSmi(a1, &non_callable);
__ bind(&non_smi); __ bind(&non_smi);
__ GetObjectType(a1, t1, t2); __ LoadMap(t1, a1);
__ GetInstanceTypeRange(t1, t2, FIRST_JS_FUNCTION_TYPE, t8);
__ Jump(masm->isolate()->builtins()->CallFunction(mode), __ Jump(masm->isolate()->builtins()->CallFunction(mode),
RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); RelocInfo::CODE_TARGET, ls, t8,
Operand(LAST_JS_FUNCTION_TYPE - FIRST_JS_FUNCTION_TYPE));
__ Jump(BUILTIN_CODE(masm->isolate(), CallBoundFunction), __ Jump(BUILTIN_CODE(masm->isolate(), CallBoundFunction),
RelocInfo::CODE_TARGET, eq, t2, Operand(JS_BOUND_FUNCTION_TYPE)); RelocInfo::CODE_TARGET, eq, t2, Operand(JS_BOUND_FUNCTION_TYPE));
...@@ -2247,9 +2249,10 @@ void Builtins::Generate_Construct(MacroAssembler* masm) { ...@@ -2247,9 +2249,10 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
__ Branch(&non_constructor, eq, t3, Operand(zero_reg)); __ Branch(&non_constructor, eq, t3, Operand(zero_reg));
// Dispatch based on instance type. // Dispatch based on instance type.
__ lhu(t2, FieldMemOperand(t1, Map::kInstanceTypeOffset)); __ GetInstanceTypeRange(t1, t2, FIRST_JS_FUNCTION_TYPE, t8);
__ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction), __ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction),
RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); RelocInfo::CODE_TARGET, ls, t8,
Operand(LAST_JS_FUNCTION_TYPE - FIRST_JS_FUNCTION_TYPE));
// Only dispatch to bound functions after checking whether they are // Only dispatch to bound functions after checking whether they are
// constructors. // constructors.
......
...@@ -2152,9 +2152,11 @@ void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) { ...@@ -2152,9 +2152,11 @@ void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode) {
Label non_callable, non_smi; Label non_callable, non_smi;
__ JumpIfSmi(a1, &non_callable); __ JumpIfSmi(a1, &non_callable);
__ bind(&non_smi); __ bind(&non_smi);
__ GetObjectType(a1, t1, t2); __ LoadMap(t1, a1);
__ GetInstanceTypeRange(t1, t2, FIRST_JS_FUNCTION_TYPE, t8);
__ Jump(masm->isolate()->builtins()->CallFunction(mode), __ Jump(masm->isolate()->builtins()->CallFunction(mode),
RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); RelocInfo::CODE_TARGET, ls, t8,
Operand(LAST_JS_FUNCTION_TYPE - FIRST_JS_FUNCTION_TYPE));
__ Jump(BUILTIN_CODE(masm->isolate(), CallBoundFunction), __ Jump(BUILTIN_CODE(masm->isolate(), CallBoundFunction),
RelocInfo::CODE_TARGET, eq, t2, Operand(JS_BOUND_FUNCTION_TYPE)); RelocInfo::CODE_TARGET, eq, t2, Operand(JS_BOUND_FUNCTION_TYPE));
...@@ -2309,9 +2311,10 @@ void Builtins::Generate_Construct(MacroAssembler* masm) { ...@@ -2309,9 +2311,10 @@ void Builtins::Generate_Construct(MacroAssembler* masm) {
__ Branch(&non_constructor, eq, t3, Operand(zero_reg)); __ Branch(&non_constructor, eq, t3, Operand(zero_reg));
// Dispatch based on instance type. // Dispatch based on instance type.
__ Lhu(t2, FieldMemOperand(t1, Map::kInstanceTypeOffset)); __ GetInstanceTypeRange(t1, t2, FIRST_JS_FUNCTION_TYPE, t8);
__ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction), __ Jump(BUILTIN_CODE(masm->isolate(), ConstructFunction),
RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); RelocInfo::CODE_TARGET, ls, t8,
Operand(LAST_JS_FUNCTION_TYPE - FIRST_JS_FUNCTION_TYPE));
// Only dispatch to bound functions after checking whether they are // Only dispatch to bound functions after checking whether they are
// constructors. // constructors.
......
...@@ -4559,6 +4559,14 @@ void MacroAssembler::GetObjectType(Register object, Register map, ...@@ -4559,6 +4559,14 @@ void MacroAssembler::GetObjectType(Register object, Register map,
lhu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); lhu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset));
} }
void MacroAssembler::GetInstanceTypeRange(Register map, Register type_reg,
InstanceType lower_limit,
Register range) {
DCHECK_LT(lower_limit, higher_limit);
lhu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset));
Subu(range, type_reg, Operand(lower_limit));
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Runtime calls. // Runtime calls.
...@@ -5058,9 +5066,12 @@ void MacroAssembler::AssertFunction(Register object) { ...@@ -5058,9 +5066,12 @@ void MacroAssembler::AssertFunction(Register object) {
SmiTst(object, t8); SmiTst(object, t8);
Check(ne, AbortReason::kOperandIsASmiAndNotAFunction, t8, Check(ne, AbortReason::kOperandIsASmiAndNotAFunction, t8,
Operand(zero_reg)); Operand(zero_reg));
GetObjectType(object, t8, t8); push(object);
Check(eq, AbortReason::kOperandIsNotAFunction, t8, LoadMap(object, object);
Operand(JS_FUNCTION_TYPE)); GetInstanceTypeRange(object, object, FIRST_JS_FUNCTION_TYPE, t8);
Check(ls, AbortReason::kOperandIsNotAFunction, t8,
Operand(LAST_JS_FUNCTION_TYPE - FIRST_JS_FUNCTION_TYPE));
pop(object);
} }
} }
......
...@@ -1041,6 +1041,9 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler { ...@@ -1041,6 +1041,9 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
void GetObjectType(Register function, Register map, Register type_reg); void GetObjectType(Register function, Register map, Register type_reg);
void GetInstanceTypeRange(Register map, Register type_reg,
InstanceType lower_limit, Register range);
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Runtime calls. // Runtime calls.
......
...@@ -5000,6 +5000,14 @@ void MacroAssembler::GetObjectType(Register object, Register map, ...@@ -5000,6 +5000,14 @@ void MacroAssembler::GetObjectType(Register object, Register map,
Lhu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); Lhu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset));
} }
void MacroAssembler::GetInstanceTypeRange(Register map, Register type_reg,
InstanceType lower_limit,
Register range) {
DCHECK_LT(lower_limit, higher_limit);
Lhu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset));
Dsubu(range, type_reg, Operand(lower_limit));
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Runtime calls. // Runtime calls.
...@@ -5518,9 +5526,12 @@ void MacroAssembler::AssertFunction(Register object) { ...@@ -5518,9 +5526,12 @@ void MacroAssembler::AssertFunction(Register object) {
SmiTst(object, t8); SmiTst(object, t8);
Check(ne, AbortReason::kOperandIsASmiAndNotAFunction, t8, Check(ne, AbortReason::kOperandIsASmiAndNotAFunction, t8,
Operand(zero_reg)); Operand(zero_reg));
GetObjectType(object, t8, t8); push(object);
Check(eq, AbortReason::kOperandIsNotAFunction, t8, LoadMap(object, object);
Operand(JS_FUNCTION_TYPE)); GetInstanceTypeRange(object, object, FIRST_JS_FUNCTION_TYPE, t8);
Check(ls, AbortReason::kOperandIsNotAFunction, t8,
Operand(LAST_JS_FUNCTION_TYPE - FIRST_JS_FUNCTION_TYPE));
pop(object);
} }
} }
......
...@@ -1091,6 +1091,9 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler { ...@@ -1091,6 +1091,9 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
void GetObjectType(Register function, Register map, Register type_reg); void GetObjectType(Register function, Register map, Register type_reg);
void GetInstanceTypeRange(Register map, Register type_reg,
InstanceType lower_limit, Register range);
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Runtime calls. // Runtime calls.
......
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