From 9ba8c3374d9fc788f430f619a1aae52df77d3954 Mon Sep 17 00:00:00 2001 From: Georg Neis Date: Thu, 14 Sep 2017 13:42:51 +0200 Subject: [PATCH] [collections] Avoid repeatedly loading same map and instance type. The difference seems to matter at least in one benchmark. R=jarin@chromium.org Bug: chromium:764644 Change-Id: I6d74fbbd8026942637d2301da805b003a9e58af7 Reviewed-on: https://chromium-review.googlesource.com/666922 Reviewed-by: Jaroslav Sevcik Commit-Queue: Georg Neis Cr-Commit-Position: refs/heads/master@{#48015} --- src/builtins/builtins-collections-gen.cc | 20 ++++++++++++++------ src/code-stub-assembler.cc | 3 +-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/builtins/builtins-collections-gen.cc b/src/builtins/builtins-collections-gen.cc index fb8d3bdea5..476c4833f7 100644 --- a/src/builtins/builtins-collections-gen.cc +++ b/src/builtins/builtins-collections-gen.cc @@ -1453,9 +1453,13 @@ TF_BUILTIN(SetHas, CollectionsBuiltinsAssembler) { if_key_bigint(this), entry_found(this), not_found(this), done(this); GotoIf(TaggedIsSmi(key), &if_key_smi); - GotoIf(IsString(key), &if_key_string); - GotoIf(IsHeapNumber(key), &if_key_heap_number); - GotoIf(IsBigInt(key), &if_key_bigint); + + Node* key_map = LoadMap(key); + Node* key_instance_type = LoadMapInstanceType(key_map); + + GotoIf(IsStringInstanceType(key_instance_type), &if_key_string); + GotoIf(IsHeapNumberMap(key_map), &if_key_heap_number); + GotoIf(IsBigIntInstanceType(key_instance_type), &if_key_bigint); FindOrderedHashTableEntryForOtherKey( context, table, key, &entry_start_position, &entry_found, ¬_found); @@ -1648,9 +1652,13 @@ void CollectionsBuiltinsAssembler::TryLookupOrderedHashTableIndex( if_key_bigint(this); GotoIf(TaggedIsSmi(key), &if_key_smi); - GotoIf(IsString(key), &if_key_string); - GotoIf(IsHeapNumber(key), &if_key_heap_number); - GotoIf(IsBigInt(key), &if_key_bigint); + + Node* key_map = LoadMap(key); + Node* key_instance_type = LoadMapInstanceType(key_map); + + GotoIf(IsStringInstanceType(key_instance_type), &if_key_string); + GotoIf(IsHeapNumberMap(key_map), &if_key_heap_number); + GotoIf(IsBigIntInstanceType(key_instance_type), &if_key_bigint); FindOrderedHashTableEntryForOtherKey( context, table, key, result, if_entry_found, if_not_found); diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc index 755036ac36..a0d4022d2d 100644 --- a/src/code-stub-assembler.cc +++ b/src/code-stub-assembler.cc @@ -3809,8 +3809,7 @@ Node* CodeStubAssembler::IsName(Node* object) { } Node* CodeStubAssembler::IsString(Node* object) { - return Int32LessThan(LoadInstanceType(object), - Int32Constant(FIRST_NONSTRING_TYPE)); + return IsStringInstanceType(LoadInstanceType(object)); } Node* CodeStubAssembler::IsSymbolInstanceType(Node* instance_type) {