From ec6368bf125c00810273d577a600cb2b889187e3 Mon Sep 17 00:00:00 2001 From: Lu Yahan Date: Thu, 28 Jul 2022 09:53:27 +0800 Subject: [PATCH] [Cleanup] Use CmpInstanceTypeRange in MacroAssembler Bug: v8:11325 Change-Id: Iffe8d049cbb97384e81fa3eeae5066e58b303066 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3787682 Reviewed-by: Igor Sheludko Auto-Submit: Yahan Lu Commit-Queue: Yahan Lu Cr-Commit-Position: refs/heads/main@{#82013} --- src/codegen/arm/macro-assembler-arm.cc | 16 +++------------- src/codegen/arm64/macro-assembler-arm64.cc | 16 +++------------- src/codegen/ia32/macro-assembler-ia32.cc | 15 +++------------ src/codegen/x64/macro-assembler-x64.cc | 16 +++------------- 4 files changed, 12 insertions(+), 51 deletions(-) diff --git a/src/codegen/arm/macro-assembler-arm.cc b/src/codegen/arm/macro-assembler-arm.cc index f1bd6f9ca1..b91eb8fbcc 100644 --- a/src/codegen/arm/macro-assembler-arm.cc +++ b/src/codegen/arm/macro-assembler-arm.cc @@ -2208,22 +2208,12 @@ void MacroAssembler::AssertGeneratorObject(Register object) { LoadMap(map, object); // Check if JSGeneratorObject - Label do_check; Register instance_type = object; - CompareInstanceType(map, instance_type, JS_GENERATOR_OBJECT_TYPE); - b(eq, &do_check); - - // Check if JSAsyncFunctionObject (See MacroAssembler::CompareInstanceType) - cmp(instance_type, Operand(JS_ASYNC_FUNCTION_OBJECT_TYPE)); - b(eq, &do_check); - - // Check if JSAsyncGeneratorObject (See MacroAssembler::CompareInstanceType) - cmp(instance_type, Operand(JS_ASYNC_GENERATOR_OBJECT_TYPE)); - - bind(&do_check); + CompareInstanceTypeRange(map, instance_type, FIRST_JS_GENERATOR_OBJECT_TYPE, + LAST_JS_GENERATOR_OBJECT_TYPE); // Restore generator object to register and perform assertion pop(object); - Check(eq, AbortReason::kOperandIsNotAGeneratorObject); + Check(ls, AbortReason::kOperandIsNotAGeneratorObject); } void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, diff --git a/src/codegen/arm64/macro-assembler-arm64.cc b/src/codegen/arm64/macro-assembler-arm64.cc index 7486b1ab70..4c0686f08e 100644 --- a/src/codegen/arm64/macro-assembler-arm64.cc +++ b/src/codegen/arm64/macro-assembler-arm64.cc @@ -1626,21 +1626,11 @@ void MacroAssembler::AssertGeneratorObject(Register object) { Register temp = temps.AcquireX(); LoadMap(temp, object); - Label do_check; // Load instance type and check if JSGeneratorObject - CompareInstanceType(temp, temp, JS_GENERATOR_OBJECT_TYPE); - B(eq, &do_check); - - // Check if JSAsyncFunctionObject - Cmp(temp, JS_ASYNC_FUNCTION_OBJECT_TYPE); - B(eq, &do_check); - - // Check if JSAsyncGeneratorObject - Cmp(temp, JS_ASYNC_GENERATOR_OBJECT_TYPE); - - bind(&do_check); + CompareInstanceTypeRange(temp, temp, FIRST_JS_GENERATOR_OBJECT_TYPE, + LAST_JS_GENERATOR_OBJECT_TYPE); // Restore generator object to register and perform assertion - Check(eq, AbortReason::kOperandIsNotAGeneratorObject); + Check(ls, AbortReason::kOperandIsNotAGeneratorObject); } void MacroAssembler::AssertUndefinedOrAllocationSite(Register object) { diff --git a/src/codegen/ia32/macro-assembler-ia32.cc b/src/codegen/ia32/macro-assembler-ia32.cc index 2148b0df15..9a3ed5ba8f 100644 --- a/src/codegen/ia32/macro-assembler-ia32.cc +++ b/src/codegen/ia32/macro-assembler-ia32.cc @@ -799,21 +799,12 @@ void MacroAssembler::AssertGeneratorObject(Register object) { Label do_check; // Check if JSGeneratorObject - CmpInstanceType(map, JS_GENERATOR_OBJECT_TYPE); - j(equal, &do_check, Label::kNear); - - // Check if JSAsyncFunctionObject. - CmpInstanceType(map, JS_ASYNC_FUNCTION_OBJECT_TYPE); - j(equal, &do_check, Label::kNear); - - // Check if JSAsyncGeneratorObject - CmpInstanceType(map, JS_ASYNC_GENERATOR_OBJECT_TYPE); - - bind(&do_check); + CmpInstanceTypeRange(map, map, map, FIRST_JS_GENERATOR_OBJECT_TYPE, + LAST_JS_GENERATOR_OBJECT_TYPE); Pop(object); } - Check(equal, AbortReason::kOperandIsNotAGeneratorObject); + Check(below_equal, AbortReason::kOperandIsNotAGeneratorObject); } void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, diff --git a/src/codegen/x64/macro-assembler-x64.cc b/src/codegen/x64/macro-assembler-x64.cc index aa2f69acf5..0697f8b352 100644 --- a/src/codegen/x64/macro-assembler-x64.cc +++ b/src/codegen/x64/macro-assembler-x64.cc @@ -2542,22 +2542,12 @@ void MacroAssembler::AssertGeneratorObject(Register object) { Push(object); LoadMap(map, object); - Label do_check; // Check if JSGeneratorObject - CmpInstanceType(map, JS_GENERATOR_OBJECT_TYPE); - j(equal, &do_check); - - // Check if JSAsyncFunctionObject - CmpInstanceType(map, JS_ASYNC_FUNCTION_OBJECT_TYPE); - j(equal, &do_check); - - // Check if JSAsyncGeneratorObject - CmpInstanceType(map, JS_ASYNC_GENERATOR_OBJECT_TYPE); - - bind(&do_check); + CmpInstanceTypeRange(map, kScratchRegister, FIRST_JS_GENERATOR_OBJECT_TYPE, + LAST_JS_GENERATOR_OBJECT_TYPE); // Restore generator object to register and perform assertion Pop(object); - Check(equal, AbortReason::kOperandIsNotAGeneratorObject); + Check(below_equal, AbortReason::kOperandIsNotAGeneratorObject); } void MacroAssembler::AssertUndefinedOrAllocationSite(Register object) {