From c0e247910626a4a442e41356f93c4ec1102de5b5 Mon Sep 17 00:00:00 2001 From: Daniel Clifford Date: Tue, 30 Jun 2020 21:02:30 +0200 Subject: [PATCH] [torque] Make more classes eligible for direct map Cast<> checks Also should address minor performance regressions for instance types that should (and used to) use map compare rather than instance_type comparison. In the process, convert a bunch of IsXXX methods from the CSA into exported Torque methods that call through to the Cast<> to ensure there is only a single implementation of the type checkers. Also clean up and remove duplicate/redundant code and unused Torque imports. Bug: v8:7793, chromium:1098481 Change-Id: I3cd5146d913bb75bab4f73415b1b94bc30924725 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2270545 Commit-Queue: Daniel Clifford Reviewed-by: Tobias Tebbi Cr-Commit-Position: refs/heads/master@{#68621} --- src/builtins/cast.tq | 155 ++++++++++++--- src/builtins/proxy-delete-property.tq | 2 +- src/builtins/proxy-get-property.tq | 2 +- src/builtins/proxy-has-property.tq | 4 +- src/builtins/proxy-set-property.tq | 2 +- src/codegen/code-stub-assembler.cc | 99 +--------- src/codegen/code-stub-assembler.h | 247 +++++++++--------------- src/objects/instance-type.h | 39 +++- test/cctest/test-code-stub-assembler.cc | 4 +- 9 files changed, 263 insertions(+), 291 deletions(-) diff --git a/src/builtins/cast.tq b/src/builtins/cast.tq index 9adbd7ecc4..7120befa44 100644 --- a/src/builtins/cast.tq +++ b/src/builtins/cast.tq @@ -4,24 +4,114 @@ extern macro IsBigInt(HeapObject): bool; extern macro IsConstructor(HeapObject): bool; -extern macro IsContext(HeapObject): bool; extern macro IsCustomElementsReceiverInstanceType(int32): bool; extern macro IsExtensibleMap(Map): bool; -extern macro IsFixedArray(HeapObject): bool; -extern macro IsHeapNumber(HeapObject): bool; -extern macro IsJSArrayMap(Map): bool; -extern macro IsJSProxy(HeapObject): bool; -extern macro IsName(HeapObject): bool; -extern macro IsNativeContext(HeapObject): bool; extern macro IsNumberNormalized(Number): bool; -extern macro IsNumber(Object): bool; -extern macro IsPrivateSymbol(HeapObject): bool; extern macro IsSafeInteger(Object): bool; +@export +macro IsAccessorInfo(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsAccessorPair(o: HeapObject): bool { + return Is(o); +} + @export macro IsAllocationSite(o: HeapObject): bool { - Cast(o) otherwise return false; - return true; + return Is(o); +} + +@export +macro IsCell(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsCode(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsContext(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsCoverageInfo(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsDebugInfo(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsFixedDoubleArray(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsFeedbackCell(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsFeedbackVector(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsHeapNumber(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsNativeContext(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsNumber(o: Object): bool { + return Is(o); +} + +@export +macro IsPrivateSymbol(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsPromiseCapability(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsPromiseFulfillReactionJobTask(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsPromiseReaction(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsPromiseRejectReactionJobTask(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsSharedFunctionInfo(o: HeapObject): bool { + return Is(o); +} + +@export +macro IsSymbol(o: HeapObject): bool { + return Is(o); } extern macro TaggedToHeapObject(Object): HeapObject @@ -39,8 +129,6 @@ extern macro HeapObjectToConstructor(HeapObject): Constructor extern macro HeapObjectToJSFunctionWithPrototypeSlot(HeapObject): JSFunctionWithPrototypeSlot labels CastError; -extern macro TaggedToNumber(Object): Number - labels CastError; macro Cast(o: A|Object): A labels CastError { if (!IsWeakOrCleared(o)) goto CastError; @@ -87,7 +175,17 @@ Cast(o: Object): Zero labels CastError { Cast(o: Object): Number labels CastError { - return TaggedToNumber(o) otherwise CastError; + typeswitch (o) { + case (s: Smi): { + return s; + } + case (n: HeapNumber): { + return n; + } + case (Object): { + goto CastError; + } + } } Cast(o: Object): Undefined @@ -288,24 +386,21 @@ Cast(o: HeapObject): Undefined|Callable } macro Cast(o: Symbol): T labels CastError; -Cast(o: Symbol): PublicSymbol labels CastError { - if (IsPrivateSymbol(o)) goto CastError; - return %RawDownCast(o); +Cast(s: Symbol): PublicSymbol labels CastError { + if (s.flags.is_private) goto CastError; + return %RawDownCast(s); } -Cast(o: Symbol): PrivateSymbol labels CastError { - if (IsPrivateSymbol(o)) { - return %RawDownCast(o); - } +Cast(s: Symbol): PrivateSymbol labels CastError { + if (s.flags.is_private) return %RawDownCast(s); goto CastError; } - Cast(o: HeapObject): PublicSymbol labels CastError { - const o = Cast(o) otherwise CastError; - return Cast(o) otherwise CastError; + const s = Cast(o) otherwise CastError; + return Cast(s) otherwise CastError; } Cast(o: HeapObject): PrivateSymbol labels CastError { - const o = Cast(o) otherwise CastError; - return Cast(o) otherwise CastError; + const s = Cast(o) otherwise CastError; + return Cast(s) otherwise CastError; } Cast(o: HeapObject): DirectString @@ -385,10 +480,10 @@ Cast(implicit context: Context)(o: HeapObject): FastJSArray labels CastError { if (IsForceSlowPath()) goto CastError; - const map: Map = o.map; - if (!IsJSArrayMap(map)) goto CastError; + if (!Is(o)) goto CastError; // Bailout if receiver has slow elements. + const map: Map = o.map; const elementsKind: ElementsKind = LoadMapElementsKind(map); if (!IsFastElementsKind(elementsKind)) goto CastError; @@ -402,10 +497,10 @@ Cast(implicit context: Context)(o: HeapObject): FastJSArray Cast(implicit context: Context)(o: HeapObject): FastJSArrayForRead labels CastError { - const map: Map = o.map; - if (!IsJSArrayMap(map)) goto CastError; + if (!Is(o)) goto CastError; // Bailout if receiver has slow elements. + const map: Map = o.map; const elementsKind: ElementsKind = LoadMapElementsKind(map); if (!IsElementsKindLessThanOrEqual( elementsKind, ElementsKind::LAST_ANY_NONEXTENSIBLE_ELEMENTS_KIND)) diff --git a/src/builtins/proxy-delete-property.tq b/src/builtins/proxy-delete-property.tq index 45914a6ed5..a5925c2f7d 100644 --- a/src/builtins/proxy-delete-property.tq +++ b/src/builtins/proxy-delete-property.tq @@ -16,7 +16,7 @@ ProxyDeleteProperty(implicit context: Context)( PerformStackCheck(); // 1. Assert: IsPropertyKey(P) is true. assert(TaggedIsNotSmi(name)); - assert(IsName(name)); + assert(Is(name)); assert(!IsPrivateSymbol(name)); try { diff --git a/src/builtins/proxy-get-property.tq b/src/builtins/proxy-get-property.tq index 2d6a1edee6..563b38be37 100644 --- a/src/builtins/proxy-get-property.tq +++ b/src/builtins/proxy-get-property.tq @@ -18,7 +18,7 @@ ProxyGetProperty(implicit context: Context)( PerformStackCheck(); // 1. Assert: IsPropertyKey(P) is true. assert(TaggedIsNotSmi(name)); - assert(IsName(name)); + assert(Is(name)); assert(!IsPrivateSymbol(name)); // 2. Let handler be O.[[ProxyHandler]]. diff --git a/src/builtins/proxy-has-property.tq b/src/builtins/proxy-has-property.tq index 488f6fabb3..fc81d5dcc9 100644 --- a/src/builtins/proxy-has-property.tq +++ b/src/builtins/proxy-has-property.tq @@ -10,12 +10,12 @@ namespace proxy { // https://tc39.github.io/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-hasproperty-p transitioning builtin ProxyHasProperty(implicit context: Context)( proxy: JSProxy, name: PropertyKey): JSAny { - assert(IsJSProxy(proxy)); + assert(Is(proxy)); PerformStackCheck(); // 1. Assert: IsPropertyKey(P) is true. - assert(IsName(name)); + assert(Is(name)); assert(!IsPrivateSymbol(name)); try { diff --git a/src/builtins/proxy-set-property.tq b/src/builtins/proxy-set-property.tq index 49f55fcd33..441a5d418d 100644 --- a/src/builtins/proxy-set-property.tq +++ b/src/builtins/proxy-set-property.tq @@ -23,7 +23,7 @@ ProxySetProperty(implicit context: Context)( receiverValue: JSAny): JSAny { // 1. Assert: IsPropertyKey(P) is true. assert(TaggedIsNotSmi(name)); - assert(IsName(name)); + assert(Is(name)); let key: PropertyKey; typeswitch (name) { diff --git a/src/codegen/code-stub-assembler.cc b/src/codegen/code-stub-assembler.cc index 6e9b817759..9d153de6a5 100644 --- a/src/codegen/code-stub-assembler.cc +++ b/src/codegen/code-stub-assembler.cc @@ -5635,14 +5635,6 @@ TNode CodeStubAssembler::IsCallableMap(SloppyTNode map) { return IsSetWord32(LoadMapBitField(map)); } -TNode CodeStubAssembler::IsCoverageInfo(TNode object) { - return IsCoverageInfoMap(LoadMap(object)); -} - -TNode CodeStubAssembler::IsDebugInfo(TNode object) { - return HasInstanceType(object, DEBUG_INFO_TYPE); -} - TNode CodeStubAssembler::IsDeprecatedMap(SloppyTNode map) { CSA_ASSERT(this, IsMap(map)); return IsSetWord32(LoadMapBitField3(map)); @@ -5774,14 +5766,6 @@ TNode CodeStubAssembler::IsCallable(SloppyTNode object) { return IsCallableMap(LoadMap(object)); } -TNode CodeStubAssembler::IsCell(SloppyTNode object) { - return TaggedEqual(LoadMap(object), CellMapConstant()); -} - -TNode CodeStubAssembler::IsCode(SloppyTNode object) { - return HasInstanceType(object, CODE_TYPE); -} - TNode CodeStubAssembler::IsConstructorMap(SloppyTNode map) { CSA_ASSERT(this, IsMap(map)); return IsSetWord32(LoadMapBitField(map)); @@ -5996,13 +5980,6 @@ TNode CodeStubAssembler::IsJSAsyncGeneratorObject( return HasInstanceType(object, JS_ASYNC_GENERATOR_OBJECT_TYPE); } -TNode CodeStubAssembler::IsContext(SloppyTNode object) { - TNode instance_type = LoadInstanceType(object); - return UncheckedCast(Word32And( - Int32GreaterThanOrEqual(instance_type, Int32Constant(FIRST_CONTEXT_TYPE)), - Int32LessThanOrEqual(instance_type, Int32Constant(LAST_CONTEXT_TYPE)))); -} - TNode CodeStubAssembler::IsFixedArray(SloppyTNode object) { return HasInstanceType(object, FIXED_ARRAY_TYPE); } @@ -6026,21 +6003,11 @@ TNode CodeStubAssembler::IsNotWeakFixedArraySubclass( Int32Constant(LAST_WEAK_FIXED_ARRAY_TYPE)))); } -TNode CodeStubAssembler::IsPromiseCapability( - SloppyTNode object) { - return HasInstanceType(object, PROMISE_CAPABILITY_TYPE); -} - TNode CodeStubAssembler::IsPropertyArray( SloppyTNode object) { return HasInstanceType(object, PROPERTY_ARRAY_TYPE); } -TNode CodeStubAssembler::IsPromiseReaction( - SloppyTNode object) { - return HasInstanceType(object, PROMISE_REACTION_TYPE); -} - TNode CodeStubAssembler::IsPromiseReactionJobTask( TNode object) { TNode instance_type = LoadInstanceType(object); @@ -6048,16 +6015,6 @@ TNode CodeStubAssembler::IsPromiseReactionJobTask( LAST_PROMISE_REACTION_JOB_TASK_TYPE); } -TNode CodeStubAssembler::IsPromiseRejectReactionJobTask( - SloppyTNode object) { - return HasInstanceType(object, PROMISE_REJECT_REACTION_JOB_TASK_TYPE); -} - -TNode CodeStubAssembler::IsPromiseFulfillReactionJobTask( - SloppyTNode object) { - return HasInstanceType(object, PROMISE_FULFILL_REACTION_JOB_TASK_TYPE); -} - // This complicated check is due to elements oddities. If a smi array is empty // after Array.p.shift, it is replaced by the empty array constant. If it is // later filled with a double element, we try to grow it but pass in a double @@ -6103,18 +6060,6 @@ TNode CodeStubAssembler::IsPropertyCell(SloppyTNode object) { return IsPropertyCellMap(LoadMap(object)); } -TNode CodeStubAssembler::IsAccessorInfo(SloppyTNode object) { - return IsAccessorInfoMap(LoadMap(object)); -} - -TNode CodeStubAssembler::IsAccessorPair(SloppyTNode object) { - return IsAccessorPairMap(LoadMap(object)); -} - -TNode CodeStubAssembler::IsHeapNumber(SloppyTNode object) { - return IsHeapNumberMap(LoadMap(object)); -} - TNode CodeStubAssembler::IsHeapNumberInstanceType( SloppyTNode instance_type) { return InstanceTypeEqual(instance_type, HEAP_NUMBER_TYPE); @@ -6129,15 +6074,6 @@ TNode CodeStubAssembler::IsOddballInstanceType( return InstanceTypeEqual(instance_type, ODDBALL_TYPE); } -TNode CodeStubAssembler::IsFeedbackCell(SloppyTNode object) { - return HasInstanceType(object, FEEDBACK_CELL_TYPE); -} - -TNode CodeStubAssembler::IsFeedbackVector( - SloppyTNode object) { - return IsFeedbackVectorMap(LoadMap(object)); -} - TNode CodeStubAssembler::IsName(SloppyTNode object) { return IsNameInstanceType(LoadInstanceType(object)); } @@ -6156,10 +6092,6 @@ TNode CodeStubAssembler::IsSymbolInstanceType( return InstanceTypeEqual(instance_type, SYMBOL_TYPE); } -TNode CodeStubAssembler::IsSymbol(SloppyTNode object) { - return IsSymbolMap(LoadMap(object)); -} - TNode CodeStubAssembler::IsInternalizedStringInstanceType( TNode instance_type) { STATIC_ASSERT(kNotInternalizedTag != 0); @@ -6225,34 +6157,11 @@ TNode CodeStubAssembler::IsPrimitiveInstanceType( Int32Constant(LAST_PRIMITIVE_HEAP_OBJECT_TYPE)); } -TNode CodeStubAssembler::IsPrivateSymbol( - SloppyTNode object) { - return Select( - IsSymbol(object), - [=] { - TNode symbol = CAST(object); - TNode flags = - LoadObjectField(symbol, Symbol::kFlagsOffset); - return IsSetWord32(flags); - }, - [=] { return Int32FalseConstant(); }); -} - TNode CodeStubAssembler::IsPrivateName(SloppyTNode symbol) { TNode flags = LoadObjectField(symbol, Symbol::kFlagsOffset); return IsSetWord32(flags); } -TNode CodeStubAssembler::IsNativeContext( - SloppyTNode object) { - return HasInstanceType(object, NATIVE_CONTEXT_TYPE); -} - -TNode CodeStubAssembler::IsFixedDoubleArray( - SloppyTNode object) { - return TaggedEqual(LoadMap(object), FixedDoubleArrayMapConstant()); -} - TNode CodeStubAssembler::IsHashTable(SloppyTNode object) { TNode instance_type = LoadInstanceType(object); return UncheckedCast( @@ -6330,12 +6239,6 @@ TNode CodeStubAssembler::IsJSRegExp(SloppyTNode object) { return HasInstanceType(object, JS_REG_EXP_TYPE); } -TNode CodeStubAssembler::IsNumber(SloppyTNode object) { - return Select( - TaggedIsSmi(object), [=] { return Int32TrueConstant(); }, - [=] { return IsHeapNumber(CAST(object)); }); -} - TNode CodeStubAssembler::IsNumeric(SloppyTNode object) { return Select( TaggedIsSmi(object), [=] { return Int32TrueConstant(); }, @@ -9663,7 +9566,7 @@ Node* CodeStubAssembler::PrepareValueForWriteToTypedArray( // We can handle both HeapNumber and Oddball here, since Oddball has the // same layout as the HeapNumber for the HeapNumber::value field. This // way we can also properly optimize stores of oddballs to typed arrays. - GotoIf(IsHeapNumber(var_input.value()), &if_heapnumber_or_oddball); + GotoIf(IsHeapNumber(CAST(var_input.value())), &if_heapnumber_or_oddball); STATIC_ASSERT_FIELD_OFFSETS_EQUAL(HeapNumber::kValueOffset, Oddball::kToNumberRawOffset); Branch(HasInstanceType(var_input.value(), ODDBALL_TYPE), diff --git a/src/codegen/code-stub-assembler.h b/src/codegen/code-stub-assembler.h index a136999399..48c45b74f5 100644 --- a/src/codegen/code-stub-assembler.h +++ b/src/codegen/code-stub-assembler.h @@ -111,132 +111,96 @@ enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; V, rootIndexName, rootAccessorName, class_name) \ V(rootIndexName, rootAccessorName, class_name##Map) -#define HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(V) \ - V(AccessorInfoMap, accessor_info_map, AccessorInfoMap) \ - V(AccessorPairMap, accessor_pair_map, AccessorPairMap) \ - V(AllocationMementoMap, allocation_memento_map, AllocationMementoMap) \ - V(AllocationSiteWithoutWeakNextMap, allocation_site_without_weaknext_map, \ - AllocationSiteWithoutWeakNextMap) \ - V(AllocationSiteWithWeakNextMap, allocation_site_map, AllocationSiteMap) \ - V(arguments_to_string, arguments_to_string, ArgumentsToString) \ - V(ArrayBoilerplateDescriptionMap, array_boilerplate_description_map, \ - ArrayBoilerplateDescriptionMap) \ - V(Array_string, Array_string, ArrayString) \ - V(array_to_string, array_to_string, ArrayToString) \ - V(BooleanMap, boolean_map, BooleanMap) \ - V(boolean_to_string, boolean_to_string, BooleanToString) \ - V(CellMap, cell_map, CellMap) \ - V(CodeMap, code_map, CodeMap) \ - V(ConsOneByteStringMap, cons_one_byte_string_map, ConsOneByteStringMap) \ - V(ConsStringMap, cons_string_map, ConsStringMap) \ - V(constructor_string, constructor_string, ConstructorString) \ - V(CoverageInfoMap, coverage_info_map, CoverageInfoMap) \ - V(date_to_string, date_to_string, DateToString) \ - V(default_string, default_string, DefaultString) \ - V(EmptyByteArray, empty_byte_array, EmptyByteArray) \ - V(EmptyFixedArray, empty_fixed_array, EmptyFixedArray) \ - V(EmptyPropertyDictionary, empty_property_dictionary, \ - EmptyPropertyDictionary) \ - V(EmptySlowElementDictionary, empty_slow_element_dictionary, \ - EmptySlowElementDictionary) \ - V(empty_string, empty_string, EmptyString) \ - V(error_to_string, error_to_string, ErrorToString) \ - V(errors_string, errors_string, ErrorsString) \ - V(FalseValue, false_value, False) \ - V(FeedbackVectorMap, feedback_vector_map, FeedbackVectorMap) \ - V(FixedArrayMap, fixed_array_map, FixedArrayMap) \ - V(FixedCOWArrayMap, fixed_cow_array_map, FixedCOWArrayMap) \ - V(FixedDoubleArrayMap, fixed_double_array_map, FixedDoubleArrayMap) \ - V(Function_string, function_string, FunctionString) \ - V(FunctionTemplateInfoMap, function_template_info_map, \ - FunctionTemplateInfoMap) \ - V(function_to_string, function_to_string, FunctionToString) \ - V(GlobalPropertyCellMap, global_property_cell_map, PropertyCellMap) \ - V(has_instance_symbol, has_instance_symbol, HasInstanceSymbol) \ - V(HeapNumberMap, heap_number_map, HeapNumberMap) \ - V(Infinity_string, Infinity_string, InfinityString) \ - V(is_concat_spreadable_symbol, is_concat_spreadable_symbol, \ - IsConcatSpreadableSymbol) \ - V(iterator_symbol, iterator_symbol, IteratorSymbol) \ - V(length_string, length_string, LengthString) \ - V(ManyClosuresCellMap, many_closures_cell_map, ManyClosuresCellMap) \ - V(match_symbol, match_symbol, MatchSymbol) \ - V(megamorphic_symbol, megamorphic_symbol, MegamorphicSymbol) \ - V(message_string, message_string, MessageString) \ - V(MetaMap, meta_map, MetaMap) \ - V(minus_Infinity_string, minus_Infinity_string, MinusInfinityString) \ - V(MinusZeroValue, minus_zero_value, MinusZero) \ - V(name_string, name_string, NameString) \ - V(NanValue, nan_value, Nan) \ - V(NaN_string, NaN_string, NaNString) \ - V(next_string, next_string, NextString) \ - V(NoClosuresCellMap, no_closures_cell_map, NoClosuresCellMap) \ - V(null_to_string, null_to_string, NullToString) \ - V(NullValue, null_value, Null) \ - V(number_string, number_string, NumberString) \ - V(number_to_string, number_to_string, NumberToString) \ - V(Object_string, Object_string, ObjectString) \ - V(object_to_string, object_to_string, ObjectToString) \ - V(OneByteStringMap, one_byte_string_map, OneByteStringMap) \ - V(OneClosureCellMap, one_closure_cell_map, OneClosureCellMap) \ - V(OnePointerFillerMap, one_pointer_filler_map, OnePointerFillerMap) \ - V(PreparseDataMap, preparse_data_map, PreparseDataMap) \ - V(PromiseCapabilityMap, promise_capability_map, PromiseCapabilityMap) \ - V(promise_forwarding_handler_symbol, promise_forwarding_handler_symbol, \ - PromiseForwardingHandlerSymbol) \ - V(PromiseFulfillReactionJobTaskMap, promise_fulfill_reaction_job_task_map, \ - PromiseFulfillReactionJobTaskMap) \ - V(promise_handled_by_symbol, promise_handled_by_symbol, \ - PromiseHandledBySymbol) \ - V(PromiseReactionMap, promise_reaction_map, PromiseReactionMap) \ - V(PromiseRejectReactionJobTaskMap, promise_reject_reaction_job_task_map, \ - PromiseRejectReactionJobTaskMap) \ - V(PromiseResolveThenableJobTaskMap, promise_resolve_thenable_job_task_map, \ - PromiseResolveThenableJobTaskMap) \ - V(prototype_string, prototype_string, PrototypeString) \ - V(PrototypeInfoMap, prototype_info_map, PrototypeInfoMap) \ - V(replace_symbol, replace_symbol, ReplaceSymbol) \ - V(regexp_to_string, regexp_to_string, RegexpToString) \ - V(resolve_string, resolve_string, ResolveString) \ - V(return_string, return_string, ReturnString) \ - V(SharedFunctionInfoMap, shared_function_info_map, SharedFunctionInfoMap) \ - V(SmallOrderedHashSetMap, small_ordered_hash_set_map, \ - SmallOrderedHashSetMap) \ - V(SmallOrderedHashMapMap, small_ordered_hash_map_map, \ - SmallOrderedHashMapMap) \ - V(SmallOrderedNameDictionaryMap, small_ordered_name_dictionary_map, \ - SmallOrderedNameDictionaryMap) \ - V(species_symbol, species_symbol, SpeciesSymbol) \ - V(StaleRegister, stale_register, StaleRegister) \ - V(StoreHandler0Map, store_handler0_map, StoreHandler0Map) \ - V(string_string, string_string, StringString) \ - V(string_to_string, string_to_string, StringToString) \ - V(StringMap, string_map, StringMap) \ - V(SymbolMap, symbol_map, SymbolMap) \ - V(TheHoleValue, the_hole_value, TheHole) \ - V(then_string, then_string, ThenString) \ - V(toString_string, toString_string, ToStringString) \ - V(to_primitive_symbol, to_primitive_symbol, ToPrimitiveSymbol) \ - V(to_string_tag_symbol, to_string_tag_symbol, ToStringTagSymbol) \ - V(TransitionArrayMap, transition_array_map, TransitionArrayMap) \ - V(TrueValue, true_value, True) \ - V(Tuple2Map, tuple2_map, Tuple2Map) \ - V(BreakPointMap, break_point_map, BreakPointMap) \ - V(BreakPointInfoMap, break_point_info_map, BreakPointInfoMap) \ - V(CachedTemplateObjectMap, cached_template_object_map, \ - CachedTemplateObjectMap) \ - V(UncompiledDataWithoutPreparseDataMap, \ - uncompiled_data_without_preparse_data_map, \ - UncompiledDataWithoutPreparseDataMap) \ - V(UncompiledDataWithPreparseDataMap, uncompiled_data_with_preparse_data_map, \ - UncompiledDataWithPreparseDataMap) \ - V(undefined_to_string, undefined_to_string, UndefinedToString) \ - V(UndefinedValue, undefined_value, Undefined) \ - V(uninitialized_symbol, uninitialized_symbol, UninitializedSymbol) \ - V(valueOf_string, valueOf_string, ValueOfString) \ - V(WeakFixedArrayMap, weak_fixed_array_map, WeakFixedArrayMap) \ - V(zero_string, zero_string, ZeroString) \ - UNIQUE_INSTANCE_TYPE_MAP_LIST_GENERATOR( \ +#define HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(V) \ + V(AllocationSiteWithoutWeakNextMap, allocation_site_without_weaknext_map, \ + AllocationSiteWithoutWeakNextMap) \ + V(AllocationSiteWithWeakNextMap, allocation_site_map, AllocationSiteMap) \ + V(arguments_to_string, arguments_to_string, ArgumentsToString) \ + V(Array_string, Array_string, ArrayString) \ + V(array_to_string, array_to_string, ArrayToString) \ + V(BooleanMap, boolean_map, BooleanMap) \ + V(boolean_to_string, boolean_to_string, BooleanToString) \ + V(ConsOneByteStringMap, cons_one_byte_string_map, ConsOneByteStringMap) \ + V(ConsStringMap, cons_string_map, ConsStringMap) \ + V(constructor_string, constructor_string, ConstructorString) \ + V(date_to_string, date_to_string, DateToString) \ + V(default_string, default_string, DefaultString) \ + V(EmptyByteArray, empty_byte_array, EmptyByteArray) \ + V(EmptyFixedArray, empty_fixed_array, EmptyFixedArray) \ + V(EmptyPropertyDictionary, empty_property_dictionary, \ + EmptyPropertyDictionary) \ + V(EmptySlowElementDictionary, empty_slow_element_dictionary, \ + EmptySlowElementDictionary) \ + V(empty_string, empty_string, EmptyString) \ + V(error_to_string, error_to_string, ErrorToString) \ + V(errors_string, errors_string, ErrorsString) \ + V(FalseValue, false_value, False) \ + V(FixedArrayMap, fixed_array_map, FixedArrayMap) \ + V(FixedCOWArrayMap, fixed_cow_array_map, FixedCOWArrayMap) \ + V(Function_string, function_string, FunctionString) \ + V(function_to_string, function_to_string, FunctionToString) \ + V(GlobalPropertyCellMap, global_property_cell_map, PropertyCellMap) \ + V(has_instance_symbol, has_instance_symbol, HasInstanceSymbol) \ + V(Infinity_string, Infinity_string, InfinityString) \ + V(is_concat_spreadable_symbol, is_concat_spreadable_symbol, \ + IsConcatSpreadableSymbol) \ + V(iterator_symbol, iterator_symbol, IteratorSymbol) \ + V(length_string, length_string, LengthString) \ + V(ManyClosuresCellMap, many_closures_cell_map, ManyClosuresCellMap) \ + V(match_symbol, match_symbol, MatchSymbol) \ + V(megamorphic_symbol, megamorphic_symbol, MegamorphicSymbol) \ + V(message_string, message_string, MessageString) \ + V(minus_Infinity_string, minus_Infinity_string, MinusInfinityString) \ + V(MinusZeroValue, minus_zero_value, MinusZero) \ + V(name_string, name_string, NameString) \ + V(NanValue, nan_value, Nan) \ + V(NaN_string, NaN_string, NaNString) \ + V(next_string, next_string, NextString) \ + V(NoClosuresCellMap, no_closures_cell_map, NoClosuresCellMap) \ + V(null_to_string, null_to_string, NullToString) \ + V(NullValue, null_value, Null) \ + V(number_string, number_string, NumberString) \ + V(number_to_string, number_to_string, NumberToString) \ + V(Object_string, Object_string, ObjectString) \ + V(object_to_string, object_to_string, ObjectToString) \ + V(OneByteStringMap, one_byte_string_map, OneByteStringMap) \ + V(OneClosureCellMap, one_closure_cell_map, OneClosureCellMap) \ + V(OnePointerFillerMap, one_pointer_filler_map, OnePointerFillerMap) \ + V(PromiseCapabilityMap, promise_capability_map, PromiseCapabilityMap) \ + V(promise_forwarding_handler_symbol, promise_forwarding_handler_symbol, \ + PromiseForwardingHandlerSymbol) \ + V(PromiseFulfillReactionJobTaskMap, promise_fulfill_reaction_job_task_map, \ + PromiseFulfillReactionJobTaskMap) \ + V(promise_handled_by_symbol, promise_handled_by_symbol, \ + PromiseHandledBySymbol) \ + V(PromiseReactionMap, promise_reaction_map, PromiseReactionMap) \ + V(PromiseRejectReactionJobTaskMap, promise_reject_reaction_job_task_map, \ + PromiseRejectReactionJobTaskMap) \ + V(PromiseResolveThenableJobTaskMap, promise_resolve_thenable_job_task_map, \ + PromiseResolveThenableJobTaskMap) \ + V(prototype_string, prototype_string, PrototypeString) \ + V(replace_symbol, replace_symbol, ReplaceSymbol) \ + V(regexp_to_string, regexp_to_string, RegexpToString) \ + V(resolve_string, resolve_string, ResolveString) \ + V(return_string, return_string, ReturnString) \ + V(species_symbol, species_symbol, SpeciesSymbol) \ + V(StaleRegister, stale_register, StaleRegister) \ + V(StoreHandler0Map, store_handler0_map, StoreHandler0Map) \ + V(string_string, string_string, StringString) \ + V(string_to_string, string_to_string, StringToString) \ + V(StringMap, string_map, StringMap) \ + V(TheHoleValue, the_hole_value, TheHole) \ + V(then_string, then_string, ThenString) \ + V(toString_string, toString_string, ToStringString) \ + V(to_primitive_symbol, to_primitive_symbol, ToPrimitiveSymbol) \ + V(to_string_tag_symbol, to_string_tag_symbol, ToStringTagSymbol) \ + V(TrueValue, true_value, True) \ + V(undefined_to_string, undefined_to_string, UndefinedToString) \ + V(UndefinedValue, undefined_value, Undefined) \ + V(uninitialized_symbol, uninitialized_symbol, UninitializedSymbol) \ + V(valueOf_string, valueOf_string, ValueOfString) \ + V(zero_string, zero_string, ZeroString) \ + UNIQUE_INSTANCE_TYPE_MAP_LIST_GENERATOR( \ UNIQUE_INSTANCE_TYPE_IMMUTABLE_IMMOVABLE_MAP_ADAPTER, V) #define HEAP_IMMOVABLE_OBJECT_LIST(V) \ @@ -465,11 +429,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler TNode TaggedToDirectString(TNode value, Label* fail); - TNode TaggedToNumber(TNode value, Label* fail) { - GotoIfNot(IsNumber(value), fail); - return UncheckedCast(value); - } - TNode TaggedToHeapObject(TNode value, Label* fail) { GotoIf(TaggedIsSmi(value), fail); return UncheckedCast(value); @@ -2524,8 +2483,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler // Check whether the map is for an object with special properties, such as a // JSProxy or an object with interceptors. TNode InstanceTypeEqual(SloppyTNode instance_type, int type); - TNode IsAccessorInfo(SloppyTNode object); - TNode IsAccessorPair(SloppyTNode object); TNode IsNoElementsProtectorCellInvalid(); TNode IsArrayIteratorProtectorCellInvalid(); TNode IsBigIntInstanceType(SloppyTNode instance_type); @@ -2534,33 +2491,24 @@ class V8_EXPORT_PRIVATE CodeStubAssembler TNode IsCallableMap(SloppyTNode map); TNode IsCallable(SloppyTNode object); TNode TaggedIsCallable(TNode object); - TNode IsCell(SloppyTNode object); - TNode IsCode(SloppyTNode object); TNode IsConsStringInstanceType(SloppyTNode instance_type); TNode IsConstructorMap(SloppyTNode map); TNode IsConstructor(SloppyTNode object); - TNode IsCoverageInfo(TNode object); - TNode IsDebugInfo(TNode object); TNode IsDeprecatedMap(SloppyTNode map); TNode IsNameDictionary(SloppyTNode object); TNode IsGlobalDictionary(SloppyTNode object); TNode IsExtensibleMap(SloppyTNode map); TNode IsExtensibleNonPrototypeMap(TNode map); TNode IsExternalStringInstanceType(SloppyTNode instance_type); - TNode IsFeedbackCell(SloppyTNode object); - TNode IsFeedbackVector(SloppyTNode object); - TNode IsContext(SloppyTNode object); TNode IsFixedArray(SloppyTNode object); TNode IsFixedArraySubclass(SloppyTNode object); TNode IsFixedArrayWithKind(SloppyTNode object, ElementsKind kind); TNode IsFixedArrayWithKindOrEmpty(SloppyTNode object, ElementsKind kind); - TNode IsFixedDoubleArray(SloppyTNode object); TNode IsFunctionWithPrototypeSlotMap(SloppyTNode map); TNode IsHashTable(SloppyTNode object); TNode IsEphemeronHashTable(SloppyTNode object); - TNode IsHeapNumber(SloppyTNode object); TNode IsHeapNumberInstanceType(SloppyTNode instance_type); TNode IsOddball(SloppyTNode object); TNode IsOddballInstanceType(SloppyTNode instance_type); @@ -2605,21 +2553,15 @@ class V8_EXPORT_PRIVATE CodeStubAssembler TNode IsMap(SloppyTNode object); TNode IsName(SloppyTNode object); TNode IsNameInstanceType(SloppyTNode instance_type); - TNode IsNativeContext(SloppyTNode object); TNode IsNullOrJSReceiver(SloppyTNode object); TNode IsNullOrUndefined(SloppyTNode object); TNode IsNumberDictionary(SloppyTNode object); TNode IsOneByteStringInstanceType(TNode instance_type); TNode IsPrimitiveInstanceType(SloppyTNode instance_type); - TNode IsPrivateSymbol(SloppyTNode object); TNode IsPrivateName(SloppyTNode symbol); - TNode IsPromiseCapability(SloppyTNode object); TNode IsPropertyArray(SloppyTNode object); TNode IsPropertyCell(SloppyTNode object); - TNode IsPromiseReaction(SloppyTNode object); TNode IsPromiseReactionJobTask(TNode object); - TNode IsPromiseRejectReactionJobTask(SloppyTNode object); - TNode IsPromiseFulfillReactionJobTask(SloppyTNode object); TNode IsPrototypeInitialArrayPrototype(SloppyTNode context, SloppyTNode map); TNode IsPrototypeTypedArrayPrototype(SloppyTNode context, @@ -2643,7 +2585,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler TNode IsStringInstanceType(SloppyTNode instance_type); TNode IsString(SloppyTNode object); TNode IsSymbolInstanceType(SloppyTNode instance_type); - TNode IsSymbol(SloppyTNode object); TNode IsInternalizedStringInstanceType(TNode instance_type); TNode IsUniqueName(TNode object); TNode IsUniqueNameNoIndex(TNode object); @@ -2652,10 +2593,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler TNode IsNotWeakFixedArraySubclass(SloppyTNode object); TNode IsZeroOrContext(SloppyTNode object); - inline TNode IsSharedFunctionInfo(TNode object) { - return IsSharedFunctionInfoMap(LoadMap(object)); - } - TNode IsPromiseResolveProtectorCellInvalid(); TNode IsPromiseThenProtectorCellInvalid(); TNode IsArraySpeciesProtectorCellInvalid(); @@ -2672,8 +2609,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler Int32Constant(0)); } - // True iff |object| is a Smi or a HeapNumber. - TNode IsNumber(SloppyTNode object); // True iff |object| is a Smi or a HeapNumber or a BigInt. TNode IsNumeric(SloppyTNode object); @@ -2705,6 +2640,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler Node* element_count, int base_size = FixedArray::kHeaderSize, ParameterMode mode = INTPTR_PARAMETERS); + TNode IsMetaMap(TNode o) { return IsMapMap(o); } + // ElementsKind helpers: TNode ElementsKindEqual(TNode a, TNode b) { return Word32Equal(a, b); diff --git a/src/objects/instance-type.h b/src/objects/instance-type.h index 077eb30701..03e479747f 100644 --- a/src/objects/instance-type.h +++ b/src/objects/instance-type.h @@ -245,7 +245,44 @@ TYPED_ARRAYS(TYPED_ARRAY_IS_TYPE_FUNCTION_DECL) // This list must contain only maps that are shared by all objects of their // instance type. -#define UNIQUE_INSTANCE_TYPE_MAP_LIST_GENERATOR(V, _) \ +#define UNIQUE_INSTANCE_TYPE_MAP_LIST_GENERATOR(V, _) \ + V(_, AccessorInfoMap, accessor_info_map, AccessorInfo) \ + V(_, AccessorPairMap, accessor_pair_map, AccessorPair) \ + V(_, AllocationMementoMap, allocation_memento_map, AllocationMemento) \ + V(_, ArrayBoilerplateDescriptionMap, array_boilerplate_description_map, \ + ArrayBoilerplateDescription) \ + V(_, BreakPointMap, break_point_map, BreakPoint) \ + V(_, BreakPointInfoMap, break_point_info_map, BreakPointInfo) \ + V(_, CachedTemplateObjectMap, cached_template_object_map, \ + CachedTemplateObject) \ + V(_, CellMap, cell_map, Cell) \ + V(_, CodeMap, code_map, Code) \ + V(_, CoverageInfoMap, coverage_info_map, CoverageInfo) \ + V(_, DebugInfoMap, debug_info_map, DebugInfo) \ + V(_, FeedbackVectorMap, feedback_vector_map, FeedbackVector) \ + V(_, FixedDoubleArrayMap, fixed_double_array_map, FixedDoubleArray) \ + V(_, FunctionTemplateInfoMap, function_template_info_map, \ + FunctionTemplateInfo) \ + V(_, HeapNumberMap, heap_number_map, HeapNumber) \ + V(_, MetaMap, meta_map, Map) \ + V(_, PreparseDataMap, preparse_data_map, PreparseData) \ + V(_, PrototypeInfoMap, prototype_info_map, PrototypeInfo) \ + V(_, SharedFunctionInfoMap, shared_function_info_map, SharedFunctionInfo) \ + V(_, SmallOrderedHashSetMap, small_ordered_hash_set_map, \ + SmallOrderedHashSet) \ + V(_, SmallOrderedHashMapMap, small_ordered_hash_map_map, \ + SmallOrderedHashMap) \ + V(_, SmallOrderedNameDictionaryMap, small_ordered_name_dictionary_map, \ + SmallOrderedNameDictionary) \ + V(_, SymbolMap, symbol_map, Symbol) \ + V(_, TransitionArrayMap, transition_array_map, TransitionArray) \ + V(_, Tuple2Map, tuple2_map, Tuple2) \ + V(_, UncompiledDataWithoutPreparseDataMap, \ + uncompiled_data_without_preparse_data_map, \ + UncompiledDataWithoutPreparseData) \ + V(_, UncompiledDataWithPreparseDataMap, \ + uncompiled_data_with_preparse_data_map, UncompiledDataWithPreparseData) \ + V(_, WeakFixedArrayMap, weak_fixed_array_map, WeakFixedArray) \ TORQUE_DEFINED_MAP_CSA_LIST_GENERATOR(V, _) } // namespace internal diff --git a/test/cctest/test-code-stub-assembler.cc b/test/cctest/test-code-stub-assembler.cc index a3434ae3c3..4dc67f07e3 100644 --- a/test/cctest/test-code-stub-assembler.cc +++ b/test/cctest/test-code-stub-assembler.cc @@ -2418,7 +2418,7 @@ TEST(IsSymbol) { CodeAssemblerTester asm_tester(isolate, kNumParams); CodeStubAssembler m(asm_tester.state()); - Node* const symbol = m.Parameter(0); + TNode const symbol = m.CAST(m.Parameter(0)); m.Return(m.SelectBooleanConstant(m.IsSymbol(symbol))); FunctionTester ft(asm_tester.GenerateCode(), kNumParams); @@ -2437,7 +2437,7 @@ TEST(IsPrivateSymbol) { CodeAssemblerTester asm_tester(isolate, kNumParams); CodeStubAssembler m(asm_tester.state()); - Node* const symbol = m.Parameter(0); + TNode const symbol = m.CAST(m.Parameter(0)); m.Return(m.SelectBooleanConstant(m.IsPrivateSymbol(symbol))); FunctionTester ft(asm_tester.GenerateCode(), kNumParams);