11cb0ef41Sopenharmony_ci// Copyright 2016 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef V8_CODEGEN_CODE_STUB_ASSEMBLER_H_
61cb0ef41Sopenharmony_ci#define V8_CODEGEN_CODE_STUB_ASSEMBLER_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include <functional>
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci#include "src/base/macros.h"
111cb0ef41Sopenharmony_ci#include "src/codegen/bailout-reason.h"
121cb0ef41Sopenharmony_ci#include "src/codegen/tnode.h"
131cb0ef41Sopenharmony_ci#include "src/common/globals.h"
141cb0ef41Sopenharmony_ci#include "src/common/message-template.h"
151cb0ef41Sopenharmony_ci#include "src/compiler/code-assembler.h"
161cb0ef41Sopenharmony_ci#include "src/numbers/integer-literal.h"
171cb0ef41Sopenharmony_ci#include "src/objects/arguments.h"
181cb0ef41Sopenharmony_ci#include "src/objects/bigint.h"
191cb0ef41Sopenharmony_ci#include "src/objects/cell.h"
201cb0ef41Sopenharmony_ci#include "src/objects/feedback-vector.h"
211cb0ef41Sopenharmony_ci#include "src/objects/js-function.h"
221cb0ef41Sopenharmony_ci#include "src/objects/js-generator.h"
231cb0ef41Sopenharmony_ci#include "src/objects/js-promise.h"
241cb0ef41Sopenharmony_ci#include "src/objects/objects.h"
251cb0ef41Sopenharmony_ci#include "src/objects/promise.h"
261cb0ef41Sopenharmony_ci#include "src/objects/shared-function-info.h"
271cb0ef41Sopenharmony_ci#include "src/objects/smi.h"
281cb0ef41Sopenharmony_ci#include "src/objects/swiss-name-dictionary.h"
291cb0ef41Sopenharmony_ci#include "src/objects/tagged-index.h"
301cb0ef41Sopenharmony_ci#include "src/roots/roots.h"
311cb0ef41Sopenharmony_ci#include "src/sandbox/external-pointer.h"
321cb0ef41Sopenharmony_ci#include "torque-generated/exported-macros-assembler.h"
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_cinamespace v8 {
351cb0ef41Sopenharmony_cinamespace internal {
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ciclass CallInterfaceDescriptor;
381cb0ef41Sopenharmony_ciclass CodeStubArguments;
391cb0ef41Sopenharmony_ciclass CodeStubAssembler;
401cb0ef41Sopenharmony_ciclass StatsCounter;
411cb0ef41Sopenharmony_ciclass StubCache;
421cb0ef41Sopenharmony_ci
431cb0ef41Sopenharmony_cienum class PrimitiveType { kBoolean, kNumber, kString, kSymbol };
441cb0ef41Sopenharmony_ci
451cb0ef41Sopenharmony_ci#define HEAP_MUTABLE_IMMOVABLE_OBJECT_LIST(V)                                  \
461cb0ef41Sopenharmony_ci  V(ArrayIteratorProtector, array_iterator_protector, ArrayIteratorProtector)  \
471cb0ef41Sopenharmony_ci  V(ArraySpeciesProtector, array_species_protector, ArraySpeciesProtector)     \
481cb0ef41Sopenharmony_ci  V(AsyncFunctionAwaitRejectSharedFun, async_function_await_reject_shared_fun, \
491cb0ef41Sopenharmony_ci    AsyncFunctionAwaitRejectSharedFun)                                         \
501cb0ef41Sopenharmony_ci  V(AsyncFunctionAwaitResolveSharedFun,                                        \
511cb0ef41Sopenharmony_ci    async_function_await_resolve_shared_fun,                                   \
521cb0ef41Sopenharmony_ci    AsyncFunctionAwaitResolveSharedFun)                                        \
531cb0ef41Sopenharmony_ci  V(AsyncGeneratorAwaitRejectSharedFun,                                        \
541cb0ef41Sopenharmony_ci    async_generator_await_reject_shared_fun,                                   \
551cb0ef41Sopenharmony_ci    AsyncGeneratorAwaitRejectSharedFun)                                        \
561cb0ef41Sopenharmony_ci  V(AsyncGeneratorAwaitResolveSharedFun,                                       \
571cb0ef41Sopenharmony_ci    async_generator_await_resolve_shared_fun,                                  \
581cb0ef41Sopenharmony_ci    AsyncGeneratorAwaitResolveSharedFun)                                       \
591cb0ef41Sopenharmony_ci  V(AsyncGeneratorReturnClosedRejectSharedFun,                                 \
601cb0ef41Sopenharmony_ci    async_generator_return_closed_reject_shared_fun,                           \
611cb0ef41Sopenharmony_ci    AsyncGeneratorReturnClosedRejectSharedFun)                                 \
621cb0ef41Sopenharmony_ci  V(AsyncGeneratorReturnClosedResolveSharedFun,                                \
631cb0ef41Sopenharmony_ci    async_generator_return_closed_resolve_shared_fun,                          \
641cb0ef41Sopenharmony_ci    AsyncGeneratorReturnClosedResolveSharedFun)                                \
651cb0ef41Sopenharmony_ci  V(AsyncGeneratorReturnResolveSharedFun,                                      \
661cb0ef41Sopenharmony_ci    async_generator_return_resolve_shared_fun,                                 \
671cb0ef41Sopenharmony_ci    AsyncGeneratorReturnResolveSharedFun)                                      \
681cb0ef41Sopenharmony_ci  V(AsyncGeneratorYieldResolveSharedFun,                                       \
691cb0ef41Sopenharmony_ci    async_generator_yield_resolve_shared_fun,                                  \
701cb0ef41Sopenharmony_ci    AsyncGeneratorYieldResolveSharedFun)                                       \
711cb0ef41Sopenharmony_ci  V(AsyncIteratorValueUnwrapSharedFun, async_iterator_value_unwrap_shared_fun, \
721cb0ef41Sopenharmony_ci    AsyncIteratorValueUnwrapSharedFun)                                         \
731cb0ef41Sopenharmony_ci  V(IsConcatSpreadableProtector, is_concat_spreadable_protector,               \
741cb0ef41Sopenharmony_ci    IsConcatSpreadableProtector)                                               \
751cb0ef41Sopenharmony_ci  V(MapIteratorProtector, map_iterator_protector, MapIteratorProtector)        \
761cb0ef41Sopenharmony_ci  V(NoElementsProtector, no_elements_protector, NoElementsProtector)           \
771cb0ef41Sopenharmony_ci  V(MegaDOMProtector, mega_dom_protector, MegaDOMProtector)                    \
781cb0ef41Sopenharmony_ci  V(NumberStringCache, number_string_cache, NumberStringCache)                 \
791cb0ef41Sopenharmony_ci  V(PromiseAllResolveElementSharedFun, promise_all_resolve_element_shared_fun, \
801cb0ef41Sopenharmony_ci    PromiseAllResolveElementSharedFun)                                         \
811cb0ef41Sopenharmony_ci  V(PromiseAllSettledRejectElementSharedFun,                                   \
821cb0ef41Sopenharmony_ci    promise_all_settled_reject_element_shared_fun,                             \
831cb0ef41Sopenharmony_ci    PromiseAllSettledRejectElementSharedFun)                                   \
841cb0ef41Sopenharmony_ci  V(PromiseAllSettledResolveElementSharedFun,                                  \
851cb0ef41Sopenharmony_ci    promise_all_settled_resolve_element_shared_fun,                            \
861cb0ef41Sopenharmony_ci    PromiseAllSettledResolveElementSharedFun)                                  \
871cb0ef41Sopenharmony_ci  V(PromiseAnyRejectElementSharedFun, promise_any_reject_element_shared_fun,   \
881cb0ef41Sopenharmony_ci    PromiseAnyRejectElementSharedFun)                                          \
891cb0ef41Sopenharmony_ci  V(PromiseCapabilityDefaultRejectSharedFun,                                   \
901cb0ef41Sopenharmony_ci    promise_capability_default_reject_shared_fun,                              \
911cb0ef41Sopenharmony_ci    PromiseCapabilityDefaultRejectSharedFun)                                   \
921cb0ef41Sopenharmony_ci  V(PromiseCapabilityDefaultResolveSharedFun,                                  \
931cb0ef41Sopenharmony_ci    promise_capability_default_resolve_shared_fun,                             \
941cb0ef41Sopenharmony_ci    PromiseCapabilityDefaultResolveSharedFun)                                  \
951cb0ef41Sopenharmony_ci  V(PromiseCatchFinallySharedFun, promise_catch_finally_shared_fun,            \
961cb0ef41Sopenharmony_ci    PromiseCatchFinallySharedFun)                                              \
971cb0ef41Sopenharmony_ci  V(PromiseGetCapabilitiesExecutorSharedFun,                                   \
981cb0ef41Sopenharmony_ci    promise_get_capabilities_executor_shared_fun,                              \
991cb0ef41Sopenharmony_ci    PromiseGetCapabilitiesExecutorSharedFun)                                   \
1001cb0ef41Sopenharmony_ci  V(PromiseResolveProtector, promise_resolve_protector,                        \
1011cb0ef41Sopenharmony_ci    PromiseResolveProtector)                                                   \
1021cb0ef41Sopenharmony_ci  V(PromiseSpeciesProtector, promise_species_protector,                        \
1031cb0ef41Sopenharmony_ci    PromiseSpeciesProtector)                                                   \
1041cb0ef41Sopenharmony_ci  V(PromiseThenFinallySharedFun, promise_then_finally_shared_fun,              \
1051cb0ef41Sopenharmony_ci    PromiseThenFinallySharedFun)                                               \
1061cb0ef41Sopenharmony_ci  V(PromiseThenProtector, promise_then_protector, PromiseThenProtector)        \
1071cb0ef41Sopenharmony_ci  V(PromiseThrowerFinallySharedFun, promise_thrower_finally_shared_fun,        \
1081cb0ef41Sopenharmony_ci    PromiseThrowerFinallySharedFun)                                            \
1091cb0ef41Sopenharmony_ci  V(PromiseValueThunkFinallySharedFun, promise_value_thunk_finally_shared_fun, \
1101cb0ef41Sopenharmony_ci    PromiseValueThunkFinallySharedFun)                                         \
1111cb0ef41Sopenharmony_ci  V(ProxyRevokeSharedFun, proxy_revoke_shared_fun, ProxyRevokeSharedFun)       \
1121cb0ef41Sopenharmony_ci  V(RegExpSpeciesProtector, regexp_species_protector, RegExpSpeciesProtector)  \
1131cb0ef41Sopenharmony_ci  V(SetIteratorProtector, set_iterator_protector, SetIteratorProtector)        \
1141cb0ef41Sopenharmony_ci  V(SingleCharacterStringCache, single_character_string_cache,                 \
1151cb0ef41Sopenharmony_ci    SingleCharacterStringCache)                                                \
1161cb0ef41Sopenharmony_ci  V(StringIteratorProtector, string_iterator_protector,                        \
1171cb0ef41Sopenharmony_ci    StringIteratorProtector)                                                   \
1181cb0ef41Sopenharmony_ci  V(TypedArraySpeciesProtector, typed_array_species_protector,                 \
1191cb0ef41Sopenharmony_ci    TypedArraySpeciesProtector)
1201cb0ef41Sopenharmony_ci
1211cb0ef41Sopenharmony_ci#define UNIQUE_INSTANCE_TYPE_IMMUTABLE_IMMOVABLE_MAP_ADAPTER( \
1221cb0ef41Sopenharmony_ci    V, rootIndexName, rootAccessorName, class_name)           \
1231cb0ef41Sopenharmony_ci  V(rootIndexName, rootAccessorName, class_name##Map)
1241cb0ef41Sopenharmony_ci
1251cb0ef41Sopenharmony_ci#define HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(V)                              \
1261cb0ef41Sopenharmony_ci  V(AllocationSiteWithoutWeakNextMap, allocation_site_without_weaknext_map,  \
1271cb0ef41Sopenharmony_ci    AllocationSiteWithoutWeakNextMap)                                        \
1281cb0ef41Sopenharmony_ci  V(AllocationSiteWithWeakNextMap, allocation_site_map, AllocationSiteMap)   \
1291cb0ef41Sopenharmony_ci  V(arguments_to_string, arguments_to_string, ArgumentsToString)             \
1301cb0ef41Sopenharmony_ci  V(Array_string, Array_string, ArrayString)                                 \
1311cb0ef41Sopenharmony_ci  V(array_to_string, array_to_string, ArrayToString)                         \
1321cb0ef41Sopenharmony_ci  V(BooleanMap, boolean_map, BooleanMap)                                     \
1331cb0ef41Sopenharmony_ci  V(boolean_to_string, boolean_to_string, BooleanToString)                   \
1341cb0ef41Sopenharmony_ci  V(ConsOneByteStringMap, cons_one_byte_string_map, ConsOneByteStringMap)    \
1351cb0ef41Sopenharmony_ci  V(ConsStringMap, cons_string_map, ConsStringMap)                           \
1361cb0ef41Sopenharmony_ci  V(constructor_string, constructor_string, ConstructorString)               \
1371cb0ef41Sopenharmony_ci  V(date_to_string, date_to_string, DateToString)                            \
1381cb0ef41Sopenharmony_ci  V(default_string, default_string, DefaultString)                           \
1391cb0ef41Sopenharmony_ci  V(EmptyByteArray, empty_byte_array, EmptyByteArray)                        \
1401cb0ef41Sopenharmony_ci  V(EmptyFixedArray, empty_fixed_array, EmptyFixedArray)                     \
1411cb0ef41Sopenharmony_ci  V(EmptyScopeInfo, empty_scope_info, EmptyScopeInfo)                        \
1421cb0ef41Sopenharmony_ci  V(EmptyPropertyDictionary, empty_property_dictionary,                      \
1431cb0ef41Sopenharmony_ci    EmptyPropertyDictionary)                                                 \
1441cb0ef41Sopenharmony_ci  V(EmptyOrderedPropertyDictionary, empty_ordered_property_dictionary,       \
1451cb0ef41Sopenharmony_ci    EmptyOrderedPropertyDictionary)                                          \
1461cb0ef41Sopenharmony_ci  V(EmptySwissPropertyDictionary, empty_swiss_property_dictionary,           \
1471cb0ef41Sopenharmony_ci    EmptySwissPropertyDictionary)                                            \
1481cb0ef41Sopenharmony_ci  V(EmptySlowElementDictionary, empty_slow_element_dictionary,               \
1491cb0ef41Sopenharmony_ci    EmptySlowElementDictionary)                                              \
1501cb0ef41Sopenharmony_ci  V(empty_string, empty_string, EmptyString)                                 \
1511cb0ef41Sopenharmony_ci  V(error_to_string, error_to_string, ErrorToString)                         \
1521cb0ef41Sopenharmony_ci  V(errors_string, errors_string, ErrorsString)                              \
1531cb0ef41Sopenharmony_ci  V(FalseValue, false_value, False)                                          \
1541cb0ef41Sopenharmony_ci  V(FixedArrayMap, fixed_array_map, FixedArrayMap)                           \
1551cb0ef41Sopenharmony_ci  V(FixedCOWArrayMap, fixed_cow_array_map, FixedCOWArrayMap)                 \
1561cb0ef41Sopenharmony_ci  V(Function_string, function_string, FunctionString)                        \
1571cb0ef41Sopenharmony_ci  V(function_to_string, function_to_string, FunctionToString)                \
1581cb0ef41Sopenharmony_ci  V(GlobalPropertyCellMap, global_property_cell_map, PropertyCellMap)        \
1591cb0ef41Sopenharmony_ci  V(has_instance_symbol, has_instance_symbol, HasInstanceSymbol)             \
1601cb0ef41Sopenharmony_ci  V(Infinity_string, Infinity_string, InfinityString)                        \
1611cb0ef41Sopenharmony_ci  V(is_concat_spreadable_symbol, is_concat_spreadable_symbol,                \
1621cb0ef41Sopenharmony_ci    IsConcatSpreadableSymbol)                                                \
1631cb0ef41Sopenharmony_ci  V(iterator_symbol, iterator_symbol, IteratorSymbol)                        \
1641cb0ef41Sopenharmony_ci  V(length_string, length_string, LengthString)                              \
1651cb0ef41Sopenharmony_ci  V(ManyClosuresCellMap, many_closures_cell_map, ManyClosuresCellMap)        \
1661cb0ef41Sopenharmony_ci  V(match_symbol, match_symbol, MatchSymbol)                                 \
1671cb0ef41Sopenharmony_ci  V(megamorphic_symbol, megamorphic_symbol, MegamorphicSymbol)               \
1681cb0ef41Sopenharmony_ci  V(mega_dom_symbol, mega_dom_symbol, MegaDOMSymbol)                         \
1691cb0ef41Sopenharmony_ci  V(message_string, message_string, MessageString)                           \
1701cb0ef41Sopenharmony_ci  V(minus_Infinity_string, minus_Infinity_string, MinusInfinityString)       \
1711cb0ef41Sopenharmony_ci  V(MinusZeroValue, minus_zero_value, MinusZero)                             \
1721cb0ef41Sopenharmony_ci  V(name_string, name_string, NameString)                                    \
1731cb0ef41Sopenharmony_ci  V(NanValue, nan_value, Nan)                                                \
1741cb0ef41Sopenharmony_ci  V(NaN_string, NaN_string, NaNString)                                       \
1751cb0ef41Sopenharmony_ci  V(next_string, next_string, NextString)                                    \
1761cb0ef41Sopenharmony_ci  V(NoClosuresCellMap, no_closures_cell_map, NoClosuresCellMap)              \
1771cb0ef41Sopenharmony_ci  V(null_to_string, null_to_string, NullToString)                            \
1781cb0ef41Sopenharmony_ci  V(NullValue, null_value, Null)                                             \
1791cb0ef41Sopenharmony_ci  V(number_string, number_string, NumberString)                              \
1801cb0ef41Sopenharmony_ci  V(number_to_string, number_to_string, NumberToString)                      \
1811cb0ef41Sopenharmony_ci  V(Object_string, Object_string, ObjectString)                              \
1821cb0ef41Sopenharmony_ci  V(object_to_string, object_to_string, ObjectToString)                      \
1831cb0ef41Sopenharmony_ci  V(OneByteStringMap, one_byte_string_map, OneByteStringMap)                 \
1841cb0ef41Sopenharmony_ci  V(OneClosureCellMap, one_closure_cell_map, OneClosureCellMap)              \
1851cb0ef41Sopenharmony_ci  V(OnePointerFillerMap, one_pointer_filler_map, OnePointerFillerMap)        \
1861cb0ef41Sopenharmony_ci  V(PromiseCapabilityMap, promise_capability_map, PromiseCapabilityMap)      \
1871cb0ef41Sopenharmony_ci  V(promise_forwarding_handler_symbol, promise_forwarding_handler_symbol,    \
1881cb0ef41Sopenharmony_ci    PromiseForwardingHandlerSymbol)                                          \
1891cb0ef41Sopenharmony_ci  V(PromiseFulfillReactionJobTaskMap, promise_fulfill_reaction_job_task_map, \
1901cb0ef41Sopenharmony_ci    PromiseFulfillReactionJobTaskMap)                                        \
1911cb0ef41Sopenharmony_ci  V(promise_handled_by_symbol, promise_handled_by_symbol,                    \
1921cb0ef41Sopenharmony_ci    PromiseHandledBySymbol)                                                  \
1931cb0ef41Sopenharmony_ci  V(PromiseReactionMap, promise_reaction_map, PromiseReactionMap)            \
1941cb0ef41Sopenharmony_ci  V(PromiseRejectReactionJobTaskMap, promise_reject_reaction_job_task_map,   \
1951cb0ef41Sopenharmony_ci    PromiseRejectReactionJobTaskMap)                                         \
1961cb0ef41Sopenharmony_ci  V(PromiseResolveThenableJobTaskMap, promise_resolve_thenable_job_task_map, \
1971cb0ef41Sopenharmony_ci    PromiseResolveThenableJobTaskMap)                                        \
1981cb0ef41Sopenharmony_ci  V(prototype_string, prototype_string, PrototypeString)                     \
1991cb0ef41Sopenharmony_ci  V(replace_symbol, replace_symbol, ReplaceSymbol)                           \
2001cb0ef41Sopenharmony_ci  V(regexp_to_string, regexp_to_string, RegexpToString)                      \
2011cb0ef41Sopenharmony_ci  V(resolve_string, resolve_string, ResolveString)                           \
2021cb0ef41Sopenharmony_ci  V(return_string, return_string, ReturnString)                              \
2031cb0ef41Sopenharmony_ci  V(search_symbol, search_symbol, SearchSymbol)                              \
2041cb0ef41Sopenharmony_ci  V(species_symbol, species_symbol, SpeciesSymbol)                           \
2051cb0ef41Sopenharmony_ci  V(StaleRegister, stale_register, StaleRegister)                            \
2061cb0ef41Sopenharmony_ci  V(StoreHandler0Map, store_handler0_map, StoreHandler0Map)                  \
2071cb0ef41Sopenharmony_ci  V(string_string, string_string, StringString)                              \
2081cb0ef41Sopenharmony_ci  V(string_to_string, string_to_string, StringToString)                      \
2091cb0ef41Sopenharmony_ci  V(StringMap, string_map, StringMap)                                        \
2101cb0ef41Sopenharmony_ci  V(TheHoleValue, the_hole_value, TheHole)                                   \
2111cb0ef41Sopenharmony_ci  V(then_string, then_string, ThenString)                                    \
2121cb0ef41Sopenharmony_ci  V(toString_string, toString_string, ToStringString)                        \
2131cb0ef41Sopenharmony_ci  V(to_primitive_symbol, to_primitive_symbol, ToPrimitiveSymbol)             \
2141cb0ef41Sopenharmony_ci  V(to_string_tag_symbol, to_string_tag_symbol, ToStringTagSymbol)           \
2151cb0ef41Sopenharmony_ci  V(TrueValue, true_value, True)                                             \
2161cb0ef41Sopenharmony_ci  V(undefined_to_string, undefined_to_string, UndefinedToString)             \
2171cb0ef41Sopenharmony_ci  V(UndefinedValue, undefined_value, Undefined)                              \
2181cb0ef41Sopenharmony_ci  V(uninitialized_symbol, uninitialized_symbol, UninitializedSymbol)         \
2191cb0ef41Sopenharmony_ci  V(valueOf_string, valueOf_string, ValueOfString)                           \
2201cb0ef41Sopenharmony_ci  V(wasm_wrapped_object_symbol, wasm_wrapped_object_symbol,                  \
2211cb0ef41Sopenharmony_ci    WasmWrappedObjectSymbol)                                                 \
2221cb0ef41Sopenharmony_ci  V(zero_string, zero_string, ZeroString)                                    \
2231cb0ef41Sopenharmony_ci  UNIQUE_INSTANCE_TYPE_MAP_LIST_GENERATOR(                                   \
2241cb0ef41Sopenharmony_ci      UNIQUE_INSTANCE_TYPE_IMMUTABLE_IMMOVABLE_MAP_ADAPTER, V)
2251cb0ef41Sopenharmony_ci
2261cb0ef41Sopenharmony_ci#define HEAP_IMMOVABLE_OBJECT_LIST(V)   \
2271cb0ef41Sopenharmony_ci  HEAP_MUTABLE_IMMOVABLE_OBJECT_LIST(V) \
2281cb0ef41Sopenharmony_ci  HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(V)
2291cb0ef41Sopenharmony_ci
2301cb0ef41Sopenharmony_ci#ifdef DEBUG
2311cb0ef41Sopenharmony_ci#define CSA_CHECK(csa, x) \
2321cb0ef41Sopenharmony_ci  (csa)->Check([&]() -> TNode<BoolT> { return x; }, #x, __FILE__, __LINE__)
2331cb0ef41Sopenharmony_ci#else
2341cb0ef41Sopenharmony_ci#define CSA_CHECK(csa, x) (csa)->FastCheck(x)
2351cb0ef41Sopenharmony_ci#endif
2361cb0ef41Sopenharmony_ci
2371cb0ef41Sopenharmony_ci#ifdef DEBUG
2381cb0ef41Sopenharmony_ci// CSA_DCHECK_ARGS generates an
2391cb0ef41Sopenharmony_ci// std::initializer_list<CodeStubAssembler::ExtraNode> from __VA_ARGS__. It
2401cb0ef41Sopenharmony_ci// currently supports between 0 and 2 arguments.
2411cb0ef41Sopenharmony_ci
2421cb0ef41Sopenharmony_ci// clang-format off
2431cb0ef41Sopenharmony_ci#define CSA_DCHECK_0_ARGS(...) {}
2441cb0ef41Sopenharmony_ci#define CSA_DCHECK_1_ARG(a, ...) {{a, #a}}
2451cb0ef41Sopenharmony_ci#define CSA_DCHECK_2_ARGS(a, b, ...) {{a, #a}, {b, #b}}
2461cb0ef41Sopenharmony_ci// clang-format on
2471cb0ef41Sopenharmony_ci#define SWITCH_CSA_DCHECK_ARGS(dummy, a, b, FUNC, ...) FUNC(a, b)
2481cb0ef41Sopenharmony_ci#define CSA_DCHECK_ARGS(...)                                        \
2491cb0ef41Sopenharmony_ci  CALL(SWITCH_CSA_DCHECK_ARGS, (, ##__VA_ARGS__, CSA_DCHECK_2_ARGS, \
2501cb0ef41Sopenharmony_ci                                CSA_DCHECK_1_ARG, CSA_DCHECK_0_ARGS))
2511cb0ef41Sopenharmony_ci// Workaround for MSVC to skip comma in empty __VA_ARGS__.
2521cb0ef41Sopenharmony_ci#define CALL(x, y) x y
2531cb0ef41Sopenharmony_ci
2541cb0ef41Sopenharmony_ci// CSA_DCHECK(csa, <condition>, <extra values to print...>)
2551cb0ef41Sopenharmony_ci
2561cb0ef41Sopenharmony_ci#define CSA_DCHECK(csa, condition_node, ...)                         \
2571cb0ef41Sopenharmony_ci  (csa)->Dcheck(condition_node, #condition_node, __FILE__, __LINE__, \
2581cb0ef41Sopenharmony_ci                CSA_DCHECK_ARGS(__VA_ARGS__))
2591cb0ef41Sopenharmony_ci
2601cb0ef41Sopenharmony_ci// CSA_DCHECK_BRANCH(csa, [](Label* ok, Label* not_ok) {...},
2611cb0ef41Sopenharmony_ci//     <extra values to print...>)
2621cb0ef41Sopenharmony_ci
2631cb0ef41Sopenharmony_ci#define CSA_DCHECK_BRANCH(csa, gen, ...) \
2641cb0ef41Sopenharmony_ci  (csa)->Dcheck(gen, #gen, __FILE__, __LINE__, CSA_DCHECK_ARGS(__VA_ARGS__))
2651cb0ef41Sopenharmony_ci
2661cb0ef41Sopenharmony_ci#define CSA_DCHECK_JS_ARGC_OP(csa, Op, op, expected)                           \
2671cb0ef41Sopenharmony_ci  (csa)->Dcheck(                                                               \
2681cb0ef41Sopenharmony_ci      [&]() -> TNode<BoolT> {                                                  \
2691cb0ef41Sopenharmony_ci        const TNode<Word32T> argc = (csa)->UncheckedParameter<Word32T>(        \
2701cb0ef41Sopenharmony_ci            Descriptor::kJSActualArgumentsCount);                              \
2711cb0ef41Sopenharmony_ci        return (csa)->Op(argc,                                                 \
2721cb0ef41Sopenharmony_ci                         (csa)->Int32Constant(i::JSParameterCount(expected))); \
2731cb0ef41Sopenharmony_ci      },                                                                       \
2741cb0ef41Sopenharmony_ci      "argc " #op " " #expected, __FILE__, __LINE__,                           \
2751cb0ef41Sopenharmony_ci      {{SmiFromInt32((csa)->UncheckedParameter<Int32T>(                        \
2761cb0ef41Sopenharmony_ci            Descriptor::kJSActualArgumentsCount)),                             \
2771cb0ef41Sopenharmony_ci        "argc"}})
2781cb0ef41Sopenharmony_ci
2791cb0ef41Sopenharmony_ci#define CSA_DCHECK_JS_ARGC_EQ(csa, expected) \
2801cb0ef41Sopenharmony_ci  CSA_DCHECK_JS_ARGC_OP(csa, Word32Equal, ==, expected)
2811cb0ef41Sopenharmony_ci
2821cb0ef41Sopenharmony_ci#define CSA_DEBUG_INFO(name) \
2831cb0ef41Sopenharmony_ci  { #name, __FILE__, __LINE__ }
2841cb0ef41Sopenharmony_ci#define BIND(label) Bind(label, CSA_DEBUG_INFO(label))
2851cb0ef41Sopenharmony_ci#define TYPED_VARIABLE_DEF(type, name, ...) \
2861cb0ef41Sopenharmony_ci  TVariable<type> name(CSA_DEBUG_INFO(name), __VA_ARGS__)
2871cb0ef41Sopenharmony_ci#define TYPED_VARIABLE_CONSTRUCTOR(name, ...) \
2881cb0ef41Sopenharmony_ci  name(CSA_DEBUG_INFO(name), __VA_ARGS__)
2891cb0ef41Sopenharmony_ci#else  // DEBUG
2901cb0ef41Sopenharmony_ci#define CSA_DCHECK(csa, ...) ((void)0)
2911cb0ef41Sopenharmony_ci#define CSA_DCHECK_BRANCH(csa, ...) ((void)0)
2921cb0ef41Sopenharmony_ci#define CSA_DCHECK_JS_ARGC_EQ(csa, expected) ((void)0)
2931cb0ef41Sopenharmony_ci#define BIND(label) Bind(label)
2941cb0ef41Sopenharmony_ci#define TYPED_VARIABLE_DEF(type, name, ...) TVariable<type> name(__VA_ARGS__)
2951cb0ef41Sopenharmony_ci#define TYPED_VARIABLE_CONSTRUCTOR(name, ...) name(__VA_ARGS__)
2961cb0ef41Sopenharmony_ci#endif  // DEBUG
2971cb0ef41Sopenharmony_ci
2981cb0ef41Sopenharmony_ci#define TVARIABLE(...) EXPAND(TYPED_VARIABLE_DEF(__VA_ARGS__, this))
2991cb0ef41Sopenharmony_ci#define TVARIABLE_CONSTRUCTOR(...) \
3001cb0ef41Sopenharmony_ci  EXPAND(TYPED_VARIABLE_CONSTRUCTOR(__VA_ARGS__, this))
3011cb0ef41Sopenharmony_ci
3021cb0ef41Sopenharmony_ci#ifdef ENABLE_SLOW_DCHECKS
3031cb0ef41Sopenharmony_ci#define CSA_SLOW_DCHECK(csa, ...) \
3041cb0ef41Sopenharmony_ci  if (FLAG_enable_slow_asserts) { \
3051cb0ef41Sopenharmony_ci    CSA_DCHECK(csa, __VA_ARGS__); \
3061cb0ef41Sopenharmony_ci  }
3071cb0ef41Sopenharmony_ci#else
3081cb0ef41Sopenharmony_ci#define CSA_SLOW_DCHECK(csa, ...) ((void)0)
3091cb0ef41Sopenharmony_ci#endif
3101cb0ef41Sopenharmony_ci
3111cb0ef41Sopenharmony_ci// Provides JavaScript-specific "macro-assembler" functionality on top of the
3121cb0ef41Sopenharmony_ci// CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler,
3131cb0ef41Sopenharmony_ci// it's possible to add JavaScript-specific useful CodeAssembler "macros"
3141cb0ef41Sopenharmony_ci// without modifying files in the compiler directory (and requiring a review
3151cb0ef41Sopenharmony_ci// from a compiler directory OWNER).
3161cb0ef41Sopenharmony_ciclass V8_EXPORT_PRIVATE CodeStubAssembler
3171cb0ef41Sopenharmony_ci    : public compiler::CodeAssembler,
3181cb0ef41Sopenharmony_ci      public TorqueGeneratedExportedMacrosAssembler {
3191cb0ef41Sopenharmony_ci public:
3201cb0ef41Sopenharmony_ci  using ScopedExceptionHandler = compiler::ScopedExceptionHandler;
3211cb0ef41Sopenharmony_ci
3221cb0ef41Sopenharmony_ci  template <typename T>
3231cb0ef41Sopenharmony_ci  using LazyNode = std::function<TNode<T>()>;
3241cb0ef41Sopenharmony_ci
3251cb0ef41Sopenharmony_ci  explicit CodeStubAssembler(compiler::CodeAssemblerState* state);
3261cb0ef41Sopenharmony_ci
3271cb0ef41Sopenharmony_ci  enum class AllocationFlag : uint8_t {
3281cb0ef41Sopenharmony_ci    kNone = 0,
3291cb0ef41Sopenharmony_ci    kDoubleAlignment = 1,
3301cb0ef41Sopenharmony_ci    kPretenured = 1 << 1,
3311cb0ef41Sopenharmony_ci    kAllowLargeObjectAllocation = 1 << 2,
3321cb0ef41Sopenharmony_ci  };
3331cb0ef41Sopenharmony_ci
3341cb0ef41Sopenharmony_ci  enum SlackTrackingMode { kWithSlackTracking, kNoSlackTracking };
3351cb0ef41Sopenharmony_ci
3361cb0ef41Sopenharmony_ci  using AllocationFlags = base::Flags<AllocationFlag>;
3371cb0ef41Sopenharmony_ci
3381cb0ef41Sopenharmony_ci  TNode<IntPtrT> ParameterToIntPtr(TNode<Smi> value) { return SmiUntag(value); }
3391cb0ef41Sopenharmony_ci  TNode<IntPtrT> ParameterToIntPtr(TNode<IntPtrT> value) { return value; }
3401cb0ef41Sopenharmony_ci  TNode<IntPtrT> ParameterToIntPtr(TNode<UintPtrT> value) {
3411cb0ef41Sopenharmony_ci    return Signed(value);
3421cb0ef41Sopenharmony_ci  }
3431cb0ef41Sopenharmony_ci
3441cb0ef41Sopenharmony_ci  enum InitializationMode {
3451cb0ef41Sopenharmony_ci    kUninitialized,
3461cb0ef41Sopenharmony_ci    kInitializeToZero,
3471cb0ef41Sopenharmony_ci    kInitializeToNull
3481cb0ef41Sopenharmony_ci  };
3491cb0ef41Sopenharmony_ci
3501cb0ef41Sopenharmony_ci  TNode<Smi> ParameterToTagged(TNode<Smi> value) { return value; }
3511cb0ef41Sopenharmony_ci
3521cb0ef41Sopenharmony_ci  TNode<Smi> ParameterToTagged(TNode<IntPtrT> value) { return SmiTag(value); }
3531cb0ef41Sopenharmony_ci
3541cb0ef41Sopenharmony_ci  template <typename TIndex>
3551cb0ef41Sopenharmony_ci  TNode<TIndex> TaggedToParameter(TNode<Smi> value);
3561cb0ef41Sopenharmony_ci
3571cb0ef41Sopenharmony_ci  bool ToParameterConstant(TNode<Smi> node, intptr_t* out) {
3581cb0ef41Sopenharmony_ci    if (TryToIntPtrConstant(node, out)) {
3591cb0ef41Sopenharmony_ci      return true;
3601cb0ef41Sopenharmony_ci    }
3611cb0ef41Sopenharmony_ci    return false;
3621cb0ef41Sopenharmony_ci  }
3631cb0ef41Sopenharmony_ci
3641cb0ef41Sopenharmony_ci  bool ToParameterConstant(TNode<IntPtrT> node, intptr_t* out) {
3651cb0ef41Sopenharmony_ci    intptr_t constant;
3661cb0ef41Sopenharmony_ci    if (TryToIntPtrConstant(node, &constant)) {
3671cb0ef41Sopenharmony_ci      *out = constant;
3681cb0ef41Sopenharmony_ci      return true;
3691cb0ef41Sopenharmony_ci    }
3701cb0ef41Sopenharmony_ci    return false;
3711cb0ef41Sopenharmony_ci  }
3721cb0ef41Sopenharmony_ci
3731cb0ef41Sopenharmony_ci#if defined(BINT_IS_SMI)
3741cb0ef41Sopenharmony_ci  TNode<Smi> BIntToSmi(TNode<BInt> source) { return source; }
3751cb0ef41Sopenharmony_ci  TNode<IntPtrT> BIntToIntPtr(TNode<BInt> source) {
3761cb0ef41Sopenharmony_ci    return SmiToIntPtr(source);
3771cb0ef41Sopenharmony_ci  }
3781cb0ef41Sopenharmony_ci  TNode<BInt> SmiToBInt(TNode<Smi> source) { return source; }
3791cb0ef41Sopenharmony_ci  TNode<BInt> IntPtrToBInt(TNode<IntPtrT> source) {
3801cb0ef41Sopenharmony_ci    return SmiFromIntPtr(source);
3811cb0ef41Sopenharmony_ci  }
3821cb0ef41Sopenharmony_ci#elif defined(BINT_IS_INTPTR)
3831cb0ef41Sopenharmony_ci  TNode<Smi> BIntToSmi(TNode<BInt> source) { return SmiFromIntPtr(source); }
3841cb0ef41Sopenharmony_ci  TNode<IntPtrT> BIntToIntPtr(TNode<BInt> source) { return source; }
3851cb0ef41Sopenharmony_ci  TNode<BInt> SmiToBInt(TNode<Smi> source) { return SmiToIntPtr(source); }
3861cb0ef41Sopenharmony_ci  TNode<BInt> IntPtrToBInt(TNode<IntPtrT> source) { return source; }
3871cb0ef41Sopenharmony_ci#else
3881cb0ef41Sopenharmony_ci#error Unknown architecture.
3891cb0ef41Sopenharmony_ci#endif
3901cb0ef41Sopenharmony_ci
3911cb0ef41Sopenharmony_ci  TNode<IntPtrT> TaggedIndexToIntPtr(TNode<TaggedIndex> value);
3921cb0ef41Sopenharmony_ci  TNode<TaggedIndex> IntPtrToTaggedIndex(TNode<IntPtrT> value);
3931cb0ef41Sopenharmony_ci  // TODO(v8:10047): Get rid of these convertions eventually.
3941cb0ef41Sopenharmony_ci  TNode<Smi> TaggedIndexToSmi(TNode<TaggedIndex> value);
3951cb0ef41Sopenharmony_ci  TNode<TaggedIndex> SmiToTaggedIndex(TNode<Smi> value);
3961cb0ef41Sopenharmony_ci
3971cb0ef41Sopenharmony_ci  // Pointer compression specific. Ensures that the upper 32 bits of a Smi
3981cb0ef41Sopenharmony_ci  // contain the sign of a lower 32 bits so that the Smi can be directly used
3991cb0ef41Sopenharmony_ci  // as an index in element offset computation.
4001cb0ef41Sopenharmony_ci  TNode<Smi> NormalizeSmiIndex(TNode<Smi> smi_index);
4011cb0ef41Sopenharmony_ci
4021cb0ef41Sopenharmony_ci  TNode<Smi> TaggedToSmi(TNode<Object> value, Label* fail) {
4031cb0ef41Sopenharmony_ci    GotoIf(TaggedIsNotSmi(value), fail);
4041cb0ef41Sopenharmony_ci    return UncheckedCast<Smi>(value);
4051cb0ef41Sopenharmony_ci  }
4061cb0ef41Sopenharmony_ci
4071cb0ef41Sopenharmony_ci  TNode<Smi> TaggedToPositiveSmi(TNode<Object> value, Label* fail) {
4081cb0ef41Sopenharmony_ci    GotoIfNot(TaggedIsPositiveSmi(value), fail);
4091cb0ef41Sopenharmony_ci    return UncheckedCast<Smi>(value);
4101cb0ef41Sopenharmony_ci  }
4111cb0ef41Sopenharmony_ci
4121cb0ef41Sopenharmony_ci  TNode<String> TaggedToDirectString(TNode<Object> value, Label* fail);
4131cb0ef41Sopenharmony_ci
4141cb0ef41Sopenharmony_ci  TNode<HeapObject> TaggedToHeapObject(TNode<Object> value, Label* fail) {
4151cb0ef41Sopenharmony_ci    GotoIf(TaggedIsSmi(value), fail);
4161cb0ef41Sopenharmony_ci    return UncheckedCast<HeapObject>(value);
4171cb0ef41Sopenharmony_ci  }
4181cb0ef41Sopenharmony_ci
4191cb0ef41Sopenharmony_ci  TNode<Uint16T> Uint16Constant(uint16_t t) {
4201cb0ef41Sopenharmony_ci    return UncheckedCast<Uint16T>(Int32Constant(t));
4211cb0ef41Sopenharmony_ci  }
4221cb0ef41Sopenharmony_ci
4231cb0ef41Sopenharmony_ci  TNode<JSDataView> HeapObjectToJSDataView(TNode<HeapObject> heap_object,
4241cb0ef41Sopenharmony_ci                                           Label* fail) {
4251cb0ef41Sopenharmony_ci    GotoIfNot(IsJSDataView(heap_object), fail);
4261cb0ef41Sopenharmony_ci    return CAST(heap_object);
4271cb0ef41Sopenharmony_ci  }
4281cb0ef41Sopenharmony_ci
4291cb0ef41Sopenharmony_ci  TNode<JSProxy> HeapObjectToJSProxy(TNode<HeapObject> heap_object,
4301cb0ef41Sopenharmony_ci                                     Label* fail) {
4311cb0ef41Sopenharmony_ci    GotoIfNot(IsJSProxy(heap_object), fail);
4321cb0ef41Sopenharmony_ci    return CAST(heap_object);
4331cb0ef41Sopenharmony_ci  }
4341cb0ef41Sopenharmony_ci
4351cb0ef41Sopenharmony_ci  TNode<JSStringIterator> HeapObjectToJSStringIterator(
4361cb0ef41Sopenharmony_ci      TNode<HeapObject> heap_object, Label* fail) {
4371cb0ef41Sopenharmony_ci    GotoIfNot(IsJSStringIterator(heap_object), fail);
4381cb0ef41Sopenharmony_ci    return CAST(heap_object);
4391cb0ef41Sopenharmony_ci  }
4401cb0ef41Sopenharmony_ci
4411cb0ef41Sopenharmony_ci  TNode<JSReceiver> HeapObjectToCallable(TNode<HeapObject> heap_object,
4421cb0ef41Sopenharmony_ci                                         Label* fail) {
4431cb0ef41Sopenharmony_ci    GotoIfNot(IsCallable(heap_object), fail);
4441cb0ef41Sopenharmony_ci    return CAST(heap_object);
4451cb0ef41Sopenharmony_ci  }
4461cb0ef41Sopenharmony_ci
4471cb0ef41Sopenharmony_ci  TNode<String> HeapObjectToString(TNode<HeapObject> heap_object, Label* fail) {
4481cb0ef41Sopenharmony_ci    GotoIfNot(IsString(heap_object), fail);
4491cb0ef41Sopenharmony_ci    return CAST(heap_object);
4501cb0ef41Sopenharmony_ci  }
4511cb0ef41Sopenharmony_ci
4521cb0ef41Sopenharmony_ci  TNode<JSReceiver> HeapObjectToConstructor(TNode<HeapObject> heap_object,
4531cb0ef41Sopenharmony_ci                                            Label* fail) {
4541cb0ef41Sopenharmony_ci    GotoIfNot(IsConstructor(heap_object), fail);
4551cb0ef41Sopenharmony_ci    return CAST(heap_object);
4561cb0ef41Sopenharmony_ci  }
4571cb0ef41Sopenharmony_ci
4581cb0ef41Sopenharmony_ci  TNode<JSFunction> HeapObjectToJSFunctionWithPrototypeSlot(
4591cb0ef41Sopenharmony_ci      TNode<HeapObject> heap_object, Label* fail) {
4601cb0ef41Sopenharmony_ci    GotoIfNot(IsJSFunctionWithPrototypeSlot(heap_object), fail);
4611cb0ef41Sopenharmony_ci    return CAST(heap_object);
4621cb0ef41Sopenharmony_ci  }
4631cb0ef41Sopenharmony_ci
4641cb0ef41Sopenharmony_ci  template <typename T>
4651cb0ef41Sopenharmony_ci  TNode<T> RunLazy(LazyNode<T> lazy) {
4661cb0ef41Sopenharmony_ci    return lazy();
4671cb0ef41Sopenharmony_ci  }
4681cb0ef41Sopenharmony_ci
4691cb0ef41Sopenharmony_ci#define PARAMETER_BINOP(OpName, IntPtrOpName, SmiOpName)                    \
4701cb0ef41Sopenharmony_ci  TNode<Smi> OpName(TNode<Smi> a, TNode<Smi> b) { return SmiOpName(a, b); } \
4711cb0ef41Sopenharmony_ci  TNode<IntPtrT> OpName(TNode<IntPtrT> a, TNode<IntPtrT> b) {               \
4721cb0ef41Sopenharmony_ci    return IntPtrOpName(a, b);                                              \
4731cb0ef41Sopenharmony_ci  }                                                                         \
4741cb0ef41Sopenharmony_ci  TNode<UintPtrT> OpName(TNode<UintPtrT> a, TNode<UintPtrT> b) {            \
4751cb0ef41Sopenharmony_ci    return Unsigned(IntPtrOpName(Signed(a), Signed(b)));                    \
4761cb0ef41Sopenharmony_ci  }                                                                         \
4771cb0ef41Sopenharmony_ci  TNode<RawPtrT> OpName(TNode<RawPtrT> a, TNode<RawPtrT> b) {               \
4781cb0ef41Sopenharmony_ci    return ReinterpretCast<RawPtrT>(IntPtrOpName(                           \
4791cb0ef41Sopenharmony_ci        ReinterpretCast<IntPtrT>(a), ReinterpretCast<IntPtrT>(b)));         \
4801cb0ef41Sopenharmony_ci  }
4811cb0ef41Sopenharmony_ci  // TODO(v8:9708): Define BInt operations once all uses are ported.
4821cb0ef41Sopenharmony_ci  PARAMETER_BINOP(IntPtrOrSmiAdd, IntPtrAdd, SmiAdd)
4831cb0ef41Sopenharmony_ci  PARAMETER_BINOP(IntPtrOrSmiSub, IntPtrSub, SmiSub)
4841cb0ef41Sopenharmony_ci#undef PARAMETER_BINOP
4851cb0ef41Sopenharmony_ci
4861cb0ef41Sopenharmony_ci#define PARAMETER_BINOP(OpName, IntPtrOpName, SmiOpName)                      \
4871cb0ef41Sopenharmony_ci  TNode<BoolT> OpName(TNode<Smi> a, TNode<Smi> b) { return SmiOpName(a, b); } \
4881cb0ef41Sopenharmony_ci  TNode<BoolT> OpName(TNode<IntPtrT> a, TNode<IntPtrT> b) {                   \
4891cb0ef41Sopenharmony_ci    return IntPtrOpName(a, b);                                                \
4901cb0ef41Sopenharmony_ci  }                                                                           \
4911cb0ef41Sopenharmony_ci  TNode<BoolT> OpName(TNode<UintPtrT> a, TNode<UintPtrT> b) {                 \
4921cb0ef41Sopenharmony_ci    return IntPtrOpName(Signed(a), Signed(b));                                \
4931cb0ef41Sopenharmony_ci  }                                                                           \
4941cb0ef41Sopenharmony_ci  TNode<BoolT> OpName(TNode<RawPtrT> a, TNode<RawPtrT> b) {                   \
4951cb0ef41Sopenharmony_ci    return IntPtrOpName(a, b);                                                \
4961cb0ef41Sopenharmony_ci  }
4971cb0ef41Sopenharmony_ci  // TODO(v8:9708): Define BInt operations once all uses are ported.
4981cb0ef41Sopenharmony_ci  PARAMETER_BINOP(IntPtrOrSmiEqual, WordEqual, SmiEqual)
4991cb0ef41Sopenharmony_ci  PARAMETER_BINOP(IntPtrOrSmiNotEqual, WordNotEqual, SmiNotEqual)
5001cb0ef41Sopenharmony_ci  PARAMETER_BINOP(IntPtrOrSmiLessThanOrEqual, IntPtrLessThanOrEqual,
5011cb0ef41Sopenharmony_ci                  SmiLessThanOrEqual)
5021cb0ef41Sopenharmony_ci  PARAMETER_BINOP(IntPtrOrSmiGreaterThan, IntPtrGreaterThan, SmiGreaterThan)
5031cb0ef41Sopenharmony_ci  PARAMETER_BINOP(UintPtrOrSmiLessThan, UintPtrLessThan, SmiBelow)
5041cb0ef41Sopenharmony_ci  PARAMETER_BINOP(UintPtrOrSmiGreaterThanOrEqual, UintPtrGreaterThanOrEqual,
5051cb0ef41Sopenharmony_ci                  SmiAboveOrEqual)
5061cb0ef41Sopenharmony_ci#undef PARAMETER_BINOP
5071cb0ef41Sopenharmony_ci
5081cb0ef41Sopenharmony_ci  uintptr_t ConstexprUintPtrShl(uintptr_t a, int32_t b) { return a << b; }
5091cb0ef41Sopenharmony_ci  uintptr_t ConstexprUintPtrShr(uintptr_t a, int32_t b) { return a >> b; }
5101cb0ef41Sopenharmony_ci  intptr_t ConstexprIntPtrAdd(intptr_t a, intptr_t b) { return a + b; }
5111cb0ef41Sopenharmony_ci  uintptr_t ConstexprUintPtrAdd(uintptr_t a, uintptr_t b) { return a + b; }
5121cb0ef41Sopenharmony_ci  intptr_t ConstexprWordNot(intptr_t a) { return ~a; }
5131cb0ef41Sopenharmony_ci  uintptr_t ConstexprWordNot(uintptr_t a) { return ~a; }
5141cb0ef41Sopenharmony_ci
5151cb0ef41Sopenharmony_ci  TNode<BoolT> TaggedEqual(TNode<AnyTaggedT> a, TNode<AnyTaggedT> b) {
5161cb0ef41Sopenharmony_ci    if (COMPRESS_POINTERS_BOOL) {
5171cb0ef41Sopenharmony_ci      return Word32Equal(ReinterpretCast<Word32T>(a),
5181cb0ef41Sopenharmony_ci                         ReinterpretCast<Word32T>(b));
5191cb0ef41Sopenharmony_ci    } else {
5201cb0ef41Sopenharmony_ci      return WordEqual(ReinterpretCast<WordT>(a), ReinterpretCast<WordT>(b));
5211cb0ef41Sopenharmony_ci    }
5221cb0ef41Sopenharmony_ci  }
5231cb0ef41Sopenharmony_ci
5241cb0ef41Sopenharmony_ci  TNode<BoolT> TaggedNotEqual(TNode<AnyTaggedT> a, TNode<AnyTaggedT> b) {
5251cb0ef41Sopenharmony_ci    return Word32BinaryNot(TaggedEqual(a, b));
5261cb0ef41Sopenharmony_ci  }
5271cb0ef41Sopenharmony_ci
5281cb0ef41Sopenharmony_ci  TNode<Smi> NoContextConstant();
5291cb0ef41Sopenharmony_ci
5301cb0ef41Sopenharmony_ci#define HEAP_CONSTANT_ACCESSOR(rootIndexName, rootAccessorName, name)  \
5311cb0ef41Sopenharmony_ci  TNode<std::remove_pointer<std::remove_reference<decltype(            \
5321cb0ef41Sopenharmony_ci      std::declval<ReadOnlyRoots>().rootAccessorName())>::type>::type> \
5331cb0ef41Sopenharmony_ci      name##Constant();
5341cb0ef41Sopenharmony_ci  HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(HEAP_CONSTANT_ACCESSOR)
5351cb0ef41Sopenharmony_ci#undef HEAP_CONSTANT_ACCESSOR
5361cb0ef41Sopenharmony_ci
5371cb0ef41Sopenharmony_ci#define HEAP_CONSTANT_ACCESSOR(rootIndexName, rootAccessorName, name) \
5381cb0ef41Sopenharmony_ci  TNode<std::remove_pointer<std::remove_reference<decltype(           \
5391cb0ef41Sopenharmony_ci      std::declval<Heap>().rootAccessorName())>::type>::type>         \
5401cb0ef41Sopenharmony_ci      name##Constant();
5411cb0ef41Sopenharmony_ci  HEAP_MUTABLE_IMMOVABLE_OBJECT_LIST(HEAP_CONSTANT_ACCESSOR)
5421cb0ef41Sopenharmony_ci#undef HEAP_CONSTANT_ACCESSOR
5431cb0ef41Sopenharmony_ci
5441cb0ef41Sopenharmony_ci#define HEAP_CONSTANT_TEST(rootIndexName, rootAccessorName, name) \
5451cb0ef41Sopenharmony_ci  TNode<BoolT> Is##name(TNode<Object> value);                     \
5461cb0ef41Sopenharmony_ci  TNode<BoolT> IsNot##name(TNode<Object> value);
5471cb0ef41Sopenharmony_ci  HEAP_IMMOVABLE_OBJECT_LIST(HEAP_CONSTANT_TEST)
5481cb0ef41Sopenharmony_ci#undef HEAP_CONSTANT_TEST
5491cb0ef41Sopenharmony_ci
5501cb0ef41Sopenharmony_ci  TNode<BInt> BIntConstant(int value);
5511cb0ef41Sopenharmony_ci
5521cb0ef41Sopenharmony_ci  template <typename TIndex>
5531cb0ef41Sopenharmony_ci  TNode<TIndex> IntPtrOrSmiConstant(int value);
5541cb0ef41Sopenharmony_ci
5551cb0ef41Sopenharmony_ci  bool TryGetIntPtrOrSmiConstantValue(TNode<Smi> maybe_constant, int* value);
5561cb0ef41Sopenharmony_ci  bool TryGetIntPtrOrSmiConstantValue(TNode<IntPtrT> maybe_constant,
5571cb0ef41Sopenharmony_ci                                      int* value);
5581cb0ef41Sopenharmony_ci
5591cb0ef41Sopenharmony_ci  TNode<IntPtrT> PopulationCountFallback(TNode<UintPtrT> value);
5601cb0ef41Sopenharmony_ci  TNode<Int64T> PopulationCount64(TNode<Word64T> value);
5611cb0ef41Sopenharmony_ci  TNode<Int32T> PopulationCount32(TNode<Word32T> value);
5621cb0ef41Sopenharmony_ci  TNode<Int64T> CountTrailingZeros64(TNode<Word64T> value);
5631cb0ef41Sopenharmony_ci  TNode<Int32T> CountTrailingZeros32(TNode<Word32T> value);
5641cb0ef41Sopenharmony_ci  TNode<Int64T> CountLeadingZeros64(TNode<Word64T> value);
5651cb0ef41Sopenharmony_ci  TNode<Int32T> CountLeadingZeros32(TNode<Word32T> value);
5661cb0ef41Sopenharmony_ci
5671cb0ef41Sopenharmony_ci  // Round the 32bits payload of the provided word up to the next power of two.
5681cb0ef41Sopenharmony_ci  TNode<IntPtrT> IntPtrRoundUpToPowerOfTwo32(TNode<IntPtrT> value);
5691cb0ef41Sopenharmony_ci  // Select the maximum of the two provided IntPtr values.
5701cb0ef41Sopenharmony_ci  TNode<IntPtrT> IntPtrMax(TNode<IntPtrT> left, TNode<IntPtrT> right);
5711cb0ef41Sopenharmony_ci  // Select the minimum of the two provided IntPtr values.
5721cb0ef41Sopenharmony_ci  TNode<IntPtrT> IntPtrMin(TNode<IntPtrT> left, TNode<IntPtrT> right);
5731cb0ef41Sopenharmony_ci  TNode<UintPtrT> UintPtrMin(TNode<UintPtrT> left, TNode<UintPtrT> right);
5741cb0ef41Sopenharmony_ci
5751cb0ef41Sopenharmony_ci  // Float64 operations.
5761cb0ef41Sopenharmony_ci  TNode<Float64T> Float64Ceil(TNode<Float64T> x);
5771cb0ef41Sopenharmony_ci  TNode<Float64T> Float64Floor(TNode<Float64T> x);
5781cb0ef41Sopenharmony_ci  TNode<Float64T> Float64Round(TNode<Float64T> x);
5791cb0ef41Sopenharmony_ci  TNode<Float64T> Float64RoundToEven(TNode<Float64T> x);
5801cb0ef41Sopenharmony_ci  TNode<Float64T> Float64Trunc(TNode<Float64T> x);
5811cb0ef41Sopenharmony_ci  // Select the minimum of the two provided Number values.
5821cb0ef41Sopenharmony_ci  TNode<Number> NumberMax(TNode<Number> left, TNode<Number> right);
5831cb0ef41Sopenharmony_ci  // Select the minimum of the two provided Number values.
5841cb0ef41Sopenharmony_ci  TNode<Number> NumberMin(TNode<Number> left, TNode<Number> right);
5851cb0ef41Sopenharmony_ci
5861cb0ef41Sopenharmony_ci  // Returns true iff the given value fits into smi range and is >= 0.
5871cb0ef41Sopenharmony_ci  TNode<BoolT> IsValidPositiveSmi(TNode<IntPtrT> value);
5881cb0ef41Sopenharmony_ci
5891cb0ef41Sopenharmony_ci  // Tag an IntPtr as a Smi value.
5901cb0ef41Sopenharmony_ci  TNode<Smi> SmiTag(TNode<IntPtrT> value);
5911cb0ef41Sopenharmony_ci  // Untag a Smi value as an IntPtr.
5921cb0ef41Sopenharmony_ci  TNode<IntPtrT> SmiUntag(TNode<Smi> value);
5931cb0ef41Sopenharmony_ci
5941cb0ef41Sopenharmony_ci  // Smi conversions.
5951cb0ef41Sopenharmony_ci  TNode<Float64T> SmiToFloat64(TNode<Smi> value);
5961cb0ef41Sopenharmony_ci  TNode<Smi> SmiFromIntPtr(TNode<IntPtrT> value) { return SmiTag(value); }
5971cb0ef41Sopenharmony_ci  TNode<Smi> SmiFromInt32(TNode<Int32T> value);
5981cb0ef41Sopenharmony_ci  TNode<Smi> SmiFromUint32(TNode<Uint32T> value);
5991cb0ef41Sopenharmony_ci  TNode<IntPtrT> SmiToIntPtr(TNode<Smi> value) { return SmiUntag(value); }
6001cb0ef41Sopenharmony_ci  TNode<Int32T> SmiToInt32(TNode<Smi> value);
6011cb0ef41Sopenharmony_ci
6021cb0ef41Sopenharmony_ci  // Smi operations.
6031cb0ef41Sopenharmony_ci#define SMI_ARITHMETIC_BINOP(SmiOpName, IntPtrOpName, Int32OpName)          \
6041cb0ef41Sopenharmony_ci  TNode<Smi> SmiOpName(TNode<Smi> a, TNode<Smi> b) {                        \
6051cb0ef41Sopenharmony_ci    if (SmiValuesAre32Bits()) {                                             \
6061cb0ef41Sopenharmony_ci      return BitcastWordToTaggedSigned(                                     \
6071cb0ef41Sopenharmony_ci          IntPtrOpName(BitcastTaggedToWordForTagAndSmiBits(a),              \
6081cb0ef41Sopenharmony_ci                       BitcastTaggedToWordForTagAndSmiBits(b)));            \
6091cb0ef41Sopenharmony_ci    } else {                                                                \
6101cb0ef41Sopenharmony_ci      DCHECK(SmiValuesAre31Bits());                                         \
6111cb0ef41Sopenharmony_ci      return BitcastWordToTaggedSigned(ChangeInt32ToIntPtr(Int32OpName(     \
6121cb0ef41Sopenharmony_ci          TruncateIntPtrToInt32(BitcastTaggedToWordForTagAndSmiBits(a)),    \
6131cb0ef41Sopenharmony_ci          TruncateIntPtrToInt32(BitcastTaggedToWordForTagAndSmiBits(b))))); \
6141cb0ef41Sopenharmony_ci    }                                                                       \
6151cb0ef41Sopenharmony_ci  }
6161cb0ef41Sopenharmony_ci  SMI_ARITHMETIC_BINOP(SmiAdd, IntPtrAdd, Int32Add)
6171cb0ef41Sopenharmony_ci  SMI_ARITHMETIC_BINOP(SmiSub, IntPtrSub, Int32Sub)
6181cb0ef41Sopenharmony_ci  SMI_ARITHMETIC_BINOP(SmiAnd, WordAnd, Word32And)
6191cb0ef41Sopenharmony_ci  SMI_ARITHMETIC_BINOP(SmiOr, WordOr, Word32Or)
6201cb0ef41Sopenharmony_ci  SMI_ARITHMETIC_BINOP(SmiXor, WordXor, Word32Xor)
6211cb0ef41Sopenharmony_ci#undef SMI_ARITHMETIC_BINOP
6221cb0ef41Sopenharmony_ci
6231cb0ef41Sopenharmony_ci  TNode<IntPtrT> TryIntPtrAdd(TNode<IntPtrT> a, TNode<IntPtrT> b,
6241cb0ef41Sopenharmony_ci                              Label* if_overflow);
6251cb0ef41Sopenharmony_ci  TNode<IntPtrT> TryIntPtrSub(TNode<IntPtrT> a, TNode<IntPtrT> b,
6261cb0ef41Sopenharmony_ci                              Label* if_overflow);
6271cb0ef41Sopenharmony_ci  TNode<Int32T> TryInt32Mul(TNode<Int32T> a, TNode<Int32T> b,
6281cb0ef41Sopenharmony_ci                            Label* if_overflow);
6291cb0ef41Sopenharmony_ci  TNode<Smi> TrySmiAdd(TNode<Smi> a, TNode<Smi> b, Label* if_overflow);
6301cb0ef41Sopenharmony_ci  TNode<Smi> TrySmiSub(TNode<Smi> a, TNode<Smi> b, Label* if_overflow);
6311cb0ef41Sopenharmony_ci  TNode<Smi> TrySmiAbs(TNode<Smi> a, Label* if_overflow);
6321cb0ef41Sopenharmony_ci
6331cb0ef41Sopenharmony_ci  TNode<Smi> SmiShl(TNode<Smi> a, int shift) {
6341cb0ef41Sopenharmony_ci    TNode<Smi> result = BitcastWordToTaggedSigned(
6351cb0ef41Sopenharmony_ci        WordShl(BitcastTaggedToWordForTagAndSmiBits(a), shift));
6361cb0ef41Sopenharmony_ci    // Smi shift have different result to int32 shift when the inputs are not
6371cb0ef41Sopenharmony_ci    // strictly limited. The CSA_DCHECK is to ensure valid inputs.
6381cb0ef41Sopenharmony_ci    CSA_DCHECK(
6391cb0ef41Sopenharmony_ci        this, TaggedEqual(result, BitwiseOp(SmiToInt32(a), Int32Constant(shift),
6401cb0ef41Sopenharmony_ci                                            Operation::kShiftLeft)));
6411cb0ef41Sopenharmony_ci    return result;
6421cb0ef41Sopenharmony_ci  }
6431cb0ef41Sopenharmony_ci
6441cb0ef41Sopenharmony_ci  TNode<Smi> SmiShr(TNode<Smi> a, int shift) {
6451cb0ef41Sopenharmony_ci    TNode<Smi> result;
6461cb0ef41Sopenharmony_ci    if (kTaggedSize == kInt64Size) {
6471cb0ef41Sopenharmony_ci      result = BitcastWordToTaggedSigned(
6481cb0ef41Sopenharmony_ci          WordAnd(WordShr(BitcastTaggedToWordForTagAndSmiBits(a), shift),
6491cb0ef41Sopenharmony_ci                  BitcastTaggedToWordForTagAndSmiBits(SmiConstant(-1))));
6501cb0ef41Sopenharmony_ci    } else {
6511cb0ef41Sopenharmony_ci      // For pointer compressed Smis, we want to make sure that we truncate to
6521cb0ef41Sopenharmony_ci      // int32 before shifting, to avoid the values of the top 32-bits from
6531cb0ef41Sopenharmony_ci      // leaking into the sign bit of the smi.
6541cb0ef41Sopenharmony_ci      result = BitcastWordToTaggedSigned(WordAnd(
6551cb0ef41Sopenharmony_ci          ChangeInt32ToIntPtr(Word32Shr(
6561cb0ef41Sopenharmony_ci              TruncateWordToInt32(BitcastTaggedToWordForTagAndSmiBits(a)),
6571cb0ef41Sopenharmony_ci              shift)),
6581cb0ef41Sopenharmony_ci          BitcastTaggedToWordForTagAndSmiBits(SmiConstant(-1))));
6591cb0ef41Sopenharmony_ci    }
6601cb0ef41Sopenharmony_ci    // Smi shift have different result to int32 shift when the inputs are not
6611cb0ef41Sopenharmony_ci    // strictly limited. The CSA_DCHECK is to ensure valid inputs.
6621cb0ef41Sopenharmony_ci    CSA_DCHECK(
6631cb0ef41Sopenharmony_ci        this, TaggedEqual(result, BitwiseOp(SmiToInt32(a), Int32Constant(shift),
6641cb0ef41Sopenharmony_ci                                            Operation::kShiftRightLogical)));
6651cb0ef41Sopenharmony_ci    return result;
6661cb0ef41Sopenharmony_ci  }
6671cb0ef41Sopenharmony_ci
6681cb0ef41Sopenharmony_ci  TNode<Smi> SmiSar(TNode<Smi> a, int shift) {
6691cb0ef41Sopenharmony_ci    // The number of shift bits is |shift % 64| for 64-bits value and |shift %
6701cb0ef41Sopenharmony_ci    // 32| for 32-bits value. The DCHECK is to ensure valid inputs.
6711cb0ef41Sopenharmony_ci    DCHECK_LT(shift, 32);
6721cb0ef41Sopenharmony_ci    if (kTaggedSize == kInt64Size) {
6731cb0ef41Sopenharmony_ci      return BitcastWordToTaggedSigned(
6741cb0ef41Sopenharmony_ci          WordAnd(WordSar(BitcastTaggedToWordForTagAndSmiBits(a), shift),
6751cb0ef41Sopenharmony_ci                  BitcastTaggedToWordForTagAndSmiBits(SmiConstant(-1))));
6761cb0ef41Sopenharmony_ci    } else {
6771cb0ef41Sopenharmony_ci      // For pointer compressed Smis, we want to make sure that we truncate to
6781cb0ef41Sopenharmony_ci      // int32 before shifting, to avoid the values of the top 32-bits from
6791cb0ef41Sopenharmony_ci      // changing the sign bit of the smi.
6801cb0ef41Sopenharmony_ci      return BitcastWordToTaggedSigned(WordAnd(
6811cb0ef41Sopenharmony_ci          ChangeInt32ToIntPtr(Word32Sar(
6821cb0ef41Sopenharmony_ci              TruncateWordToInt32(BitcastTaggedToWordForTagAndSmiBits(a)),
6831cb0ef41Sopenharmony_ci              shift)),
6841cb0ef41Sopenharmony_ci          BitcastTaggedToWordForTagAndSmiBits(SmiConstant(-1))));
6851cb0ef41Sopenharmony_ci    }
6861cb0ef41Sopenharmony_ci  }
6871cb0ef41Sopenharmony_ci
6881cb0ef41Sopenharmony_ci  TNode<Smi> WordOrSmiShr(TNode<Smi> a, int shift) { return SmiShr(a, shift); }
6891cb0ef41Sopenharmony_ci
6901cb0ef41Sopenharmony_ci  TNode<IntPtrT> WordOrSmiShr(TNode<IntPtrT> a, int shift) {
6911cb0ef41Sopenharmony_ci    return WordShr(a, shift);
6921cb0ef41Sopenharmony_ci  }
6931cb0ef41Sopenharmony_ci
6941cb0ef41Sopenharmony_ci#define SMI_COMPARISON_OP(SmiOpName, IntPtrOpName, Int32OpName)           \
6951cb0ef41Sopenharmony_ci  TNode<BoolT> SmiOpName(TNode<Smi> a, TNode<Smi> b) {                    \
6961cb0ef41Sopenharmony_ci    if (kTaggedSize == kInt64Size) {                                      \
6971cb0ef41Sopenharmony_ci      return IntPtrOpName(BitcastTaggedToWordForTagAndSmiBits(a),         \
6981cb0ef41Sopenharmony_ci                          BitcastTaggedToWordForTagAndSmiBits(b));        \
6991cb0ef41Sopenharmony_ci    } else {                                                              \
7001cb0ef41Sopenharmony_ci      DCHECK_EQ(kTaggedSize, kInt32Size);                                 \
7011cb0ef41Sopenharmony_ci      DCHECK(SmiValuesAre31Bits());                                       \
7021cb0ef41Sopenharmony_ci      return Int32OpName(                                                 \
7031cb0ef41Sopenharmony_ci          TruncateIntPtrToInt32(BitcastTaggedToWordForTagAndSmiBits(a)),  \
7041cb0ef41Sopenharmony_ci          TruncateIntPtrToInt32(BitcastTaggedToWordForTagAndSmiBits(b))); \
7051cb0ef41Sopenharmony_ci    }                                                                     \
7061cb0ef41Sopenharmony_ci  }
7071cb0ef41Sopenharmony_ci  SMI_COMPARISON_OP(SmiEqual, WordEqual, Word32Equal)
7081cb0ef41Sopenharmony_ci  SMI_COMPARISON_OP(SmiNotEqual, WordNotEqual, Word32NotEqual)
7091cb0ef41Sopenharmony_ci  SMI_COMPARISON_OP(SmiAbove, UintPtrGreaterThan, Uint32GreaterThan)
7101cb0ef41Sopenharmony_ci  SMI_COMPARISON_OP(SmiAboveOrEqual, UintPtrGreaterThanOrEqual,
7111cb0ef41Sopenharmony_ci                    Uint32GreaterThanOrEqual)
7121cb0ef41Sopenharmony_ci  SMI_COMPARISON_OP(SmiBelow, UintPtrLessThan, Uint32LessThan)
7131cb0ef41Sopenharmony_ci  SMI_COMPARISON_OP(SmiLessThan, IntPtrLessThan, Int32LessThan)
7141cb0ef41Sopenharmony_ci  SMI_COMPARISON_OP(SmiLessThanOrEqual, IntPtrLessThanOrEqual,
7151cb0ef41Sopenharmony_ci                    Int32LessThanOrEqual)
7161cb0ef41Sopenharmony_ci  SMI_COMPARISON_OP(SmiGreaterThan, IntPtrGreaterThan, Int32GreaterThan)
7171cb0ef41Sopenharmony_ci  SMI_COMPARISON_OP(SmiGreaterThanOrEqual, IntPtrGreaterThanOrEqual,
7181cb0ef41Sopenharmony_ci                    Int32GreaterThanOrEqual)
7191cb0ef41Sopenharmony_ci#undef SMI_COMPARISON_OP
7201cb0ef41Sopenharmony_ci  TNode<Smi> SmiMax(TNode<Smi> a, TNode<Smi> b);
7211cb0ef41Sopenharmony_ci  TNode<Smi> SmiMin(TNode<Smi> a, TNode<Smi> b);
7221cb0ef41Sopenharmony_ci  // Computes a % b for Smi inputs a and b; result is not necessarily a Smi.
7231cb0ef41Sopenharmony_ci  TNode<Number> SmiMod(TNode<Smi> a, TNode<Smi> b);
7241cb0ef41Sopenharmony_ci  // Computes a * b for Smi inputs a and b; result is not necessarily a Smi.
7251cb0ef41Sopenharmony_ci  TNode<Number> SmiMul(TNode<Smi> a, TNode<Smi> b);
7261cb0ef41Sopenharmony_ci  // Tries to compute dividend / divisor for Smi inputs; branching to bailout
7271cb0ef41Sopenharmony_ci  // if the division needs to be performed as a floating point operation.
7281cb0ef41Sopenharmony_ci  TNode<Smi> TrySmiDiv(TNode<Smi> dividend, TNode<Smi> divisor, Label* bailout);
7291cb0ef41Sopenharmony_ci
7301cb0ef41Sopenharmony_ci  // Compares two Smis a and b as if they were converted to strings and then
7311cb0ef41Sopenharmony_ci  // compared lexicographically. Returns:
7321cb0ef41Sopenharmony_ci  // -1 iff x < y.
7331cb0ef41Sopenharmony_ci  //  0 iff x == y.
7341cb0ef41Sopenharmony_ci  //  1 iff x > y.
7351cb0ef41Sopenharmony_ci  TNode<Smi> SmiLexicographicCompare(TNode<Smi> x, TNode<Smi> y);
7361cb0ef41Sopenharmony_ci
7371cb0ef41Sopenharmony_ci#ifdef BINT_IS_SMI
7381cb0ef41Sopenharmony_ci#define BINT_COMPARISON_OP(BIntOpName, SmiOpName, IntPtrOpName) \
7391cb0ef41Sopenharmony_ci  TNode<BoolT> BIntOpName(TNode<BInt> a, TNode<BInt> b) {       \
7401cb0ef41Sopenharmony_ci    return SmiOpName(a, b);                                     \
7411cb0ef41Sopenharmony_ci  }
7421cb0ef41Sopenharmony_ci#else
7431cb0ef41Sopenharmony_ci#define BINT_COMPARISON_OP(BIntOpName, SmiOpName, IntPtrOpName) \
7441cb0ef41Sopenharmony_ci  TNode<BoolT> BIntOpName(TNode<BInt> a, TNode<BInt> b) {       \
7451cb0ef41Sopenharmony_ci    return IntPtrOpName(a, b);                                  \
7461cb0ef41Sopenharmony_ci  }
7471cb0ef41Sopenharmony_ci#endif
7481cb0ef41Sopenharmony_ci  BINT_COMPARISON_OP(BIntEqual, SmiEqual, WordEqual)
7491cb0ef41Sopenharmony_ci  BINT_COMPARISON_OP(BIntNotEqual, SmiNotEqual, WordNotEqual)
7501cb0ef41Sopenharmony_ci  BINT_COMPARISON_OP(BIntAbove, SmiAbove, UintPtrGreaterThan)
7511cb0ef41Sopenharmony_ci  BINT_COMPARISON_OP(BIntAboveOrEqual, SmiAboveOrEqual,
7521cb0ef41Sopenharmony_ci                     UintPtrGreaterThanOrEqual)
7531cb0ef41Sopenharmony_ci  BINT_COMPARISON_OP(BIntBelow, SmiBelow, UintPtrLessThan)
7541cb0ef41Sopenharmony_ci  BINT_COMPARISON_OP(BIntLessThan, SmiLessThan, IntPtrLessThan)
7551cb0ef41Sopenharmony_ci  BINT_COMPARISON_OP(BIntLessThanOrEqual, SmiLessThanOrEqual,
7561cb0ef41Sopenharmony_ci                     IntPtrLessThanOrEqual)
7571cb0ef41Sopenharmony_ci  BINT_COMPARISON_OP(BIntGreaterThan, SmiGreaterThan, IntPtrGreaterThan)
7581cb0ef41Sopenharmony_ci  BINT_COMPARISON_OP(BIntGreaterThanOrEqual, SmiGreaterThanOrEqual,
7591cb0ef41Sopenharmony_ci                     IntPtrGreaterThanOrEqual)
7601cb0ef41Sopenharmony_ci#undef BINT_COMPARISON_OP
7611cb0ef41Sopenharmony_ci
7621cb0ef41Sopenharmony_ci  // Smi | HeapNumber operations.
7631cb0ef41Sopenharmony_ci  TNode<Number> NumberInc(TNode<Number> value);
7641cb0ef41Sopenharmony_ci  TNode<Number> NumberDec(TNode<Number> value);
7651cb0ef41Sopenharmony_ci  TNode<Number> NumberAdd(TNode<Number> a, TNode<Number> b);
7661cb0ef41Sopenharmony_ci  TNode<Number> NumberSub(TNode<Number> a, TNode<Number> b);
7671cb0ef41Sopenharmony_ci  void GotoIfNotNumber(TNode<Object> value, Label* is_not_number);
7681cb0ef41Sopenharmony_ci  void GotoIfNumber(TNode<Object> value, Label* is_number);
7691cb0ef41Sopenharmony_ci  TNode<Number> SmiToNumber(TNode<Smi> v) { return v; }
7701cb0ef41Sopenharmony_ci
7711cb0ef41Sopenharmony_ci  TNode<Number> BitwiseOp(TNode<Word32T> left32, TNode<Word32T> right32,
7721cb0ef41Sopenharmony_ci                          Operation bitwise_op);
7731cb0ef41Sopenharmony_ci  TNode<Number> BitwiseSmiOp(TNode<Smi> left32, TNode<Smi> right32,
7741cb0ef41Sopenharmony_ci                             Operation bitwise_op);
7751cb0ef41Sopenharmony_ci
7761cb0ef41Sopenharmony_ci  // Allocate an object of the given size.
7771cb0ef41Sopenharmony_ci  TNode<HeapObject> AllocateInNewSpace(
7781cb0ef41Sopenharmony_ci      TNode<IntPtrT> size, AllocationFlags flags = AllocationFlag::kNone);
7791cb0ef41Sopenharmony_ci  TNode<HeapObject> AllocateInNewSpace(
7801cb0ef41Sopenharmony_ci      int size, AllocationFlags flags = AllocationFlag::kNone);
7811cb0ef41Sopenharmony_ci  TNode<HeapObject> Allocate(TNode<IntPtrT> size,
7821cb0ef41Sopenharmony_ci                             AllocationFlags flags = AllocationFlag::kNone);
7831cb0ef41Sopenharmony_ci
7841cb0ef41Sopenharmony_ci  TNode<HeapObject> Allocate(int size,
7851cb0ef41Sopenharmony_ci                             AllocationFlags flags = AllocationFlag::kNone);
7861cb0ef41Sopenharmony_ci
7871cb0ef41Sopenharmony_ci  TNode<BoolT> IsRegularHeapObjectSize(TNode<IntPtrT> size);
7881cb0ef41Sopenharmony_ci
7891cb0ef41Sopenharmony_ci  using BranchGenerator = std::function<void(Label*, Label*)>;
7901cb0ef41Sopenharmony_ci  template <typename T>
7911cb0ef41Sopenharmony_ci  using NodeGenerator = std::function<TNode<T>()>;
7921cb0ef41Sopenharmony_ci  using ExtraNode = std::pair<TNode<Object>, const char*>;
7931cb0ef41Sopenharmony_ci
7941cb0ef41Sopenharmony_ci  void Dcheck(const BranchGenerator& branch, const char* message,
7951cb0ef41Sopenharmony_ci              const char* file, int line,
7961cb0ef41Sopenharmony_ci              std::initializer_list<ExtraNode> extra_nodes = {});
7971cb0ef41Sopenharmony_ci  void Dcheck(const NodeGenerator<BoolT>& condition_body, const char* message,
7981cb0ef41Sopenharmony_ci              const char* file, int line,
7991cb0ef41Sopenharmony_ci              std::initializer_list<ExtraNode> extra_nodes = {});
8001cb0ef41Sopenharmony_ci  void Dcheck(TNode<Word32T> condition_node, const char* message,
8011cb0ef41Sopenharmony_ci              const char* file, int line,
8021cb0ef41Sopenharmony_ci              std::initializer_list<ExtraNode> extra_nodes = {});
8031cb0ef41Sopenharmony_ci  void Check(const BranchGenerator& branch, const char* message,
8041cb0ef41Sopenharmony_ci             const char* file, int line,
8051cb0ef41Sopenharmony_ci             std::initializer_list<ExtraNode> extra_nodes = {});
8061cb0ef41Sopenharmony_ci  void Check(const NodeGenerator<BoolT>& condition_body, const char* message,
8071cb0ef41Sopenharmony_ci             const char* file, int line,
8081cb0ef41Sopenharmony_ci             std::initializer_list<ExtraNode> extra_nodes = {});
8091cb0ef41Sopenharmony_ci  void Check(TNode<Word32T> condition_node, const char* message,
8101cb0ef41Sopenharmony_ci             const char* file, int line,
8111cb0ef41Sopenharmony_ci             std::initializer_list<ExtraNode> extra_nodes = {});
8121cb0ef41Sopenharmony_ci  void FailAssert(const char* message,
8131cb0ef41Sopenharmony_ci                  const std::vector<FileAndLine>& files_and_lines,
8141cb0ef41Sopenharmony_ci                  std::initializer_list<ExtraNode> extra_nodes = {});
8151cb0ef41Sopenharmony_ci
8161cb0ef41Sopenharmony_ci  void FastCheck(TNode<BoolT> condition);
8171cb0ef41Sopenharmony_ci
8181cb0ef41Sopenharmony_ci  TNode<BoolT> IsCodeTMap(TNode<Map> map) {
8191cb0ef41Sopenharmony_ci    return V8_EXTERNAL_CODE_SPACE_BOOL ? IsCodeDataContainerMap(map)
8201cb0ef41Sopenharmony_ci                                       : IsCodeMap(map);
8211cb0ef41Sopenharmony_ci  }
8221cb0ef41Sopenharmony_ci  TNode<BoolT> IsCodeT(TNode<HeapObject> object) {
8231cb0ef41Sopenharmony_ci    return IsCodeTMap(LoadMap(object));
8241cb0ef41Sopenharmony_ci  }
8251cb0ef41Sopenharmony_ci
8261cb0ef41Sopenharmony_ci  // TODO(v8:11880): remove once Code::bytecode_or_interpreter_data field
8271cb0ef41Sopenharmony_ci  // is cached in or moved to CodeT.
8281cb0ef41Sopenharmony_ci  TNode<Code> FromCodeT(TNode<CodeT> code) {
8291cb0ef41Sopenharmony_ci#ifdef V8_EXTERNAL_CODE_SPACE
8301cb0ef41Sopenharmony_ci#if V8_TARGET_BIG_ENDIAN
8311cb0ef41Sopenharmony_ci#error "This code requires updating for big-endian architectures"
8321cb0ef41Sopenharmony_ci#endif
8331cb0ef41Sopenharmony_ci    // Given the fields layout we can read the Code reference as a full word.
8341cb0ef41Sopenharmony_ci    STATIC_ASSERT(CodeDataContainer::kCodeCageBaseUpper32BitsOffset ==
8351cb0ef41Sopenharmony_ci                  CodeDataContainer::kCodeOffset + kTaggedSize);
8361cb0ef41Sopenharmony_ci    TNode<Object> o = BitcastWordToTagged(Load<RawPtrT>(
8371cb0ef41Sopenharmony_ci        code, IntPtrConstant(CodeDataContainer::kCodeOffset - kHeapObjectTag)));
8381cb0ef41Sopenharmony_ci    return CAST(o);
8391cb0ef41Sopenharmony_ci#else
8401cb0ef41Sopenharmony_ci    return code;
8411cb0ef41Sopenharmony_ci#endif
8421cb0ef41Sopenharmony_ci  }
8431cb0ef41Sopenharmony_ci
8441cb0ef41Sopenharmony_ci  TNode<CodeDataContainer> CodeDataContainerFromCodeT(TNode<CodeT> code) {
8451cb0ef41Sopenharmony_ci#ifdef V8_EXTERNAL_CODE_SPACE
8461cb0ef41Sopenharmony_ci    return code;
8471cb0ef41Sopenharmony_ci#else
8481cb0ef41Sopenharmony_ci    return LoadObjectField<CodeDataContainer>(code,
8491cb0ef41Sopenharmony_ci                                              Code::kCodeDataContainerOffset);
8501cb0ef41Sopenharmony_ci#endif
8511cb0ef41Sopenharmony_ci  }
8521cb0ef41Sopenharmony_ci
8531cb0ef41Sopenharmony_ci  TNode<CodeT> ToCodeT(TNode<Code> code) {
8541cb0ef41Sopenharmony_ci#ifdef V8_EXTERNAL_CODE_SPACE
8551cb0ef41Sopenharmony_ci    return LoadObjectField<CodeDataContainer>(code,
8561cb0ef41Sopenharmony_ci                                              Code::kCodeDataContainerOffset);
8571cb0ef41Sopenharmony_ci#else
8581cb0ef41Sopenharmony_ci    return code;
8591cb0ef41Sopenharmony_ci#endif
8601cb0ef41Sopenharmony_ci  }
8611cb0ef41Sopenharmony_ci
8621cb0ef41Sopenharmony_ci  TNode<CodeT> ToCodeT(TNode<Code> code,
8631cb0ef41Sopenharmony_ci                       TNode<CodeDataContainer> code_data_container) {
8641cb0ef41Sopenharmony_ci#ifdef V8_EXTERNAL_CODE_SPACE
8651cb0ef41Sopenharmony_ci    return code_data_container;
8661cb0ef41Sopenharmony_ci#else
8671cb0ef41Sopenharmony_ci    return code;
8681cb0ef41Sopenharmony_ci#endif
8691cb0ef41Sopenharmony_ci  }
8701cb0ef41Sopenharmony_ci
8711cb0ef41Sopenharmony_ci  TNode<RawPtrT> GetCodeEntry(TNode<CodeT> code);
8721cb0ef41Sopenharmony_ci
8731cb0ef41Sopenharmony_ci  // The following Call wrappers call an object according to the semantics that
8741cb0ef41Sopenharmony_ci  // one finds in the EcmaScript spec, operating on an Callable (e.g. a
8751cb0ef41Sopenharmony_ci  // JSFunction or proxy) rather than a Code object.
8761cb0ef41Sopenharmony_ci  template <class... TArgs>
8771cb0ef41Sopenharmony_ci  TNode<Object> Call(TNode<Context> context, TNode<Object> callable,
8781cb0ef41Sopenharmony_ci                     TNode<JSReceiver> receiver, TArgs... args) {
8791cb0ef41Sopenharmony_ci    return CallJS(
8801cb0ef41Sopenharmony_ci        CodeFactory::Call(isolate(), ConvertReceiverMode::kNotNullOrUndefined),
8811cb0ef41Sopenharmony_ci        context, callable, receiver, args...);
8821cb0ef41Sopenharmony_ci  }
8831cb0ef41Sopenharmony_ci  template <class... TArgs>
8841cb0ef41Sopenharmony_ci  TNode<Object> Call(TNode<Context> context, TNode<Object> callable,
8851cb0ef41Sopenharmony_ci                     TNode<Object> receiver, TArgs... args) {
8861cb0ef41Sopenharmony_ci    if (IsUndefinedConstant(receiver) || IsNullConstant(receiver)) {
8871cb0ef41Sopenharmony_ci      return CallJS(
8881cb0ef41Sopenharmony_ci          CodeFactory::Call(isolate(), ConvertReceiverMode::kNullOrUndefined),
8891cb0ef41Sopenharmony_ci          context, callable, receiver, args...);
8901cb0ef41Sopenharmony_ci    }
8911cb0ef41Sopenharmony_ci    return CallJS(CodeFactory::Call(isolate()), context, callable, receiver,
8921cb0ef41Sopenharmony_ci                  args...);
8931cb0ef41Sopenharmony_ci  }
8941cb0ef41Sopenharmony_ci
8951cb0ef41Sopenharmony_ci  TNode<Object> CallApiCallback(TNode<Object> context, TNode<RawPtrT> callback,
8961cb0ef41Sopenharmony_ci                                TNode<IntPtrT> argc, TNode<Object> data,
8971cb0ef41Sopenharmony_ci                                TNode<Object> holder, TNode<Object> receiver);
8981cb0ef41Sopenharmony_ci
8991cb0ef41Sopenharmony_ci  TNode<Object> CallApiCallback(TNode<Object> context, TNode<RawPtrT> callback,
9001cb0ef41Sopenharmony_ci                                TNode<IntPtrT> argc, TNode<Object> data,
9011cb0ef41Sopenharmony_ci                                TNode<Object> holder, TNode<Object> receiver,
9021cb0ef41Sopenharmony_ci                                TNode<Object> value);
9031cb0ef41Sopenharmony_ci
9041cb0ef41Sopenharmony_ci  TNode<Object> CallRuntimeNewArray(TNode<Context> context,
9051cb0ef41Sopenharmony_ci                                    TNode<Object> receiver,
9061cb0ef41Sopenharmony_ci                                    TNode<Object> length,
9071cb0ef41Sopenharmony_ci                                    TNode<Object> new_target,
9081cb0ef41Sopenharmony_ci                                    TNode<Object> allocation_site);
9091cb0ef41Sopenharmony_ci
9101cb0ef41Sopenharmony_ci  void TailCallRuntimeNewArray(TNode<Context> context, TNode<Object> receiver,
9111cb0ef41Sopenharmony_ci                               TNode<Object> length, TNode<Object> new_target,
9121cb0ef41Sopenharmony_ci                               TNode<Object> allocation_site);
9131cb0ef41Sopenharmony_ci
9141cb0ef41Sopenharmony_ci  template <class... TArgs>
9151cb0ef41Sopenharmony_ci  TNode<JSReceiver> ConstructWithTarget(TNode<Context> context,
9161cb0ef41Sopenharmony_ci                                        TNode<JSReceiver> target,
9171cb0ef41Sopenharmony_ci                                        TNode<JSReceiver> new_target,
9181cb0ef41Sopenharmony_ci                                        TArgs... args) {
9191cb0ef41Sopenharmony_ci    return CAST(ConstructJSWithTarget(CodeFactory::Construct(isolate()),
9201cb0ef41Sopenharmony_ci                                      context, target, new_target,
9211cb0ef41Sopenharmony_ci                                      implicit_cast<TNode<Object>>(args)...));
9221cb0ef41Sopenharmony_ci  }
9231cb0ef41Sopenharmony_ci  template <class... TArgs>
9241cb0ef41Sopenharmony_ci  TNode<JSReceiver> Construct(TNode<Context> context,
9251cb0ef41Sopenharmony_ci                              TNode<JSReceiver> new_target, TArgs... args) {
9261cb0ef41Sopenharmony_ci    return ConstructWithTarget(context, new_target, new_target, args...);
9271cb0ef41Sopenharmony_ci  }
9281cb0ef41Sopenharmony_ci
9291cb0ef41Sopenharmony_ci  template <typename T>
9301cb0ef41Sopenharmony_ci  TNode<T> Select(TNode<BoolT> condition, const NodeGenerator<T>& true_body,
9311cb0ef41Sopenharmony_ci                  const NodeGenerator<T>& false_body) {
9321cb0ef41Sopenharmony_ci    TVARIABLE(T, value);
9331cb0ef41Sopenharmony_ci    Label vtrue(this), vfalse(this), end(this);
9341cb0ef41Sopenharmony_ci    Branch(condition, &vtrue, &vfalse);
9351cb0ef41Sopenharmony_ci
9361cb0ef41Sopenharmony_ci    BIND(&vtrue);
9371cb0ef41Sopenharmony_ci    {
9381cb0ef41Sopenharmony_ci      value = true_body();
9391cb0ef41Sopenharmony_ci      Goto(&end);
9401cb0ef41Sopenharmony_ci    }
9411cb0ef41Sopenharmony_ci    BIND(&vfalse);
9421cb0ef41Sopenharmony_ci    {
9431cb0ef41Sopenharmony_ci      value = false_body();
9441cb0ef41Sopenharmony_ci      Goto(&end);
9451cb0ef41Sopenharmony_ci    }
9461cb0ef41Sopenharmony_ci
9471cb0ef41Sopenharmony_ci    BIND(&end);
9481cb0ef41Sopenharmony_ci    return value.value();
9491cb0ef41Sopenharmony_ci  }
9501cb0ef41Sopenharmony_ci
9511cb0ef41Sopenharmony_ci  template <class A>
9521cb0ef41Sopenharmony_ci  TNode<A> SelectConstant(TNode<BoolT> condition, TNode<A> true_value,
9531cb0ef41Sopenharmony_ci                          TNode<A> false_value) {
9541cb0ef41Sopenharmony_ci    return Select<A>(
9551cb0ef41Sopenharmony_ci        condition, [=] { return true_value; }, [=] { return false_value; });
9561cb0ef41Sopenharmony_ci  }
9571cb0ef41Sopenharmony_ci
9581cb0ef41Sopenharmony_ci  TNode<Int32T> SelectInt32Constant(TNode<BoolT> condition, int true_value,
9591cb0ef41Sopenharmony_ci                                    int false_value);
9601cb0ef41Sopenharmony_ci  TNode<IntPtrT> SelectIntPtrConstant(TNode<BoolT> condition, int true_value,
9611cb0ef41Sopenharmony_ci                                      int false_value);
9621cb0ef41Sopenharmony_ci  TNode<Oddball> SelectBooleanConstant(TNode<BoolT> condition);
9631cb0ef41Sopenharmony_ci  TNode<Smi> SelectSmiConstant(TNode<BoolT> condition, Smi true_value,
9641cb0ef41Sopenharmony_ci                               Smi false_value);
9651cb0ef41Sopenharmony_ci  TNode<Smi> SelectSmiConstant(TNode<BoolT> condition, int true_value,
9661cb0ef41Sopenharmony_ci                               Smi false_value) {
9671cb0ef41Sopenharmony_ci    return SelectSmiConstant(condition, Smi::FromInt(true_value), false_value);
9681cb0ef41Sopenharmony_ci  }
9691cb0ef41Sopenharmony_ci  TNode<Smi> SelectSmiConstant(TNode<BoolT> condition, Smi true_value,
9701cb0ef41Sopenharmony_ci                               int false_value) {
9711cb0ef41Sopenharmony_ci    return SelectSmiConstant(condition, true_value, Smi::FromInt(false_value));
9721cb0ef41Sopenharmony_ci  }
9731cb0ef41Sopenharmony_ci  TNode<Smi> SelectSmiConstant(TNode<BoolT> condition, int true_value,
9741cb0ef41Sopenharmony_ci                               int false_value) {
9751cb0ef41Sopenharmony_ci    return SelectSmiConstant(condition, Smi::FromInt(true_value),
9761cb0ef41Sopenharmony_ci                             Smi::FromInt(false_value));
9771cb0ef41Sopenharmony_ci  }
9781cb0ef41Sopenharmony_ci
9791cb0ef41Sopenharmony_ci  TNode<String> SingleCharacterStringConstant(char const* single_char) {
9801cb0ef41Sopenharmony_ci    DCHECK_EQ(strlen(single_char), 1);
9811cb0ef41Sopenharmony_ci    return HeapConstant(
9821cb0ef41Sopenharmony_ci        isolate()->factory()->LookupSingleCharacterStringFromCode(
9831cb0ef41Sopenharmony_ci            single_char[0]));
9841cb0ef41Sopenharmony_ci  }
9851cb0ef41Sopenharmony_ci
9861cb0ef41Sopenharmony_ci  TNode<Int32T> TruncateWordToInt32(TNode<WordT> value);
9871cb0ef41Sopenharmony_ci  TNode<Int32T> TruncateIntPtrToInt32(TNode<IntPtrT> value);
9881cb0ef41Sopenharmony_ci
9891cb0ef41Sopenharmony_ci  // Check a value for smi-ness
9901cb0ef41Sopenharmony_ci  TNode<BoolT> TaggedIsSmi(TNode<MaybeObject> a);
9911cb0ef41Sopenharmony_ci  TNode<BoolT> TaggedIsNotSmi(TNode<MaybeObject> a);
9921cb0ef41Sopenharmony_ci
9931cb0ef41Sopenharmony_ci  // Check that the value is a non-negative smi.
9941cb0ef41Sopenharmony_ci  TNode<BoolT> TaggedIsPositiveSmi(TNode<Object> a);
9951cb0ef41Sopenharmony_ci  // Check that a word has a word-aligned address.
9961cb0ef41Sopenharmony_ci  TNode<BoolT> WordIsAligned(TNode<WordT> word, size_t alignment);
9971cb0ef41Sopenharmony_ci  TNode<BoolT> WordIsPowerOfTwo(TNode<IntPtrT> value);
9981cb0ef41Sopenharmony_ci
9991cb0ef41Sopenharmony_ci  // Check if lower_limit <= value <= higher_limit.
10001cb0ef41Sopenharmony_ci  template <typename U>
10011cb0ef41Sopenharmony_ci  TNode<BoolT> IsInRange(TNode<Word32T> value, U lower_limit, U higher_limit) {
10021cb0ef41Sopenharmony_ci    DCHECK_LE(lower_limit, higher_limit);
10031cb0ef41Sopenharmony_ci    STATIC_ASSERT(sizeof(U) <= kInt32Size);
10041cb0ef41Sopenharmony_ci    return Uint32LessThanOrEqual(Int32Sub(value, Int32Constant(lower_limit)),
10051cb0ef41Sopenharmony_ci                                 Int32Constant(higher_limit - lower_limit));
10061cb0ef41Sopenharmony_ci  }
10071cb0ef41Sopenharmony_ci
10081cb0ef41Sopenharmony_ci  TNode<BoolT> IsInRange(TNode<WordT> value, intptr_t lower_limit,
10091cb0ef41Sopenharmony_ci                         intptr_t higher_limit) {
10101cb0ef41Sopenharmony_ci    DCHECK_LE(lower_limit, higher_limit);
10111cb0ef41Sopenharmony_ci    return UintPtrLessThanOrEqual(IntPtrSub(value, IntPtrConstant(lower_limit)),
10121cb0ef41Sopenharmony_ci                                  IntPtrConstant(higher_limit - lower_limit));
10131cb0ef41Sopenharmony_ci  }
10141cb0ef41Sopenharmony_ci
10151cb0ef41Sopenharmony_ci#if DEBUG
10161cb0ef41Sopenharmony_ci  void Bind(Label* label, AssemblerDebugInfo debug_info);
10171cb0ef41Sopenharmony_ci#endif  // DEBUG
10181cb0ef41Sopenharmony_ci  void Bind(Label* label);
10191cb0ef41Sopenharmony_ci
10201cb0ef41Sopenharmony_ci  template <class... T>
10211cb0ef41Sopenharmony_ci  void Bind(compiler::CodeAssemblerParameterizedLabel<T...>* label,
10221cb0ef41Sopenharmony_ci            TNode<T>*... phis) {
10231cb0ef41Sopenharmony_ci    CodeAssembler::Bind(label, phis...);
10241cb0ef41Sopenharmony_ci  }
10251cb0ef41Sopenharmony_ci
10261cb0ef41Sopenharmony_ci  void BranchIfSmiEqual(TNode<Smi> a, TNode<Smi> b, Label* if_true,
10271cb0ef41Sopenharmony_ci                        Label* if_false) {
10281cb0ef41Sopenharmony_ci    Branch(SmiEqual(a, b), if_true, if_false);
10291cb0ef41Sopenharmony_ci  }
10301cb0ef41Sopenharmony_ci
10311cb0ef41Sopenharmony_ci  void BranchIfSmiLessThan(TNode<Smi> a, TNode<Smi> b, Label* if_true,
10321cb0ef41Sopenharmony_ci                           Label* if_false) {
10331cb0ef41Sopenharmony_ci    Branch(SmiLessThan(a, b), if_true, if_false);
10341cb0ef41Sopenharmony_ci  }
10351cb0ef41Sopenharmony_ci
10361cb0ef41Sopenharmony_ci  void BranchIfSmiLessThanOrEqual(TNode<Smi> a, TNode<Smi> b, Label* if_true,
10371cb0ef41Sopenharmony_ci                                  Label* if_false) {
10381cb0ef41Sopenharmony_ci    Branch(SmiLessThanOrEqual(a, b), if_true, if_false);
10391cb0ef41Sopenharmony_ci  }
10401cb0ef41Sopenharmony_ci
10411cb0ef41Sopenharmony_ci  void BranchIfFloat64IsNaN(TNode<Float64T> value, Label* if_true,
10421cb0ef41Sopenharmony_ci                            Label* if_false) {
10431cb0ef41Sopenharmony_ci    Branch(Float64Equal(value, value), if_false, if_true);
10441cb0ef41Sopenharmony_ci  }
10451cb0ef41Sopenharmony_ci
10461cb0ef41Sopenharmony_ci  // Branches to {if_true} if ToBoolean applied to {value} yields true,
10471cb0ef41Sopenharmony_ci  // otherwise goes to {if_false}.
10481cb0ef41Sopenharmony_ci  void BranchIfToBooleanIsTrue(TNode<Object> value, Label* if_true,
10491cb0ef41Sopenharmony_ci                               Label* if_false);
10501cb0ef41Sopenharmony_ci
10511cb0ef41Sopenharmony_ci  // Branches to {if_false} if ToBoolean applied to {value} yields false,
10521cb0ef41Sopenharmony_ci  // otherwise goes to {if_true}.
10531cb0ef41Sopenharmony_ci  void BranchIfToBooleanIsFalse(TNode<Object> value, Label* if_false,
10541cb0ef41Sopenharmony_ci                                Label* if_true) {
10551cb0ef41Sopenharmony_ci    BranchIfToBooleanIsTrue(value, if_true, if_false);
10561cb0ef41Sopenharmony_ci  }
10571cb0ef41Sopenharmony_ci
10581cb0ef41Sopenharmony_ci  void BranchIfJSReceiver(TNode<Object> object, Label* if_true,
10591cb0ef41Sopenharmony_ci                          Label* if_false);
10601cb0ef41Sopenharmony_ci
10611cb0ef41Sopenharmony_ci  // Branches to {if_true} when --force-slow-path flag has been passed.
10621cb0ef41Sopenharmony_ci  // It's used for testing to ensure that slow path implementation behave
10631cb0ef41Sopenharmony_ci  // equivalent to corresponding fast paths (where applicable).
10641cb0ef41Sopenharmony_ci  //
10651cb0ef41Sopenharmony_ci  // Works only with V8_ENABLE_FORCE_SLOW_PATH compile time flag. Nop otherwise.
10661cb0ef41Sopenharmony_ci  void GotoIfForceSlowPath(Label* if_true);
10671cb0ef41Sopenharmony_ci
10681cb0ef41Sopenharmony_ci  //
10691cb0ef41Sopenharmony_ci  // Caged pointer related functionality.
10701cb0ef41Sopenharmony_ci  //
10711cb0ef41Sopenharmony_ci
10721cb0ef41Sopenharmony_ci  // Load a caged pointer value from an object.
10731cb0ef41Sopenharmony_ci  TNode<RawPtrT> LoadSandboxedPointerFromObject(TNode<HeapObject> object,
10741cb0ef41Sopenharmony_ci                                                int offset) {
10751cb0ef41Sopenharmony_ci    return LoadSandboxedPointerFromObject(object, IntPtrConstant(offset));
10761cb0ef41Sopenharmony_ci  }
10771cb0ef41Sopenharmony_ci
10781cb0ef41Sopenharmony_ci  TNode<RawPtrT> LoadSandboxedPointerFromObject(TNode<HeapObject> object,
10791cb0ef41Sopenharmony_ci                                                TNode<IntPtrT> offset);
10801cb0ef41Sopenharmony_ci
10811cb0ef41Sopenharmony_ci  // Stored a caged pointer value to an object.
10821cb0ef41Sopenharmony_ci  void StoreSandboxedPointerToObject(TNode<HeapObject> object, int offset,
10831cb0ef41Sopenharmony_ci                                     TNode<RawPtrT> pointer) {
10841cb0ef41Sopenharmony_ci    StoreSandboxedPointerToObject(object, IntPtrConstant(offset), pointer);
10851cb0ef41Sopenharmony_ci  }
10861cb0ef41Sopenharmony_ci
10871cb0ef41Sopenharmony_ci  void StoreSandboxedPointerToObject(TNode<HeapObject> object,
10881cb0ef41Sopenharmony_ci                                     TNode<IntPtrT> offset,
10891cb0ef41Sopenharmony_ci                                     TNode<RawPtrT> pointer);
10901cb0ef41Sopenharmony_ci
10911cb0ef41Sopenharmony_ci  TNode<RawPtrT> EmptyBackingStoreBufferConstant();
10921cb0ef41Sopenharmony_ci
10931cb0ef41Sopenharmony_ci  //
10941cb0ef41Sopenharmony_ci  // ExternalPointerT-related functionality.
10951cb0ef41Sopenharmony_ci  //
10961cb0ef41Sopenharmony_ci
10971cb0ef41Sopenharmony_ci#ifdef V8_SANDBOXED_EXTERNAL_POINTERS
10981cb0ef41Sopenharmony_ci  TNode<ExternalPointerT> ChangeIndexToExternalPointer(TNode<Uint32T> index);
10991cb0ef41Sopenharmony_ci  TNode<Uint32T> ChangeExternalPointerToIndex(TNode<ExternalPointerT> pointer);
11001cb0ef41Sopenharmony_ci#endif  // V8_SANDBOXED_EXTERNAL_POINTERS
11011cb0ef41Sopenharmony_ci
11021cb0ef41Sopenharmony_ci  // Initialize an external pointer field in an object.
11031cb0ef41Sopenharmony_ci  void InitializeExternalPointerField(TNode<HeapObject> object, int offset) {
11041cb0ef41Sopenharmony_ci    InitializeExternalPointerField(object, IntPtrConstant(offset));
11051cb0ef41Sopenharmony_ci  }
11061cb0ef41Sopenharmony_ci  void InitializeExternalPointerField(TNode<HeapObject> object,
11071cb0ef41Sopenharmony_ci                                      TNode<IntPtrT> offset);
11081cb0ef41Sopenharmony_ci
11091cb0ef41Sopenharmony_ci  // Initialize an external pointer field in an object with given value.
11101cb0ef41Sopenharmony_ci  void InitializeExternalPointerField(TNode<HeapObject> object, int offset,
11111cb0ef41Sopenharmony_ci                                      TNode<RawPtrT> pointer,
11121cb0ef41Sopenharmony_ci                                      ExternalPointerTag tag) {
11131cb0ef41Sopenharmony_ci    InitializeExternalPointerField(object, IntPtrConstant(offset), pointer,
11141cb0ef41Sopenharmony_ci                                   tag);
11151cb0ef41Sopenharmony_ci  }
11161cb0ef41Sopenharmony_ci
11171cb0ef41Sopenharmony_ci  void InitializeExternalPointerField(TNode<HeapObject> object,
11181cb0ef41Sopenharmony_ci                                      TNode<IntPtrT> offset,
11191cb0ef41Sopenharmony_ci                                      TNode<RawPtrT> pointer,
11201cb0ef41Sopenharmony_ci                                      ExternalPointerTag tag) {
11211cb0ef41Sopenharmony_ci    InitializeExternalPointerField(object, offset);
11221cb0ef41Sopenharmony_ci    StoreExternalPointerToObject(object, offset, pointer, tag);
11231cb0ef41Sopenharmony_ci  }
11241cb0ef41Sopenharmony_ci
11251cb0ef41Sopenharmony_ci  // Load an external pointer value from an object.
11261cb0ef41Sopenharmony_ci  TNode<RawPtrT> LoadExternalPointerFromObject(TNode<HeapObject> object,
11271cb0ef41Sopenharmony_ci                                               int offset,
11281cb0ef41Sopenharmony_ci                                               ExternalPointerTag tag) {
11291cb0ef41Sopenharmony_ci    return LoadExternalPointerFromObject(object, IntPtrConstant(offset), tag);
11301cb0ef41Sopenharmony_ci  }
11311cb0ef41Sopenharmony_ci
11321cb0ef41Sopenharmony_ci  TNode<RawPtrT> LoadExternalPointerFromObject(TNode<HeapObject> object,
11331cb0ef41Sopenharmony_ci                                               TNode<IntPtrT> offset,
11341cb0ef41Sopenharmony_ci                                               ExternalPointerTag tag);
11351cb0ef41Sopenharmony_ci
11361cb0ef41Sopenharmony_ci  // Store external object pointer to object.
11371cb0ef41Sopenharmony_ci  void StoreExternalPointerToObject(TNode<HeapObject> object, int offset,
11381cb0ef41Sopenharmony_ci                                    TNode<RawPtrT> pointer,
11391cb0ef41Sopenharmony_ci                                    ExternalPointerTag tag) {
11401cb0ef41Sopenharmony_ci    StoreExternalPointerToObject(object, IntPtrConstant(offset), pointer, tag);
11411cb0ef41Sopenharmony_ci  }
11421cb0ef41Sopenharmony_ci
11431cb0ef41Sopenharmony_ci  void StoreExternalPointerToObject(TNode<HeapObject> object,
11441cb0ef41Sopenharmony_ci                                    TNode<IntPtrT> offset,
11451cb0ef41Sopenharmony_ci                                    TNode<RawPtrT> pointer,
11461cb0ef41Sopenharmony_ci                                    ExternalPointerTag tag);
11471cb0ef41Sopenharmony_ci
11481cb0ef41Sopenharmony_ci  TNode<RawPtrT> LoadForeignForeignAddressPtr(TNode<Foreign> object) {
11491cb0ef41Sopenharmony_ci    return LoadExternalPointerFromObject(object, Foreign::kForeignAddressOffset,
11501cb0ef41Sopenharmony_ci                                         kForeignForeignAddressTag);
11511cb0ef41Sopenharmony_ci  }
11521cb0ef41Sopenharmony_ci
11531cb0ef41Sopenharmony_ci  TNode<RawPtrT> LoadExternalStringResourcePtr(TNode<ExternalString> object) {
11541cb0ef41Sopenharmony_ci    return LoadExternalPointerFromObject(
11551cb0ef41Sopenharmony_ci        object, ExternalString::kResourceOffset, kExternalStringResourceTag);
11561cb0ef41Sopenharmony_ci  }
11571cb0ef41Sopenharmony_ci
11581cb0ef41Sopenharmony_ci  TNode<RawPtrT> LoadExternalStringResourceDataPtr(
11591cb0ef41Sopenharmony_ci      TNode<ExternalString> object) {
11601cb0ef41Sopenharmony_ci    // This is only valid for ExternalStrings where the resource data
11611cb0ef41Sopenharmony_ci    // pointer is cached (i.e. no uncached external strings).
11621cb0ef41Sopenharmony_ci    CSA_DCHECK(this, Word32NotEqual(
11631cb0ef41Sopenharmony_ci                         Word32And(LoadInstanceType(object),
11641cb0ef41Sopenharmony_ci                                   Int32Constant(kUncachedExternalStringMask)),
11651cb0ef41Sopenharmony_ci                         Int32Constant(kUncachedExternalStringTag)));
11661cb0ef41Sopenharmony_ci    return LoadExternalPointerFromObject(object,
11671cb0ef41Sopenharmony_ci                                         ExternalString::kResourceDataOffset,
11681cb0ef41Sopenharmony_ci                                         kExternalStringResourceDataTag);
11691cb0ef41Sopenharmony_ci  }
11701cb0ef41Sopenharmony_ci
11711cb0ef41Sopenharmony_ci  TNode<RawPtrT> LoadJSTypedArrayExternalPointerPtr(
11721cb0ef41Sopenharmony_ci      TNode<JSTypedArray> holder) {
11731cb0ef41Sopenharmony_ci    return LoadSandboxedPointerFromObject(holder,
11741cb0ef41Sopenharmony_ci                                          JSTypedArray::kExternalPointerOffset);
11751cb0ef41Sopenharmony_ci  }
11761cb0ef41Sopenharmony_ci
11771cb0ef41Sopenharmony_ci  void StoreJSTypedArrayExternalPointerPtr(TNode<JSTypedArray> holder,
11781cb0ef41Sopenharmony_ci                                           TNode<RawPtrT> value) {
11791cb0ef41Sopenharmony_ci    StoreSandboxedPointerToObject(holder, JSTypedArray::kExternalPointerOffset,
11801cb0ef41Sopenharmony_ci                                  value);
11811cb0ef41Sopenharmony_ci  }
11821cb0ef41Sopenharmony_ci
11831cb0ef41Sopenharmony_ci  // Load value from current parent frame by given offset in bytes.
11841cb0ef41Sopenharmony_ci  TNode<Object> LoadFromParentFrame(int offset);
11851cb0ef41Sopenharmony_ci
11861cb0ef41Sopenharmony_ci  // Load an object pointer from a buffer that isn't in the heap.
11871cb0ef41Sopenharmony_ci  TNode<Object> LoadBufferObject(TNode<RawPtrT> buffer, int offset) {
11881cb0ef41Sopenharmony_ci    return LoadFullTagged(buffer, IntPtrConstant(offset));
11891cb0ef41Sopenharmony_ci  }
11901cb0ef41Sopenharmony_ci  template <typename T>
11911cb0ef41Sopenharmony_ci  TNode<T> LoadBufferData(TNode<RawPtrT> buffer, int offset) {
11921cb0ef41Sopenharmony_ci    return UncheckedCast<T>(
11931cb0ef41Sopenharmony_ci        Load(MachineTypeOf<T>::value, buffer, IntPtrConstant(offset)));
11941cb0ef41Sopenharmony_ci  }
11951cb0ef41Sopenharmony_ci  TNode<RawPtrT> LoadBufferPointer(TNode<RawPtrT> buffer, int offset) {
11961cb0ef41Sopenharmony_ci    return LoadBufferData<RawPtrT>(buffer, offset);
11971cb0ef41Sopenharmony_ci  }
11981cb0ef41Sopenharmony_ci  TNode<Smi> LoadBufferSmi(TNode<RawPtrT> buffer, int offset) {
11991cb0ef41Sopenharmony_ci    return CAST(LoadBufferObject(buffer, offset));
12001cb0ef41Sopenharmony_ci  }
12011cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadBufferIntptr(TNode<RawPtrT> buffer, int offset) {
12021cb0ef41Sopenharmony_ci    return LoadBufferData<IntPtrT>(buffer, offset);
12031cb0ef41Sopenharmony_ci  }
12041cb0ef41Sopenharmony_ci  TNode<Uint8T> LoadUint8Ptr(TNode<RawPtrT> ptr, TNode<IntPtrT> offset);
12051cb0ef41Sopenharmony_ci
12061cb0ef41Sopenharmony_ci  // Load a field from an object on the heap.
12071cb0ef41Sopenharmony_ci  template <class T, typename std::enable_if<
12081cb0ef41Sopenharmony_ci                         std::is_convertible<TNode<T>, TNode<Object>>::value &&
12091cb0ef41Sopenharmony_ci                             std::is_base_of<T, Map>::value,
12101cb0ef41Sopenharmony_ci                         int>::type = 0>
12111cb0ef41Sopenharmony_ci  TNode<T> LoadObjectField(TNode<HeapObject> object, int offset) {
12121cb0ef41Sopenharmony_ci    const MachineType machine_type = offset == HeapObject::kMapOffset
12131cb0ef41Sopenharmony_ci                                         ? MachineType::MapInHeader()
12141cb0ef41Sopenharmony_ci                                         : MachineTypeOf<T>::value;
12151cb0ef41Sopenharmony_ci    return CAST(LoadFromObject(machine_type, object,
12161cb0ef41Sopenharmony_ci                               IntPtrConstant(offset - kHeapObjectTag)));
12171cb0ef41Sopenharmony_ci  }
12181cb0ef41Sopenharmony_ci  template <class T, typename std::enable_if<
12191cb0ef41Sopenharmony_ci                         std::is_convertible<TNode<T>, TNode<Object>>::value &&
12201cb0ef41Sopenharmony_ci                             !std::is_base_of<T, Map>::value,
12211cb0ef41Sopenharmony_ci                         int>::type = 0>
12221cb0ef41Sopenharmony_ci  TNode<T> LoadObjectField(TNode<HeapObject> object, int offset) {
12231cb0ef41Sopenharmony_ci    return CAST(LoadFromObject(MachineTypeOf<T>::value, object,
12241cb0ef41Sopenharmony_ci                               IntPtrConstant(offset - kHeapObjectTag)));
12251cb0ef41Sopenharmony_ci  }
12261cb0ef41Sopenharmony_ci  template <class T, typename std::enable_if<
12271cb0ef41Sopenharmony_ci                         std::is_convertible<TNode<T>, TNode<UntaggedT>>::value,
12281cb0ef41Sopenharmony_ci                         int>::type = 0>
12291cb0ef41Sopenharmony_ci  TNode<T> LoadObjectField(TNode<HeapObject> object, int offset) {
12301cb0ef41Sopenharmony_ci    return UncheckedCast<T>(
12311cb0ef41Sopenharmony_ci        LoadFromObject(MachineTypeOf<T>::value, object,
12321cb0ef41Sopenharmony_ci                       IntPtrConstant(offset - kHeapObjectTag)));
12331cb0ef41Sopenharmony_ci  }
12341cb0ef41Sopenharmony_ci  TNode<Object> LoadObjectField(TNode<HeapObject> object, int offset) {
12351cb0ef41Sopenharmony_ci    return UncheckedCast<Object>(
12361cb0ef41Sopenharmony_ci        LoadFromObject(MachineType::AnyTagged(), object,
12371cb0ef41Sopenharmony_ci                       IntPtrConstant(offset - kHeapObjectTag)));
12381cb0ef41Sopenharmony_ci  }
12391cb0ef41Sopenharmony_ci  TNode<Object> LoadObjectField(TNode<HeapObject> object,
12401cb0ef41Sopenharmony_ci                                TNode<IntPtrT> offset) {
12411cb0ef41Sopenharmony_ci    return UncheckedCast<Object>(
12421cb0ef41Sopenharmony_ci        LoadFromObject(MachineType::AnyTagged(), object,
12431cb0ef41Sopenharmony_ci                       IntPtrSub(offset, IntPtrConstant(kHeapObjectTag))));
12441cb0ef41Sopenharmony_ci  }
12451cb0ef41Sopenharmony_ci  template <class T, typename std::enable_if<
12461cb0ef41Sopenharmony_ci                         std::is_convertible<TNode<T>, TNode<UntaggedT>>::value,
12471cb0ef41Sopenharmony_ci                         int>::type = 0>
12481cb0ef41Sopenharmony_ci  TNode<T> LoadObjectField(TNode<HeapObject> object, TNode<IntPtrT> offset) {
12491cb0ef41Sopenharmony_ci    return UncheckedCast<T>(
12501cb0ef41Sopenharmony_ci        LoadFromObject(MachineTypeOf<T>::value, object,
12511cb0ef41Sopenharmony_ci                       IntPtrSub(offset, IntPtrConstant(kHeapObjectTag))));
12521cb0ef41Sopenharmony_ci  }
12531cb0ef41Sopenharmony_ci  // Load a SMI field and untag it.
12541cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadAndUntagObjectField(TNode<HeapObject> object, int offset);
12551cb0ef41Sopenharmony_ci  // Load a SMI field, untag it, and convert to Word32.
12561cb0ef41Sopenharmony_ci  TNode<Int32T> LoadAndUntagToWord32ObjectField(TNode<HeapObject> object,
12571cb0ef41Sopenharmony_ci                                                int offset);
12581cb0ef41Sopenharmony_ci
12591cb0ef41Sopenharmony_ci  TNode<MaybeObject> LoadMaybeWeakObjectField(TNode<HeapObject> object,
12601cb0ef41Sopenharmony_ci                                              int offset) {
12611cb0ef41Sopenharmony_ci    return UncheckedCast<MaybeObject>(LoadObjectField(object, offset));
12621cb0ef41Sopenharmony_ci  }
12631cb0ef41Sopenharmony_ci
12641cb0ef41Sopenharmony_ci  TNode<Object> LoadConstructorOrBackPointer(TNode<Map> map) {
12651cb0ef41Sopenharmony_ci    return LoadObjectField(map,
12661cb0ef41Sopenharmony_ci                           Map::kConstructorOrBackPointerOrNativeContextOffset);
12671cb0ef41Sopenharmony_ci  }
12681cb0ef41Sopenharmony_ci
12691cb0ef41Sopenharmony_ci  TNode<Simd128T> LoadSimd128(TNode<IntPtrT> ptr) {
12701cb0ef41Sopenharmony_ci    return Load<Simd128T>(ptr);
12711cb0ef41Sopenharmony_ci  }
12721cb0ef41Sopenharmony_ci
12731cb0ef41Sopenharmony_ci  // Reference is the CSA-equivalent of a Torque reference value, representing
12741cb0ef41Sopenharmony_ci  // an inner pointer into a HeapObject.
12751cb0ef41Sopenharmony_ci  //
12761cb0ef41Sopenharmony_ci  // The object can be a HeapObject or an all-zero bitpattern. The latter is
12771cb0ef41Sopenharmony_ci  // used for off-heap data, in which case the offset holds the actual address
12781cb0ef41Sopenharmony_ci  // and the data must be untagged (i.e. accessed via the Load-/StoreReference
12791cb0ef41Sopenharmony_ci  // overloads for TNode<UntaggedT>-convertible types below).
12801cb0ef41Sopenharmony_ci  //
12811cb0ef41Sopenharmony_ci  // TODO(gsps): Remove in favor of flattened {Load,Store}Reference interface.
12821cb0ef41Sopenharmony_ci  struct Reference {
12831cb0ef41Sopenharmony_ci    TNode<Object> object;
12841cb0ef41Sopenharmony_ci    TNode<IntPtrT> offset;
12851cb0ef41Sopenharmony_ci
12861cb0ef41Sopenharmony_ci    std::tuple<TNode<Object>, TNode<IntPtrT>> Flatten() const {
12871cb0ef41Sopenharmony_ci      return std::make_tuple(object, offset);
12881cb0ef41Sopenharmony_ci    }
12891cb0ef41Sopenharmony_ci  };
12901cb0ef41Sopenharmony_ci
12911cb0ef41Sopenharmony_ci  template <class T, typename std::enable_if<
12921cb0ef41Sopenharmony_ci                         std::is_convertible<TNode<T>, TNode<Object>>::value,
12931cb0ef41Sopenharmony_ci                         int>::type = 0>
12941cb0ef41Sopenharmony_ci  TNode<T> LoadReference(Reference reference) {
12951cb0ef41Sopenharmony_ci    if (IsMapOffsetConstant(reference.offset)) {
12961cb0ef41Sopenharmony_ci      TNode<Map> map = LoadMap(CAST(reference.object));
12971cb0ef41Sopenharmony_ci      DCHECK((std::is_base_of<T, Map>::value));
12981cb0ef41Sopenharmony_ci      return ReinterpretCast<T>(map);
12991cb0ef41Sopenharmony_ci    }
13001cb0ef41Sopenharmony_ci
13011cb0ef41Sopenharmony_ci    TNode<IntPtrT> offset =
13021cb0ef41Sopenharmony_ci        IntPtrSub(reference.offset, IntPtrConstant(kHeapObjectTag));
13031cb0ef41Sopenharmony_ci    CSA_DCHECK(this, TaggedIsNotSmi(reference.object));
13041cb0ef41Sopenharmony_ci    return CAST(
13051cb0ef41Sopenharmony_ci        LoadFromObject(MachineTypeOf<T>::value, reference.object, offset));
13061cb0ef41Sopenharmony_ci  }
13071cb0ef41Sopenharmony_ci  template <class T,
13081cb0ef41Sopenharmony_ci            typename std::enable_if<
13091cb0ef41Sopenharmony_ci                std::is_convertible<TNode<T>, TNode<UntaggedT>>::value ||
13101cb0ef41Sopenharmony_ci                    std::is_same<T, MaybeObject>::value,
13111cb0ef41Sopenharmony_ci                int>::type = 0>
13121cb0ef41Sopenharmony_ci  TNode<T> LoadReference(Reference reference) {
13131cb0ef41Sopenharmony_ci    DCHECK(!IsMapOffsetConstant(reference.offset));
13141cb0ef41Sopenharmony_ci    TNode<IntPtrT> offset =
13151cb0ef41Sopenharmony_ci        IntPtrSub(reference.offset, IntPtrConstant(kHeapObjectTag));
13161cb0ef41Sopenharmony_ci    return UncheckedCast<T>(
13171cb0ef41Sopenharmony_ci        LoadFromObject(MachineTypeOf<T>::value, reference.object, offset));
13181cb0ef41Sopenharmony_ci  }
13191cb0ef41Sopenharmony_ci  template <class T, typename std::enable_if<
13201cb0ef41Sopenharmony_ci                         std::is_convertible<TNode<T>, TNode<Object>>::value ||
13211cb0ef41Sopenharmony_ci                             std::is_same<T, MaybeObject>::value,
13221cb0ef41Sopenharmony_ci                         int>::type = 0>
13231cb0ef41Sopenharmony_ci  void StoreReference(Reference reference, TNode<T> value) {
13241cb0ef41Sopenharmony_ci    if (IsMapOffsetConstant(reference.offset)) {
13251cb0ef41Sopenharmony_ci      DCHECK((std::is_base_of<T, Map>::value));
13261cb0ef41Sopenharmony_ci      return StoreMap(CAST(reference.object), ReinterpretCast<Map>(value));
13271cb0ef41Sopenharmony_ci    }
13281cb0ef41Sopenharmony_ci    MachineRepresentation rep = MachineRepresentationOf<T>::value;
13291cb0ef41Sopenharmony_ci    StoreToObjectWriteBarrier write_barrier = StoreToObjectWriteBarrier::kFull;
13301cb0ef41Sopenharmony_ci    if (std::is_same<T, Smi>::value) {
13311cb0ef41Sopenharmony_ci      write_barrier = StoreToObjectWriteBarrier::kNone;
13321cb0ef41Sopenharmony_ci    } else if (std::is_same<T, Map>::value) {
13331cb0ef41Sopenharmony_ci      write_barrier = StoreToObjectWriteBarrier::kMap;
13341cb0ef41Sopenharmony_ci    }
13351cb0ef41Sopenharmony_ci    TNode<IntPtrT> offset =
13361cb0ef41Sopenharmony_ci        IntPtrSub(reference.offset, IntPtrConstant(kHeapObjectTag));
13371cb0ef41Sopenharmony_ci    CSA_DCHECK(this, TaggedIsNotSmi(reference.object));
13381cb0ef41Sopenharmony_ci    StoreToObject(rep, reference.object, offset, value, write_barrier);
13391cb0ef41Sopenharmony_ci  }
13401cb0ef41Sopenharmony_ci  template <class T, typename std::enable_if<
13411cb0ef41Sopenharmony_ci                         std::is_convertible<TNode<T>, TNode<UntaggedT>>::value,
13421cb0ef41Sopenharmony_ci                         int>::type = 0>
13431cb0ef41Sopenharmony_ci  void StoreReference(Reference reference, TNode<T> value) {
13441cb0ef41Sopenharmony_ci    DCHECK(!IsMapOffsetConstant(reference.offset));
13451cb0ef41Sopenharmony_ci    TNode<IntPtrT> offset =
13461cb0ef41Sopenharmony_ci        IntPtrSub(reference.offset, IntPtrConstant(kHeapObjectTag));
13471cb0ef41Sopenharmony_ci    StoreToObject(MachineRepresentationOf<T>::value, reference.object, offset,
13481cb0ef41Sopenharmony_ci                  value, StoreToObjectWriteBarrier::kNone);
13491cb0ef41Sopenharmony_ci  }
13501cb0ef41Sopenharmony_ci
13511cb0ef41Sopenharmony_ci  TNode<RawPtrT> GCUnsafeReferenceToRawPtr(TNode<Object> object,
13521cb0ef41Sopenharmony_ci                                           TNode<IntPtrT> offset) {
13531cb0ef41Sopenharmony_ci    return ReinterpretCast<RawPtrT>(
13541cb0ef41Sopenharmony_ci        IntPtrAdd(BitcastTaggedToWord(object),
13551cb0ef41Sopenharmony_ci                  IntPtrSub(offset, IntPtrConstant(kHeapObjectTag))));
13561cb0ef41Sopenharmony_ci  }
13571cb0ef41Sopenharmony_ci
13581cb0ef41Sopenharmony_ci  // Load the floating point value of a HeapNumber.
13591cb0ef41Sopenharmony_ci  TNode<Float64T> LoadHeapNumberValue(TNode<HeapObject> object);
13601cb0ef41Sopenharmony_ci  // Load the Map of an HeapObject.
13611cb0ef41Sopenharmony_ci  TNode<Map> LoadMap(TNode<HeapObject> object);
13621cb0ef41Sopenharmony_ci  // Load the instance type of an HeapObject.
13631cb0ef41Sopenharmony_ci  TNode<Uint16T> LoadInstanceType(TNode<HeapObject> object);
13641cb0ef41Sopenharmony_ci  // Compare the instance the type of the object against the provided one.
13651cb0ef41Sopenharmony_ci  TNode<BoolT> HasInstanceType(TNode<HeapObject> object, InstanceType type);
13661cb0ef41Sopenharmony_ci  TNode<BoolT> DoesntHaveInstanceType(TNode<HeapObject> object,
13671cb0ef41Sopenharmony_ci                                      InstanceType type);
13681cb0ef41Sopenharmony_ci  TNode<BoolT> TaggedDoesntHaveInstanceType(TNode<HeapObject> any_tagged,
13691cb0ef41Sopenharmony_ci                                            InstanceType type);
13701cb0ef41Sopenharmony_ci
13711cb0ef41Sopenharmony_ci  TNode<Word32T> IsStringWrapperElementsKind(TNode<Map> map);
13721cb0ef41Sopenharmony_ci  void GotoIfMapHasSlowProperties(TNode<Map> map, Label* if_slow);
13731cb0ef41Sopenharmony_ci
13741cb0ef41Sopenharmony_ci  // Load the properties backing store of a JSReceiver.
13751cb0ef41Sopenharmony_ci  TNode<HeapObject> LoadSlowProperties(TNode<JSReceiver> object);
13761cb0ef41Sopenharmony_ci  TNode<HeapObject> LoadFastProperties(TNode<JSReceiver> object);
13771cb0ef41Sopenharmony_ci  // Load the elements backing store of a JSObject.
13781cb0ef41Sopenharmony_ci  TNode<FixedArrayBase> LoadElements(TNode<JSObject> object) {
13791cb0ef41Sopenharmony_ci    return LoadJSObjectElements(object);
13801cb0ef41Sopenharmony_ci  }
13811cb0ef41Sopenharmony_ci  // Load the length of a JSArray instance.
13821cb0ef41Sopenharmony_ci  TNode<Object> LoadJSArgumentsObjectLength(TNode<Context> context,
13831cb0ef41Sopenharmony_ci                                            TNode<JSArgumentsObject> array);
13841cb0ef41Sopenharmony_ci  // Load the length of a fast JSArray instance. Returns a positive Smi.
13851cb0ef41Sopenharmony_ci  TNode<Smi> LoadFastJSArrayLength(TNode<JSArray> array);
13861cb0ef41Sopenharmony_ci  // Load the length of a fixed array base instance.
13871cb0ef41Sopenharmony_ci  TNode<Smi> LoadFixedArrayBaseLength(TNode<FixedArrayBase> array);
13881cb0ef41Sopenharmony_ci  // Load the length of a fixed array base instance.
13891cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadAndUntagFixedArrayBaseLength(TNode<FixedArrayBase> array);
13901cb0ef41Sopenharmony_ci  // Load the length of a WeakFixedArray.
13911cb0ef41Sopenharmony_ci  TNode<Smi> LoadWeakFixedArrayLength(TNode<WeakFixedArray> array);
13921cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadAndUntagWeakFixedArrayLength(TNode<WeakFixedArray> array);
13931cb0ef41Sopenharmony_ci  // Load the number of descriptors in DescriptorArray.
13941cb0ef41Sopenharmony_ci  TNode<Int32T> LoadNumberOfDescriptors(TNode<DescriptorArray> array);
13951cb0ef41Sopenharmony_ci  // Load the number of own descriptors of a map.
13961cb0ef41Sopenharmony_ci  TNode<Int32T> LoadNumberOfOwnDescriptors(TNode<Map> map);
13971cb0ef41Sopenharmony_ci  // Load the bit field of a Map.
13981cb0ef41Sopenharmony_ci  TNode<Int32T> LoadMapBitField(TNode<Map> map);
13991cb0ef41Sopenharmony_ci  // Load bit field 2 of a map.
14001cb0ef41Sopenharmony_ci  TNode<Int32T> LoadMapBitField2(TNode<Map> map);
14011cb0ef41Sopenharmony_ci  // Load bit field 3 of a map.
14021cb0ef41Sopenharmony_ci  TNode<Uint32T> LoadMapBitField3(TNode<Map> map);
14031cb0ef41Sopenharmony_ci  // Load the instance type of a map.
14041cb0ef41Sopenharmony_ci  TNode<Uint16T> LoadMapInstanceType(TNode<Map> map);
14051cb0ef41Sopenharmony_ci  // Load the ElementsKind of a map.
14061cb0ef41Sopenharmony_ci  TNode<Int32T> LoadMapElementsKind(TNode<Map> map);
14071cb0ef41Sopenharmony_ci  TNode<Int32T> LoadElementsKind(TNode<HeapObject> object);
14081cb0ef41Sopenharmony_ci  // Load the instance descriptors of a map.
14091cb0ef41Sopenharmony_ci  TNode<DescriptorArray> LoadMapDescriptors(TNode<Map> map);
14101cb0ef41Sopenharmony_ci  // Load the prototype of a map.
14111cb0ef41Sopenharmony_ci  TNode<HeapObject> LoadMapPrototype(TNode<Map> map);
14121cb0ef41Sopenharmony_ci  // Load the instance size of a Map.
14131cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadMapInstanceSizeInWords(TNode<Map> map);
14141cb0ef41Sopenharmony_ci  // Load the inobject properties start of a Map (valid only for JSObjects).
14151cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadMapInobjectPropertiesStartInWords(TNode<Map> map);
14161cb0ef41Sopenharmony_ci  // Load the constructor function index of a Map (only for primitive maps).
14171cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadMapConstructorFunctionIndex(TNode<Map> map);
14181cb0ef41Sopenharmony_ci  // Load the constructor of a Map (equivalent to Map::GetConstructor()).
14191cb0ef41Sopenharmony_ci  TNode<Object> LoadMapConstructor(TNode<Map> map);
14201cb0ef41Sopenharmony_ci  // Load the EnumLength of a Map.
14211cb0ef41Sopenharmony_ci  TNode<WordT> LoadMapEnumLength(TNode<Map> map);
14221cb0ef41Sopenharmony_ci  // Load the back-pointer of a Map.
14231cb0ef41Sopenharmony_ci  TNode<Object> LoadMapBackPointer(TNode<Map> map);
14241cb0ef41Sopenharmony_ci  // Checks that |map| has only simple properties, returns bitfield3.
14251cb0ef41Sopenharmony_ci  TNode<Uint32T> EnsureOnlyHasSimpleProperties(TNode<Map> map,
14261cb0ef41Sopenharmony_ci                                               TNode<Int32T> instance_type,
14271cb0ef41Sopenharmony_ci                                               Label* bailout);
14281cb0ef41Sopenharmony_ci  // Load the identity hash of a JSRececiver.
14291cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadJSReceiverIdentityHash(TNode<JSReceiver> receiver,
14301cb0ef41Sopenharmony_ci                                            Label* if_no_hash = nullptr);
14311cb0ef41Sopenharmony_ci
14321cb0ef41Sopenharmony_ci  // This is only used on a newly allocated PropertyArray which
14331cb0ef41Sopenharmony_ci  // doesn't have an existing hash.
14341cb0ef41Sopenharmony_ci  void InitializePropertyArrayLength(TNode<PropertyArray> property_array,
14351cb0ef41Sopenharmony_ci                                     TNode<IntPtrT> length);
14361cb0ef41Sopenharmony_ci
14371cb0ef41Sopenharmony_ci  // Check if the map is set for slow properties.
14381cb0ef41Sopenharmony_ci  TNode<BoolT> IsDictionaryMap(TNode<Map> map);
14391cb0ef41Sopenharmony_ci
14401cb0ef41Sopenharmony_ci  // Load the Name::hash() value of a name as an uint32 value.
14411cb0ef41Sopenharmony_ci  // If {if_hash_not_computed} label is specified then it also checks if
14421cb0ef41Sopenharmony_ci  // hash is actually computed.
14431cb0ef41Sopenharmony_ci  TNode<Uint32T> LoadNameHash(TNode<Name> name,
14441cb0ef41Sopenharmony_ci                              Label* if_hash_not_computed = nullptr);
14451cb0ef41Sopenharmony_ci  TNode<Uint32T> LoadNameHashAssumeComputed(TNode<Name> name);
14461cb0ef41Sopenharmony_ci
14471cb0ef41Sopenharmony_ci  // Load length field of a String object as Smi value.
14481cb0ef41Sopenharmony_ci  TNode<Smi> LoadStringLengthAsSmi(TNode<String> string);
14491cb0ef41Sopenharmony_ci  // Load length field of a String object as intptr_t value.
14501cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadStringLengthAsWord(TNode<String> string);
14511cb0ef41Sopenharmony_ci  // Load length field of a String object as uint32_t value.
14521cb0ef41Sopenharmony_ci  TNode<Uint32T> LoadStringLengthAsWord32(TNode<String> string);
14531cb0ef41Sopenharmony_ci  // Load value field of a JSPrimitiveWrapper object.
14541cb0ef41Sopenharmony_ci  TNode<Object> LoadJSPrimitiveWrapperValue(TNode<JSPrimitiveWrapper> object);
14551cb0ef41Sopenharmony_ci
14561cb0ef41Sopenharmony_ci  // Figures out whether the value of maybe_object is:
14571cb0ef41Sopenharmony_ci  // - a SMI (jump to "if_smi", "extracted" will be the SMI value)
14581cb0ef41Sopenharmony_ci  // - a cleared weak reference (jump to "if_cleared", "extracted" will be
14591cb0ef41Sopenharmony_ci  // untouched)
14601cb0ef41Sopenharmony_ci  // - a weak reference (jump to "if_weak", "extracted" will be the object
14611cb0ef41Sopenharmony_ci  // pointed to)
14621cb0ef41Sopenharmony_ci  // - a strong reference (jump to "if_strong", "extracted" will be the object
14631cb0ef41Sopenharmony_ci  // pointed to)
14641cb0ef41Sopenharmony_ci  void DispatchMaybeObject(TNode<MaybeObject> maybe_object, Label* if_smi,
14651cb0ef41Sopenharmony_ci                           Label* if_cleared, Label* if_weak, Label* if_strong,
14661cb0ef41Sopenharmony_ci                           TVariable<Object>* extracted);
14671cb0ef41Sopenharmony_ci  // See MaybeObject for semantics of these functions.
14681cb0ef41Sopenharmony_ci  TNode<BoolT> IsStrong(TNode<MaybeObject> value);
14691cb0ef41Sopenharmony_ci  TNode<HeapObject> GetHeapObjectIfStrong(TNode<MaybeObject> value,
14701cb0ef41Sopenharmony_ci                                          Label* if_not_strong);
14711cb0ef41Sopenharmony_ci
14721cb0ef41Sopenharmony_ci  TNode<BoolT> IsWeakOrCleared(TNode<MaybeObject> value);
14731cb0ef41Sopenharmony_ci  TNode<BoolT> IsCleared(TNode<MaybeObject> value);
14741cb0ef41Sopenharmony_ci  TNode<BoolT> IsNotCleared(TNode<MaybeObject> value) {
14751cb0ef41Sopenharmony_ci    return Word32BinaryNot(IsCleared(value));
14761cb0ef41Sopenharmony_ci  }
14771cb0ef41Sopenharmony_ci
14781cb0ef41Sopenharmony_ci  // Removes the weak bit + asserts it was set.
14791cb0ef41Sopenharmony_ci  TNode<HeapObject> GetHeapObjectAssumeWeak(TNode<MaybeObject> value);
14801cb0ef41Sopenharmony_ci
14811cb0ef41Sopenharmony_ci  TNode<HeapObject> GetHeapObjectAssumeWeak(TNode<MaybeObject> value,
14821cb0ef41Sopenharmony_ci                                            Label* if_cleared);
14831cb0ef41Sopenharmony_ci
14841cb0ef41Sopenharmony_ci  // Checks if |maybe_object| is a weak reference to given |heap_object|.
14851cb0ef41Sopenharmony_ci  // Works for both any tagged |maybe_object| values.
14861cb0ef41Sopenharmony_ci  TNode<BoolT> IsWeakReferenceTo(TNode<MaybeObject> maybe_object,
14871cb0ef41Sopenharmony_ci                                 TNode<HeapObject> heap_object);
14881cb0ef41Sopenharmony_ci  // Returns true if the |object| is a HeapObject and |maybe_object| is a weak
14891cb0ef41Sopenharmony_ci  // reference to |object|.
14901cb0ef41Sopenharmony_ci  // The |maybe_object| must not be a Smi.
14911cb0ef41Sopenharmony_ci  TNode<BoolT> IsWeakReferenceToObject(TNode<MaybeObject> maybe_object,
14921cb0ef41Sopenharmony_ci                                       TNode<Object> object);
14931cb0ef41Sopenharmony_ci
14941cb0ef41Sopenharmony_ci  TNode<MaybeObject> MakeWeak(TNode<HeapObject> value);
14951cb0ef41Sopenharmony_ci
14961cb0ef41Sopenharmony_ci  void FixedArrayBoundsCheck(TNode<FixedArrayBase> array, TNode<Smi> index,
14971cb0ef41Sopenharmony_ci                             int additional_offset);
14981cb0ef41Sopenharmony_ci
14991cb0ef41Sopenharmony_ci  void FixedArrayBoundsCheck(TNode<FixedArrayBase> array, TNode<IntPtrT> index,
15001cb0ef41Sopenharmony_ci                             int additional_offset);
15011cb0ef41Sopenharmony_ci
15021cb0ef41Sopenharmony_ci  void FixedArrayBoundsCheck(TNode<FixedArrayBase> array, TNode<UintPtrT> index,
15031cb0ef41Sopenharmony_ci                             int additional_offset) {
15041cb0ef41Sopenharmony_ci    FixedArrayBoundsCheck(array, Signed(index), additional_offset);
15051cb0ef41Sopenharmony_ci  }
15061cb0ef41Sopenharmony_ci
15071cb0ef41Sopenharmony_ci  // Array is any array-like type that has a fixed header followed by
15081cb0ef41Sopenharmony_ci  // tagged elements.
15091cb0ef41Sopenharmony_ci  template <typename Array>
15101cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadArrayLength(TNode<Array> array);
15111cb0ef41Sopenharmony_ci
15121cb0ef41Sopenharmony_ci  // Array is any array-like type that has a fixed header followed by
15131cb0ef41Sopenharmony_ci  // tagged elements.
15141cb0ef41Sopenharmony_ci  template <typename Array, typename TIndex, typename TValue = MaybeObject>
15151cb0ef41Sopenharmony_ci  TNode<TValue> LoadArrayElement(TNode<Array> array, int array_header_size,
15161cb0ef41Sopenharmony_ci                                 TNode<TIndex> index,
15171cb0ef41Sopenharmony_ci                                 int additional_offset = 0);
15181cb0ef41Sopenharmony_ci
15191cb0ef41Sopenharmony_ci  template <typename TIndex>
15201cb0ef41Sopenharmony_ci  TNode<Object> LoadFixedArrayElement(
15211cb0ef41Sopenharmony_ci      TNode<FixedArray> object, TNode<TIndex> index, int additional_offset = 0,
15221cb0ef41Sopenharmony_ci      CheckBounds check_bounds = CheckBounds::kAlways);
15231cb0ef41Sopenharmony_ci
15241cb0ef41Sopenharmony_ci  // This doesn't emit a bounds-check. As part of the security-performance
15251cb0ef41Sopenharmony_ci  // tradeoff, only use it if it is performance critical.
15261cb0ef41Sopenharmony_ci  TNode<Object> UnsafeLoadFixedArrayElement(TNode<FixedArray> object,
15271cb0ef41Sopenharmony_ci                                            TNode<IntPtrT> index,
15281cb0ef41Sopenharmony_ci                                            int additional_offset = 0) {
15291cb0ef41Sopenharmony_ci    return LoadFixedArrayElement(object, index, additional_offset,
15301cb0ef41Sopenharmony_ci                                 CheckBounds::kDebugOnly);
15311cb0ef41Sopenharmony_ci  }
15321cb0ef41Sopenharmony_ci
15331cb0ef41Sopenharmony_ci  TNode<Object> LoadFixedArrayElement(TNode<FixedArray> object, int index,
15341cb0ef41Sopenharmony_ci                                      int additional_offset = 0) {
15351cb0ef41Sopenharmony_ci    return LoadFixedArrayElement(object, IntPtrConstant(index),
15361cb0ef41Sopenharmony_ci                                 additional_offset);
15371cb0ef41Sopenharmony_ci  }
15381cb0ef41Sopenharmony_ci  // This doesn't emit a bounds-check. As part of the security-performance
15391cb0ef41Sopenharmony_ci  // tradeoff, only use it if it is performance critical.
15401cb0ef41Sopenharmony_ci  TNode<Object> UnsafeLoadFixedArrayElement(TNode<FixedArray> object, int index,
15411cb0ef41Sopenharmony_ci                                            int additional_offset = 0) {
15421cb0ef41Sopenharmony_ci    return LoadFixedArrayElement(object, IntPtrConstant(index),
15431cb0ef41Sopenharmony_ci                                 additional_offset, CheckBounds::kDebugOnly);
15441cb0ef41Sopenharmony_ci  }
15451cb0ef41Sopenharmony_ci
15461cb0ef41Sopenharmony_ci  TNode<Object> LoadPropertyArrayElement(TNode<PropertyArray> object,
15471cb0ef41Sopenharmony_ci                                         TNode<IntPtrT> index);
15481cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadPropertyArrayLength(TNode<PropertyArray> object);
15491cb0ef41Sopenharmony_ci
15501cb0ef41Sopenharmony_ci  // Load an element from an array and untag it and return it as Word32.
15511cb0ef41Sopenharmony_ci  // Array is any array-like type that has a fixed header followed by
15521cb0ef41Sopenharmony_ci  // tagged elements.
15531cb0ef41Sopenharmony_ci  template <typename Array>
15541cb0ef41Sopenharmony_ci  TNode<Int32T> LoadAndUntagToWord32ArrayElement(TNode<Array> array,
15551cb0ef41Sopenharmony_ci                                                 int array_header_size,
15561cb0ef41Sopenharmony_ci                                                 TNode<IntPtrT> index,
15571cb0ef41Sopenharmony_ci                                                 int additional_offset = 0);
15581cb0ef41Sopenharmony_ci
15591cb0ef41Sopenharmony_ci  // Load an array element from a FixedArray, untag it and return it as Word32.
15601cb0ef41Sopenharmony_ci  TNode<Int32T> LoadAndUntagToWord32FixedArrayElement(
15611cb0ef41Sopenharmony_ci      TNode<FixedArray> object, TNode<IntPtrT> index,
15621cb0ef41Sopenharmony_ci      int additional_offset = 0);
15631cb0ef41Sopenharmony_ci
15641cb0ef41Sopenharmony_ci  // Load an array element from a WeakFixedArray.
15651cb0ef41Sopenharmony_ci  TNode<MaybeObject> LoadWeakFixedArrayElement(TNode<WeakFixedArray> object,
15661cb0ef41Sopenharmony_ci                                               TNode<IntPtrT> index,
15671cb0ef41Sopenharmony_ci                                               int additional_offset = 0);
15681cb0ef41Sopenharmony_ci
15691cb0ef41Sopenharmony_ci  // Load an array element from a FixedDoubleArray.
15701cb0ef41Sopenharmony_ci  TNode<Float64T> LoadFixedDoubleArrayElement(
15711cb0ef41Sopenharmony_ci      TNode<FixedDoubleArray> object, TNode<IntPtrT> index,
15721cb0ef41Sopenharmony_ci      Label* if_hole = nullptr,
15731cb0ef41Sopenharmony_ci      MachineType machine_type = MachineType::Float64());
15741cb0ef41Sopenharmony_ci
15751cb0ef41Sopenharmony_ci  // Load an array element from a FixedArray, FixedDoubleArray or a
15761cb0ef41Sopenharmony_ci  // NumberDictionary (depending on the |elements_kind|) and return
15771cb0ef41Sopenharmony_ci  // it as a tagged value. Assumes that the |index| passed a length
15781cb0ef41Sopenharmony_ci  // check before. Bails out to |if_accessor| if the element that
15791cb0ef41Sopenharmony_ci  // was found is an accessor, or to |if_hole| if the element at
15801cb0ef41Sopenharmony_ci  // the given |index| is not found in |elements|.
15811cb0ef41Sopenharmony_ci  TNode<Object> LoadFixedArrayBaseElementAsTagged(
15821cb0ef41Sopenharmony_ci      TNode<FixedArrayBase> elements, TNode<IntPtrT> index,
15831cb0ef41Sopenharmony_ci      TNode<Int32T> elements_kind, Label* if_accessor, Label* if_hole);
15841cb0ef41Sopenharmony_ci
15851cb0ef41Sopenharmony_ci  // Load a feedback slot from a FeedbackVector.
15861cb0ef41Sopenharmony_ci  template <typename TIndex>
15871cb0ef41Sopenharmony_ci  TNode<MaybeObject> LoadFeedbackVectorSlot(
15881cb0ef41Sopenharmony_ci      TNode<FeedbackVector> feedback_vector, TNode<TIndex> slot,
15891cb0ef41Sopenharmony_ci      int additional_offset = 0);
15901cb0ef41Sopenharmony_ci
15911cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadFeedbackVectorLength(TNode<FeedbackVector>);
15921cb0ef41Sopenharmony_ci  TNode<Float64T> LoadDoubleWithHoleCheck(TNode<FixedDoubleArray> array,
15931cb0ef41Sopenharmony_ci                                          TNode<IntPtrT> index,
15941cb0ef41Sopenharmony_ci                                          Label* if_hole = nullptr);
15951cb0ef41Sopenharmony_ci
15961cb0ef41Sopenharmony_ci  TNode<BoolT> IsDoubleHole(TNode<Object> base, TNode<IntPtrT> offset);
15971cb0ef41Sopenharmony_ci  // Load Float64 value by |base| + |offset| address. If the value is a double
15981cb0ef41Sopenharmony_ci  // hole then jump to |if_hole|. If |machine_type| is None then only the hole
15991cb0ef41Sopenharmony_ci  // check is generated.
16001cb0ef41Sopenharmony_ci  TNode<Float64T> LoadDoubleWithHoleCheck(
16011cb0ef41Sopenharmony_ci      TNode<Object> base, TNode<IntPtrT> offset, Label* if_hole,
16021cb0ef41Sopenharmony_ci      MachineType machine_type = MachineType::Float64());
16031cb0ef41Sopenharmony_ci  TNode<Numeric> LoadFixedTypedArrayElementAsTagged(TNode<RawPtrT> data_pointer,
16041cb0ef41Sopenharmony_ci                                                    TNode<UintPtrT> index,
16051cb0ef41Sopenharmony_ci                                                    ElementsKind elements_kind);
16061cb0ef41Sopenharmony_ci  TNode<Numeric> LoadFixedTypedArrayElementAsTagged(
16071cb0ef41Sopenharmony_ci      TNode<RawPtrT> data_pointer, TNode<UintPtrT> index,
16081cb0ef41Sopenharmony_ci      TNode<Int32T> elements_kind);
16091cb0ef41Sopenharmony_ci  // Parts of the above, factored out for readability:
16101cb0ef41Sopenharmony_ci  TNode<BigInt> LoadFixedBigInt64ArrayElementAsTagged(
16111cb0ef41Sopenharmony_ci      TNode<RawPtrT> data_pointer, TNode<IntPtrT> offset);
16121cb0ef41Sopenharmony_ci  TNode<BigInt> LoadFixedBigUint64ArrayElementAsTagged(
16131cb0ef41Sopenharmony_ci      TNode<RawPtrT> data_pointer, TNode<IntPtrT> offset);
16141cb0ef41Sopenharmony_ci  // 64-bit platforms only:
16151cb0ef41Sopenharmony_ci  TNode<BigInt> BigIntFromInt64(TNode<IntPtrT> value);
16161cb0ef41Sopenharmony_ci  TNode<BigInt> BigIntFromUint64(TNode<UintPtrT> value);
16171cb0ef41Sopenharmony_ci  // 32-bit platforms only:
16181cb0ef41Sopenharmony_ci  TNode<BigInt> BigIntFromInt32Pair(TNode<IntPtrT> low, TNode<IntPtrT> high);
16191cb0ef41Sopenharmony_ci  TNode<BigInt> BigIntFromUint32Pair(TNode<UintPtrT> low, TNode<UintPtrT> high);
16201cb0ef41Sopenharmony_ci
16211cb0ef41Sopenharmony_ci  // ScopeInfo:
16221cb0ef41Sopenharmony_ci  TNode<ScopeInfo> LoadScopeInfo(TNode<Context> context);
16231cb0ef41Sopenharmony_ci  TNode<BoolT> LoadScopeInfoHasExtensionField(TNode<ScopeInfo> scope_info);
16241cb0ef41Sopenharmony_ci
16251cb0ef41Sopenharmony_ci  // Context manipulation:
16261cb0ef41Sopenharmony_ci  void StoreContextElementNoWriteBarrier(TNode<Context> context, int slot_index,
16271cb0ef41Sopenharmony_ci                                         TNode<Object> value);
16281cb0ef41Sopenharmony_ci  TNode<NativeContext> LoadNativeContext(TNode<Context> context);
16291cb0ef41Sopenharmony_ci  // Calling this is only valid if there's a module context in the chain.
16301cb0ef41Sopenharmony_ci  TNode<Context> LoadModuleContext(TNode<Context> context);
16311cb0ef41Sopenharmony_ci
16321cb0ef41Sopenharmony_ci  TNode<Object> GetImportMetaObject(TNode<Context> context);
16331cb0ef41Sopenharmony_ci
16341cb0ef41Sopenharmony_ci  void GotoIfContextElementEqual(TNode<Object> value,
16351cb0ef41Sopenharmony_ci                                 TNode<NativeContext> native_context,
16361cb0ef41Sopenharmony_ci                                 int slot_index, Label* if_equal) {
16371cb0ef41Sopenharmony_ci    GotoIf(TaggedEqual(value, LoadContextElement(native_context, slot_index)),
16381cb0ef41Sopenharmony_ci           if_equal);
16391cb0ef41Sopenharmony_ci  }
16401cb0ef41Sopenharmony_ci
16411cb0ef41Sopenharmony_ci  // Loads the initial map of the the Object constructor.
16421cb0ef41Sopenharmony_ci  TNode<Map> LoadObjectFunctionInitialMap(TNode<NativeContext> native_context);
16431cb0ef41Sopenharmony_ci  TNode<Map> LoadSlowObjectWithNullPrototypeMap(
16441cb0ef41Sopenharmony_ci      TNode<NativeContext> native_context);
16451cb0ef41Sopenharmony_ci
16461cb0ef41Sopenharmony_ci  TNode<Map> LoadJSArrayElementsMap(ElementsKind kind,
16471cb0ef41Sopenharmony_ci                                    TNode<NativeContext> native_context);
16481cb0ef41Sopenharmony_ci  TNode<Map> LoadJSArrayElementsMap(TNode<Int32T> kind,
16491cb0ef41Sopenharmony_ci                                    TNode<NativeContext> native_context);
16501cb0ef41Sopenharmony_ci
16511cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSFunctionWithPrototypeSlot(TNode<HeapObject> object);
16521cb0ef41Sopenharmony_ci  TNode<BoolT> IsGeneratorFunction(TNode<JSFunction> function);
16531cb0ef41Sopenharmony_ci  void BranchIfHasPrototypeProperty(TNode<JSFunction> function,
16541cb0ef41Sopenharmony_ci                                    TNode<Int32T> function_map_bit_field,
16551cb0ef41Sopenharmony_ci                                    Label* if_true, Label* if_false);
16561cb0ef41Sopenharmony_ci  void GotoIfPrototypeRequiresRuntimeLookup(TNode<JSFunction> function,
16571cb0ef41Sopenharmony_ci                                            TNode<Map> map, Label* runtime);
16581cb0ef41Sopenharmony_ci  // Load the "prototype" property of a JSFunction.
16591cb0ef41Sopenharmony_ci  TNode<HeapObject> LoadJSFunctionPrototype(TNode<JSFunction> function,
16601cb0ef41Sopenharmony_ci                                            Label* if_bailout);
16611cb0ef41Sopenharmony_ci
16621cb0ef41Sopenharmony_ci  TNode<BytecodeArray> LoadSharedFunctionInfoBytecodeArray(
16631cb0ef41Sopenharmony_ci      TNode<SharedFunctionInfo> shared);
16641cb0ef41Sopenharmony_ci
16651cb0ef41Sopenharmony_ci  void StoreObjectByteNoWriteBarrier(TNode<HeapObject> object, int offset,
16661cb0ef41Sopenharmony_ci                                     TNode<Word32T> value);
16671cb0ef41Sopenharmony_ci
16681cb0ef41Sopenharmony_ci  // Store the floating point value of a HeapNumber.
16691cb0ef41Sopenharmony_ci  void StoreHeapNumberValue(TNode<HeapNumber> object, TNode<Float64T> value);
16701cb0ef41Sopenharmony_ci
16711cb0ef41Sopenharmony_ci  // Store a field to an object on the heap.
16721cb0ef41Sopenharmony_ci  void StoreObjectField(TNode<HeapObject> object, int offset, TNode<Smi> value);
16731cb0ef41Sopenharmony_ci  void StoreObjectField(TNode<HeapObject> object, TNode<IntPtrT> offset,
16741cb0ef41Sopenharmony_ci                        TNode<Smi> value);
16751cb0ef41Sopenharmony_ci  void StoreObjectField(TNode<HeapObject> object, int offset,
16761cb0ef41Sopenharmony_ci                        TNode<Object> value);
16771cb0ef41Sopenharmony_ci  void StoreObjectField(TNode<HeapObject> object, TNode<IntPtrT> offset,
16781cb0ef41Sopenharmony_ci                        TNode<Object> value);
16791cb0ef41Sopenharmony_ci  template <class T>
16801cb0ef41Sopenharmony_ci  void StoreObjectFieldNoWriteBarrier(TNode<HeapObject> object,
16811cb0ef41Sopenharmony_ci                                      TNode<IntPtrT> offset, TNode<T> value) {
16821cb0ef41Sopenharmony_ci    int const_offset;
16831cb0ef41Sopenharmony_ci    if (TryToInt32Constant(offset, &const_offset)) {
16841cb0ef41Sopenharmony_ci      return StoreObjectFieldNoWriteBarrier<T>(object, const_offset, value);
16851cb0ef41Sopenharmony_ci    }
16861cb0ef41Sopenharmony_ci    StoreNoWriteBarrier(MachineRepresentationOf<T>::value, object,
16871cb0ef41Sopenharmony_ci                        IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)),
16881cb0ef41Sopenharmony_ci                        value);
16891cb0ef41Sopenharmony_ci  }
16901cb0ef41Sopenharmony_ci  template <class T>
16911cb0ef41Sopenharmony_ci  void StoreObjectFieldNoWriteBarrier(TNode<HeapObject> object, int offset,
16921cb0ef41Sopenharmony_ci                                      TNode<T> value) {
16931cb0ef41Sopenharmony_ci    if (CanBeTaggedPointer(MachineRepresentationOf<T>::value)) {
16941cb0ef41Sopenharmony_ci      OptimizedStoreFieldAssertNoWriteBarrier(MachineRepresentationOf<T>::value,
16951cb0ef41Sopenharmony_ci                                              object, offset, value);
16961cb0ef41Sopenharmony_ci    } else {
16971cb0ef41Sopenharmony_ci      OptimizedStoreFieldUnsafeNoWriteBarrier(MachineRepresentationOf<T>::value,
16981cb0ef41Sopenharmony_ci                                              object, offset, value);
16991cb0ef41Sopenharmony_ci    }
17001cb0ef41Sopenharmony_ci  }
17011cb0ef41Sopenharmony_ci
17021cb0ef41Sopenharmony_ci  void UnsafeStoreObjectFieldNoWriteBarrier(TNode<HeapObject> object,
17031cb0ef41Sopenharmony_ci                                            int offset, TNode<Object> value);
17041cb0ef41Sopenharmony_ci
17051cb0ef41Sopenharmony_ci  // Store the Map of an HeapObject.
17061cb0ef41Sopenharmony_ci  void StoreMap(TNode<HeapObject> object, TNode<Map> map);
17071cb0ef41Sopenharmony_ci  void StoreMapNoWriteBarrier(TNode<HeapObject> object,
17081cb0ef41Sopenharmony_ci                              RootIndex map_root_index);
17091cb0ef41Sopenharmony_ci  void StoreMapNoWriteBarrier(TNode<HeapObject> object, TNode<Map> map);
17101cb0ef41Sopenharmony_ci  void StoreObjectFieldRoot(TNode<HeapObject> object, int offset,
17111cb0ef41Sopenharmony_ci                            RootIndex root);
17121cb0ef41Sopenharmony_ci
17131cb0ef41Sopenharmony_ci  // Store an array element to a FixedArray.
17141cb0ef41Sopenharmony_ci  void StoreFixedArrayElement(
17151cb0ef41Sopenharmony_ci      TNode<FixedArray> object, int index, TNode<Object> value,
17161cb0ef41Sopenharmony_ci      WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
17171cb0ef41Sopenharmony_ci      CheckBounds check_bounds = CheckBounds::kAlways) {
17181cb0ef41Sopenharmony_ci    return StoreFixedArrayElement(object, IntPtrConstant(index), value,
17191cb0ef41Sopenharmony_ci                                  barrier_mode, 0, check_bounds);
17201cb0ef41Sopenharmony_ci  }
17211cb0ef41Sopenharmony_ci
17221cb0ef41Sopenharmony_ci  void StoreFixedArrayElement(TNode<FixedArray> object, int index,
17231cb0ef41Sopenharmony_ci                              TNode<Smi> value,
17241cb0ef41Sopenharmony_ci                              CheckBounds check_bounds = CheckBounds::kAlways) {
17251cb0ef41Sopenharmony_ci    return StoreFixedArrayElement(object, IntPtrConstant(index),
17261cb0ef41Sopenharmony_ci                                  TNode<Object>{value},
17271cb0ef41Sopenharmony_ci                                  UNSAFE_SKIP_WRITE_BARRIER, 0, check_bounds);
17281cb0ef41Sopenharmony_ci  }
17291cb0ef41Sopenharmony_ci
17301cb0ef41Sopenharmony_ci  template <typename TIndex>
17311cb0ef41Sopenharmony_ci  void StoreFixedArrayElement(
17321cb0ef41Sopenharmony_ci      TNode<FixedArray> array, TNode<TIndex> index, TNode<Object> value,
17331cb0ef41Sopenharmony_ci      WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
17341cb0ef41Sopenharmony_ci      int additional_offset = 0,
17351cb0ef41Sopenharmony_ci      CheckBounds check_bounds = CheckBounds::kAlways) {
17361cb0ef41Sopenharmony_ci    // TODO(v8:9708): Do we want to keep both IntPtrT and UintPtrT variants?
17371cb0ef41Sopenharmony_ci    static_assert(std::is_same<TIndex, Smi>::value ||
17381cb0ef41Sopenharmony_ci                      std::is_same<TIndex, UintPtrT>::value ||
17391cb0ef41Sopenharmony_ci                      std::is_same<TIndex, IntPtrT>::value,
17401cb0ef41Sopenharmony_ci                  "Only Smi, UintPtrT or IntPtrT index is allowed");
17411cb0ef41Sopenharmony_ci    if (NeedsBoundsCheck(check_bounds)) {
17421cb0ef41Sopenharmony_ci      FixedArrayBoundsCheck(array, index, additional_offset);
17431cb0ef41Sopenharmony_ci    }
17441cb0ef41Sopenharmony_ci    StoreFixedArrayOrPropertyArrayElement(array, index, value, barrier_mode,
17451cb0ef41Sopenharmony_ci                                          additional_offset);
17461cb0ef41Sopenharmony_ci  }
17471cb0ef41Sopenharmony_ci
17481cb0ef41Sopenharmony_ci  template <typename TIndex>
17491cb0ef41Sopenharmony_ci  void StoreFixedArrayElement(TNode<FixedArray> array, TNode<TIndex> index,
17501cb0ef41Sopenharmony_ci                              TNode<Smi> value, int additional_offset = 0) {
17511cb0ef41Sopenharmony_ci    static_assert(std::is_same<TIndex, Smi>::value ||
17521cb0ef41Sopenharmony_ci                      std::is_same<TIndex, IntPtrT>::value,
17531cb0ef41Sopenharmony_ci                  "Only Smi or IntPtrT indeces is allowed");
17541cb0ef41Sopenharmony_ci    StoreFixedArrayElement(array, index, TNode<Object>{value},
17551cb0ef41Sopenharmony_ci                           UNSAFE_SKIP_WRITE_BARRIER, additional_offset);
17561cb0ef41Sopenharmony_ci  }
17571cb0ef41Sopenharmony_ci
17581cb0ef41Sopenharmony_ci  // These don't emit a bounds-check. As part of the security-performance
17591cb0ef41Sopenharmony_ci  // tradeoff, only use it if it is performance critical.
17601cb0ef41Sopenharmony_ci  void UnsafeStoreFixedArrayElement(
17611cb0ef41Sopenharmony_ci      TNode<FixedArray> object, int index, TNode<Object> value,
17621cb0ef41Sopenharmony_ci      WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER) {
17631cb0ef41Sopenharmony_ci    return StoreFixedArrayElement(object, IntPtrConstant(index), value,
17641cb0ef41Sopenharmony_ci                                  barrier_mode, 0, CheckBounds::kDebugOnly);
17651cb0ef41Sopenharmony_ci  }
17661cb0ef41Sopenharmony_ci
17671cb0ef41Sopenharmony_ci  void UnsafeStoreFixedArrayElement(TNode<FixedArray> object, int index,
17681cb0ef41Sopenharmony_ci                                    TNode<Smi> value) {
17691cb0ef41Sopenharmony_ci    return StoreFixedArrayElement(object, IntPtrConstant(index), value,
17701cb0ef41Sopenharmony_ci                                  UNSAFE_SKIP_WRITE_BARRIER, 0,
17711cb0ef41Sopenharmony_ci                                  CheckBounds::kDebugOnly);
17721cb0ef41Sopenharmony_ci  }
17731cb0ef41Sopenharmony_ci
17741cb0ef41Sopenharmony_ci  void UnsafeStoreFixedArrayElement(
17751cb0ef41Sopenharmony_ci      TNode<FixedArray> array, TNode<IntPtrT> index, TNode<Object> value,
17761cb0ef41Sopenharmony_ci      WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
17771cb0ef41Sopenharmony_ci      int additional_offset = 0) {
17781cb0ef41Sopenharmony_ci    return StoreFixedArrayElement(array, index, value, barrier_mode,
17791cb0ef41Sopenharmony_ci                                  additional_offset, CheckBounds::kDebugOnly);
17801cb0ef41Sopenharmony_ci  }
17811cb0ef41Sopenharmony_ci
17821cb0ef41Sopenharmony_ci  void UnsafeStoreFixedArrayElement(TNode<FixedArray> array,
17831cb0ef41Sopenharmony_ci                                    TNode<IntPtrT> index, TNode<Smi> value,
17841cb0ef41Sopenharmony_ci                                    int additional_offset) {
17851cb0ef41Sopenharmony_ci    return StoreFixedArrayElement(array, index, value,
17861cb0ef41Sopenharmony_ci                                  UNSAFE_SKIP_WRITE_BARRIER, additional_offset,
17871cb0ef41Sopenharmony_ci                                  CheckBounds::kDebugOnly);
17881cb0ef41Sopenharmony_ci  }
17891cb0ef41Sopenharmony_ci
17901cb0ef41Sopenharmony_ci  void StorePropertyArrayElement(TNode<PropertyArray> array,
17911cb0ef41Sopenharmony_ci                                 TNode<IntPtrT> index, TNode<Object> value) {
17921cb0ef41Sopenharmony_ci    StoreFixedArrayOrPropertyArrayElement(array, index, value,
17931cb0ef41Sopenharmony_ci                                          UPDATE_WRITE_BARRIER);
17941cb0ef41Sopenharmony_ci  }
17951cb0ef41Sopenharmony_ci
17961cb0ef41Sopenharmony_ci  template <typename TIndex>
17971cb0ef41Sopenharmony_ci  void StoreFixedDoubleArrayElement(
17981cb0ef41Sopenharmony_ci      TNode<FixedDoubleArray> object, TNode<TIndex> index,
17991cb0ef41Sopenharmony_ci      TNode<Float64T> value, CheckBounds check_bounds = CheckBounds::kAlways);
18001cb0ef41Sopenharmony_ci
18011cb0ef41Sopenharmony_ci  void StoreDoubleHole(TNode<HeapObject> object, TNode<IntPtrT> offset);
18021cb0ef41Sopenharmony_ci  void StoreFixedDoubleArrayHole(TNode<FixedDoubleArray> array,
18031cb0ef41Sopenharmony_ci                                 TNode<IntPtrT> index);
18041cb0ef41Sopenharmony_ci  void StoreFeedbackVectorSlot(
18051cb0ef41Sopenharmony_ci      TNode<FeedbackVector> feedback_vector, TNode<UintPtrT> slot,
18061cb0ef41Sopenharmony_ci      TNode<AnyTaggedT> value,
18071cb0ef41Sopenharmony_ci      WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
18081cb0ef41Sopenharmony_ci      int additional_offset = 0);
18091cb0ef41Sopenharmony_ci
18101cb0ef41Sopenharmony_ci  void StoreJSSharedStructInObjectField(TNode<HeapObject> object,
18111cb0ef41Sopenharmony_ci                                        TNode<IntPtrT> offset,
18121cb0ef41Sopenharmony_ci                                        TNode<Object> value);
18131cb0ef41Sopenharmony_ci
18141cb0ef41Sopenharmony_ci  void StoreJSSharedStructPropertyArrayElement(TNode<PropertyArray> array,
18151cb0ef41Sopenharmony_ci                                               TNode<IntPtrT> index,
18161cb0ef41Sopenharmony_ci                                               TNode<Object> value) {
18171cb0ef41Sopenharmony_ci    // JSSharedStructs are allocated in the shared old space, which is currently
18181cb0ef41Sopenharmony_ci    // collected by stopping the world, so the incremental write barrier is not
18191cb0ef41Sopenharmony_ci    // needed. They can only store Smis and other HeapObjects in the shared old
18201cb0ef41Sopenharmony_ci    // space, so the generational write barrier is also not needed.
18211cb0ef41Sopenharmony_ci    // TODO(v8:12547): Add a safer, shared variant of SKIP_WRITE_BARRIER.
18221cb0ef41Sopenharmony_ci    StoreFixedArrayOrPropertyArrayElement(array, index, value,
18231cb0ef41Sopenharmony_ci                                          UNSAFE_SKIP_WRITE_BARRIER);
18241cb0ef41Sopenharmony_ci  }
18251cb0ef41Sopenharmony_ci
18261cb0ef41Sopenharmony_ci  // EnsureArrayPushable verifies that receiver with this map is:
18271cb0ef41Sopenharmony_ci  //   1. Is not a prototype.
18281cb0ef41Sopenharmony_ci  //   2. Is not a dictionary.
18291cb0ef41Sopenharmony_ci  //   3. Has a writeable length property.
18301cb0ef41Sopenharmony_ci  // It returns ElementsKind as a node for further division into cases.
18311cb0ef41Sopenharmony_ci  TNode<Int32T> EnsureArrayPushable(TNode<Context> context, TNode<Map> map,
18321cb0ef41Sopenharmony_ci                                    Label* bailout);
18331cb0ef41Sopenharmony_ci
18341cb0ef41Sopenharmony_ci  void TryStoreArrayElement(ElementsKind kind, Label* bailout,
18351cb0ef41Sopenharmony_ci                            TNode<FixedArrayBase> elements, TNode<BInt> index,
18361cb0ef41Sopenharmony_ci                            TNode<Object> value);
18371cb0ef41Sopenharmony_ci  // Consumes args into the array, and returns tagged new length.
18381cb0ef41Sopenharmony_ci  TNode<Smi> BuildAppendJSArray(ElementsKind kind, TNode<JSArray> array,
18391cb0ef41Sopenharmony_ci                                CodeStubArguments* args,
18401cb0ef41Sopenharmony_ci                                TVariable<IntPtrT>* arg_index, Label* bailout);
18411cb0ef41Sopenharmony_ci  // Pushes value onto the end of array.
18421cb0ef41Sopenharmony_ci  void BuildAppendJSArray(ElementsKind kind, TNode<JSArray> array,
18431cb0ef41Sopenharmony_ci                          TNode<Object> value, Label* bailout);
18441cb0ef41Sopenharmony_ci
18451cb0ef41Sopenharmony_ci  void StoreFieldsNoWriteBarrier(TNode<IntPtrT> start_address,
18461cb0ef41Sopenharmony_ci                                 TNode<IntPtrT> end_address,
18471cb0ef41Sopenharmony_ci                                 TNode<Object> value);
18481cb0ef41Sopenharmony_ci
18491cb0ef41Sopenharmony_ci  // Marks the FixedArray copy-on-write without moving it.
18501cb0ef41Sopenharmony_ci  void MakeFixedArrayCOW(TNode<FixedArray> array);
18511cb0ef41Sopenharmony_ci
18521cb0ef41Sopenharmony_ci  TNode<Cell> AllocateCellWithValue(
18531cb0ef41Sopenharmony_ci      TNode<Object> value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
18541cb0ef41Sopenharmony_ci  TNode<Cell> AllocateSmiCell(int value = 0) {
18551cb0ef41Sopenharmony_ci    return AllocateCellWithValue(SmiConstant(value), SKIP_WRITE_BARRIER);
18561cb0ef41Sopenharmony_ci  }
18571cb0ef41Sopenharmony_ci
18581cb0ef41Sopenharmony_ci  TNode<Object> LoadCellValue(TNode<Cell> cell);
18591cb0ef41Sopenharmony_ci
18601cb0ef41Sopenharmony_ci  void StoreCellValue(TNode<Cell> cell, TNode<Object> value,
18611cb0ef41Sopenharmony_ci                      WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
18621cb0ef41Sopenharmony_ci
18631cb0ef41Sopenharmony_ci  // Allocate a HeapNumber without initializing its value.
18641cb0ef41Sopenharmony_ci  TNode<HeapNumber> AllocateHeapNumber();
18651cb0ef41Sopenharmony_ci  // Allocate a HeapNumber with a specific value.
18661cb0ef41Sopenharmony_ci  TNode<HeapNumber> AllocateHeapNumberWithValue(TNode<Float64T> value);
18671cb0ef41Sopenharmony_ci  TNode<HeapNumber> AllocateHeapNumberWithValue(double value) {
18681cb0ef41Sopenharmony_ci    return AllocateHeapNumberWithValue(Float64Constant(value));
18691cb0ef41Sopenharmony_ci  }
18701cb0ef41Sopenharmony_ci
18711cb0ef41Sopenharmony_ci  // Allocate a BigInt with {length} digits. Sets the sign bit to {false}.
18721cb0ef41Sopenharmony_ci  // Does not initialize the digits.
18731cb0ef41Sopenharmony_ci  TNode<BigInt> AllocateBigInt(TNode<IntPtrT> length);
18741cb0ef41Sopenharmony_ci  // Like above, but allowing custom bitfield initialization.
18751cb0ef41Sopenharmony_ci  TNode<BigInt> AllocateRawBigInt(TNode<IntPtrT> length);
18761cb0ef41Sopenharmony_ci  void StoreBigIntBitfield(TNode<BigInt> bigint, TNode<Word32T> bitfield);
18771cb0ef41Sopenharmony_ci  void StoreBigIntDigit(TNode<BigInt> bigint, intptr_t digit_index,
18781cb0ef41Sopenharmony_ci                        TNode<UintPtrT> digit);
18791cb0ef41Sopenharmony_ci  void StoreBigIntDigit(TNode<BigInt> bigint, TNode<IntPtrT> digit_index,
18801cb0ef41Sopenharmony_ci                        TNode<UintPtrT> digit);
18811cb0ef41Sopenharmony_ci
18821cb0ef41Sopenharmony_ci  TNode<Word32T> LoadBigIntBitfield(TNode<BigInt> bigint);
18831cb0ef41Sopenharmony_ci  TNode<UintPtrT> LoadBigIntDigit(TNode<BigInt> bigint, intptr_t digit_index);
18841cb0ef41Sopenharmony_ci  TNode<UintPtrT> LoadBigIntDigit(TNode<BigInt> bigint,
18851cb0ef41Sopenharmony_ci                                  TNode<IntPtrT> digit_index);
18861cb0ef41Sopenharmony_ci
18871cb0ef41Sopenharmony_ci  // Allocate a ByteArray with the given non-zero length.
18881cb0ef41Sopenharmony_ci  TNode<ByteArray> AllocateNonEmptyByteArray(TNode<UintPtrT> length,
18891cb0ef41Sopenharmony_ci                                             AllocationFlags flags);
18901cb0ef41Sopenharmony_ci
18911cb0ef41Sopenharmony_ci  // Allocate a ByteArray with the given length.
18921cb0ef41Sopenharmony_ci  TNode<ByteArray> AllocateByteArray(
18931cb0ef41Sopenharmony_ci      TNode<UintPtrT> length, AllocationFlags flags = AllocationFlag::kNone);
18941cb0ef41Sopenharmony_ci
18951cb0ef41Sopenharmony_ci  // Allocate a SeqOneByteString with the given length.
18961cb0ef41Sopenharmony_ci  TNode<String> AllocateSeqOneByteString(
18971cb0ef41Sopenharmony_ci      uint32_t length, AllocationFlags flags = AllocationFlag::kNone);
18981cb0ef41Sopenharmony_ci  using TorqueGeneratedExportedMacrosAssembler::AllocateSeqOneByteString;
18991cb0ef41Sopenharmony_ci
19001cb0ef41Sopenharmony_ci  // Allocate a SeqTwoByteString with the given length.
19011cb0ef41Sopenharmony_ci  TNode<String> AllocateSeqTwoByteString(
19021cb0ef41Sopenharmony_ci      uint32_t length, AllocationFlags flags = AllocationFlag::kNone);
19031cb0ef41Sopenharmony_ci  using TorqueGeneratedExportedMacrosAssembler::AllocateSeqTwoByteString;
19041cb0ef41Sopenharmony_ci
19051cb0ef41Sopenharmony_ci  // Allocate a SlicedOneByteString with the given length, parent and offset.
19061cb0ef41Sopenharmony_ci  // |length| and |offset| are expected to be tagged.
19071cb0ef41Sopenharmony_ci
19081cb0ef41Sopenharmony_ci  TNode<String> AllocateSlicedOneByteString(TNode<Uint32T> length,
19091cb0ef41Sopenharmony_ci                                            TNode<String> parent,
19101cb0ef41Sopenharmony_ci                                            TNode<Smi> offset);
19111cb0ef41Sopenharmony_ci  // Allocate a SlicedTwoByteString with the given length, parent and offset.
19121cb0ef41Sopenharmony_ci  // |length| and |offset| are expected to be tagged.
19131cb0ef41Sopenharmony_ci  TNode<String> AllocateSlicedTwoByteString(TNode<Uint32T> length,
19141cb0ef41Sopenharmony_ci                                            TNode<String> parent,
19151cb0ef41Sopenharmony_ci                                            TNode<Smi> offset);
19161cb0ef41Sopenharmony_ci
19171cb0ef41Sopenharmony_ci  TNode<NameDictionary> AllocateNameDictionary(int at_least_space_for);
19181cb0ef41Sopenharmony_ci  TNode<NameDictionary> AllocateNameDictionary(
19191cb0ef41Sopenharmony_ci      TNode<IntPtrT> at_least_space_for,
19201cb0ef41Sopenharmony_ci      AllocationFlags = AllocationFlag::kNone);
19211cb0ef41Sopenharmony_ci  TNode<NameDictionary> AllocateNameDictionaryWithCapacity(
19221cb0ef41Sopenharmony_ci      TNode<IntPtrT> capacity, AllocationFlags = AllocationFlag::kNone);
19231cb0ef41Sopenharmony_ci  TNode<NameDictionary> CopyNameDictionary(TNode<NameDictionary> dictionary,
19241cb0ef41Sopenharmony_ci                                           Label* large_object_fallback);
19251cb0ef41Sopenharmony_ci
19261cb0ef41Sopenharmony_ci  TNode<OrderedHashSet> AllocateOrderedHashSet();
19271cb0ef41Sopenharmony_ci
19281cb0ef41Sopenharmony_ci  TNode<OrderedHashMap> AllocateOrderedHashMap();
19291cb0ef41Sopenharmony_ci
19301cb0ef41Sopenharmony_ci  // Allocates an OrderedNameDictionary of the given capacity. This guarantees
19311cb0ef41Sopenharmony_ci  // that |capacity| entries can be added without reallocating.
19321cb0ef41Sopenharmony_ci  TNode<OrderedNameDictionary> AllocateOrderedNameDictionary(
19331cb0ef41Sopenharmony_ci      TNode<IntPtrT> capacity);
19341cb0ef41Sopenharmony_ci  TNode<OrderedNameDictionary> AllocateOrderedNameDictionary(int capacity);
19351cb0ef41Sopenharmony_ci
19361cb0ef41Sopenharmony_ci  TNode<JSObject> AllocateJSObjectFromMap(
19371cb0ef41Sopenharmony_ci      TNode<Map> map,
19381cb0ef41Sopenharmony_ci      base::Optional<TNode<HeapObject>> properties = base::nullopt,
19391cb0ef41Sopenharmony_ci      base::Optional<TNode<FixedArray>> elements = base::nullopt,
19401cb0ef41Sopenharmony_ci      AllocationFlags flags = AllocationFlag::kNone,
19411cb0ef41Sopenharmony_ci      SlackTrackingMode slack_tracking_mode = kNoSlackTracking);
19421cb0ef41Sopenharmony_ci
19431cb0ef41Sopenharmony_ci  void InitializeJSObjectFromMap(
19441cb0ef41Sopenharmony_ci      TNode<HeapObject> object, TNode<Map> map, TNode<IntPtrT> instance_size,
19451cb0ef41Sopenharmony_ci      base::Optional<TNode<HeapObject>> properties = base::nullopt,
19461cb0ef41Sopenharmony_ci      base::Optional<TNode<FixedArray>> elements = base::nullopt,
19471cb0ef41Sopenharmony_ci      SlackTrackingMode slack_tracking_mode = kNoSlackTracking);
19481cb0ef41Sopenharmony_ci
19491cb0ef41Sopenharmony_ci  void InitializeJSObjectBodyWithSlackTracking(TNode<HeapObject> object,
19501cb0ef41Sopenharmony_ci                                               TNode<Map> map,
19511cb0ef41Sopenharmony_ci                                               TNode<IntPtrT> instance_size);
19521cb0ef41Sopenharmony_ci  void InitializeJSObjectBodyNoSlackTracking(
19531cb0ef41Sopenharmony_ci      TNode<HeapObject> object, TNode<Map> map, TNode<IntPtrT> instance_size,
19541cb0ef41Sopenharmony_ci      int start_offset = JSObject::kHeaderSize);
19551cb0ef41Sopenharmony_ci
19561cb0ef41Sopenharmony_ci  TNode<BoolT> IsValidFastJSArrayCapacity(TNode<IntPtrT> capacity);
19571cb0ef41Sopenharmony_ci
19581cb0ef41Sopenharmony_ci  //
19591cb0ef41Sopenharmony_ci  // Allocate and return a JSArray with initialized header fields and its
19601cb0ef41Sopenharmony_ci  // uninitialized elements.
19611cb0ef41Sopenharmony_ci  std::pair<TNode<JSArray>, TNode<FixedArrayBase>>
19621cb0ef41Sopenharmony_ci  AllocateUninitializedJSArrayWithElements(
19631cb0ef41Sopenharmony_ci      ElementsKind kind, TNode<Map> array_map, TNode<Smi> length,
19641cb0ef41Sopenharmony_ci      base::Optional<TNode<AllocationSite>> allocation_site,
19651cb0ef41Sopenharmony_ci      TNode<IntPtrT> capacity,
19661cb0ef41Sopenharmony_ci      AllocationFlags allocation_flags = AllocationFlag::kNone,
19671cb0ef41Sopenharmony_ci      int array_header_size = JSArray::kHeaderSize);
19681cb0ef41Sopenharmony_ci
19691cb0ef41Sopenharmony_ci  // Allocate a JSArray and fill elements with the hole.
19701cb0ef41Sopenharmony_ci  TNode<JSArray> AllocateJSArray(
19711cb0ef41Sopenharmony_ci      ElementsKind kind, TNode<Map> array_map, TNode<IntPtrT> capacity,
19721cb0ef41Sopenharmony_ci      TNode<Smi> length, base::Optional<TNode<AllocationSite>> allocation_site,
19731cb0ef41Sopenharmony_ci      AllocationFlags allocation_flags = AllocationFlag::kNone);
19741cb0ef41Sopenharmony_ci  TNode<JSArray> AllocateJSArray(
19751cb0ef41Sopenharmony_ci      ElementsKind kind, TNode<Map> array_map, TNode<Smi> capacity,
19761cb0ef41Sopenharmony_ci      TNode<Smi> length, base::Optional<TNode<AllocationSite>> allocation_site,
19771cb0ef41Sopenharmony_ci      AllocationFlags allocation_flags = AllocationFlag::kNone) {
19781cb0ef41Sopenharmony_ci    return AllocateJSArray(kind, array_map, SmiUntag(capacity), length,
19791cb0ef41Sopenharmony_ci                           allocation_site, allocation_flags);
19801cb0ef41Sopenharmony_ci  }
19811cb0ef41Sopenharmony_ci  TNode<JSArray> AllocateJSArray(
19821cb0ef41Sopenharmony_ci      ElementsKind kind, TNode<Map> array_map, TNode<Smi> capacity,
19831cb0ef41Sopenharmony_ci      TNode<Smi> length,
19841cb0ef41Sopenharmony_ci      AllocationFlags allocation_flags = AllocationFlag::kNone) {
19851cb0ef41Sopenharmony_ci    return AllocateJSArray(kind, array_map, SmiUntag(capacity), length,
19861cb0ef41Sopenharmony_ci                           base::nullopt, allocation_flags);
19871cb0ef41Sopenharmony_ci  }
19881cb0ef41Sopenharmony_ci  TNode<JSArray> AllocateJSArray(
19891cb0ef41Sopenharmony_ci      ElementsKind kind, TNode<Map> array_map, TNode<IntPtrT> capacity,
19901cb0ef41Sopenharmony_ci      TNode<Smi> length,
19911cb0ef41Sopenharmony_ci      AllocationFlags allocation_flags = AllocationFlag::kNone) {
19921cb0ef41Sopenharmony_ci    return AllocateJSArray(kind, array_map, capacity, length, base::nullopt,
19931cb0ef41Sopenharmony_ci                           allocation_flags);
19941cb0ef41Sopenharmony_ci  }
19951cb0ef41Sopenharmony_ci
19961cb0ef41Sopenharmony_ci  // Allocate a JSArray and initialize the header fields.
19971cb0ef41Sopenharmony_ci  TNode<JSArray> AllocateJSArray(
19981cb0ef41Sopenharmony_ci      TNode<Map> array_map, TNode<FixedArrayBase> elements, TNode<Smi> length,
19991cb0ef41Sopenharmony_ci      base::Optional<TNode<AllocationSite>> allocation_site = base::nullopt,
20001cb0ef41Sopenharmony_ci      int array_header_size = JSArray::kHeaderSize);
20011cb0ef41Sopenharmony_ci
20021cb0ef41Sopenharmony_ci  enum class HoleConversionMode { kDontConvert, kConvertToUndefined };
20031cb0ef41Sopenharmony_ci  // Clone a fast JSArray |array| into a new fast JSArray.
20041cb0ef41Sopenharmony_ci  // |convert_holes| tells the function to convert holes into undefined or not.
20051cb0ef41Sopenharmony_ci  // If |convert_holes| is set to kConvertToUndefined, but the function did not
20061cb0ef41Sopenharmony_ci  // find any hole in |array|, the resulting array will have the same elements
20071cb0ef41Sopenharmony_ci  // kind as |array|. If the function did find a hole, it will convert holes in
20081cb0ef41Sopenharmony_ci  // |array| to undefined in the resulting array, who will now have
20091cb0ef41Sopenharmony_ci  // PACKED_ELEMENTS kind.
20101cb0ef41Sopenharmony_ci  // If |convert_holes| is set kDontConvert, holes are also copied to the
20111cb0ef41Sopenharmony_ci  // resulting array, who will have the same elements kind as |array|. The
20121cb0ef41Sopenharmony_ci  // function generates significantly less code in this case.
20131cb0ef41Sopenharmony_ci  TNode<JSArray> CloneFastJSArray(
20141cb0ef41Sopenharmony_ci      TNode<Context> context, TNode<JSArray> array,
20151cb0ef41Sopenharmony_ci      base::Optional<TNode<AllocationSite>> allocation_site = base::nullopt,
20161cb0ef41Sopenharmony_ci      HoleConversionMode convert_holes = HoleConversionMode::kDontConvert);
20171cb0ef41Sopenharmony_ci
20181cb0ef41Sopenharmony_ci  TNode<JSArray> ExtractFastJSArray(TNode<Context> context,
20191cb0ef41Sopenharmony_ci                                    TNode<JSArray> array, TNode<BInt> begin,
20201cb0ef41Sopenharmony_ci                                    TNode<BInt> count);
20211cb0ef41Sopenharmony_ci
20221cb0ef41Sopenharmony_ci  template <typename TIndex>
20231cb0ef41Sopenharmony_ci  TNode<FixedArrayBase> AllocateFixedArray(
20241cb0ef41Sopenharmony_ci      ElementsKind kind, TNode<TIndex> capacity,
20251cb0ef41Sopenharmony_ci      AllocationFlags flags = AllocationFlag::kNone,
20261cb0ef41Sopenharmony_ci      base::Optional<TNode<Map>> fixed_array_map = base::nullopt);
20271cb0ef41Sopenharmony_ci
20281cb0ef41Sopenharmony_ci  TNode<NativeContext> GetCreationContext(TNode<JSReceiver> receiver,
20291cb0ef41Sopenharmony_ci                                          Label* if_bailout);
20301cb0ef41Sopenharmony_ci  TNode<NativeContext> GetFunctionRealm(TNode<Context> context,
20311cb0ef41Sopenharmony_ci                                        TNode<JSReceiver> receiver,
20321cb0ef41Sopenharmony_ci                                        Label* if_bailout);
20331cb0ef41Sopenharmony_ci  TNode<Object> GetConstructor(TNode<Map> map);
20341cb0ef41Sopenharmony_ci
20351cb0ef41Sopenharmony_ci  TNode<Map> GetInstanceTypeMap(InstanceType instance_type);
20361cb0ef41Sopenharmony_ci
20371cb0ef41Sopenharmony_ci  TNode<FixedArray> AllocateUninitializedFixedArray(intptr_t capacity) {
20381cb0ef41Sopenharmony_ci    return UncheckedCast<FixedArray>(AllocateFixedArray(
20391cb0ef41Sopenharmony_ci        PACKED_ELEMENTS, IntPtrConstant(capacity), AllocationFlag::kNone));
20401cb0ef41Sopenharmony_ci  }
20411cb0ef41Sopenharmony_ci
20421cb0ef41Sopenharmony_ci  TNode<FixedArray> AllocateZeroedFixedArray(TNode<IntPtrT> capacity) {
20431cb0ef41Sopenharmony_ci    TNode<FixedArray> result = UncheckedCast<FixedArray>(
20441cb0ef41Sopenharmony_ci        AllocateFixedArray(PACKED_ELEMENTS, capacity,
20451cb0ef41Sopenharmony_ci                           AllocationFlag::kAllowLargeObjectAllocation));
20461cb0ef41Sopenharmony_ci    FillFixedArrayWithSmiZero(result, capacity);
20471cb0ef41Sopenharmony_ci    return result;
20481cb0ef41Sopenharmony_ci  }
20491cb0ef41Sopenharmony_ci
20501cb0ef41Sopenharmony_ci  TNode<FixedDoubleArray> AllocateZeroedFixedDoubleArray(
20511cb0ef41Sopenharmony_ci      TNode<IntPtrT> capacity) {
20521cb0ef41Sopenharmony_ci    TNode<FixedDoubleArray> result = UncheckedCast<FixedDoubleArray>(
20531cb0ef41Sopenharmony_ci        AllocateFixedArray(PACKED_DOUBLE_ELEMENTS, capacity,
20541cb0ef41Sopenharmony_ci                           AllocationFlag::kAllowLargeObjectAllocation));
20551cb0ef41Sopenharmony_ci    FillFixedDoubleArrayWithZero(result, capacity);
20561cb0ef41Sopenharmony_ci    return result;
20571cb0ef41Sopenharmony_ci  }
20581cb0ef41Sopenharmony_ci
20591cb0ef41Sopenharmony_ci  TNode<FixedArray> AllocateFixedArrayWithHoles(TNode<IntPtrT> capacity,
20601cb0ef41Sopenharmony_ci                                                AllocationFlags flags) {
20611cb0ef41Sopenharmony_ci    TNode<FixedArray> result = UncheckedCast<FixedArray>(
20621cb0ef41Sopenharmony_ci        AllocateFixedArray(PACKED_ELEMENTS, capacity, flags));
20631cb0ef41Sopenharmony_ci    FillFixedArrayWithValue(PACKED_ELEMENTS, result, IntPtrConstant(0),
20641cb0ef41Sopenharmony_ci                            capacity, RootIndex::kTheHoleValue);
20651cb0ef41Sopenharmony_ci    return result;
20661cb0ef41Sopenharmony_ci  }
20671cb0ef41Sopenharmony_ci
20681cb0ef41Sopenharmony_ci  TNode<FixedDoubleArray> AllocateFixedDoubleArrayWithHoles(
20691cb0ef41Sopenharmony_ci      TNode<IntPtrT> capacity, AllocationFlags flags) {
20701cb0ef41Sopenharmony_ci    TNode<FixedDoubleArray> result = UncheckedCast<FixedDoubleArray>(
20711cb0ef41Sopenharmony_ci        AllocateFixedArray(PACKED_DOUBLE_ELEMENTS, capacity, flags));
20721cb0ef41Sopenharmony_ci    FillFixedArrayWithValue(PACKED_DOUBLE_ELEMENTS, result, IntPtrConstant(0),
20731cb0ef41Sopenharmony_ci                            capacity, RootIndex::kTheHoleValue);
20741cb0ef41Sopenharmony_ci    return result;
20751cb0ef41Sopenharmony_ci  }
20761cb0ef41Sopenharmony_ci
20771cb0ef41Sopenharmony_ci  TNode<PropertyArray> AllocatePropertyArray(TNode<IntPtrT> capacity);
20781cb0ef41Sopenharmony_ci
20791cb0ef41Sopenharmony_ci  TNode<HeapObject> AllocateWasmArray(TNode<IntPtrT> size_in_bytes,
20801cb0ef41Sopenharmony_ci                                      int initialization);
20811cb0ef41Sopenharmony_ci
20821cb0ef41Sopenharmony_ci  // TODO(v8:9722): Return type should be JSIteratorResult
20831cb0ef41Sopenharmony_ci  TNode<JSObject> AllocateJSIteratorResult(TNode<Context> context,
20841cb0ef41Sopenharmony_ci                                           TNode<Object> value,
20851cb0ef41Sopenharmony_ci                                           TNode<Oddball> done);
20861cb0ef41Sopenharmony_ci
20871cb0ef41Sopenharmony_ci  // TODO(v8:9722): Return type should be JSIteratorResult
20881cb0ef41Sopenharmony_ci  TNode<JSObject> AllocateJSIteratorResultForEntry(TNode<Context> context,
20891cb0ef41Sopenharmony_ci                                                   TNode<Object> key,
20901cb0ef41Sopenharmony_ci                                                   TNode<Object> value);
20911cb0ef41Sopenharmony_ci
20921cb0ef41Sopenharmony_ci  TNode<JSReceiver> ArraySpeciesCreate(TNode<Context> context,
20931cb0ef41Sopenharmony_ci                                       TNode<Object> originalArray,
20941cb0ef41Sopenharmony_ci                                       TNode<Number> len);
20951cb0ef41Sopenharmony_ci
20961cb0ef41Sopenharmony_ci  template <typename TIndex>
20971cb0ef41Sopenharmony_ci  void FillFixedArrayWithValue(ElementsKind kind, TNode<FixedArrayBase> array,
20981cb0ef41Sopenharmony_ci                               TNode<TIndex> from_index, TNode<TIndex> to_index,
20991cb0ef41Sopenharmony_ci                               RootIndex value_root_index);
21001cb0ef41Sopenharmony_ci
21011cb0ef41Sopenharmony_ci  // Uses memset to effectively initialize the given FixedArray with zeroes.
21021cb0ef41Sopenharmony_ci  void FillFixedArrayWithSmiZero(TNode<FixedArray> array,
21031cb0ef41Sopenharmony_ci                                 TNode<IntPtrT> length);
21041cb0ef41Sopenharmony_ci  void FillFixedDoubleArrayWithZero(TNode<FixedDoubleArray> array,
21051cb0ef41Sopenharmony_ci                                    TNode<IntPtrT> length);
21061cb0ef41Sopenharmony_ci
21071cb0ef41Sopenharmony_ci  void FillPropertyArrayWithUndefined(TNode<PropertyArray> array,
21081cb0ef41Sopenharmony_ci                                      TNode<IntPtrT> from_index,
21091cb0ef41Sopenharmony_ci                                      TNode<IntPtrT> to_index);
21101cb0ef41Sopenharmony_ci
21111cb0ef41Sopenharmony_ci  enum class DestroySource { kNo, kYes };
21121cb0ef41Sopenharmony_ci
21131cb0ef41Sopenharmony_ci  // Increment the call count for a CALL_IC or construct call.
21141cb0ef41Sopenharmony_ci  // The call count is located at feedback_vector[slot_id + 1].
21151cb0ef41Sopenharmony_ci  void IncrementCallCount(TNode<FeedbackVector> feedback_vector,
21161cb0ef41Sopenharmony_ci                          TNode<UintPtrT> slot_id);
21171cb0ef41Sopenharmony_ci
21181cb0ef41Sopenharmony_ci  // Specify DestroySource::kYes if {from_array} is being supplanted by
21191cb0ef41Sopenharmony_ci  // {to_array}. This offers a slight performance benefit by simply copying the
21201cb0ef41Sopenharmony_ci  // array word by word. The source may be destroyed at the end of this macro.
21211cb0ef41Sopenharmony_ci  //
21221cb0ef41Sopenharmony_ci  // Otherwise, specify DestroySource::kNo for operations where an Object is
21231cb0ef41Sopenharmony_ci  // being cloned, to ensure that mutable HeapNumbers are unique between the
21241cb0ef41Sopenharmony_ci  // source and cloned object.
21251cb0ef41Sopenharmony_ci  void CopyPropertyArrayValues(TNode<HeapObject> from_array,
21261cb0ef41Sopenharmony_ci                               TNode<PropertyArray> to_array,
21271cb0ef41Sopenharmony_ci                               TNode<IntPtrT> length,
21281cb0ef41Sopenharmony_ci                               WriteBarrierMode barrier_mode,
21291cb0ef41Sopenharmony_ci                               DestroySource destroy_source);
21301cb0ef41Sopenharmony_ci
21311cb0ef41Sopenharmony_ci  // Copies all elements from |from_array| of |length| size to
21321cb0ef41Sopenharmony_ci  // |to_array| of the same size respecting the elements kind.
21331cb0ef41Sopenharmony_ci  template <typename TIndex>
21341cb0ef41Sopenharmony_ci  void CopyFixedArrayElements(
21351cb0ef41Sopenharmony_ci      ElementsKind kind, TNode<FixedArrayBase> from_array,
21361cb0ef41Sopenharmony_ci      TNode<FixedArrayBase> to_array, TNode<TIndex> length,
21371cb0ef41Sopenharmony_ci      WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER) {
21381cb0ef41Sopenharmony_ci    CopyFixedArrayElements(kind, from_array, kind, to_array,
21391cb0ef41Sopenharmony_ci                           IntPtrOrSmiConstant<TIndex>(0), length, length,
21401cb0ef41Sopenharmony_ci                           barrier_mode);
21411cb0ef41Sopenharmony_ci  }
21421cb0ef41Sopenharmony_ci
21431cb0ef41Sopenharmony_ci  // Copies |element_count| elements from |from_array| starting from element
21441cb0ef41Sopenharmony_ci  // zero to |to_array| of |capacity| size respecting both array's elements
21451cb0ef41Sopenharmony_ci  // kinds.
21461cb0ef41Sopenharmony_ci  template <typename TIndex>
21471cb0ef41Sopenharmony_ci  void CopyFixedArrayElements(
21481cb0ef41Sopenharmony_ci      ElementsKind from_kind, TNode<FixedArrayBase> from_array,
21491cb0ef41Sopenharmony_ci      ElementsKind to_kind, TNode<FixedArrayBase> to_array,
21501cb0ef41Sopenharmony_ci      TNode<TIndex> element_count, TNode<TIndex> capacity,
21511cb0ef41Sopenharmony_ci      WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER) {
21521cb0ef41Sopenharmony_ci    CopyFixedArrayElements(from_kind, from_array, to_kind, to_array,
21531cb0ef41Sopenharmony_ci                           IntPtrOrSmiConstant<TIndex>(0), element_count,
21541cb0ef41Sopenharmony_ci                           capacity, barrier_mode);
21551cb0ef41Sopenharmony_ci  }
21561cb0ef41Sopenharmony_ci
21571cb0ef41Sopenharmony_ci  // Copies |element_count| elements from |from_array| starting from element
21581cb0ef41Sopenharmony_ci  // |first_element| to |to_array| of |capacity| size respecting both array's
21591cb0ef41Sopenharmony_ci  // elements kinds.
21601cb0ef41Sopenharmony_ci  // |convert_holes| tells the function whether to convert holes to undefined.
21611cb0ef41Sopenharmony_ci  // |var_holes_converted| can be used to signify that the conversion happened
21621cb0ef41Sopenharmony_ci  // (i.e. that there were holes). If |convert_holes_to_undefined| is
21631cb0ef41Sopenharmony_ci  // HoleConversionMode::kConvertToUndefined, then it must not be the case that
21641cb0ef41Sopenharmony_ci  // IsDoubleElementsKind(to_kind).
21651cb0ef41Sopenharmony_ci  template <typename TIndex>
21661cb0ef41Sopenharmony_ci  void CopyFixedArrayElements(
21671cb0ef41Sopenharmony_ci      ElementsKind from_kind, TNode<FixedArrayBase> from_array,
21681cb0ef41Sopenharmony_ci      ElementsKind to_kind, TNode<FixedArrayBase> to_array,
21691cb0ef41Sopenharmony_ci      TNode<TIndex> first_element, TNode<TIndex> element_count,
21701cb0ef41Sopenharmony_ci      TNode<TIndex> capacity,
21711cb0ef41Sopenharmony_ci      WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
21721cb0ef41Sopenharmony_ci      HoleConversionMode convert_holes = HoleConversionMode::kDontConvert,
21731cb0ef41Sopenharmony_ci      TVariable<BoolT>* var_holes_converted = nullptr);
21741cb0ef41Sopenharmony_ci
21751cb0ef41Sopenharmony_ci  void JumpIfPointersFromHereAreInteresting(TNode<Object> object,
21761cb0ef41Sopenharmony_ci                                            Label* interesting);
21771cb0ef41Sopenharmony_ci
21781cb0ef41Sopenharmony_ci  // Efficiently copy elements within a single array. The regions
21791cb0ef41Sopenharmony_ci  // [src_index, src_index + length) and [dst_index, dst_index + length)
21801cb0ef41Sopenharmony_ci  // can be overlapping.
21811cb0ef41Sopenharmony_ci  void MoveElements(ElementsKind kind, TNode<FixedArrayBase> elements,
21821cb0ef41Sopenharmony_ci                    TNode<IntPtrT> dst_index, TNode<IntPtrT> src_index,
21831cb0ef41Sopenharmony_ci                    TNode<IntPtrT> length);
21841cb0ef41Sopenharmony_ci
21851cb0ef41Sopenharmony_ci  // Efficiently copy elements from one array to another. The ElementsKind
21861cb0ef41Sopenharmony_ci  // needs to be the same. Copy from src_elements at
21871cb0ef41Sopenharmony_ci  // [src_index, src_index + length) to dst_elements at
21881cb0ef41Sopenharmony_ci  // [dst_index, dst_index + length).
21891cb0ef41Sopenharmony_ci  // The function decides whether it can use memcpy. In case it cannot,
21901cb0ef41Sopenharmony_ci  // |write_barrier| can help it to skip write barrier. SKIP_WRITE_BARRIER is
21911cb0ef41Sopenharmony_ci  // only safe when copying to new space, or when copying to old space and the
21921cb0ef41Sopenharmony_ci  // array does not contain object pointers.
21931cb0ef41Sopenharmony_ci  void CopyElements(ElementsKind kind, TNode<FixedArrayBase> dst_elements,
21941cb0ef41Sopenharmony_ci                    TNode<IntPtrT> dst_index,
21951cb0ef41Sopenharmony_ci                    TNode<FixedArrayBase> src_elements,
21961cb0ef41Sopenharmony_ci                    TNode<IntPtrT> src_index, TNode<IntPtrT> length,
21971cb0ef41Sopenharmony_ci                    WriteBarrierMode write_barrier = UPDATE_WRITE_BARRIER);
21981cb0ef41Sopenharmony_ci
21991cb0ef41Sopenharmony_ci  TNode<FixedArray> HeapObjectToFixedArray(TNode<HeapObject> base,
22001cb0ef41Sopenharmony_ci                                           Label* cast_fail);
22011cb0ef41Sopenharmony_ci
22021cb0ef41Sopenharmony_ci  TNode<FixedDoubleArray> HeapObjectToFixedDoubleArray(TNode<HeapObject> base,
22031cb0ef41Sopenharmony_ci                                                       Label* cast_fail) {
22041cb0ef41Sopenharmony_ci    GotoIf(TaggedNotEqual(LoadMap(base), FixedDoubleArrayMapConstant()),
22051cb0ef41Sopenharmony_ci           cast_fail);
22061cb0ef41Sopenharmony_ci    return UncheckedCast<FixedDoubleArray>(base);
22071cb0ef41Sopenharmony_ci  }
22081cb0ef41Sopenharmony_ci
22091cb0ef41Sopenharmony_ci  template <typename T>
22101cb0ef41Sopenharmony_ci  bool ClassHasMapConstant() {
22111cb0ef41Sopenharmony_ci    return false;
22121cb0ef41Sopenharmony_ci  }
22131cb0ef41Sopenharmony_ci
22141cb0ef41Sopenharmony_ci  template <typename T>
22151cb0ef41Sopenharmony_ci  TNode<Map> GetClassMapConstant() {
22161cb0ef41Sopenharmony_ci    UNREACHABLE();
22171cb0ef41Sopenharmony_ci    return TNode<Map>();
22181cb0ef41Sopenharmony_ci  }
22191cb0ef41Sopenharmony_ci
22201cb0ef41Sopenharmony_ci  enum class ExtractFixedArrayFlag {
22211cb0ef41Sopenharmony_ci    kFixedArrays = 1,
22221cb0ef41Sopenharmony_ci    kFixedDoubleArrays = 2,
22231cb0ef41Sopenharmony_ci    kDontCopyCOW = 4,
22241cb0ef41Sopenharmony_ci    kAllFixedArrays = kFixedArrays | kFixedDoubleArrays,
22251cb0ef41Sopenharmony_ci    kAllFixedArraysDontCopyCOW = kAllFixedArrays | kDontCopyCOW
22261cb0ef41Sopenharmony_ci  };
22271cb0ef41Sopenharmony_ci
22281cb0ef41Sopenharmony_ci  using ExtractFixedArrayFlags = base::Flags<ExtractFixedArrayFlag>;
22291cb0ef41Sopenharmony_ci
22301cb0ef41Sopenharmony_ci  // Copy a portion of an existing FixedArray or FixedDoubleArray into a new
22311cb0ef41Sopenharmony_ci  // array, including special appropriate handling for empty arrays and COW
22321cb0ef41Sopenharmony_ci  // arrays. The result array will be of the same type as the original array.
22331cb0ef41Sopenharmony_ci  //
22341cb0ef41Sopenharmony_ci  // * |source| is either a FixedArray or FixedDoubleArray from which to copy
22351cb0ef41Sopenharmony_ci  // elements.
22361cb0ef41Sopenharmony_ci  // * |first| is the starting element index to copy from, if nullptr is passed
22371cb0ef41Sopenharmony_ci  // then index zero is used by default.
22381cb0ef41Sopenharmony_ci  // * |count| is the number of elements to copy out of the source array
22391cb0ef41Sopenharmony_ci  // starting from and including the element indexed by |start|. If |count| is
22401cb0ef41Sopenharmony_ci  // nullptr, then all of the elements from |start| to the end of |source| are
22411cb0ef41Sopenharmony_ci  // copied.
22421cb0ef41Sopenharmony_ci  // * |capacity| determines the size of the allocated result array, with
22431cb0ef41Sopenharmony_ci  // |capacity| >= |count|. If |capacity| is nullptr, then |count| is used as
22441cb0ef41Sopenharmony_ci  // the destination array's capacity.
22451cb0ef41Sopenharmony_ci  // * |extract_flags| determines whether FixedArrays, FixedDoubleArrays or both
22461cb0ef41Sopenharmony_ci  // are detected and copied. Although it's always correct to pass
22471cb0ef41Sopenharmony_ci  // kAllFixedArrays, the generated code is more compact and efficient if the
22481cb0ef41Sopenharmony_ci  // caller can specify whether only FixedArrays or FixedDoubleArrays will be
22491cb0ef41Sopenharmony_ci  // passed as the |source| parameter.
22501cb0ef41Sopenharmony_ci  // * |parameter_mode| determines the parameter mode of |first|, |count| and
22511cb0ef41Sopenharmony_ci  // |capacity|.
22521cb0ef41Sopenharmony_ci  // * If |var_holes_converted| is given, any holes will be converted to
22531cb0ef41Sopenharmony_ci  // undefined and the variable will be set according to whether or not there
22541cb0ef41Sopenharmony_ci  // were any hole.
22551cb0ef41Sopenharmony_ci  // * If |source_elements_kind| is given, the function will try to use the
22561cb0ef41Sopenharmony_ci  // runtime elements kind of source to make copy faster. More specifically, it
22571cb0ef41Sopenharmony_ci  // can skip write barriers.
22581cb0ef41Sopenharmony_ci  template <typename TIndex>
22591cb0ef41Sopenharmony_ci  TNode<FixedArrayBase> ExtractFixedArray(
22601cb0ef41Sopenharmony_ci      TNode<FixedArrayBase> source, base::Optional<TNode<TIndex>> first,
22611cb0ef41Sopenharmony_ci      base::Optional<TNode<TIndex>> count = base::nullopt,
22621cb0ef41Sopenharmony_ci      base::Optional<TNode<TIndex>> capacity = base::nullopt,
22631cb0ef41Sopenharmony_ci      ExtractFixedArrayFlags extract_flags =
22641cb0ef41Sopenharmony_ci          ExtractFixedArrayFlag::kAllFixedArrays,
22651cb0ef41Sopenharmony_ci      TVariable<BoolT>* var_holes_converted = nullptr,
22661cb0ef41Sopenharmony_ci      base::Optional<TNode<Int32T>> source_elements_kind = base::nullopt);
22671cb0ef41Sopenharmony_ci
22681cb0ef41Sopenharmony_ci  // Copy a portion of an existing FixedArray or FixedDoubleArray into a new
22691cb0ef41Sopenharmony_ci  // FixedArray, including special appropriate handling for COW arrays.
22701cb0ef41Sopenharmony_ci  // * |source| is either a FixedArray or FixedDoubleArray from which to copy
22711cb0ef41Sopenharmony_ci  // elements. |source| is assumed to be non-empty.
22721cb0ef41Sopenharmony_ci  // * |first| is the starting element index to copy from.
22731cb0ef41Sopenharmony_ci  // * |count| is the number of elements to copy out of the source array
22741cb0ef41Sopenharmony_ci  // starting from and including the element indexed by |start|.
22751cb0ef41Sopenharmony_ci  // * |capacity| determines the size of the allocated result array, with
22761cb0ef41Sopenharmony_ci  // |capacity| >= |count|.
22771cb0ef41Sopenharmony_ci  // * |source_map| is the map of the |source|.
22781cb0ef41Sopenharmony_ci  // * |from_kind| is the elements kind that is consistent with |source| being
22791cb0ef41Sopenharmony_ci  // a FixedArray or FixedDoubleArray. This function only cares about double vs.
22801cb0ef41Sopenharmony_ci  // non-double, so as to distinguish FixedDoubleArray vs. FixedArray. It does
22811cb0ef41Sopenharmony_ci  // not care about holeyness. For example, when |source| is a FixedArray,
22821cb0ef41Sopenharmony_ci  // PACKED/HOLEY_ELEMENTS can be used, but not PACKED_DOUBLE_ELEMENTS.
22831cb0ef41Sopenharmony_ci  // * |allocation_flags| and |extract_flags| influence how the target
22841cb0ef41Sopenharmony_ci  // FixedArray is allocated.
22851cb0ef41Sopenharmony_ci  // * |convert_holes| is used to signify that the target array should use
22861cb0ef41Sopenharmony_ci  // undefined in places of holes.
22871cb0ef41Sopenharmony_ci  // * If |convert_holes| is true and |var_holes_converted| not nullptr, then
22881cb0ef41Sopenharmony_ci  // |var_holes_converted| is used to signal whether any holes were found and
22891cb0ef41Sopenharmony_ci  // converted. The caller should use this information to decide which map is
22901cb0ef41Sopenharmony_ci  // compatible with the result array. For example, if the input was of
22911cb0ef41Sopenharmony_ci  // HOLEY_SMI_ELEMENTS kind, and a conversion took place, the result will be
22921cb0ef41Sopenharmony_ci  // compatible only with HOLEY_ELEMENTS and PACKED_ELEMENTS.
22931cb0ef41Sopenharmony_ci  template <typename TIndex>
22941cb0ef41Sopenharmony_ci  TNode<FixedArray> ExtractToFixedArray(
22951cb0ef41Sopenharmony_ci      TNode<FixedArrayBase> source, TNode<TIndex> first, TNode<TIndex> count,
22961cb0ef41Sopenharmony_ci      TNode<TIndex> capacity, TNode<Map> source_map, ElementsKind from_kind,
22971cb0ef41Sopenharmony_ci      AllocationFlags allocation_flags, ExtractFixedArrayFlags extract_flags,
22981cb0ef41Sopenharmony_ci      HoleConversionMode convert_holes,
22991cb0ef41Sopenharmony_ci      TVariable<BoolT>* var_holes_converted = nullptr,
23001cb0ef41Sopenharmony_ci      base::Optional<TNode<Int32T>> source_runtime_kind = base::nullopt);
23011cb0ef41Sopenharmony_ci
23021cb0ef41Sopenharmony_ci  // Attempt to copy a FixedDoubleArray to another FixedDoubleArray. In the case
23031cb0ef41Sopenharmony_ci  // where the source array has a hole, produce a FixedArray instead where holes
23041cb0ef41Sopenharmony_ci  // are replaced with undefined.
23051cb0ef41Sopenharmony_ci  // * |source| is a FixedDoubleArray from which to copy elements.
23061cb0ef41Sopenharmony_ci  // * |first| is the starting element index to copy from.
23071cb0ef41Sopenharmony_ci  // * |count| is the number of elements to copy out of the source array
23081cb0ef41Sopenharmony_ci  // starting from and including the element indexed by |start|.
23091cb0ef41Sopenharmony_ci  // * |capacity| determines the size of the allocated result array, with
23101cb0ef41Sopenharmony_ci  // |capacity| >= |count|.
23111cb0ef41Sopenharmony_ci  // * |source_map| is the map of |source|. It will be used as the map of the
23121cb0ef41Sopenharmony_ci  // target array if the target can stay a FixedDoubleArray. Otherwise if the
23131cb0ef41Sopenharmony_ci  // target array needs to be a FixedArray, the FixedArrayMap will be used.
23141cb0ef41Sopenharmony_ci  // * |var_holes_converted| is used to signal whether a FixedAray
23151cb0ef41Sopenharmony_ci  // is produced or not.
23161cb0ef41Sopenharmony_ci  // * |allocation_flags| and |extract_flags| influence how the target array is
23171cb0ef41Sopenharmony_ci  // allocated.
23181cb0ef41Sopenharmony_ci  template <typename TIndex>
23191cb0ef41Sopenharmony_ci  TNode<FixedArrayBase> ExtractFixedDoubleArrayFillingHoles(
23201cb0ef41Sopenharmony_ci      TNode<FixedArrayBase> source, TNode<TIndex> first, TNode<TIndex> count,
23211cb0ef41Sopenharmony_ci      TNode<TIndex> capacity, TNode<Map> source_map,
23221cb0ef41Sopenharmony_ci      TVariable<BoolT>* var_holes_converted, AllocationFlags allocation_flags,
23231cb0ef41Sopenharmony_ci      ExtractFixedArrayFlags extract_flags);
23241cb0ef41Sopenharmony_ci
23251cb0ef41Sopenharmony_ci  // Copy the entire contents of a FixedArray or FixedDoubleArray to a new
23261cb0ef41Sopenharmony_ci  // array, including special appropriate handling for empty arrays and COW
23271cb0ef41Sopenharmony_ci  // arrays.
23281cb0ef41Sopenharmony_ci  //
23291cb0ef41Sopenharmony_ci  // * |source| is either a FixedArray or FixedDoubleArray from which to copy
23301cb0ef41Sopenharmony_ci  // elements.
23311cb0ef41Sopenharmony_ci  // * |extract_flags| determines whether FixedArrays, FixedDoubleArrays or both
23321cb0ef41Sopenharmony_ci  // are detected and copied. Although it's always correct to pass
23331cb0ef41Sopenharmony_ci  // kAllFixedArrays, the generated code is more compact and efficient if the
23341cb0ef41Sopenharmony_ci  // caller can specify whether only FixedArrays or FixedDoubleArrays will be
23351cb0ef41Sopenharmony_ci  // passed as the |source| parameter.
23361cb0ef41Sopenharmony_ci  TNode<FixedArrayBase> CloneFixedArray(
23371cb0ef41Sopenharmony_ci      TNode<FixedArrayBase> source,
23381cb0ef41Sopenharmony_ci      ExtractFixedArrayFlags flags =
23391cb0ef41Sopenharmony_ci          ExtractFixedArrayFlag::kAllFixedArraysDontCopyCOW);
23401cb0ef41Sopenharmony_ci
23411cb0ef41Sopenharmony_ci  // Loads an element from |array| of |from_kind| elements by given |offset|
23421cb0ef41Sopenharmony_ci  // (NOTE: not index!), does a hole check if |if_hole| is provided and
23431cb0ef41Sopenharmony_ci  // converts the value so that it becomes ready for storing to array of
23441cb0ef41Sopenharmony_ci  // |to_kind| elements.
23451cb0ef41Sopenharmony_ci  template <typename TResult>
23461cb0ef41Sopenharmony_ci  TNode<TResult> LoadElementAndPrepareForStore(TNode<FixedArrayBase> array,
23471cb0ef41Sopenharmony_ci                                               TNode<IntPtrT> offset,
23481cb0ef41Sopenharmony_ci                                               ElementsKind from_kind,
23491cb0ef41Sopenharmony_ci                                               ElementsKind to_kind,
23501cb0ef41Sopenharmony_ci                                               Label* if_hole);
23511cb0ef41Sopenharmony_ci
23521cb0ef41Sopenharmony_ci  template <typename TIndex>
23531cb0ef41Sopenharmony_ci  TNode<TIndex> CalculateNewElementsCapacity(TNode<TIndex> old_capacity);
23541cb0ef41Sopenharmony_ci
23551cb0ef41Sopenharmony_ci  // Tries to grow the |elements| array of given |object| to store the |key|
23561cb0ef41Sopenharmony_ci  // or bails out if the growing gap is too big. Returns new elements.
23571cb0ef41Sopenharmony_ci  TNode<FixedArrayBase> TryGrowElementsCapacity(TNode<HeapObject> object,
23581cb0ef41Sopenharmony_ci                                                TNode<FixedArrayBase> elements,
23591cb0ef41Sopenharmony_ci                                                ElementsKind kind,
23601cb0ef41Sopenharmony_ci                                                TNode<Smi> key, Label* bailout);
23611cb0ef41Sopenharmony_ci
23621cb0ef41Sopenharmony_ci  // Tries to grow the |capacity|-length |elements| array of given |object|
23631cb0ef41Sopenharmony_ci  // to store the |key| or bails out if the growing gap is too big. Returns
23641cb0ef41Sopenharmony_ci  // new elements.
23651cb0ef41Sopenharmony_ci  template <typename TIndex>
23661cb0ef41Sopenharmony_ci  TNode<FixedArrayBase> TryGrowElementsCapacity(TNode<HeapObject> object,
23671cb0ef41Sopenharmony_ci                                                TNode<FixedArrayBase> elements,
23681cb0ef41Sopenharmony_ci                                                ElementsKind kind,
23691cb0ef41Sopenharmony_ci                                                TNode<TIndex> key,
23701cb0ef41Sopenharmony_ci                                                TNode<TIndex> capacity,
23711cb0ef41Sopenharmony_ci                                                Label* bailout);
23721cb0ef41Sopenharmony_ci
23731cb0ef41Sopenharmony_ci  // Grows elements capacity of given object. Returns new elements.
23741cb0ef41Sopenharmony_ci  template <typename TIndex>
23751cb0ef41Sopenharmony_ci  TNode<FixedArrayBase> GrowElementsCapacity(
23761cb0ef41Sopenharmony_ci      TNode<HeapObject> object, TNode<FixedArrayBase> elements,
23771cb0ef41Sopenharmony_ci      ElementsKind from_kind, ElementsKind to_kind, TNode<TIndex> capacity,
23781cb0ef41Sopenharmony_ci      TNode<TIndex> new_capacity, Label* bailout);
23791cb0ef41Sopenharmony_ci
23801cb0ef41Sopenharmony_ci  // Given a need to grow by |growth|, allocate an appropriate new capacity
23811cb0ef41Sopenharmony_ci  // if necessary, and return a new elements FixedArray object. Label |bailout|
23821cb0ef41Sopenharmony_ci  // is followed for allocation failure.
23831cb0ef41Sopenharmony_ci  void PossiblyGrowElementsCapacity(ElementsKind kind, TNode<HeapObject> array,
23841cb0ef41Sopenharmony_ci                                    TNode<BInt> length,
23851cb0ef41Sopenharmony_ci                                    TVariable<FixedArrayBase>* var_elements,
23861cb0ef41Sopenharmony_ci                                    TNode<BInt> growth, Label* bailout);
23871cb0ef41Sopenharmony_ci
23881cb0ef41Sopenharmony_ci  // Allocation site manipulation
23891cb0ef41Sopenharmony_ci  void InitializeAllocationMemento(TNode<HeapObject> base,
23901cb0ef41Sopenharmony_ci                                   TNode<IntPtrT> base_allocation_size,
23911cb0ef41Sopenharmony_ci                                   TNode<AllocationSite> allocation_site);
23921cb0ef41Sopenharmony_ci
23931cb0ef41Sopenharmony_ci  TNode<IntPtrT> TryTaggedToInt32AsIntPtr(TNode<Object> value,
23941cb0ef41Sopenharmony_ci                                          Label* if_not_possible);
23951cb0ef41Sopenharmony_ci  TNode<Float64T> TryTaggedToFloat64(TNode<Object> value,
23961cb0ef41Sopenharmony_ci                                     Label* if_valueisnotnumber);
23971cb0ef41Sopenharmony_ci  TNode<Float64T> TruncateTaggedToFloat64(TNode<Context> context,
23981cb0ef41Sopenharmony_ci                                          TNode<Object> value);
23991cb0ef41Sopenharmony_ci  TNode<Word32T> TruncateTaggedToWord32(TNode<Context> context,
24001cb0ef41Sopenharmony_ci                                        TNode<Object> value);
24011cb0ef41Sopenharmony_ci  void TaggedToWord32OrBigInt(TNode<Context> context, TNode<Object> value,
24021cb0ef41Sopenharmony_ci                              Label* if_number, TVariable<Word32T>* var_word32,
24031cb0ef41Sopenharmony_ci                              Label* if_bigint,
24041cb0ef41Sopenharmony_ci                              TVariable<BigInt>* var_maybe_bigint);
24051cb0ef41Sopenharmony_ci  void TaggedToWord32OrBigIntWithFeedback(TNode<Context> context,
24061cb0ef41Sopenharmony_ci                                          TNode<Object> value, Label* if_number,
24071cb0ef41Sopenharmony_ci                                          TVariable<Word32T>* var_word32,
24081cb0ef41Sopenharmony_ci                                          Label* if_bigint,
24091cb0ef41Sopenharmony_ci                                          TVariable<BigInt>* var_maybe_bigint,
24101cb0ef41Sopenharmony_ci                                          TVariable<Smi>* var_feedback);
24111cb0ef41Sopenharmony_ci  void TaggedPointerToWord32OrBigIntWithFeedback(
24121cb0ef41Sopenharmony_ci      TNode<Context> context, TNode<HeapObject> pointer, Label* if_number,
24131cb0ef41Sopenharmony_ci      TVariable<Word32T>* var_word32, Label* if_bigint,
24141cb0ef41Sopenharmony_ci      TVariable<BigInt>* var_maybe_bigint, TVariable<Smi>* var_feedback);
24151cb0ef41Sopenharmony_ci
24161cb0ef41Sopenharmony_ci  TNode<Int32T> TruncateNumberToWord32(TNode<Number> value);
24171cb0ef41Sopenharmony_ci  // Truncate the floating point value of a HeapNumber to an Int32.
24181cb0ef41Sopenharmony_ci  TNode<Int32T> TruncateHeapNumberValueToWord32(TNode<HeapNumber> object);
24191cb0ef41Sopenharmony_ci
24201cb0ef41Sopenharmony_ci  // Conversions.
24211cb0ef41Sopenharmony_ci  void TryHeapNumberToSmi(TNode<HeapNumber> number, TVariable<Smi>* output,
24221cb0ef41Sopenharmony_ci                          Label* if_smi);
24231cb0ef41Sopenharmony_ci  void TryFloat32ToSmi(TNode<Float32T> number, TVariable<Smi>* output,
24241cb0ef41Sopenharmony_ci                       Label* if_smi);
24251cb0ef41Sopenharmony_ci  void TryFloat64ToSmi(TNode<Float64T> number, TVariable<Smi>* output,
24261cb0ef41Sopenharmony_ci                       Label* if_smi);
24271cb0ef41Sopenharmony_ci  TNode<Number> ChangeFloat32ToTagged(TNode<Float32T> value);
24281cb0ef41Sopenharmony_ci  TNode<Number> ChangeFloat64ToTagged(TNode<Float64T> value);
24291cb0ef41Sopenharmony_ci  TNode<Number> ChangeInt32ToTagged(TNode<Int32T> value);
24301cb0ef41Sopenharmony_ci  TNode<Number> ChangeInt32ToTaggedNoOverflow(TNode<Int32T> value);
24311cb0ef41Sopenharmony_ci  TNode<Number> ChangeUint32ToTagged(TNode<Uint32T> value);
24321cb0ef41Sopenharmony_ci  TNode<Number> ChangeUintPtrToTagged(TNode<UintPtrT> value);
24331cb0ef41Sopenharmony_ci  TNode<Uint32T> ChangeNumberToUint32(TNode<Number> value);
24341cb0ef41Sopenharmony_ci  TNode<Float64T> ChangeNumberToFloat64(TNode<Number> value);
24351cb0ef41Sopenharmony_ci
24361cb0ef41Sopenharmony_ci  TNode<Int32T> ChangeTaggedNonSmiToInt32(TNode<Context> context,
24371cb0ef41Sopenharmony_ci                                          TNode<HeapObject> input);
24381cb0ef41Sopenharmony_ci  TNode<Float64T> ChangeTaggedToFloat64(TNode<Context> context,
24391cb0ef41Sopenharmony_ci                                        TNode<Object> input);
24401cb0ef41Sopenharmony_ci
24411cb0ef41Sopenharmony_ci  TNode<Int32T> ChangeBoolToInt32(TNode<BoolT> b);
24421cb0ef41Sopenharmony_ci
24431cb0ef41Sopenharmony_ci  void TaggedToNumeric(TNode<Context> context, TNode<Object> value,
24441cb0ef41Sopenharmony_ci                       TVariable<Numeric>* var_numeric);
24451cb0ef41Sopenharmony_ci  void TaggedToNumericWithFeedback(TNode<Context> context, TNode<Object> value,
24461cb0ef41Sopenharmony_ci                                   TVariable<Numeric>* var_numeric,
24471cb0ef41Sopenharmony_ci                                   TVariable<Smi>* var_feedback);
24481cb0ef41Sopenharmony_ci
24491cb0ef41Sopenharmony_ci  // Ensures that {var_shared_value} is shareable across Isolates, and throws if
24501cb0ef41Sopenharmony_ci  // not.
24511cb0ef41Sopenharmony_ci  void SharedValueBarrier(TNode<Context> context,
24521cb0ef41Sopenharmony_ci                          TVariable<Object>* var_shared_value);
24531cb0ef41Sopenharmony_ci
24541cb0ef41Sopenharmony_ci  TNode<WordT> TimesSystemPointerSize(TNode<WordT> value);
24551cb0ef41Sopenharmony_ci  TNode<IntPtrT> TimesSystemPointerSize(TNode<IntPtrT> value) {
24561cb0ef41Sopenharmony_ci    return Signed(TimesSystemPointerSize(implicit_cast<TNode<WordT>>(value)));
24571cb0ef41Sopenharmony_ci  }
24581cb0ef41Sopenharmony_ci  TNode<UintPtrT> TimesSystemPointerSize(TNode<UintPtrT> value) {
24591cb0ef41Sopenharmony_ci    return Unsigned(TimesSystemPointerSize(implicit_cast<TNode<WordT>>(value)));
24601cb0ef41Sopenharmony_ci  }
24611cb0ef41Sopenharmony_ci
24621cb0ef41Sopenharmony_ci  TNode<WordT> TimesTaggedSize(TNode<WordT> value);
24631cb0ef41Sopenharmony_ci  TNode<IntPtrT> TimesTaggedSize(TNode<IntPtrT> value) {
24641cb0ef41Sopenharmony_ci    return Signed(TimesTaggedSize(implicit_cast<TNode<WordT>>(value)));
24651cb0ef41Sopenharmony_ci  }
24661cb0ef41Sopenharmony_ci  TNode<UintPtrT> TimesTaggedSize(TNode<UintPtrT> value) {
24671cb0ef41Sopenharmony_ci    return Unsigned(TimesTaggedSize(implicit_cast<TNode<WordT>>(value)));
24681cb0ef41Sopenharmony_ci  }
24691cb0ef41Sopenharmony_ci
24701cb0ef41Sopenharmony_ci  TNode<WordT> TimesDoubleSize(TNode<WordT> value);
24711cb0ef41Sopenharmony_ci  TNode<UintPtrT> TimesDoubleSize(TNode<UintPtrT> value) {
24721cb0ef41Sopenharmony_ci    return Unsigned(TimesDoubleSize(implicit_cast<TNode<WordT>>(value)));
24731cb0ef41Sopenharmony_ci  }
24741cb0ef41Sopenharmony_ci  TNode<IntPtrT> TimesDoubleSize(TNode<IntPtrT> value) {
24751cb0ef41Sopenharmony_ci    return Signed(TimesDoubleSize(implicit_cast<TNode<WordT>>(value)));
24761cb0ef41Sopenharmony_ci  }
24771cb0ef41Sopenharmony_ci
24781cb0ef41Sopenharmony_ci  // Type conversions.
24791cb0ef41Sopenharmony_ci  // Throws a TypeError for {method_name} if {value} is not coercible to Object,
24801cb0ef41Sopenharmony_ci  // or returns the {value} converted to a String otherwise.
24811cb0ef41Sopenharmony_ci  TNode<String> ToThisString(TNode<Context> context, TNode<Object> value,
24821cb0ef41Sopenharmony_ci                             TNode<String> method_name);
24831cb0ef41Sopenharmony_ci  TNode<String> ToThisString(TNode<Context> context, TNode<Object> value,
24841cb0ef41Sopenharmony_ci                             char const* method_name) {
24851cb0ef41Sopenharmony_ci    return ToThisString(context, value, StringConstant(method_name));
24861cb0ef41Sopenharmony_ci  }
24871cb0ef41Sopenharmony_ci
24881cb0ef41Sopenharmony_ci  // Throws a TypeError for {method_name} if {value} is neither of the given
24891cb0ef41Sopenharmony_ci  // {primitive_type} nor a JSPrimitiveWrapper wrapping a value of
24901cb0ef41Sopenharmony_ci  // {primitive_type}, or returns the {value} (or wrapped value) otherwise.
24911cb0ef41Sopenharmony_ci  TNode<Object> ToThisValue(TNode<Context> context, TNode<Object> value,
24921cb0ef41Sopenharmony_ci                            PrimitiveType primitive_type,
24931cb0ef41Sopenharmony_ci                            char const* method_name);
24941cb0ef41Sopenharmony_ci
24951cb0ef41Sopenharmony_ci  // Throws a TypeError for {method_name} if {value} is not of the given
24961cb0ef41Sopenharmony_ci  // instance type.
24971cb0ef41Sopenharmony_ci  void ThrowIfNotInstanceType(TNode<Context> context, TNode<Object> value,
24981cb0ef41Sopenharmony_ci                              InstanceType instance_type,
24991cb0ef41Sopenharmony_ci                              char const* method_name);
25001cb0ef41Sopenharmony_ci  // Throws a TypeError for {method_name} if {value} is not a JSReceiver.
25011cb0ef41Sopenharmony_ci  void ThrowIfNotJSReceiver(TNode<Context> context, TNode<Object> value,
25021cb0ef41Sopenharmony_ci                            MessageTemplate msg_template,
25031cb0ef41Sopenharmony_ci                            const char* method_name);
25041cb0ef41Sopenharmony_ci  void ThrowIfNotCallable(TNode<Context> context, TNode<Object> value,
25051cb0ef41Sopenharmony_ci                          const char* method_name);
25061cb0ef41Sopenharmony_ci
25071cb0ef41Sopenharmony_ci  void ThrowRangeError(TNode<Context> context, MessageTemplate message,
25081cb0ef41Sopenharmony_ci                       base::Optional<TNode<Object>> arg0 = base::nullopt,
25091cb0ef41Sopenharmony_ci                       base::Optional<TNode<Object>> arg1 = base::nullopt,
25101cb0ef41Sopenharmony_ci                       base::Optional<TNode<Object>> arg2 = base::nullopt);
25111cb0ef41Sopenharmony_ci  void ThrowTypeError(TNode<Context> context, MessageTemplate message,
25121cb0ef41Sopenharmony_ci                      char const* arg0 = nullptr, char const* arg1 = nullptr);
25131cb0ef41Sopenharmony_ci  void ThrowTypeError(TNode<Context> context, MessageTemplate message,
25141cb0ef41Sopenharmony_ci                      base::Optional<TNode<Object>> arg0,
25151cb0ef41Sopenharmony_ci                      base::Optional<TNode<Object>> arg1 = base::nullopt,
25161cb0ef41Sopenharmony_ci                      base::Optional<TNode<Object>> arg2 = base::nullopt);
25171cb0ef41Sopenharmony_ci
25181cb0ef41Sopenharmony_ci  TNode<HeapObject> GetPendingMessage();
25191cb0ef41Sopenharmony_ci  void SetPendingMessage(TNode<HeapObject> message);
25201cb0ef41Sopenharmony_ci
25211cb0ef41Sopenharmony_ci  // Type checks.
25221cb0ef41Sopenharmony_ci  // Check whether the map is for an object with special properties, such as a
25231cb0ef41Sopenharmony_ci  // JSProxy or an object with interceptors.
25241cb0ef41Sopenharmony_ci  TNode<BoolT> InstanceTypeEqual(TNode<Int32T> instance_type, int type);
25251cb0ef41Sopenharmony_ci  TNode<BoolT> IsNoElementsProtectorCellInvalid();
25261cb0ef41Sopenharmony_ci  TNode<BoolT> IsMegaDOMProtectorCellInvalid();
25271cb0ef41Sopenharmony_ci  TNode<BoolT> IsArrayIteratorProtectorCellInvalid();
25281cb0ef41Sopenharmony_ci  TNode<BoolT> IsBigIntInstanceType(TNode<Int32T> instance_type);
25291cb0ef41Sopenharmony_ci  TNode<BoolT> IsBigInt(TNode<HeapObject> object);
25301cb0ef41Sopenharmony_ci  TNode<BoolT> IsBoolean(TNode<HeapObject> object);
25311cb0ef41Sopenharmony_ci  TNode<BoolT> IsCallableMap(TNode<Map> map);
25321cb0ef41Sopenharmony_ci  TNode<BoolT> IsCallable(TNode<HeapObject> object);
25331cb0ef41Sopenharmony_ci  TNode<BoolT> TaggedIsCallable(TNode<Object> object);
25341cb0ef41Sopenharmony_ci  TNode<BoolT> IsConsStringInstanceType(TNode<Int32T> instance_type);
25351cb0ef41Sopenharmony_ci  TNode<BoolT> IsConstructorMap(TNode<Map> map);
25361cb0ef41Sopenharmony_ci  TNode<BoolT> IsConstructor(TNode<HeapObject> object);
25371cb0ef41Sopenharmony_ci  TNode<BoolT> IsDeprecatedMap(TNode<Map> map);
25381cb0ef41Sopenharmony_ci  TNode<BoolT> IsNameDictionary(TNode<HeapObject> object);
25391cb0ef41Sopenharmony_ci  TNode<BoolT> IsOrderedNameDictionary(TNode<HeapObject> object);
25401cb0ef41Sopenharmony_ci  TNode<BoolT> IsGlobalDictionary(TNode<HeapObject> object);
25411cb0ef41Sopenharmony_ci  TNode<BoolT> IsExtensibleMap(TNode<Map> map);
25421cb0ef41Sopenharmony_ci  TNode<BoolT> IsExtensibleNonPrototypeMap(TNode<Map> map);
25431cb0ef41Sopenharmony_ci  TNode<BoolT> IsExternalStringInstanceType(TNode<Int32T> instance_type);
25441cb0ef41Sopenharmony_ci  TNode<BoolT> IsFixedArray(TNode<HeapObject> object);
25451cb0ef41Sopenharmony_ci  TNode<BoolT> IsFixedArraySubclass(TNode<HeapObject> object);
25461cb0ef41Sopenharmony_ci  TNode<BoolT> IsFixedArrayWithKind(TNode<HeapObject> object,
25471cb0ef41Sopenharmony_ci                                    ElementsKind kind);
25481cb0ef41Sopenharmony_ci  TNode<BoolT> IsFixedArrayWithKindOrEmpty(TNode<FixedArrayBase> object,
25491cb0ef41Sopenharmony_ci                                           ElementsKind kind);
25501cb0ef41Sopenharmony_ci  TNode<BoolT> IsFunctionWithPrototypeSlotMap(TNode<Map> map);
25511cb0ef41Sopenharmony_ci  TNode<BoolT> IsHashTable(TNode<HeapObject> object);
25521cb0ef41Sopenharmony_ci  TNode<BoolT> IsEphemeronHashTable(TNode<HeapObject> object);
25531cb0ef41Sopenharmony_ci  TNode<BoolT> IsHeapNumberInstanceType(TNode<Int32T> instance_type);
25541cb0ef41Sopenharmony_ci  TNode<BoolT> IsOddball(TNode<HeapObject> object);
25551cb0ef41Sopenharmony_ci  TNode<BoolT> IsOddballInstanceType(TNode<Int32T> instance_type);
25561cb0ef41Sopenharmony_ci  TNode<BoolT> IsIndirectStringInstanceType(TNode<Int32T> instance_type);
25571cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSArrayBuffer(TNode<HeapObject> object);
25581cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSDataView(TNode<HeapObject> object);
25591cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSArrayInstanceType(TNode<Int32T> instance_type);
25601cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSArrayMap(TNode<Map> map);
25611cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSArray(TNode<HeapObject> object);
25621cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSArrayIterator(TNode<HeapObject> object);
25631cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSAsyncGeneratorObject(TNode<HeapObject> object);
25641cb0ef41Sopenharmony_ci  TNode<BoolT> IsFunctionInstanceType(TNode<Int32T> instance_type);
25651cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSFunctionInstanceType(TNode<Int32T> instance_type);
25661cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSFunctionMap(TNode<Map> map);
25671cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSFunction(TNode<HeapObject> object);
25681cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSBoundFunction(TNode<HeapObject> object);
25691cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSGeneratorObject(TNode<HeapObject> object);
25701cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSGlobalProxyInstanceType(TNode<Int32T> instance_type);
25711cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSGlobalProxyMap(TNode<Map> map);
25721cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSGlobalProxy(TNode<HeapObject> object);
25731cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSObjectInstanceType(TNode<Int32T> instance_type);
25741cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSObjectMap(TNode<Map> map);
25751cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSObject(TNode<HeapObject> object);
25761cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSApiObjectInstanceType(TNode<Int32T> instance_type);
25771cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSApiObjectMap(TNode<Map> map);
25781cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSApiObject(TNode<HeapObject> object);
25791cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSFinalizationRegistryMap(TNode<Map> map);
25801cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSFinalizationRegistry(TNode<HeapObject> object);
25811cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSPromiseMap(TNode<Map> map);
25821cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSPromise(TNode<HeapObject> object);
25831cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSProxy(TNode<HeapObject> object);
25841cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSStringIterator(TNode<HeapObject> object);
25851cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSRegExpStringIterator(TNode<HeapObject> object);
25861cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSReceiverInstanceType(TNode<Int32T> instance_type);
25871cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSReceiverMap(TNode<Map> map);
25881cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSReceiver(TNode<HeapObject> object);
25891cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSRegExp(TNode<HeapObject> object);
25901cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSTypedArrayInstanceType(TNode<Int32T> instance_type);
25911cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSTypedArrayMap(TNode<Map> map);
25921cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSTypedArray(TNode<HeapObject> object);
25931cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSGeneratorMap(TNode<Map> map);
25941cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSPrimitiveWrapperInstanceType(TNode<Int32T> instance_type);
25951cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSPrimitiveWrapperMap(TNode<Map> map);
25961cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSPrimitiveWrapper(TNode<HeapObject> object);
25971cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSSharedStructInstanceType(TNode<Int32T> instance_type);
25981cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSSharedStructMap(TNode<Map> map);
25991cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSSharedStruct(TNode<HeapObject> object);
26001cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSSharedStruct(TNode<Object> object);
26011cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSWrappedFunction(TNode<HeapObject> object);
26021cb0ef41Sopenharmony_ci  TNode<BoolT> IsMap(TNode<HeapObject> object);
26031cb0ef41Sopenharmony_ci  TNode<BoolT> IsName(TNode<HeapObject> object);
26041cb0ef41Sopenharmony_ci  TNode<BoolT> IsNameInstanceType(TNode<Int32T> instance_type);
26051cb0ef41Sopenharmony_ci  TNode<BoolT> IsNullOrJSReceiver(TNode<HeapObject> object);
26061cb0ef41Sopenharmony_ci  TNode<BoolT> IsNullOrUndefined(TNode<Object> object);
26071cb0ef41Sopenharmony_ci  TNode<BoolT> IsNumberDictionary(TNode<HeapObject> object);
26081cb0ef41Sopenharmony_ci  TNode<BoolT> IsOneByteStringInstanceType(TNode<Int32T> instance_type);
26091cb0ef41Sopenharmony_ci  TNode<BoolT> IsSeqOneByteStringInstanceType(TNode<Int32T> instance_type);
26101cb0ef41Sopenharmony_ci  TNode<BoolT> IsPrimitiveInstanceType(TNode<Int32T> instance_type);
26111cb0ef41Sopenharmony_ci  TNode<BoolT> IsPrivateName(TNode<Symbol> symbol);
26121cb0ef41Sopenharmony_ci  TNode<BoolT> IsPropertyArray(TNode<HeapObject> object);
26131cb0ef41Sopenharmony_ci  TNode<BoolT> IsPropertyCell(TNode<HeapObject> object);
26141cb0ef41Sopenharmony_ci  TNode<BoolT> IsPromiseReactionJobTask(TNode<HeapObject> object);
26151cb0ef41Sopenharmony_ci  TNode<BoolT> IsPrototypeInitialArrayPrototype(TNode<Context> context,
26161cb0ef41Sopenharmony_ci                                                TNode<Map> map);
26171cb0ef41Sopenharmony_ci  TNode<BoolT> IsPrototypeTypedArrayPrototype(TNode<Context> context,
26181cb0ef41Sopenharmony_ci                                              TNode<Map> map);
26191cb0ef41Sopenharmony_ci
26201cb0ef41Sopenharmony_ci  TNode<BoolT> IsFastAliasedArgumentsMap(TNode<Context> context,
26211cb0ef41Sopenharmony_ci                                         TNode<Map> map);
26221cb0ef41Sopenharmony_ci  TNode<BoolT> IsSlowAliasedArgumentsMap(TNode<Context> context,
26231cb0ef41Sopenharmony_ci                                         TNode<Map> map);
26241cb0ef41Sopenharmony_ci  TNode<BoolT> IsSloppyArgumentsMap(TNode<Context> context, TNode<Map> map);
26251cb0ef41Sopenharmony_ci  TNode<BoolT> IsStrictArgumentsMap(TNode<Context> context, TNode<Map> map);
26261cb0ef41Sopenharmony_ci
26271cb0ef41Sopenharmony_ci  TNode<BoolT> IsSequentialStringInstanceType(TNode<Int32T> instance_type);
26281cb0ef41Sopenharmony_ci  TNode<BoolT> IsUncachedExternalStringInstanceType(
26291cb0ef41Sopenharmony_ci      TNode<Int32T> instance_type);
26301cb0ef41Sopenharmony_ci  TNode<BoolT> IsSpecialReceiverInstanceType(TNode<Int32T> instance_type);
26311cb0ef41Sopenharmony_ci  TNode<BoolT> IsCustomElementsReceiverInstanceType(
26321cb0ef41Sopenharmony_ci      TNode<Int32T> instance_type);
26331cb0ef41Sopenharmony_ci  TNode<BoolT> IsSpecialReceiverMap(TNode<Map> map);
26341cb0ef41Sopenharmony_ci  TNode<BoolT> IsStringInstanceType(TNode<Int32T> instance_type);
26351cb0ef41Sopenharmony_ci  TNode<BoolT> IsString(TNode<HeapObject> object);
26361cb0ef41Sopenharmony_ci  TNode<BoolT> IsSeqOneByteString(TNode<HeapObject> object);
26371cb0ef41Sopenharmony_ci  TNode<BoolT> IsSwissNameDictionary(TNode<HeapObject> object);
26381cb0ef41Sopenharmony_ci
26391cb0ef41Sopenharmony_ci  TNode<BoolT> IsSymbolInstanceType(TNode<Int32T> instance_type);
26401cb0ef41Sopenharmony_ci  TNode<BoolT> IsInternalizedStringInstanceType(TNode<Int32T> instance_type);
26411cb0ef41Sopenharmony_ci  TNode<BoolT> IsSharedStringInstanceType(TNode<Int32T> instance_type);
26421cb0ef41Sopenharmony_ci  TNode<BoolT> IsTemporalInstantInstanceType(TNode<Int32T> instance_type);
26431cb0ef41Sopenharmony_ci  TNode<BoolT> IsUniqueName(TNode<HeapObject> object);
26441cb0ef41Sopenharmony_ci  TNode<BoolT> IsUniqueNameNoIndex(TNode<HeapObject> object);
26451cb0ef41Sopenharmony_ci  TNode<BoolT> IsUniqueNameNoCachedIndex(TNode<HeapObject> object);
26461cb0ef41Sopenharmony_ci  TNode<BoolT> IsUndetectableMap(TNode<Map> map);
26471cb0ef41Sopenharmony_ci  TNode<BoolT> IsNotWeakFixedArraySubclass(TNode<HeapObject> object);
26481cb0ef41Sopenharmony_ci  TNode<BoolT> IsZeroOrContext(TNode<Object> object);
26491cb0ef41Sopenharmony_ci
26501cb0ef41Sopenharmony_ci  TNode<BoolT> IsPromiseResolveProtectorCellInvalid();
26511cb0ef41Sopenharmony_ci  TNode<BoolT> IsPromiseThenProtectorCellInvalid();
26521cb0ef41Sopenharmony_ci  TNode<BoolT> IsArraySpeciesProtectorCellInvalid();
26531cb0ef41Sopenharmony_ci  TNode<BoolT> IsIsConcatSpreadableProtectorCellInvalid();
26541cb0ef41Sopenharmony_ci  TNode<BoolT> IsTypedArraySpeciesProtectorCellInvalid();
26551cb0ef41Sopenharmony_ci  TNode<BoolT> IsRegExpSpeciesProtectorCellInvalid();
26561cb0ef41Sopenharmony_ci  TNode<BoolT> IsPromiseSpeciesProtectorCellInvalid();
26571cb0ef41Sopenharmony_ci
26581cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadBasicMemoryChunkFlags(TNode<HeapObject> object);
26591cb0ef41Sopenharmony_ci
26601cb0ef41Sopenharmony_ci  TNode<BoolT> LoadRuntimeFlag(ExternalReference address_of_flag) {
26611cb0ef41Sopenharmony_ci    TNode<Word32T> flag_value = UncheckedCast<Word32T>(
26621cb0ef41Sopenharmony_ci        Load(MachineType::Uint8(), ExternalConstant(address_of_flag)));
26631cb0ef41Sopenharmony_ci    return Word32NotEqual(Word32And(flag_value, Int32Constant(0xFF)),
26641cb0ef41Sopenharmony_ci                          Int32Constant(0));
26651cb0ef41Sopenharmony_ci  }
26661cb0ef41Sopenharmony_ci
26671cb0ef41Sopenharmony_ci  TNode<BoolT> IsMockArrayBufferAllocatorFlag() {
26681cb0ef41Sopenharmony_ci    return LoadRuntimeFlag(
26691cb0ef41Sopenharmony_ci        ExternalReference::address_of_mock_arraybuffer_allocator_flag());
26701cb0ef41Sopenharmony_ci  }
26711cb0ef41Sopenharmony_ci
26721cb0ef41Sopenharmony_ci  TNode<BoolT> HasBuiltinSubclassingFlag() {
26731cb0ef41Sopenharmony_ci    return LoadRuntimeFlag(
26741cb0ef41Sopenharmony_ci        ExternalReference::address_of_builtin_subclassing_flag());
26751cb0ef41Sopenharmony_ci  }
26761cb0ef41Sopenharmony_ci
26771cb0ef41Sopenharmony_ci  TNode<BoolT> HasSharedStringTableFlag() {
26781cb0ef41Sopenharmony_ci    return LoadRuntimeFlag(
26791cb0ef41Sopenharmony_ci        ExternalReference::address_of_shared_string_table_flag());
26801cb0ef41Sopenharmony_ci  }
26811cb0ef41Sopenharmony_ci
26821cb0ef41Sopenharmony_ci  // True iff |object| is a Smi or a HeapNumber or a BigInt.
26831cb0ef41Sopenharmony_ci  TNode<BoolT> IsNumeric(TNode<Object> object);
26841cb0ef41Sopenharmony_ci
26851cb0ef41Sopenharmony_ci  // True iff |number| is either a Smi, or a HeapNumber whose value is not
26861cb0ef41Sopenharmony_ci  // within Smi range.
26871cb0ef41Sopenharmony_ci  TNode<BoolT> IsNumberNormalized(TNode<Number> number);
26881cb0ef41Sopenharmony_ci  TNode<BoolT> IsNumberPositive(TNode<Number> number);
26891cb0ef41Sopenharmony_ci  TNode<BoolT> IsHeapNumberPositive(TNode<HeapNumber> number);
26901cb0ef41Sopenharmony_ci
26911cb0ef41Sopenharmony_ci  // True iff {number} is non-negative and less or equal than 2**53-1.
26921cb0ef41Sopenharmony_ci  TNode<BoolT> IsNumberNonNegativeSafeInteger(TNode<Number> number);
26931cb0ef41Sopenharmony_ci
26941cb0ef41Sopenharmony_ci  // True iff {number} represents an integer value.
26951cb0ef41Sopenharmony_ci  TNode<BoolT> IsInteger(TNode<Object> number);
26961cb0ef41Sopenharmony_ci  TNode<BoolT> IsInteger(TNode<HeapNumber> number);
26971cb0ef41Sopenharmony_ci
26981cb0ef41Sopenharmony_ci  // True iff abs({number}) <= 2**53 -1
26991cb0ef41Sopenharmony_ci  TNode<BoolT> IsSafeInteger(TNode<Object> number);
27001cb0ef41Sopenharmony_ci  TNode<BoolT> IsSafeInteger(TNode<HeapNumber> number);
27011cb0ef41Sopenharmony_ci
27021cb0ef41Sopenharmony_ci  // True iff {number} represents a valid uint32t value.
27031cb0ef41Sopenharmony_ci  TNode<BoolT> IsHeapNumberUint32(TNode<HeapNumber> number);
27041cb0ef41Sopenharmony_ci
27051cb0ef41Sopenharmony_ci  // True iff {number} is a positive number and a valid array index in the range
27061cb0ef41Sopenharmony_ci  // [0, 2^32-1).
27071cb0ef41Sopenharmony_ci  TNode<BoolT> IsNumberArrayIndex(TNode<Number> number);
27081cb0ef41Sopenharmony_ci
27091cb0ef41Sopenharmony_ci  template <typename TIndex>
27101cb0ef41Sopenharmony_ci  TNode<BoolT> FixedArraySizeDoesntFitInNewSpace(TNode<TIndex> element_count,
27111cb0ef41Sopenharmony_ci                                                 int base_size);
27121cb0ef41Sopenharmony_ci
27131cb0ef41Sopenharmony_ci  TNode<BoolT> IsMetaMap(TNode<HeapObject> o) { return IsMapMap(o); }
27141cb0ef41Sopenharmony_ci
27151cb0ef41Sopenharmony_ci  // ElementsKind helpers:
27161cb0ef41Sopenharmony_ci  TNode<BoolT> ElementsKindEqual(TNode<Int32T> a, TNode<Int32T> b) {
27171cb0ef41Sopenharmony_ci    return Word32Equal(a, b);
27181cb0ef41Sopenharmony_ci  }
27191cb0ef41Sopenharmony_ci  bool ElementsKindEqual(ElementsKind a, ElementsKind b) { return a == b; }
27201cb0ef41Sopenharmony_ci  TNode<BoolT> IsFastElementsKind(TNode<Int32T> elements_kind);
27211cb0ef41Sopenharmony_ci  bool IsFastElementsKind(ElementsKind kind) {
27221cb0ef41Sopenharmony_ci    return v8::internal::IsFastElementsKind(kind);
27231cb0ef41Sopenharmony_ci  }
27241cb0ef41Sopenharmony_ci  TNode<BoolT> IsFastOrNonExtensibleOrSealedElementsKind(
27251cb0ef41Sopenharmony_ci      TNode<Int32T> elements_kind);
27261cb0ef41Sopenharmony_ci
27271cb0ef41Sopenharmony_ci  TNode<BoolT> IsDictionaryElementsKind(TNode<Int32T> elements_kind) {
27281cb0ef41Sopenharmony_ci    return ElementsKindEqual(elements_kind, Int32Constant(DICTIONARY_ELEMENTS));
27291cb0ef41Sopenharmony_ci  }
27301cb0ef41Sopenharmony_ci  TNode<BoolT> IsDoubleElementsKind(TNode<Int32T> elements_kind);
27311cb0ef41Sopenharmony_ci  bool IsDoubleElementsKind(ElementsKind kind) {
27321cb0ef41Sopenharmony_ci    return v8::internal::IsDoubleElementsKind(kind);
27331cb0ef41Sopenharmony_ci  }
27341cb0ef41Sopenharmony_ci  TNode<BoolT> IsFastSmiOrTaggedElementsKind(TNode<Int32T> elements_kind);
27351cb0ef41Sopenharmony_ci  TNode<BoolT> IsFastSmiElementsKind(TNode<Int32T> elements_kind);
27361cb0ef41Sopenharmony_ci  TNode<BoolT> IsHoleyFastElementsKind(TNode<Int32T> elements_kind);
27371cb0ef41Sopenharmony_ci  TNode<BoolT> IsHoleyFastElementsKindForRead(TNode<Int32T> elements_kind);
27381cb0ef41Sopenharmony_ci  TNode<BoolT> IsElementsKindGreaterThan(TNode<Int32T> target_kind,
27391cb0ef41Sopenharmony_ci                                         ElementsKind reference_kind);
27401cb0ef41Sopenharmony_ci  TNode<BoolT> IsElementsKindGreaterThanOrEqual(TNode<Int32T> target_kind,
27411cb0ef41Sopenharmony_ci                                                ElementsKind reference_kind);
27421cb0ef41Sopenharmony_ci  TNode<BoolT> IsElementsKindLessThanOrEqual(TNode<Int32T> target_kind,
27431cb0ef41Sopenharmony_ci                                             ElementsKind reference_kind);
27441cb0ef41Sopenharmony_ci  // Check if lower_reference_kind <= target_kind <= higher_reference_kind.
27451cb0ef41Sopenharmony_ci  TNode<BoolT> IsElementsKindInRange(TNode<Int32T> target_kind,
27461cb0ef41Sopenharmony_ci                                     ElementsKind lower_reference_kind,
27471cb0ef41Sopenharmony_ci                                     ElementsKind higher_reference_kind) {
27481cb0ef41Sopenharmony_ci    return IsInRange(target_kind, lower_reference_kind, higher_reference_kind);
27491cb0ef41Sopenharmony_ci  }
27501cb0ef41Sopenharmony_ci
27511cb0ef41Sopenharmony_ci  // String helpers.
27521cb0ef41Sopenharmony_ci  // Load a character from a String (might flatten a ConsString).
27531cb0ef41Sopenharmony_ci  TNode<Uint16T> StringCharCodeAt(TNode<String> string, TNode<UintPtrT> index);
27541cb0ef41Sopenharmony_ci  // Return the single character string with only {code}.
27551cb0ef41Sopenharmony_ci  TNode<String> StringFromSingleCharCode(TNode<Int32T> code);
27561cb0ef41Sopenharmony_ci
27571cb0ef41Sopenharmony_ci  // Type conversion helpers.
27581cb0ef41Sopenharmony_ci  enum class BigIntHandling { kConvertToNumber, kThrow };
27591cb0ef41Sopenharmony_ci  // Convert a String to a Number.
27601cb0ef41Sopenharmony_ci  TNode<Number> StringToNumber(TNode<String> input);
27611cb0ef41Sopenharmony_ci  // Convert a Number to a String.
27621cb0ef41Sopenharmony_ci  TNode<String> NumberToString(TNode<Number> input);
27631cb0ef41Sopenharmony_ci  TNode<String> NumberToString(TNode<Number> input, Label* bailout);
27641cb0ef41Sopenharmony_ci
27651cb0ef41Sopenharmony_ci  // Convert a Non-Number object to a Number.
27661cb0ef41Sopenharmony_ci  TNode<Number> NonNumberToNumber(
27671cb0ef41Sopenharmony_ci      TNode<Context> context, TNode<HeapObject> input,
27681cb0ef41Sopenharmony_ci      BigIntHandling bigint_handling = BigIntHandling::kThrow);
27691cb0ef41Sopenharmony_ci  // Convert a Non-Number object to a Numeric.
27701cb0ef41Sopenharmony_ci  TNode<Numeric> NonNumberToNumeric(TNode<Context> context,
27711cb0ef41Sopenharmony_ci                                    TNode<HeapObject> input);
27721cb0ef41Sopenharmony_ci  // Convert any object to a Number.
27731cb0ef41Sopenharmony_ci  // Conforms to ES#sec-tonumber if {bigint_handling} == kThrow.
27741cb0ef41Sopenharmony_ci  // With {bigint_handling} == kConvertToNumber, matches behavior of
27751cb0ef41Sopenharmony_ci  // tc39.github.io/proposal-bigint/#sec-number-constructor-number-value.
27761cb0ef41Sopenharmony_ci  TNode<Number> ToNumber(
27771cb0ef41Sopenharmony_ci      TNode<Context> context, TNode<Object> input,
27781cb0ef41Sopenharmony_ci      BigIntHandling bigint_handling = BigIntHandling::kThrow);
27791cb0ef41Sopenharmony_ci  TNode<Number> ToNumber_Inline(TNode<Context> context, TNode<Object> input);
27801cb0ef41Sopenharmony_ci  TNode<Numeric> ToNumberOrNumeric(
27811cb0ef41Sopenharmony_ci      LazyNode<Context> context, TNode<Object> input,
27821cb0ef41Sopenharmony_ci      TVariable<Smi>* var_type_feedback, Object::Conversion mode,
27831cb0ef41Sopenharmony_ci      BigIntHandling bigint_handling = BigIntHandling::kThrow);
27841cb0ef41Sopenharmony_ci  // Convert any plain primitive to a Number. No need to handle BigInts since
27851cb0ef41Sopenharmony_ci  // they are not plain primitives.
27861cb0ef41Sopenharmony_ci  TNode<Number> PlainPrimitiveToNumber(TNode<Object> input);
27871cb0ef41Sopenharmony_ci
27881cb0ef41Sopenharmony_ci  // Try to convert an object to a BigInt. Throws on failure (e.g. for Numbers).
27891cb0ef41Sopenharmony_ci  // https://tc39.github.io/proposal-bigint/#sec-to-bigint
27901cb0ef41Sopenharmony_ci  TNode<BigInt> ToBigInt(TNode<Context> context, TNode<Object> input);
27911cb0ef41Sopenharmony_ci
27921cb0ef41Sopenharmony_ci  // Converts |input| to one of 2^32 integer values in the range 0 through
27931cb0ef41Sopenharmony_ci  // 2^32-1, inclusive.
27941cb0ef41Sopenharmony_ci  // ES#sec-touint32
27951cb0ef41Sopenharmony_ci  TNode<Number> ToUint32(TNode<Context> context, TNode<Object> input);
27961cb0ef41Sopenharmony_ci
27971cb0ef41Sopenharmony_ci  // Convert any object to a String.
27981cb0ef41Sopenharmony_ci  TNode<String> ToString_Inline(TNode<Context> context, TNode<Object> input);
27991cb0ef41Sopenharmony_ci
28001cb0ef41Sopenharmony_ci  TNode<JSReceiver> ToObject(TNode<Context> context, TNode<Object> input);
28011cb0ef41Sopenharmony_ci
28021cb0ef41Sopenharmony_ci  // Same as ToObject but avoids the Builtin call if |input| is already a
28031cb0ef41Sopenharmony_ci  // JSReceiver.
28041cb0ef41Sopenharmony_ci  TNode<JSReceiver> ToObject_Inline(TNode<Context> context,
28051cb0ef41Sopenharmony_ci                                    TNode<Object> input);
28061cb0ef41Sopenharmony_ci
28071cb0ef41Sopenharmony_ci  // ES6 7.1.15 ToLength, but with inlined fast path.
28081cb0ef41Sopenharmony_ci  TNode<Number> ToLength_Inline(TNode<Context> context, TNode<Object> input);
28091cb0ef41Sopenharmony_ci
28101cb0ef41Sopenharmony_ci  TNode<Object> OrdinaryToPrimitive(TNode<Context> context, TNode<Object> input,
28111cb0ef41Sopenharmony_ci                                    OrdinaryToPrimitiveHint hint);
28121cb0ef41Sopenharmony_ci
28131cb0ef41Sopenharmony_ci  // Returns a node that contains a decoded (unsigned!) value of a bit
28141cb0ef41Sopenharmony_ci  // field |BitField| in |word32|. Returns result as an uint32 node.
28151cb0ef41Sopenharmony_ci  template <typename BitField>
28161cb0ef41Sopenharmony_ci  TNode<Uint32T> DecodeWord32(TNode<Word32T> word32) {
28171cb0ef41Sopenharmony_ci    return DecodeWord32(word32, BitField::kShift, BitField::kMask);
28181cb0ef41Sopenharmony_ci  }
28191cb0ef41Sopenharmony_ci
28201cb0ef41Sopenharmony_ci  // Returns a node that contains a decoded (unsigned!) value of a bit
28211cb0ef41Sopenharmony_ci  // field |BitField| in |word|. Returns result as a word-size node.
28221cb0ef41Sopenharmony_ci  template <typename BitField>
28231cb0ef41Sopenharmony_ci  TNode<UintPtrT> DecodeWord(TNode<WordT> word) {
28241cb0ef41Sopenharmony_ci    return DecodeWord(word, BitField::kShift, BitField::kMask);
28251cb0ef41Sopenharmony_ci  }
28261cb0ef41Sopenharmony_ci
28271cb0ef41Sopenharmony_ci  // Returns a node that contains a decoded (unsigned!) value of a bit
28281cb0ef41Sopenharmony_ci  // field |BitField| in |word32|. Returns result as a word-size node.
28291cb0ef41Sopenharmony_ci  template <typename BitField>
28301cb0ef41Sopenharmony_ci  TNode<UintPtrT> DecodeWordFromWord32(TNode<Word32T> word32) {
28311cb0ef41Sopenharmony_ci    return DecodeWord<BitField>(ChangeUint32ToWord(word32));
28321cb0ef41Sopenharmony_ci  }
28331cb0ef41Sopenharmony_ci
28341cb0ef41Sopenharmony_ci  // Returns a node that contains a decoded (unsigned!) value of a bit
28351cb0ef41Sopenharmony_ci  // field |BitField| in |word|. Returns result as an uint32 node.
28361cb0ef41Sopenharmony_ci  template <typename BitField>
28371cb0ef41Sopenharmony_ci  TNode<Uint32T> DecodeWord32FromWord(TNode<WordT> word) {
28381cb0ef41Sopenharmony_ci    return UncheckedCast<Uint32T>(
28391cb0ef41Sopenharmony_ci        TruncateIntPtrToInt32(Signed(DecodeWord<BitField>(word))));
28401cb0ef41Sopenharmony_ci  }
28411cb0ef41Sopenharmony_ci
28421cb0ef41Sopenharmony_ci  // Decodes an unsigned (!) value from |word32| to an uint32 node.
28431cb0ef41Sopenharmony_ci  TNode<Uint32T> DecodeWord32(TNode<Word32T> word32, uint32_t shift,
28441cb0ef41Sopenharmony_ci                              uint32_t mask);
28451cb0ef41Sopenharmony_ci
28461cb0ef41Sopenharmony_ci  // Decodes an unsigned (!) value from |word| to a word-size node.
28471cb0ef41Sopenharmony_ci  TNode<UintPtrT> DecodeWord(TNode<WordT> word, uint32_t shift, uintptr_t mask);
28481cb0ef41Sopenharmony_ci
28491cb0ef41Sopenharmony_ci  // Returns a node that contains the updated values of a |BitField|.
28501cb0ef41Sopenharmony_ci  template <typename BitField>
28511cb0ef41Sopenharmony_ci  TNode<Word32T> UpdateWord32(TNode<Word32T> word, TNode<Uint32T> value,
28521cb0ef41Sopenharmony_ci                              bool starts_as_zero = false) {
28531cb0ef41Sopenharmony_ci    return UpdateWord32(word, value, BitField::kShift, BitField::kMask,
28541cb0ef41Sopenharmony_ci                        starts_as_zero);
28551cb0ef41Sopenharmony_ci  }
28561cb0ef41Sopenharmony_ci
28571cb0ef41Sopenharmony_ci  // Returns a node that contains the updated values of a |BitField|.
28581cb0ef41Sopenharmony_ci  template <typename BitField>
28591cb0ef41Sopenharmony_ci  TNode<WordT> UpdateWord(TNode<WordT> word, TNode<UintPtrT> value,
28601cb0ef41Sopenharmony_ci                          bool starts_as_zero = false) {
28611cb0ef41Sopenharmony_ci    return UpdateWord(word, value, BitField::kShift, BitField::kMask,
28621cb0ef41Sopenharmony_ci                      starts_as_zero);
28631cb0ef41Sopenharmony_ci  }
28641cb0ef41Sopenharmony_ci
28651cb0ef41Sopenharmony_ci  // Returns a node that contains the updated values of a |BitField|.
28661cb0ef41Sopenharmony_ci  template <typename BitField>
28671cb0ef41Sopenharmony_ci  TNode<Word32T> UpdateWordInWord32(TNode<Word32T> word, TNode<UintPtrT> value,
28681cb0ef41Sopenharmony_ci                                    bool starts_as_zero = false) {
28691cb0ef41Sopenharmony_ci    return UncheckedCast<Uint32T>(
28701cb0ef41Sopenharmony_ci        TruncateIntPtrToInt32(Signed(UpdateWord<BitField>(
28711cb0ef41Sopenharmony_ci            ChangeUint32ToWord(word), value, starts_as_zero))));
28721cb0ef41Sopenharmony_ci  }
28731cb0ef41Sopenharmony_ci
28741cb0ef41Sopenharmony_ci  // Returns a node that contains the updated values of a |BitField|.
28751cb0ef41Sopenharmony_ci  template <typename BitField>
28761cb0ef41Sopenharmony_ci  TNode<WordT> UpdateWord32InWord(TNode<WordT> word, TNode<Uint32T> value,
28771cb0ef41Sopenharmony_ci                                  bool starts_as_zero = false) {
28781cb0ef41Sopenharmony_ci    return UpdateWord<BitField>(word, ChangeUint32ToWord(value),
28791cb0ef41Sopenharmony_ci                                starts_as_zero);
28801cb0ef41Sopenharmony_ci  }
28811cb0ef41Sopenharmony_ci
28821cb0ef41Sopenharmony_ci  // Returns a node that contains the updated {value} inside {word} starting
28831cb0ef41Sopenharmony_ci  // at {shift} and fitting in {mask}.
28841cb0ef41Sopenharmony_ci  TNode<Word32T> UpdateWord32(TNode<Word32T> word, TNode<Uint32T> value,
28851cb0ef41Sopenharmony_ci                              uint32_t shift, uint32_t mask,
28861cb0ef41Sopenharmony_ci                              bool starts_as_zero = false);
28871cb0ef41Sopenharmony_ci
28881cb0ef41Sopenharmony_ci  // Returns a node that contains the updated {value} inside {word} starting
28891cb0ef41Sopenharmony_ci  // at {shift} and fitting in {mask}.
28901cb0ef41Sopenharmony_ci  TNode<WordT> UpdateWord(TNode<WordT> word, TNode<UintPtrT> value,
28911cb0ef41Sopenharmony_ci                          uint32_t shift, uintptr_t mask,
28921cb0ef41Sopenharmony_ci                          bool starts_as_zero = false);
28931cb0ef41Sopenharmony_ci
28941cb0ef41Sopenharmony_ci  // Returns true if any of the |T|'s bits in given |word32| are set.
28951cb0ef41Sopenharmony_ci  template <typename T>
28961cb0ef41Sopenharmony_ci  TNode<BoolT> IsSetWord32(TNode<Word32T> word32) {
28971cb0ef41Sopenharmony_ci    return IsSetWord32(word32, T::kMask);
28981cb0ef41Sopenharmony_ci  }
28991cb0ef41Sopenharmony_ci
29001cb0ef41Sopenharmony_ci  // Returns true if any of the mask's bits in given |word32| are set.
29011cb0ef41Sopenharmony_ci  TNode<BoolT> IsSetWord32(TNode<Word32T> word32, uint32_t mask) {
29021cb0ef41Sopenharmony_ci    return Word32NotEqual(Word32And(word32, Int32Constant(mask)),
29031cb0ef41Sopenharmony_ci                          Int32Constant(0));
29041cb0ef41Sopenharmony_ci  }
29051cb0ef41Sopenharmony_ci
29061cb0ef41Sopenharmony_ci  // Returns true if none of the mask's bits in given |word32| are set.
29071cb0ef41Sopenharmony_ci  TNode<BoolT> IsNotSetWord32(TNode<Word32T> word32, uint32_t mask) {
29081cb0ef41Sopenharmony_ci    return Word32Equal(Word32And(word32, Int32Constant(mask)),
29091cb0ef41Sopenharmony_ci                       Int32Constant(0));
29101cb0ef41Sopenharmony_ci  }
29111cb0ef41Sopenharmony_ci
29121cb0ef41Sopenharmony_ci  // Returns true if all of the mask's bits in a given |word32| are set.
29131cb0ef41Sopenharmony_ci  TNode<BoolT> IsAllSetWord32(TNode<Word32T> word32, uint32_t mask) {
29141cb0ef41Sopenharmony_ci    TNode<Int32T> const_mask = Int32Constant(mask);
29151cb0ef41Sopenharmony_ci    return Word32Equal(Word32And(word32, const_mask), const_mask);
29161cb0ef41Sopenharmony_ci  }
29171cb0ef41Sopenharmony_ci
29181cb0ef41Sopenharmony_ci  // Returns true if the bit field |BitField| in |word32| is equal to a given
29191cb0ef41Sopenharmony_ci  // constant |value|. Avoids a shift compared to using DecodeWord32.
29201cb0ef41Sopenharmony_ci  template <typename BitField>
29211cb0ef41Sopenharmony_ci  TNode<BoolT> IsEqualInWord32(TNode<Word32T> word32,
29221cb0ef41Sopenharmony_ci                               typename BitField::FieldType value) {
29231cb0ef41Sopenharmony_ci    TNode<Word32T> masked_word32 =
29241cb0ef41Sopenharmony_ci        Word32And(word32, Int32Constant(BitField::kMask));
29251cb0ef41Sopenharmony_ci    return Word32Equal(masked_word32, Int32Constant(BitField::encode(value)));
29261cb0ef41Sopenharmony_ci  }
29271cb0ef41Sopenharmony_ci
29281cb0ef41Sopenharmony_ci  // Returns true if the bit field |BitField| in |word32| is not equal to a
29291cb0ef41Sopenharmony_ci  // given constant |value|. Avoids a shift compared to using DecodeWord32.
29301cb0ef41Sopenharmony_ci  template <typename BitField>
29311cb0ef41Sopenharmony_ci  TNode<BoolT> IsNotEqualInWord32(TNode<Word32T> word32,
29321cb0ef41Sopenharmony_ci                                  typename BitField::FieldType value) {
29331cb0ef41Sopenharmony_ci    return Word32BinaryNot(IsEqualInWord32<BitField>(word32, value));
29341cb0ef41Sopenharmony_ci  }
29351cb0ef41Sopenharmony_ci
29361cb0ef41Sopenharmony_ci  // Returns true if any of the |T|'s bits in given |word| are set.
29371cb0ef41Sopenharmony_ci  template <typename T>
29381cb0ef41Sopenharmony_ci  TNode<BoolT> IsSetWord(TNode<WordT> word) {
29391cb0ef41Sopenharmony_ci    return IsSetWord(word, T::kMask);
29401cb0ef41Sopenharmony_ci  }
29411cb0ef41Sopenharmony_ci
29421cb0ef41Sopenharmony_ci  // Returns true if any of the mask's bits in given |word| are set.
29431cb0ef41Sopenharmony_ci  TNode<BoolT> IsSetWord(TNode<WordT> word, uint32_t mask) {
29441cb0ef41Sopenharmony_ci    return WordNotEqual(WordAnd(word, IntPtrConstant(mask)), IntPtrConstant(0));
29451cb0ef41Sopenharmony_ci  }
29461cb0ef41Sopenharmony_ci
29471cb0ef41Sopenharmony_ci  // Returns true if any of the mask's bit are set in the given Smi.
29481cb0ef41Sopenharmony_ci  // Smi-encoding of the mask is performed implicitly!
29491cb0ef41Sopenharmony_ci  TNode<BoolT> IsSetSmi(TNode<Smi> smi, int untagged_mask) {
29501cb0ef41Sopenharmony_ci    intptr_t mask_word = bit_cast<intptr_t>(Smi::FromInt(untagged_mask));
29511cb0ef41Sopenharmony_ci    return WordNotEqual(WordAnd(BitcastTaggedToWordForTagAndSmiBits(smi),
29521cb0ef41Sopenharmony_ci                                IntPtrConstant(mask_word)),
29531cb0ef41Sopenharmony_ci                        IntPtrConstant(0));
29541cb0ef41Sopenharmony_ci  }
29551cb0ef41Sopenharmony_ci
29561cb0ef41Sopenharmony_ci  // Returns true if all of the |T|'s bits in given |word32| are clear.
29571cb0ef41Sopenharmony_ci  template <typename T>
29581cb0ef41Sopenharmony_ci  TNode<BoolT> IsClearWord32(TNode<Word32T> word32) {
29591cb0ef41Sopenharmony_ci    return IsClearWord32(word32, T::kMask);
29601cb0ef41Sopenharmony_ci  }
29611cb0ef41Sopenharmony_ci
29621cb0ef41Sopenharmony_ci  // Returns true if all of the mask's bits in given |word32| are clear.
29631cb0ef41Sopenharmony_ci  TNode<BoolT> IsClearWord32(TNode<Word32T> word32, uint32_t mask) {
29641cb0ef41Sopenharmony_ci    return Word32Equal(Word32And(word32, Int32Constant(mask)),
29651cb0ef41Sopenharmony_ci                       Int32Constant(0));
29661cb0ef41Sopenharmony_ci  }
29671cb0ef41Sopenharmony_ci
29681cb0ef41Sopenharmony_ci  // Returns true if all of the |T|'s bits in given |word| are clear.
29691cb0ef41Sopenharmony_ci  template <typename T>
29701cb0ef41Sopenharmony_ci  TNode<BoolT> IsClearWord(TNode<WordT> word) {
29711cb0ef41Sopenharmony_ci    return IsClearWord(word, T::kMask);
29721cb0ef41Sopenharmony_ci  }
29731cb0ef41Sopenharmony_ci
29741cb0ef41Sopenharmony_ci  // Returns true if all of the mask's bits in given |word| are clear.
29751cb0ef41Sopenharmony_ci  TNode<BoolT> IsClearWord(TNode<WordT> word, uint32_t mask) {
29761cb0ef41Sopenharmony_ci    return IntPtrEqual(WordAnd(word, IntPtrConstant(mask)), IntPtrConstant(0));
29771cb0ef41Sopenharmony_ci  }
29781cb0ef41Sopenharmony_ci
29791cb0ef41Sopenharmony_ci  void SetCounter(StatsCounter* counter, int value);
29801cb0ef41Sopenharmony_ci  void IncrementCounter(StatsCounter* counter, int delta);
29811cb0ef41Sopenharmony_ci  void DecrementCounter(StatsCounter* counter, int delta);
29821cb0ef41Sopenharmony_ci
29831cb0ef41Sopenharmony_ci  template <typename TIndex>
29841cb0ef41Sopenharmony_ci  void Increment(TVariable<TIndex>* variable, int value = 1);
29851cb0ef41Sopenharmony_ci
29861cb0ef41Sopenharmony_ci  template <typename TIndex>
29871cb0ef41Sopenharmony_ci  void Decrement(TVariable<TIndex>* variable, int value = 1) {
29881cb0ef41Sopenharmony_ci    Increment(variable, -value);
29891cb0ef41Sopenharmony_ci  }
29901cb0ef41Sopenharmony_ci
29911cb0ef41Sopenharmony_ci  // Generates "if (false) goto label" code. Useful for marking a label as
29921cb0ef41Sopenharmony_ci  // "live" to avoid assertion failures during graph building. In the resulting
29931cb0ef41Sopenharmony_ci  // code this check will be eliminated.
29941cb0ef41Sopenharmony_ci  void Use(Label* label);
29951cb0ef41Sopenharmony_ci
29961cb0ef41Sopenharmony_ci  // Various building blocks for stubs doing property lookups.
29971cb0ef41Sopenharmony_ci
29981cb0ef41Sopenharmony_ci  // |if_notinternalized| is optional; |if_bailout| will be used by default.
29991cb0ef41Sopenharmony_ci  // Note: If |key| does not yet have a hash, |if_notinternalized| will be taken
30001cb0ef41Sopenharmony_ci  // even if |key| is an array index. |if_keyisunique| will never
30011cb0ef41Sopenharmony_ci  // be taken for array indices.
30021cb0ef41Sopenharmony_ci  void TryToName(TNode<Object> key, Label* if_keyisindex,
30031cb0ef41Sopenharmony_ci                 TVariable<IntPtrT>* var_index, Label* if_keyisunique,
30041cb0ef41Sopenharmony_ci                 TVariable<Name>* var_unique, Label* if_bailout,
30051cb0ef41Sopenharmony_ci                 Label* if_notinternalized = nullptr);
30061cb0ef41Sopenharmony_ci
30071cb0ef41Sopenharmony_ci  // Call non-allocating runtime String::WriteToFlat using fast C-calls.
30081cb0ef41Sopenharmony_ci  void StringWriteToFlatOneByte(TNode<String> source, TNode<RawPtrT> sink,
30091cb0ef41Sopenharmony_ci                                TNode<Int32T> start, TNode<Int32T> length);
30101cb0ef41Sopenharmony_ci  void StringWriteToFlatTwoByte(TNode<String> source, TNode<RawPtrT> sink,
30111cb0ef41Sopenharmony_ci                                TNode<Int32T> start, TNode<Int32T> length);
30121cb0ef41Sopenharmony_ci
30131cb0ef41Sopenharmony_ci  // Calls External{One,Two}ByteString::GetChars with a fast C-call.
30141cb0ef41Sopenharmony_ci  TNode<RawPtr<Uint8T>> ExternalOneByteStringGetChars(
30151cb0ef41Sopenharmony_ci      TNode<ExternalOneByteString> string);
30161cb0ef41Sopenharmony_ci  TNode<RawPtr<Uint16T>> ExternalTwoByteStringGetChars(
30171cb0ef41Sopenharmony_ci      TNode<ExternalTwoByteString> string);
30181cb0ef41Sopenharmony_ci
30191cb0ef41Sopenharmony_ci  TNode<RawPtr<Uint8T>> IntlAsciiCollationWeightsL1();
30201cb0ef41Sopenharmony_ci  TNode<RawPtr<Uint8T>> IntlAsciiCollationWeightsL3();
30211cb0ef41Sopenharmony_ci
30221cb0ef41Sopenharmony_ci  // Performs a hash computation and string table lookup for the given string,
30231cb0ef41Sopenharmony_ci  // and jumps to:
30241cb0ef41Sopenharmony_ci  // - |if_index| if the string is an array index like "123"; |var_index|
30251cb0ef41Sopenharmony_ci  //              will contain the intptr representation of that index.
30261cb0ef41Sopenharmony_ci  // - |if_internalized| if the string exists in the string table; the
30271cb0ef41Sopenharmony_ci  //                     internalized version will be in |var_internalized|.
30281cb0ef41Sopenharmony_ci  // - |if_not_internalized| if the string is not in the string table (but
30291cb0ef41Sopenharmony_ci  //                         does not add it).
30301cb0ef41Sopenharmony_ci  // - |if_bailout| for unsupported cases (e.g. uncachable array index).
30311cb0ef41Sopenharmony_ci  void TryInternalizeString(TNode<String> string, Label* if_index,
30321cb0ef41Sopenharmony_ci                            TVariable<IntPtrT>* var_index,
30331cb0ef41Sopenharmony_ci                            Label* if_internalized,
30341cb0ef41Sopenharmony_ci                            TVariable<Name>* var_internalized,
30351cb0ef41Sopenharmony_ci                            Label* if_not_internalized, Label* if_bailout);
30361cb0ef41Sopenharmony_ci
30371cb0ef41Sopenharmony_ci  // Calculates array index for given dictionary entry and entry field.
30381cb0ef41Sopenharmony_ci  // See Dictionary::EntryToIndex().
30391cb0ef41Sopenharmony_ci  template <typename Dictionary>
30401cb0ef41Sopenharmony_ci  TNode<IntPtrT> EntryToIndex(TNode<IntPtrT> entry, int field_index);
30411cb0ef41Sopenharmony_ci  template <typename Dictionary>
30421cb0ef41Sopenharmony_ci  TNode<IntPtrT> EntryToIndex(TNode<IntPtrT> entry) {
30431cb0ef41Sopenharmony_ci    return EntryToIndex<Dictionary>(entry, Dictionary::kEntryKeyIndex);
30441cb0ef41Sopenharmony_ci  }
30451cb0ef41Sopenharmony_ci
30461cb0ef41Sopenharmony_ci  // Loads the details for the entry with the given key_index.
30471cb0ef41Sopenharmony_ci  // Returns an untagged int32.
30481cb0ef41Sopenharmony_ci  template <class ContainerType>
30491cb0ef41Sopenharmony_ci  TNode<Uint32T> LoadDetailsByKeyIndex(TNode<ContainerType> container,
30501cb0ef41Sopenharmony_ci                                       TNode<IntPtrT> key_index);
30511cb0ef41Sopenharmony_ci
30521cb0ef41Sopenharmony_ci  // Loads the value for the entry with the given key_index.
30531cb0ef41Sopenharmony_ci  // Returns a tagged value.
30541cb0ef41Sopenharmony_ci  template <class ContainerType>
30551cb0ef41Sopenharmony_ci  TNode<Object> LoadValueByKeyIndex(TNode<ContainerType> container,
30561cb0ef41Sopenharmony_ci                                    TNode<IntPtrT> key_index);
30571cb0ef41Sopenharmony_ci
30581cb0ef41Sopenharmony_ci  // Stores the details for the entry with the given key_index.
30591cb0ef41Sopenharmony_ci  // |details| must be a Smi.
30601cb0ef41Sopenharmony_ci  template <class ContainerType>
30611cb0ef41Sopenharmony_ci  void StoreDetailsByKeyIndex(TNode<ContainerType> container,
30621cb0ef41Sopenharmony_ci                              TNode<IntPtrT> key_index, TNode<Smi> details);
30631cb0ef41Sopenharmony_ci
30641cb0ef41Sopenharmony_ci  // Stores the value for the entry with the given key_index.
30651cb0ef41Sopenharmony_ci  template <class ContainerType>
30661cb0ef41Sopenharmony_ci  void StoreValueByKeyIndex(
30671cb0ef41Sopenharmony_ci      TNode<ContainerType> container, TNode<IntPtrT> key_index,
30681cb0ef41Sopenharmony_ci      TNode<Object> value,
30691cb0ef41Sopenharmony_ci      WriteBarrierMode write_barrier = UPDATE_WRITE_BARRIER);
30701cb0ef41Sopenharmony_ci
30711cb0ef41Sopenharmony_ci  // Calculate a valid size for the a hash table.
30721cb0ef41Sopenharmony_ci  TNode<IntPtrT> HashTableComputeCapacity(TNode<IntPtrT> at_least_space_for);
30731cb0ef41Sopenharmony_ci
30741cb0ef41Sopenharmony_ci  TNode<IntPtrT> NameToIndexHashTableLookup(TNode<NameToIndexHashTable> table,
30751cb0ef41Sopenharmony_ci                                            TNode<Name> name, Label* not_found);
30761cb0ef41Sopenharmony_ci
30771cb0ef41Sopenharmony_ci  template <class Dictionary>
30781cb0ef41Sopenharmony_ci  TNode<Smi> GetNumberOfElements(TNode<Dictionary> dictionary);
30791cb0ef41Sopenharmony_ci
30801cb0ef41Sopenharmony_ci  TNode<Smi> GetNumberDictionaryNumberOfElements(
30811cb0ef41Sopenharmony_ci      TNode<NumberDictionary> dictionary) {
30821cb0ef41Sopenharmony_ci    return GetNumberOfElements<NumberDictionary>(dictionary);
30831cb0ef41Sopenharmony_ci  }
30841cb0ef41Sopenharmony_ci
30851cb0ef41Sopenharmony_ci  template <class Dictionary>
30861cb0ef41Sopenharmony_ci  void SetNumberOfElements(TNode<Dictionary> dictionary,
30871cb0ef41Sopenharmony_ci                           TNode<Smi> num_elements_smi) {
30881cb0ef41Sopenharmony_ci    // Not supposed to be used for SwissNameDictionary.
30891cb0ef41Sopenharmony_ci    STATIC_ASSERT(!(std::is_same<Dictionary, SwissNameDictionary>::value));
30901cb0ef41Sopenharmony_ci
30911cb0ef41Sopenharmony_ci    StoreFixedArrayElement(dictionary, Dictionary::kNumberOfElementsIndex,
30921cb0ef41Sopenharmony_ci                           num_elements_smi, SKIP_WRITE_BARRIER);
30931cb0ef41Sopenharmony_ci  }
30941cb0ef41Sopenharmony_ci
30951cb0ef41Sopenharmony_ci  template <class Dictionary>
30961cb0ef41Sopenharmony_ci  TNode<Smi> GetNumberOfDeletedElements(TNode<Dictionary> dictionary) {
30971cb0ef41Sopenharmony_ci    // Not supposed to be used for SwissNameDictionary.
30981cb0ef41Sopenharmony_ci    STATIC_ASSERT(!(std::is_same<Dictionary, SwissNameDictionary>::value));
30991cb0ef41Sopenharmony_ci
31001cb0ef41Sopenharmony_ci    return CAST(LoadFixedArrayElement(
31011cb0ef41Sopenharmony_ci        dictionary, Dictionary::kNumberOfDeletedElementsIndex));
31021cb0ef41Sopenharmony_ci  }
31031cb0ef41Sopenharmony_ci
31041cb0ef41Sopenharmony_ci  template <class Dictionary>
31051cb0ef41Sopenharmony_ci  void SetNumberOfDeletedElements(TNode<Dictionary> dictionary,
31061cb0ef41Sopenharmony_ci                                  TNode<Smi> num_deleted_smi) {
31071cb0ef41Sopenharmony_ci    // Not supposed to be used for SwissNameDictionary.
31081cb0ef41Sopenharmony_ci    STATIC_ASSERT(!(std::is_same<Dictionary, SwissNameDictionary>::value));
31091cb0ef41Sopenharmony_ci
31101cb0ef41Sopenharmony_ci    StoreFixedArrayElement(dictionary,
31111cb0ef41Sopenharmony_ci                           Dictionary::kNumberOfDeletedElementsIndex,
31121cb0ef41Sopenharmony_ci                           num_deleted_smi, SKIP_WRITE_BARRIER);
31131cb0ef41Sopenharmony_ci  }
31141cb0ef41Sopenharmony_ci
31151cb0ef41Sopenharmony_ci  template <class Dictionary>
31161cb0ef41Sopenharmony_ci  TNode<Smi> GetCapacity(TNode<Dictionary> dictionary) {
31171cb0ef41Sopenharmony_ci    // Not supposed to be used for SwissNameDictionary.
31181cb0ef41Sopenharmony_ci    STATIC_ASSERT(!(std::is_same<Dictionary, SwissNameDictionary>::value));
31191cb0ef41Sopenharmony_ci
31201cb0ef41Sopenharmony_ci    return CAST(
31211cb0ef41Sopenharmony_ci        UnsafeLoadFixedArrayElement(dictionary, Dictionary::kCapacityIndex));
31221cb0ef41Sopenharmony_ci  }
31231cb0ef41Sopenharmony_ci
31241cb0ef41Sopenharmony_ci  template <class Dictionary>
31251cb0ef41Sopenharmony_ci  TNode<Smi> GetNextEnumerationIndex(TNode<Dictionary> dictionary) {
31261cb0ef41Sopenharmony_ci    return CAST(LoadFixedArrayElement(dictionary,
31271cb0ef41Sopenharmony_ci                                      Dictionary::kNextEnumerationIndexIndex));
31281cb0ef41Sopenharmony_ci  }
31291cb0ef41Sopenharmony_ci
31301cb0ef41Sopenharmony_ci  template <class Dictionary>
31311cb0ef41Sopenharmony_ci  void SetNextEnumerationIndex(TNode<Dictionary> dictionary,
31321cb0ef41Sopenharmony_ci                               TNode<Smi> next_enum_index_smi) {
31331cb0ef41Sopenharmony_ci    StoreFixedArrayElement(dictionary, Dictionary::kNextEnumerationIndexIndex,
31341cb0ef41Sopenharmony_ci                           next_enum_index_smi, SKIP_WRITE_BARRIER);
31351cb0ef41Sopenharmony_ci  }
31361cb0ef41Sopenharmony_ci
31371cb0ef41Sopenharmony_ci  // Looks up an entry in a NameDictionaryBase successor. If the entry is found
31381cb0ef41Sopenharmony_ci  // control goes to {if_found} and {var_name_index} contains an index of the
31391cb0ef41Sopenharmony_ci  // key field of the entry found. If the key is not found control goes to
31401cb0ef41Sopenharmony_ci  // {if_not_found}.
31411cb0ef41Sopenharmony_ci  enum LookupMode { kFindExisting, kFindInsertionIndex };
31421cb0ef41Sopenharmony_ci
31431cb0ef41Sopenharmony_ci  template <typename Dictionary>
31441cb0ef41Sopenharmony_ci  TNode<HeapObject> LoadName(TNode<HeapObject> key);
31451cb0ef41Sopenharmony_ci
31461cb0ef41Sopenharmony_ci  template <typename Dictionary>
31471cb0ef41Sopenharmony_ci  void NameDictionaryLookup(TNode<Dictionary> dictionary,
31481cb0ef41Sopenharmony_ci                            TNode<Name> unique_name, Label* if_found,
31491cb0ef41Sopenharmony_ci                            TVariable<IntPtrT>* var_name_index,
31501cb0ef41Sopenharmony_ci                            Label* if_not_found,
31511cb0ef41Sopenharmony_ci                            LookupMode mode = kFindExisting);
31521cb0ef41Sopenharmony_ci
31531cb0ef41Sopenharmony_ci  TNode<Word32T> ComputeSeededHash(TNode<IntPtrT> key);
31541cb0ef41Sopenharmony_ci
31551cb0ef41Sopenharmony_ci  void NumberDictionaryLookup(TNode<NumberDictionary> dictionary,
31561cb0ef41Sopenharmony_ci                              TNode<IntPtrT> intptr_index, Label* if_found,
31571cb0ef41Sopenharmony_ci                              TVariable<IntPtrT>* var_entry,
31581cb0ef41Sopenharmony_ci                              Label* if_not_found);
31591cb0ef41Sopenharmony_ci
31601cb0ef41Sopenharmony_ci  TNode<Object> BasicLoadNumberDictionaryElement(
31611cb0ef41Sopenharmony_ci      TNode<NumberDictionary> dictionary, TNode<IntPtrT> intptr_index,
31621cb0ef41Sopenharmony_ci      Label* not_data, Label* if_hole);
31631cb0ef41Sopenharmony_ci
31641cb0ef41Sopenharmony_ci  template <class Dictionary>
31651cb0ef41Sopenharmony_ci  void FindInsertionEntry(TNode<Dictionary> dictionary, TNode<Name> key,
31661cb0ef41Sopenharmony_ci                          TVariable<IntPtrT>* var_key_index);
31671cb0ef41Sopenharmony_ci
31681cb0ef41Sopenharmony_ci  template <class Dictionary>
31691cb0ef41Sopenharmony_ci  void InsertEntry(TNode<Dictionary> dictionary, TNode<Name> key,
31701cb0ef41Sopenharmony_ci                   TNode<Object> value, TNode<IntPtrT> index,
31711cb0ef41Sopenharmony_ci                   TNode<Smi> enum_index);
31721cb0ef41Sopenharmony_ci
31731cb0ef41Sopenharmony_ci  template <class Dictionary>
31741cb0ef41Sopenharmony_ci  void Add(TNode<Dictionary> dictionary, TNode<Name> key, TNode<Object> value,
31751cb0ef41Sopenharmony_ci           Label* bailout);
31761cb0ef41Sopenharmony_ci
31771cb0ef41Sopenharmony_ci  // Tries to check if {object} has own {unique_name} property.
31781cb0ef41Sopenharmony_ci  void TryHasOwnProperty(TNode<HeapObject> object, TNode<Map> map,
31791cb0ef41Sopenharmony_ci                         TNode<Int32T> instance_type, TNode<Name> unique_name,
31801cb0ef41Sopenharmony_ci                         Label* if_found, Label* if_not_found,
31811cb0ef41Sopenharmony_ci                         Label* if_bailout);
31821cb0ef41Sopenharmony_ci
31831cb0ef41Sopenharmony_ci  // Operating mode for TryGetOwnProperty and CallGetterIfAccessor
31841cb0ef41Sopenharmony_ci  enum GetOwnPropertyMode {
31851cb0ef41Sopenharmony_ci    // kCallJSGetterDontUseCachedName is used when we want to get the result of
31861cb0ef41Sopenharmony_ci    // the getter call, and don't use cached_name_property when the getter is
31871cb0ef41Sopenharmony_ci    // the function template and it has cached_property_name, which would just
31881cb0ef41Sopenharmony_ci    // bailout for the IC system to create a named property handler
31891cb0ef41Sopenharmony_ci    kCallJSGetterDontUseCachedName,
31901cb0ef41Sopenharmony_ci    // kCallJSGetterUseCachedName is used when we want to get the result of
31911cb0ef41Sopenharmony_ci    // the getter call, and use cached_name_property when the getter is
31921cb0ef41Sopenharmony_ci    // the function template and it has cached_property_name, which would call
31931cb0ef41Sopenharmony_ci    // GetProperty rather than bailout for Generic/NoFeedback load
31941cb0ef41Sopenharmony_ci    kCallJSGetterUseCachedName,
31951cb0ef41Sopenharmony_ci    // kReturnAccessorPair is used when we're only getting the property
31961cb0ef41Sopenharmony_ci    // descriptor
31971cb0ef41Sopenharmony_ci    kReturnAccessorPair
31981cb0ef41Sopenharmony_ci  };
31991cb0ef41Sopenharmony_ci  // Tries to get {object}'s own {unique_name} property value. If the property
32001cb0ef41Sopenharmony_ci  // is an accessor then it also calls a getter. If the property is a double
32011cb0ef41Sopenharmony_ci  // field it re-wraps value in an immutable heap number. {unique_name} must be
32021cb0ef41Sopenharmony_ci  // a unique name (Symbol or InternalizedString) that is not an array index.
32031cb0ef41Sopenharmony_ci  void TryGetOwnProperty(TNode<Context> context, TNode<Object> receiver,
32041cb0ef41Sopenharmony_ci                         TNode<JSReceiver> object, TNode<Map> map,
32051cb0ef41Sopenharmony_ci                         TNode<Int32T> instance_type, TNode<Name> unique_name,
32061cb0ef41Sopenharmony_ci                         Label* if_found_value, TVariable<Object>* var_value,
32071cb0ef41Sopenharmony_ci                         Label* if_not_found, Label* if_bailout);
32081cb0ef41Sopenharmony_ci  void TryGetOwnProperty(TNode<Context> context, TNode<Object> receiver,
32091cb0ef41Sopenharmony_ci                         TNode<JSReceiver> object, TNode<Map> map,
32101cb0ef41Sopenharmony_ci                         TNode<Int32T> instance_type, TNode<Name> unique_name,
32111cb0ef41Sopenharmony_ci                         Label* if_found_value, TVariable<Object>* var_value,
32121cb0ef41Sopenharmony_ci                         TVariable<Uint32T>* var_details,
32131cb0ef41Sopenharmony_ci                         TVariable<Object>* var_raw_value, Label* if_not_found,
32141cb0ef41Sopenharmony_ci                         Label* if_bailout, GetOwnPropertyMode mode);
32151cb0ef41Sopenharmony_ci
32161cb0ef41Sopenharmony_ci  TNode<Object> GetProperty(TNode<Context> context, TNode<Object> receiver,
32171cb0ef41Sopenharmony_ci                            Handle<Name> name) {
32181cb0ef41Sopenharmony_ci    return GetProperty(context, receiver, HeapConstant(name));
32191cb0ef41Sopenharmony_ci  }
32201cb0ef41Sopenharmony_ci
32211cb0ef41Sopenharmony_ci  TNode<Object> GetProperty(TNode<Context> context, TNode<Object> receiver,
32221cb0ef41Sopenharmony_ci                            TNode<Object> name) {
32231cb0ef41Sopenharmony_ci    return CallBuiltin(Builtin::kGetProperty, context, receiver, name);
32241cb0ef41Sopenharmony_ci  }
32251cb0ef41Sopenharmony_ci
32261cb0ef41Sopenharmony_ci  TNode<Object> SetPropertyStrict(TNode<Context> context,
32271cb0ef41Sopenharmony_ci                                  TNode<Object> receiver, TNode<Object> key,
32281cb0ef41Sopenharmony_ci                                  TNode<Object> value) {
32291cb0ef41Sopenharmony_ci    return CallBuiltin(Builtin::kSetProperty, context, receiver, key, value);
32301cb0ef41Sopenharmony_ci  }
32311cb0ef41Sopenharmony_ci
32321cb0ef41Sopenharmony_ci  TNode<Object> CreateDataProperty(TNode<Context> context,
32331cb0ef41Sopenharmony_ci                                   TNode<JSObject> receiver, TNode<Object> key,
32341cb0ef41Sopenharmony_ci                                   TNode<Object> value) {
32351cb0ef41Sopenharmony_ci    return CallBuiltin(Builtin::kCreateDataProperty, context, receiver, key,
32361cb0ef41Sopenharmony_ci                       value);
32371cb0ef41Sopenharmony_ci  }
32381cb0ef41Sopenharmony_ci
32391cb0ef41Sopenharmony_ci  TNode<Object> GetMethod(TNode<Context> context, TNode<Object> object,
32401cb0ef41Sopenharmony_ci                          Handle<Name> name, Label* if_null_or_undefined);
32411cb0ef41Sopenharmony_ci
32421cb0ef41Sopenharmony_ci  TNode<Object> GetIteratorMethod(TNode<Context> context,
32431cb0ef41Sopenharmony_ci                                  TNode<HeapObject> heap_obj,
32441cb0ef41Sopenharmony_ci                                  Label* if_iteratorundefined);
32451cb0ef41Sopenharmony_ci
32461cb0ef41Sopenharmony_ci  TNode<Object> CreateAsyncFromSyncIterator(TNode<Context> context,
32471cb0ef41Sopenharmony_ci                                            TNode<Object> sync_iterator);
32481cb0ef41Sopenharmony_ci
32491cb0ef41Sopenharmony_ci  template <class... TArgs>
32501cb0ef41Sopenharmony_ci  TNode<Object> CallBuiltin(Builtin id, TNode<Object> context, TArgs... args) {
32511cb0ef41Sopenharmony_ci    return CallStub<Object>(Builtins::CallableFor(isolate(), id), context,
32521cb0ef41Sopenharmony_ci                            args...);
32531cb0ef41Sopenharmony_ci  }
32541cb0ef41Sopenharmony_ci
32551cb0ef41Sopenharmony_ci  template <class... TArgs>
32561cb0ef41Sopenharmony_ci  void TailCallBuiltin(Builtin id, TNode<Object> context, TArgs... args) {
32571cb0ef41Sopenharmony_ci    return TailCallStub(Builtins::CallableFor(isolate(), id), context, args...);
32581cb0ef41Sopenharmony_ci  }
32591cb0ef41Sopenharmony_ci
32601cb0ef41Sopenharmony_ci  void LoadPropertyFromFastObject(TNode<HeapObject> object, TNode<Map> map,
32611cb0ef41Sopenharmony_ci                                  TNode<DescriptorArray> descriptors,
32621cb0ef41Sopenharmony_ci                                  TNode<IntPtrT> name_index,
32631cb0ef41Sopenharmony_ci                                  TVariable<Uint32T>* var_details,
32641cb0ef41Sopenharmony_ci                                  TVariable<Object>* var_value);
32651cb0ef41Sopenharmony_ci
32661cb0ef41Sopenharmony_ci  void LoadPropertyFromFastObject(TNode<HeapObject> object, TNode<Map> map,
32671cb0ef41Sopenharmony_ci                                  TNode<DescriptorArray> descriptors,
32681cb0ef41Sopenharmony_ci                                  TNode<IntPtrT> name_index, TNode<Uint32T>,
32691cb0ef41Sopenharmony_ci                                  TVariable<Object>* var_value);
32701cb0ef41Sopenharmony_ci
32711cb0ef41Sopenharmony_ci  template <typename Dictionary>
32721cb0ef41Sopenharmony_ci  void LoadPropertyFromDictionary(TNode<Dictionary> dictionary,
32731cb0ef41Sopenharmony_ci                                  TNode<IntPtrT> name_index,
32741cb0ef41Sopenharmony_ci                                  TVariable<Uint32T>* var_details,
32751cb0ef41Sopenharmony_ci                                  TVariable<Object>* var_value);
32761cb0ef41Sopenharmony_ci  void LoadPropertyFromGlobalDictionary(TNode<GlobalDictionary> dictionary,
32771cb0ef41Sopenharmony_ci                                        TNode<IntPtrT> name_index,
32781cb0ef41Sopenharmony_ci                                        TVariable<Uint32T>* var_details,
32791cb0ef41Sopenharmony_ci                                        TVariable<Object>* var_value,
32801cb0ef41Sopenharmony_ci                                        Label* if_deleted);
32811cb0ef41Sopenharmony_ci
32821cb0ef41Sopenharmony_ci  // Generic property lookup generator. If the {object} is fast and
32831cb0ef41Sopenharmony_ci  // {unique_name} property is found then the control goes to {if_found_fast}
32841cb0ef41Sopenharmony_ci  // label and {var_meta_storage} and {var_name_index} will contain
32851cb0ef41Sopenharmony_ci  // DescriptorArray and an index of the descriptor's name respectively.
32861cb0ef41Sopenharmony_ci  // If the {object} is slow or global then the control goes to {if_found_dict}
32871cb0ef41Sopenharmony_ci  // or {if_found_global} and the {var_meta_storage} and {var_name_index} will
32881cb0ef41Sopenharmony_ci  // contain a dictionary and an index of the key field of the found entry.
32891cb0ef41Sopenharmony_ci  // If property is not found or given lookup is not supported then
32901cb0ef41Sopenharmony_ci  // the control goes to {if_not_found} or {if_bailout} respectively.
32911cb0ef41Sopenharmony_ci  //
32921cb0ef41Sopenharmony_ci  // Note: this code does not check if the global dictionary points to deleted
32931cb0ef41Sopenharmony_ci  // entry! This has to be done by the caller.
32941cb0ef41Sopenharmony_ci  void TryLookupProperty(TNode<HeapObject> object, TNode<Map> map,
32951cb0ef41Sopenharmony_ci                         TNode<Int32T> instance_type, TNode<Name> unique_name,
32961cb0ef41Sopenharmony_ci                         Label* if_found_fast, Label* if_found_dict,
32971cb0ef41Sopenharmony_ci                         Label* if_found_global,
32981cb0ef41Sopenharmony_ci                         TVariable<HeapObject>* var_meta_storage,
32991cb0ef41Sopenharmony_ci                         TVariable<IntPtrT>* var_name_index,
33001cb0ef41Sopenharmony_ci                         Label* if_not_found, Label* if_bailout);
33011cb0ef41Sopenharmony_ci
33021cb0ef41Sopenharmony_ci  // This is a building block for TryLookupProperty() above. Supports only
33031cb0ef41Sopenharmony_ci  // non-special fast and dictionary objects.
33041cb0ef41Sopenharmony_ci  // TODO(v8:11167, v8:11177) |bailout| only needed for SetDataProperties
33051cb0ef41Sopenharmony_ci  // workaround.
33061cb0ef41Sopenharmony_ci  void TryLookupPropertyInSimpleObject(TNode<JSObject> object, TNode<Map> map,
33071cb0ef41Sopenharmony_ci                                       TNode<Name> unique_name,
33081cb0ef41Sopenharmony_ci                                       Label* if_found_fast,
33091cb0ef41Sopenharmony_ci                                       Label* if_found_dict,
33101cb0ef41Sopenharmony_ci                                       TVariable<HeapObject>* var_meta_storage,
33111cb0ef41Sopenharmony_ci                                       TVariable<IntPtrT>* var_name_index,
33121cb0ef41Sopenharmony_ci                                       Label* if_not_found, Label* bailout);
33131cb0ef41Sopenharmony_ci
33141cb0ef41Sopenharmony_ci  // This method jumps to if_found if the element is known to exist. To
33151cb0ef41Sopenharmony_ci  // if_absent if it's known to not exist. To if_not_found if the prototype
33161cb0ef41Sopenharmony_ci  // chain needs to be checked. And if_bailout if the lookup is unsupported.
33171cb0ef41Sopenharmony_ci  void TryLookupElement(TNode<HeapObject> object, TNode<Map> map,
33181cb0ef41Sopenharmony_ci                        TNode<Int32T> instance_type,
33191cb0ef41Sopenharmony_ci                        TNode<IntPtrT> intptr_index, Label* if_found,
33201cb0ef41Sopenharmony_ci                        Label* if_absent, Label* if_not_found,
33211cb0ef41Sopenharmony_ci                        Label* if_bailout);
33221cb0ef41Sopenharmony_ci
33231cb0ef41Sopenharmony_ci  // For integer indexed exotic cases, check if the given string cannot be a
33241cb0ef41Sopenharmony_ci  // special index. If we are not sure that the given string is not a special
33251cb0ef41Sopenharmony_ci  // index with a simple check, return False. Note that "False" return value
33261cb0ef41Sopenharmony_ci  // does not mean that the name_string is a special index in the current
33271cb0ef41Sopenharmony_ci  // implementation.
33281cb0ef41Sopenharmony_ci  void BranchIfMaybeSpecialIndex(TNode<String> name_string,
33291cb0ef41Sopenharmony_ci                                 Label* if_maybe_special_index,
33301cb0ef41Sopenharmony_ci                                 Label* if_not_special_index);
33311cb0ef41Sopenharmony_ci
33321cb0ef41Sopenharmony_ci  // This is a type of a lookup property in holder generator function. The {key}
33331cb0ef41Sopenharmony_ci  // is guaranteed to be an unique name.
33341cb0ef41Sopenharmony_ci  using LookupPropertyInHolder = std::function<void(
33351cb0ef41Sopenharmony_ci      TNode<HeapObject> receiver, TNode<HeapObject> holder, TNode<Map> map,
33361cb0ef41Sopenharmony_ci      TNode<Int32T> instance_type, TNode<Name> key, Label* next_holder,
33371cb0ef41Sopenharmony_ci      Label* if_bailout)>;
33381cb0ef41Sopenharmony_ci
33391cb0ef41Sopenharmony_ci  // This is a type of a lookup element in holder generator function. The {key}
33401cb0ef41Sopenharmony_ci  // is an Int32 index.
33411cb0ef41Sopenharmony_ci  using LookupElementInHolder = std::function<void(
33421cb0ef41Sopenharmony_ci      TNode<HeapObject> receiver, TNode<HeapObject> holder, TNode<Map> map,
33431cb0ef41Sopenharmony_ci      TNode<Int32T> instance_type, TNode<IntPtrT> key, Label* next_holder,
33441cb0ef41Sopenharmony_ci      Label* if_bailout)>;
33451cb0ef41Sopenharmony_ci
33461cb0ef41Sopenharmony_ci  // Generic property prototype chain lookup generator.
33471cb0ef41Sopenharmony_ci  // For properties it generates lookup using given {lookup_property_in_holder}
33481cb0ef41Sopenharmony_ci  // and for elements it uses {lookup_element_in_holder}.
33491cb0ef41Sopenharmony_ci  // Upon reaching the end of prototype chain the control goes to {if_end}.
33501cb0ef41Sopenharmony_ci  // If it can't handle the case {receiver}/{key} case then the control goes
33511cb0ef41Sopenharmony_ci  // to {if_bailout}.
33521cb0ef41Sopenharmony_ci  // If {if_proxy} is nullptr, proxies go to if_bailout.
33531cb0ef41Sopenharmony_ci  void TryPrototypeChainLookup(
33541cb0ef41Sopenharmony_ci      TNode<Object> receiver, TNode<Object> object, TNode<Object> key,
33551cb0ef41Sopenharmony_ci      const LookupPropertyInHolder& lookup_property_in_holder,
33561cb0ef41Sopenharmony_ci      const LookupElementInHolder& lookup_element_in_holder, Label* if_end,
33571cb0ef41Sopenharmony_ci      Label* if_bailout, Label* if_proxy, bool handle_private_names = false);
33581cb0ef41Sopenharmony_ci
33591cb0ef41Sopenharmony_ci  // Instanceof helpers.
33601cb0ef41Sopenharmony_ci  // Returns true if {object} has {prototype} somewhere in it's prototype
33611cb0ef41Sopenharmony_ci  // chain, otherwise false is returned. Might cause arbitrary side effects
33621cb0ef41Sopenharmony_ci  // due to [[GetPrototypeOf]] invocations.
33631cb0ef41Sopenharmony_ci  TNode<Oddball> HasInPrototypeChain(TNode<Context> context,
33641cb0ef41Sopenharmony_ci                                     TNode<HeapObject> object,
33651cb0ef41Sopenharmony_ci                                     TNode<Object> prototype);
33661cb0ef41Sopenharmony_ci  // ES6 section 7.3.19 OrdinaryHasInstance (C, O)
33671cb0ef41Sopenharmony_ci  TNode<Oddball> OrdinaryHasInstance(TNode<Context> context,
33681cb0ef41Sopenharmony_ci                                     TNode<Object> callable,
33691cb0ef41Sopenharmony_ci                                     TNode<Object> object);
33701cb0ef41Sopenharmony_ci
33711cb0ef41Sopenharmony_ci  // Load type feedback vector from the stub caller's frame.
33721cb0ef41Sopenharmony_ci  TNode<FeedbackVector> LoadFeedbackVectorForStub();
33731cb0ef41Sopenharmony_ci  TNode<FeedbackVector> LoadFeedbackVectorFromBaseline();
33741cb0ef41Sopenharmony_ci  TNode<Context> LoadContextFromBaseline();
33751cb0ef41Sopenharmony_ci  // Load type feedback vector from the stub caller's frame, skipping an
33761cb0ef41Sopenharmony_ci  // intermediate trampoline frame.
33771cb0ef41Sopenharmony_ci  TNode<FeedbackVector> LoadFeedbackVectorForStubWithTrampoline();
33781cb0ef41Sopenharmony_ci
33791cb0ef41Sopenharmony_ci  // Load the value from closure's feedback cell.
33801cb0ef41Sopenharmony_ci  TNode<HeapObject> LoadFeedbackCellValue(TNode<JSFunction> closure);
33811cb0ef41Sopenharmony_ci
33821cb0ef41Sopenharmony_ci  // Load the object from feedback vector cell for the given closure.
33831cb0ef41Sopenharmony_ci  // The returned object could be undefined if the closure does not have
33841cb0ef41Sopenharmony_ci  // a feedback vector associated with it.
33851cb0ef41Sopenharmony_ci  TNode<HeapObject> LoadFeedbackVector(TNode<JSFunction> closure);
33861cb0ef41Sopenharmony_ci
33871cb0ef41Sopenharmony_ci  // Load the ClosureFeedbackCellArray that contains the feedback cells
33881cb0ef41Sopenharmony_ci  // used when creating closures from this function. This array could be
33891cb0ef41Sopenharmony_ci  // directly hanging off the FeedbackCell when there is no feedback vector
33901cb0ef41Sopenharmony_ci  // or available from the feedback vector's header.
33911cb0ef41Sopenharmony_ci  TNode<ClosureFeedbackCellArray> LoadClosureFeedbackArray(
33921cb0ef41Sopenharmony_ci      TNode<JSFunction> closure);
33931cb0ef41Sopenharmony_ci
33941cb0ef41Sopenharmony_ci  // Update the type feedback vector.
33951cb0ef41Sopenharmony_ci  bool UpdateFeedbackModeEqual(UpdateFeedbackMode a, UpdateFeedbackMode b) {
33961cb0ef41Sopenharmony_ci    return a == b;
33971cb0ef41Sopenharmony_ci  }
33981cb0ef41Sopenharmony_ci  void UpdateFeedback(TNode<Smi> feedback,
33991cb0ef41Sopenharmony_ci                      TNode<HeapObject> maybe_feedback_vector,
34001cb0ef41Sopenharmony_ci                      TNode<UintPtrT> slot_id, UpdateFeedbackMode mode);
34011cb0ef41Sopenharmony_ci  void UpdateFeedback(TNode<Smi> feedback,
34021cb0ef41Sopenharmony_ci                      TNode<FeedbackVector> feedback_vector,
34031cb0ef41Sopenharmony_ci                      TNode<UintPtrT> slot_id);
34041cb0ef41Sopenharmony_ci  void MaybeUpdateFeedback(TNode<Smi> feedback,
34051cb0ef41Sopenharmony_ci                           TNode<HeapObject> maybe_feedback_vector,
34061cb0ef41Sopenharmony_ci                           TNode<UintPtrT> slot_id);
34071cb0ef41Sopenharmony_ci
34081cb0ef41Sopenharmony_ci  // Report that there was a feedback update, performing any tasks that should
34091cb0ef41Sopenharmony_ci  // be done after a feedback update.
34101cb0ef41Sopenharmony_ci  void ReportFeedbackUpdate(TNode<FeedbackVector> feedback_vector,
34111cb0ef41Sopenharmony_ci                            TNode<UintPtrT> slot_id, const char* reason);
34121cb0ef41Sopenharmony_ci
34131cb0ef41Sopenharmony_ci  // Combine the new feedback with the existing_feedback. Do nothing if
34141cb0ef41Sopenharmony_ci  // existing_feedback is nullptr.
34151cb0ef41Sopenharmony_ci  void CombineFeedback(TVariable<Smi>* existing_feedback, int feedback);
34161cb0ef41Sopenharmony_ci  void CombineFeedback(TVariable<Smi>* existing_feedback, TNode<Smi> feedback);
34171cb0ef41Sopenharmony_ci
34181cb0ef41Sopenharmony_ci  // Overwrite the existing feedback with new_feedback. Do nothing if
34191cb0ef41Sopenharmony_ci  // existing_feedback is nullptr.
34201cb0ef41Sopenharmony_ci  void OverwriteFeedback(TVariable<Smi>* existing_feedback, int new_feedback);
34211cb0ef41Sopenharmony_ci
34221cb0ef41Sopenharmony_ci  // Check if a property name might require protector invalidation when it is
34231cb0ef41Sopenharmony_ci  // used for a property store or deletion.
34241cb0ef41Sopenharmony_ci  void CheckForAssociatedProtector(TNode<Name> name, Label* if_protector);
34251cb0ef41Sopenharmony_ci
34261cb0ef41Sopenharmony_ci  TNode<Map> LoadReceiverMap(TNode<Object> receiver);
34271cb0ef41Sopenharmony_ci
34281cb0ef41Sopenharmony_ci  // Loads script context from the script context table.
34291cb0ef41Sopenharmony_ci  TNode<Context> LoadScriptContext(TNode<Context> context,
34301cb0ef41Sopenharmony_ci                                   TNode<IntPtrT> context_index);
34311cb0ef41Sopenharmony_ci
34321cb0ef41Sopenharmony_ci  TNode<Uint8T> Int32ToUint8Clamped(TNode<Int32T> int32_value);
34331cb0ef41Sopenharmony_ci  TNode<Uint8T> Float64ToUint8Clamped(TNode<Float64T> float64_value);
34341cb0ef41Sopenharmony_ci
34351cb0ef41Sopenharmony_ci  template <typename T>
34361cb0ef41Sopenharmony_ci  TNode<T> PrepareValueForWriteToTypedArray(TNode<Object> input,
34371cb0ef41Sopenharmony_ci                                            ElementsKind elements_kind,
34381cb0ef41Sopenharmony_ci                                            TNode<Context> context);
34391cb0ef41Sopenharmony_ci
34401cb0ef41Sopenharmony_ci  // Store value to an elements array with given elements kind.
34411cb0ef41Sopenharmony_ci  // TODO(turbofan): For BIGINT64_ELEMENTS and BIGUINT64_ELEMENTS
34421cb0ef41Sopenharmony_ci  // we pass {value} as BigInt object instead of int64_t. We should
34431cb0ef41Sopenharmony_ci  // teach TurboFan to handle int64_t on 32-bit platforms eventually.
34441cb0ef41Sopenharmony_ci  template <typename TIndex, typename TValue>
34451cb0ef41Sopenharmony_ci  void StoreElement(TNode<RawPtrT> elements, ElementsKind kind,
34461cb0ef41Sopenharmony_ci                    TNode<TIndex> index, TNode<TValue> value);
34471cb0ef41Sopenharmony_ci
34481cb0ef41Sopenharmony_ci  // Implements the BigInt part of
34491cb0ef41Sopenharmony_ci  // https://tc39.github.io/proposal-bigint/#sec-numbertorawbytes,
34501cb0ef41Sopenharmony_ci  // including truncation to 64 bits (i.e. modulo 2^64).
34511cb0ef41Sopenharmony_ci  // {var_high} is only used on 32-bit platforms.
34521cb0ef41Sopenharmony_ci  void BigIntToRawBytes(TNode<BigInt> bigint, TVariable<UintPtrT>* var_low,
34531cb0ef41Sopenharmony_ci                        TVariable<UintPtrT>* var_high);
34541cb0ef41Sopenharmony_ci
34551cb0ef41Sopenharmony_ci  void EmitElementStore(TNode<JSObject> object, TNode<Object> key,
34561cb0ef41Sopenharmony_ci                        TNode<Object> value, ElementsKind elements_kind,
34571cb0ef41Sopenharmony_ci                        KeyedAccessStoreMode store_mode, Label* bailout,
34581cb0ef41Sopenharmony_ci                        TNode<Context> context,
34591cb0ef41Sopenharmony_ci                        TVariable<Object>* maybe_converted_value = nullptr);
34601cb0ef41Sopenharmony_ci
34611cb0ef41Sopenharmony_ci  TNode<FixedArrayBase> CheckForCapacityGrow(
34621cb0ef41Sopenharmony_ci      TNode<JSObject> object, TNode<FixedArrayBase> elements, ElementsKind kind,
34631cb0ef41Sopenharmony_ci      TNode<UintPtrT> length, TNode<IntPtrT> key, Label* bailout);
34641cb0ef41Sopenharmony_ci
34651cb0ef41Sopenharmony_ci  TNode<FixedArrayBase> CopyElementsOnWrite(TNode<HeapObject> object,
34661cb0ef41Sopenharmony_ci                                            TNode<FixedArrayBase> elements,
34671cb0ef41Sopenharmony_ci                                            ElementsKind kind,
34681cb0ef41Sopenharmony_ci                                            TNode<IntPtrT> length,
34691cb0ef41Sopenharmony_ci                                            Label* bailout);
34701cb0ef41Sopenharmony_ci
34711cb0ef41Sopenharmony_ci  void TransitionElementsKind(TNode<JSObject> object, TNode<Map> map,
34721cb0ef41Sopenharmony_ci                              ElementsKind from_kind, ElementsKind to_kind,
34731cb0ef41Sopenharmony_ci                              Label* bailout);
34741cb0ef41Sopenharmony_ci
34751cb0ef41Sopenharmony_ci  void TrapAllocationMemento(TNode<JSObject> object, Label* memento_found);
34761cb0ef41Sopenharmony_ci
34771cb0ef41Sopenharmony_ci  TNode<IntPtrT> PageFromAddress(TNode<IntPtrT> address);
34781cb0ef41Sopenharmony_ci
34791cb0ef41Sopenharmony_ci  // Store a weak in-place reference into the FeedbackVector.
34801cb0ef41Sopenharmony_ci  TNode<MaybeObject> StoreWeakReferenceInFeedbackVector(
34811cb0ef41Sopenharmony_ci      TNode<FeedbackVector> feedback_vector, TNode<UintPtrT> slot,
34821cb0ef41Sopenharmony_ci      TNode<HeapObject> value, int additional_offset = 0);
34831cb0ef41Sopenharmony_ci
34841cb0ef41Sopenharmony_ci  // Create a new AllocationSite and install it into a feedback vector.
34851cb0ef41Sopenharmony_ci  TNode<AllocationSite> CreateAllocationSiteInFeedbackVector(
34861cb0ef41Sopenharmony_ci      TNode<FeedbackVector> feedback_vector, TNode<UintPtrT> slot);
34871cb0ef41Sopenharmony_ci
34881cb0ef41Sopenharmony_ci  TNode<BoolT> HasBoilerplate(TNode<Object> maybe_literal_site);
34891cb0ef41Sopenharmony_ci  TNode<Smi> LoadTransitionInfo(TNode<AllocationSite> allocation_site);
34901cb0ef41Sopenharmony_ci  TNode<JSObject> LoadBoilerplate(TNode<AllocationSite> allocation_site);
34911cb0ef41Sopenharmony_ci  TNode<Int32T> LoadElementsKind(TNode<AllocationSite> allocation_site);
34921cb0ef41Sopenharmony_ci
34931cb0ef41Sopenharmony_ci  enum class IndexAdvanceMode { kPre, kPost };
34941cb0ef41Sopenharmony_ci
34951cb0ef41Sopenharmony_ci  template <typename TIndex>
34961cb0ef41Sopenharmony_ci  using FastLoopBody = std::function<void(TNode<TIndex> index)>;
34971cb0ef41Sopenharmony_ci
34981cb0ef41Sopenharmony_ci  template <typename TIndex>
34991cb0ef41Sopenharmony_ci  TNode<TIndex> BuildFastLoop(
35001cb0ef41Sopenharmony_ci      const VariableList& var_list, TNode<TIndex> start_index,
35011cb0ef41Sopenharmony_ci      TNode<TIndex> end_index, const FastLoopBody<TIndex>& body, int increment,
35021cb0ef41Sopenharmony_ci      IndexAdvanceMode advance_mode = IndexAdvanceMode::kPre);
35031cb0ef41Sopenharmony_ci
35041cb0ef41Sopenharmony_ci  template <typename TIndex>
35051cb0ef41Sopenharmony_ci  TNode<TIndex> BuildFastLoop(
35061cb0ef41Sopenharmony_ci      TNode<TIndex> start_index, TNode<TIndex> end_index,
35071cb0ef41Sopenharmony_ci      const FastLoopBody<TIndex>& body, int increment,
35081cb0ef41Sopenharmony_ci      IndexAdvanceMode advance_mode = IndexAdvanceMode::kPre) {
35091cb0ef41Sopenharmony_ci    return BuildFastLoop(VariableList(0, zone()), start_index, end_index, body,
35101cb0ef41Sopenharmony_ci                         increment, advance_mode);
35111cb0ef41Sopenharmony_ci  }
35121cb0ef41Sopenharmony_ci
35131cb0ef41Sopenharmony_ci  enum class ForEachDirection { kForward, kReverse };
35141cb0ef41Sopenharmony_ci
35151cb0ef41Sopenharmony_ci  using FastArrayForEachBody =
35161cb0ef41Sopenharmony_ci      std::function<void(TNode<HeapObject> array, TNode<IntPtrT> offset)>;
35171cb0ef41Sopenharmony_ci
35181cb0ef41Sopenharmony_ci  template <typename TIndex>
35191cb0ef41Sopenharmony_ci  void BuildFastArrayForEach(
35201cb0ef41Sopenharmony_ci      TNode<UnionT<UnionT<FixedArray, PropertyArray>, HeapObject>> array,
35211cb0ef41Sopenharmony_ci      ElementsKind kind, TNode<TIndex> first_element_inclusive,
35221cb0ef41Sopenharmony_ci      TNode<TIndex> last_element_exclusive, const FastArrayForEachBody& body,
35231cb0ef41Sopenharmony_ci      ForEachDirection direction = ForEachDirection::kReverse);
35241cb0ef41Sopenharmony_ci
35251cb0ef41Sopenharmony_ci  template <typename TIndex>
35261cb0ef41Sopenharmony_ci  TNode<IntPtrT> GetArrayAllocationSize(TNode<TIndex> element_count,
35271cb0ef41Sopenharmony_ci                                        ElementsKind kind, int header_size) {
35281cb0ef41Sopenharmony_ci    return ElementOffsetFromIndex(element_count, kind, header_size);
35291cb0ef41Sopenharmony_ci  }
35301cb0ef41Sopenharmony_ci
35311cb0ef41Sopenharmony_ci  template <typename TIndex>
35321cb0ef41Sopenharmony_ci  TNode<IntPtrT> GetFixedArrayAllocationSize(TNode<TIndex> element_count,
35331cb0ef41Sopenharmony_ci                                             ElementsKind kind) {
35341cb0ef41Sopenharmony_ci    return GetArrayAllocationSize(element_count, kind, FixedArray::kHeaderSize);
35351cb0ef41Sopenharmony_ci  }
35361cb0ef41Sopenharmony_ci
35371cb0ef41Sopenharmony_ci  TNode<IntPtrT> GetPropertyArrayAllocationSize(TNode<IntPtrT> element_count) {
35381cb0ef41Sopenharmony_ci    return GetArrayAllocationSize(element_count, PACKED_ELEMENTS,
35391cb0ef41Sopenharmony_ci                                  PropertyArray::kHeaderSize);
35401cb0ef41Sopenharmony_ci  }
35411cb0ef41Sopenharmony_ci
35421cb0ef41Sopenharmony_ci  template <typename TIndex>
35431cb0ef41Sopenharmony_ci  void GotoIfFixedArraySizeDoesntFitInNewSpace(TNode<TIndex> element_count,
35441cb0ef41Sopenharmony_ci                                               Label* doesnt_fit,
35451cb0ef41Sopenharmony_ci                                               int base_size);
35461cb0ef41Sopenharmony_ci
35471cb0ef41Sopenharmony_ci  void InitializeFieldsWithRoot(TNode<HeapObject> object,
35481cb0ef41Sopenharmony_ci                                TNode<IntPtrT> start_offset,
35491cb0ef41Sopenharmony_ci                                TNode<IntPtrT> end_offset, RootIndex root);
35501cb0ef41Sopenharmony_ci
35511cb0ef41Sopenharmony_ci  // Goto the given |target| if the context chain starting at |context| has any
35521cb0ef41Sopenharmony_ci  // extensions up to the given |depth|. Returns the Context with the
35531cb0ef41Sopenharmony_ci  // extensions if there was one, otherwise returns the Context at the given
35541cb0ef41Sopenharmony_ci  // |depth|.
35551cb0ef41Sopenharmony_ci  TNode<Context> GotoIfHasContextExtensionUpToDepth(TNode<Context> context,
35561cb0ef41Sopenharmony_ci                                                    TNode<Uint32T> depth,
35571cb0ef41Sopenharmony_ci                                                    Label* target);
35581cb0ef41Sopenharmony_ci
35591cb0ef41Sopenharmony_ci  TNode<Oddball> RelationalComparison(
35601cb0ef41Sopenharmony_ci      Operation op, TNode<Object> left, TNode<Object> right,
35611cb0ef41Sopenharmony_ci      TNode<Context> context, TVariable<Smi>* var_type_feedback = nullptr) {
35621cb0ef41Sopenharmony_ci    return RelationalComparison(
35631cb0ef41Sopenharmony_ci        op, left, right, [=]() { return context; }, var_type_feedback);
35641cb0ef41Sopenharmony_ci  }
35651cb0ef41Sopenharmony_ci
35661cb0ef41Sopenharmony_ci  TNode<Oddball> RelationalComparison(
35671cb0ef41Sopenharmony_ci      Operation op, TNode<Object> left, TNode<Object> right,
35681cb0ef41Sopenharmony_ci      const LazyNode<Context>& context,
35691cb0ef41Sopenharmony_ci      TVariable<Smi>* var_type_feedback = nullptr);
35701cb0ef41Sopenharmony_ci
35711cb0ef41Sopenharmony_ci  void BranchIfNumberRelationalComparison(Operation op, TNode<Number> left,
35721cb0ef41Sopenharmony_ci                                          TNode<Number> right, Label* if_true,
35731cb0ef41Sopenharmony_ci                                          Label* if_false);
35741cb0ef41Sopenharmony_ci
35751cb0ef41Sopenharmony_ci  void BranchIfNumberEqual(TNode<Number> left, TNode<Number> right,
35761cb0ef41Sopenharmony_ci                           Label* if_true, Label* if_false) {
35771cb0ef41Sopenharmony_ci    BranchIfNumberRelationalComparison(Operation::kEqual, left, right, if_true,
35781cb0ef41Sopenharmony_ci                                       if_false);
35791cb0ef41Sopenharmony_ci  }
35801cb0ef41Sopenharmony_ci
35811cb0ef41Sopenharmony_ci  void BranchIfNumberNotEqual(TNode<Number> left, TNode<Number> right,
35821cb0ef41Sopenharmony_ci                              Label* if_true, Label* if_false) {
35831cb0ef41Sopenharmony_ci    BranchIfNumberEqual(left, right, if_false, if_true);
35841cb0ef41Sopenharmony_ci  }
35851cb0ef41Sopenharmony_ci
35861cb0ef41Sopenharmony_ci  void BranchIfNumberLessThan(TNode<Number> left, TNode<Number> right,
35871cb0ef41Sopenharmony_ci                              Label* if_true, Label* if_false) {
35881cb0ef41Sopenharmony_ci    BranchIfNumberRelationalComparison(Operation::kLessThan, left, right,
35891cb0ef41Sopenharmony_ci                                       if_true, if_false);
35901cb0ef41Sopenharmony_ci  }
35911cb0ef41Sopenharmony_ci
35921cb0ef41Sopenharmony_ci  void BranchIfNumberLessThanOrEqual(TNode<Number> left, TNode<Number> right,
35931cb0ef41Sopenharmony_ci                                     Label* if_true, Label* if_false) {
35941cb0ef41Sopenharmony_ci    BranchIfNumberRelationalComparison(Operation::kLessThanOrEqual, left, right,
35951cb0ef41Sopenharmony_ci                                       if_true, if_false);
35961cb0ef41Sopenharmony_ci  }
35971cb0ef41Sopenharmony_ci
35981cb0ef41Sopenharmony_ci  void BranchIfNumberGreaterThan(TNode<Number> left, TNode<Number> right,
35991cb0ef41Sopenharmony_ci                                 Label* if_true, Label* if_false) {
36001cb0ef41Sopenharmony_ci    BranchIfNumberRelationalComparison(Operation::kGreaterThan, left, right,
36011cb0ef41Sopenharmony_ci                                       if_true, if_false);
36021cb0ef41Sopenharmony_ci  }
36031cb0ef41Sopenharmony_ci
36041cb0ef41Sopenharmony_ci  void BranchIfNumberGreaterThanOrEqual(TNode<Number> left, TNode<Number> right,
36051cb0ef41Sopenharmony_ci                                        Label* if_true, Label* if_false) {
36061cb0ef41Sopenharmony_ci    BranchIfNumberRelationalComparison(Operation::kGreaterThanOrEqual, left,
36071cb0ef41Sopenharmony_ci                                       right, if_true, if_false);
36081cb0ef41Sopenharmony_ci  }
36091cb0ef41Sopenharmony_ci
36101cb0ef41Sopenharmony_ci  void BranchIfAccessorPair(TNode<Object> value, Label* if_accessor_pair,
36111cb0ef41Sopenharmony_ci                            Label* if_not_accessor_pair) {
36121cb0ef41Sopenharmony_ci    GotoIf(TaggedIsSmi(value), if_not_accessor_pair);
36131cb0ef41Sopenharmony_ci    Branch(IsAccessorPair(CAST(value)), if_accessor_pair, if_not_accessor_pair);
36141cb0ef41Sopenharmony_ci  }
36151cb0ef41Sopenharmony_ci
36161cb0ef41Sopenharmony_ci  void GotoIfNumberGreaterThanOrEqual(TNode<Number> left, TNode<Number> right,
36171cb0ef41Sopenharmony_ci                                      Label* if_false);
36181cb0ef41Sopenharmony_ci
36191cb0ef41Sopenharmony_ci  TNode<Oddball> Equal(TNode<Object> lhs, TNode<Object> rhs,
36201cb0ef41Sopenharmony_ci                       TNode<Context> context,
36211cb0ef41Sopenharmony_ci                       TVariable<Smi>* var_type_feedback = nullptr) {
36221cb0ef41Sopenharmony_ci    return Equal(
36231cb0ef41Sopenharmony_ci        lhs, rhs, [=]() { return context; }, var_type_feedback);
36241cb0ef41Sopenharmony_ci  }
36251cb0ef41Sopenharmony_ci  TNode<Oddball> Equal(TNode<Object> lhs, TNode<Object> rhs,
36261cb0ef41Sopenharmony_ci                       const LazyNode<Context>& context,
36271cb0ef41Sopenharmony_ci                       TVariable<Smi>* var_type_feedback = nullptr);
36281cb0ef41Sopenharmony_ci
36291cb0ef41Sopenharmony_ci  TNode<Oddball> StrictEqual(TNode<Object> lhs, TNode<Object> rhs,
36301cb0ef41Sopenharmony_ci                             TVariable<Smi>* var_type_feedback = nullptr);
36311cb0ef41Sopenharmony_ci
36321cb0ef41Sopenharmony_ci  // ECMA#sec-samevalue
36331cb0ef41Sopenharmony_ci  // Similar to StrictEqual except that NaNs are treated as equal and minus zero
36341cb0ef41Sopenharmony_ci  // differs from positive zero.
36351cb0ef41Sopenharmony_ci  enum class SameValueMode { kNumbersOnly, kFull };
36361cb0ef41Sopenharmony_ci  void BranchIfSameValue(TNode<Object> lhs, TNode<Object> rhs, Label* if_true,
36371cb0ef41Sopenharmony_ci                         Label* if_false,
36381cb0ef41Sopenharmony_ci                         SameValueMode mode = SameValueMode::kFull);
36391cb0ef41Sopenharmony_ci  // A part of BranchIfSameValue() that handles two double values.
36401cb0ef41Sopenharmony_ci  // Treats NaN == NaN and +0 != -0.
36411cb0ef41Sopenharmony_ci  void BranchIfSameNumberValue(TNode<Float64T> lhs_value,
36421cb0ef41Sopenharmony_ci                               TNode<Float64T> rhs_value, Label* if_true,
36431cb0ef41Sopenharmony_ci                               Label* if_false);
36441cb0ef41Sopenharmony_ci
36451cb0ef41Sopenharmony_ci  enum HasPropertyLookupMode { kHasProperty, kForInHasProperty };
36461cb0ef41Sopenharmony_ci
36471cb0ef41Sopenharmony_ci  TNode<Oddball> HasProperty(TNode<Context> context, TNode<Object> object,
36481cb0ef41Sopenharmony_ci                             TNode<Object> key, HasPropertyLookupMode mode);
36491cb0ef41Sopenharmony_ci
36501cb0ef41Sopenharmony_ci  // Due to naming conflict with the builtin function namespace.
36511cb0ef41Sopenharmony_ci  TNode<Oddball> HasProperty_Inline(TNode<Context> context,
36521cb0ef41Sopenharmony_ci                                    TNode<JSReceiver> object,
36531cb0ef41Sopenharmony_ci                                    TNode<Object> key) {
36541cb0ef41Sopenharmony_ci    return HasProperty(context, object, key,
36551cb0ef41Sopenharmony_ci                       HasPropertyLookupMode::kHasProperty);
36561cb0ef41Sopenharmony_ci  }
36571cb0ef41Sopenharmony_ci
36581cb0ef41Sopenharmony_ci  void ForInPrepare(TNode<HeapObject> enumerator, TNode<UintPtrT> slot,
36591cb0ef41Sopenharmony_ci                    TNode<HeapObject> maybe_feedback_vector,
36601cb0ef41Sopenharmony_ci                    TNode<FixedArray>* cache_array_out,
36611cb0ef41Sopenharmony_ci                    TNode<Smi>* cache_length_out,
36621cb0ef41Sopenharmony_ci                    UpdateFeedbackMode update_feedback_mode);
36631cb0ef41Sopenharmony_ci
36641cb0ef41Sopenharmony_ci  TNode<String> Typeof(TNode<Object> value);
36651cb0ef41Sopenharmony_ci
36661cb0ef41Sopenharmony_ci  TNode<HeapObject> GetSuperConstructor(TNode<JSFunction> active_function);
36671cb0ef41Sopenharmony_ci
36681cb0ef41Sopenharmony_ci  TNode<JSReceiver> SpeciesConstructor(TNode<Context> context,
36691cb0ef41Sopenharmony_ci                                       TNode<Object> object,
36701cb0ef41Sopenharmony_ci                                       TNode<JSReceiver> default_constructor);
36711cb0ef41Sopenharmony_ci
36721cb0ef41Sopenharmony_ci  TNode<Oddball> InstanceOf(TNode<Object> object, TNode<Object> callable,
36731cb0ef41Sopenharmony_ci                            TNode<Context> context);
36741cb0ef41Sopenharmony_ci
36751cb0ef41Sopenharmony_ci  // Debug helpers
36761cb0ef41Sopenharmony_ci  TNode<BoolT> IsDebugActive();
36771cb0ef41Sopenharmony_ci  TNode<BoolT> IsSideEffectFreeDebuggingActive();
36781cb0ef41Sopenharmony_ci
36791cb0ef41Sopenharmony_ci  // JSArrayBuffer helpers
36801cb0ef41Sopenharmony_ci  TNode<RawPtrT> LoadJSArrayBufferBackingStorePtr(
36811cb0ef41Sopenharmony_ci      TNode<JSArrayBuffer> array_buffer);
36821cb0ef41Sopenharmony_ci  void ThrowIfArrayBufferIsDetached(TNode<Context> context,
36831cb0ef41Sopenharmony_ci                                    TNode<JSArrayBuffer> array_buffer,
36841cb0ef41Sopenharmony_ci                                    const char* method_name);
36851cb0ef41Sopenharmony_ci
36861cb0ef41Sopenharmony_ci  // JSArrayBufferView helpers
36871cb0ef41Sopenharmony_ci  TNode<JSArrayBuffer> LoadJSArrayBufferViewBuffer(
36881cb0ef41Sopenharmony_ci      TNode<JSArrayBufferView> array_buffer_view);
36891cb0ef41Sopenharmony_ci  TNode<UintPtrT> LoadJSArrayBufferViewByteLength(
36901cb0ef41Sopenharmony_ci      TNode<JSArrayBufferView> array_buffer_view);
36911cb0ef41Sopenharmony_ci
36921cb0ef41Sopenharmony_ci  TNode<UintPtrT> LoadJSArrayBufferViewByteOffset(
36931cb0ef41Sopenharmony_ci      TNode<JSArrayBufferView> array_buffer_view);
36941cb0ef41Sopenharmony_ci  void ThrowIfArrayBufferViewBufferIsDetached(
36951cb0ef41Sopenharmony_ci      TNode<Context> context, TNode<JSArrayBufferView> array_buffer_view,
36961cb0ef41Sopenharmony_ci      const char* method_name);
36971cb0ef41Sopenharmony_ci
36981cb0ef41Sopenharmony_ci  // JSTypedArray helpers
36991cb0ef41Sopenharmony_ci  TNode<UintPtrT> LoadJSTypedArrayLengthAndCheckDetached(
37001cb0ef41Sopenharmony_ci      TNode<JSTypedArray> typed_array, Label* detached);
37011cb0ef41Sopenharmony_ci  // Helper for length tracking JSTypedArrays and JSTypedArrays backed by
37021cb0ef41Sopenharmony_ci  // ResizableArrayBuffer.
37031cb0ef41Sopenharmony_ci  TNode<UintPtrT> LoadVariableLengthJSTypedArrayLength(
37041cb0ef41Sopenharmony_ci      TNode<JSTypedArray> array, TNode<JSArrayBuffer> buffer,
37051cb0ef41Sopenharmony_ci      Label* detached_or_out_of_bounds);
37061cb0ef41Sopenharmony_ci  // Helper for length tracking JSTypedArrays and JSTypedArrays backed by
37071cb0ef41Sopenharmony_ci  // ResizableArrayBuffer.
37081cb0ef41Sopenharmony_ci  TNode<UintPtrT> LoadVariableLengthJSTypedArrayByteLength(
37091cb0ef41Sopenharmony_ci      TNode<Context> context, TNode<JSTypedArray> array,
37101cb0ef41Sopenharmony_ci      TNode<JSArrayBuffer> buffer);
37111cb0ef41Sopenharmony_ci  TNode<UintPtrT> LoadVariableLengthJSArrayBufferViewByteLength(
37121cb0ef41Sopenharmony_ci      TNode<JSArrayBufferView> array, TNode<JSArrayBuffer> buffer,
37131cb0ef41Sopenharmony_ci      Label* detached_or_out_of_bounds);
37141cb0ef41Sopenharmony_ci
37151cb0ef41Sopenharmony_ci  void IsJSArrayBufferViewDetachedOrOutOfBounds(
37161cb0ef41Sopenharmony_ci      TNode<JSArrayBufferView> array_buffer_view, Label* detached_or_oob,
37171cb0ef41Sopenharmony_ci      Label* not_detached_nor_oob);
37181cb0ef41Sopenharmony_ci
37191cb0ef41Sopenharmony_ci  TNode<BoolT> IsJSArrayBufferViewDetachedOrOutOfBoundsBoolean(
37201cb0ef41Sopenharmony_ci      TNode<JSArrayBufferView> array_buffer_view);
37211cb0ef41Sopenharmony_ci
37221cb0ef41Sopenharmony_ci  void CheckJSTypedArrayIndex(TNode<UintPtrT> index,
37231cb0ef41Sopenharmony_ci                              TNode<JSTypedArray> typed_array,
37241cb0ef41Sopenharmony_ci                              Label* detached_or_out_of_bounds);
37251cb0ef41Sopenharmony_ci
37261cb0ef41Sopenharmony_ci  TNode<IntPtrT> RabGsabElementsKindToElementByteSize(
37271cb0ef41Sopenharmony_ci      TNode<Int32T> elementsKind);
37281cb0ef41Sopenharmony_ci  TNode<RawPtrT> LoadJSTypedArrayDataPtr(TNode<JSTypedArray> typed_array);
37291cb0ef41Sopenharmony_ci  TNode<JSArrayBuffer> GetTypedArrayBuffer(TNode<Context> context,
37301cb0ef41Sopenharmony_ci                                           TNode<JSTypedArray> array);
37311cb0ef41Sopenharmony_ci
37321cb0ef41Sopenharmony_ci  template <typename TIndex>
37331cb0ef41Sopenharmony_ci  TNode<IntPtrT> ElementOffsetFromIndex(TNode<TIndex> index, ElementsKind kind,
37341cb0ef41Sopenharmony_ci                                        int base_size = 0);
37351cb0ef41Sopenharmony_ci
37361cb0ef41Sopenharmony_ci  // Check that a field offset is within the bounds of the an object.
37371cb0ef41Sopenharmony_ci  TNode<BoolT> IsOffsetInBounds(TNode<IntPtrT> offset, TNode<IntPtrT> length,
37381cb0ef41Sopenharmony_ci                                int header_size,
37391cb0ef41Sopenharmony_ci                                ElementsKind kind = HOLEY_ELEMENTS);
37401cb0ef41Sopenharmony_ci
37411cb0ef41Sopenharmony_ci  // Load a builtin's code from the builtin array in the isolate.
37421cb0ef41Sopenharmony_ci  TNode<CodeT> LoadBuiltin(TNode<Smi> builtin_id);
37431cb0ef41Sopenharmony_ci
37441cb0ef41Sopenharmony_ci  // Figure out the SFI's code object using its data field.
37451cb0ef41Sopenharmony_ci  // If |data_type_out| is provided, the instance type of the function data will
37461cb0ef41Sopenharmony_ci  // be stored in it. In case the code object is a builtin (data is a Smi),
37471cb0ef41Sopenharmony_ci  // data_type_out will be set to 0.
37481cb0ef41Sopenharmony_ci  // If |if_compile_lazy| is provided then the execution will go to the given
37491cb0ef41Sopenharmony_ci  // label in case of an CompileLazy code object.
37501cb0ef41Sopenharmony_ci  TNode<CodeT> GetSharedFunctionInfoCode(
37511cb0ef41Sopenharmony_ci      TNode<SharedFunctionInfo> shared_info,
37521cb0ef41Sopenharmony_ci      TVariable<Uint16T>* data_type_out = nullptr,
37531cb0ef41Sopenharmony_ci      Label* if_compile_lazy = nullptr);
37541cb0ef41Sopenharmony_ci
37551cb0ef41Sopenharmony_ci  TNode<JSFunction> AllocateFunctionWithMapAndContext(
37561cb0ef41Sopenharmony_ci      TNode<Map> map, TNode<SharedFunctionInfo> shared_info,
37571cb0ef41Sopenharmony_ci      TNode<Context> context);
37581cb0ef41Sopenharmony_ci
37591cb0ef41Sopenharmony_ci  // Promise helpers
37601cb0ef41Sopenharmony_ci  TNode<Uint32T> PromiseHookFlags();
37611cb0ef41Sopenharmony_ci  TNode<BoolT> HasAsyncEventDelegate();
37621cb0ef41Sopenharmony_ci#ifdef V8_ENABLE_JAVASCRIPT_PROMISE_HOOKS
37631cb0ef41Sopenharmony_ci  TNode<BoolT> IsContextPromiseHookEnabled(TNode<Uint32T> flags);
37641cb0ef41Sopenharmony_ci#endif
37651cb0ef41Sopenharmony_ci  TNode<BoolT> IsIsolatePromiseHookEnabled(TNode<Uint32T> flags);
37661cb0ef41Sopenharmony_ci  TNode<BoolT> IsAnyPromiseHookEnabled(TNode<Uint32T> flags);
37671cb0ef41Sopenharmony_ci  TNode<BoolT> IsAnyPromiseHookEnabled() {
37681cb0ef41Sopenharmony_ci    return IsAnyPromiseHookEnabled(PromiseHookFlags());
37691cb0ef41Sopenharmony_ci  }
37701cb0ef41Sopenharmony_ci  TNode<BoolT> IsIsolatePromiseHookEnabledOrHasAsyncEventDelegate(
37711cb0ef41Sopenharmony_ci      TNode<Uint32T> flags);
37721cb0ef41Sopenharmony_ci  TNode<BoolT> IsIsolatePromiseHookEnabledOrHasAsyncEventDelegate() {
37731cb0ef41Sopenharmony_ci    return IsIsolatePromiseHookEnabledOrHasAsyncEventDelegate(
37741cb0ef41Sopenharmony_ci        PromiseHookFlags());
37751cb0ef41Sopenharmony_ci  }
37761cb0ef41Sopenharmony_ci  TNode<BoolT>
37771cb0ef41Sopenharmony_ci  IsIsolatePromiseHookEnabledOrDebugIsActiveOrHasAsyncEventDelegate(
37781cb0ef41Sopenharmony_ci      TNode<Uint32T> flags);
37791cb0ef41Sopenharmony_ci  TNode<BoolT>
37801cb0ef41Sopenharmony_ci  IsIsolatePromiseHookEnabledOrDebugIsActiveOrHasAsyncEventDelegate() {
37811cb0ef41Sopenharmony_ci    return IsIsolatePromiseHookEnabledOrDebugIsActiveOrHasAsyncEventDelegate(
37821cb0ef41Sopenharmony_ci        PromiseHookFlags());
37831cb0ef41Sopenharmony_ci  }
37841cb0ef41Sopenharmony_ci
37851cb0ef41Sopenharmony_ci  TNode<BoolT> NeedsAnyPromiseHooks(TNode<Uint32T> flags);
37861cb0ef41Sopenharmony_ci  TNode<BoolT> NeedsAnyPromiseHooks() {
37871cb0ef41Sopenharmony_ci    return NeedsAnyPromiseHooks(PromiseHookFlags());
37881cb0ef41Sopenharmony_ci  }
37891cb0ef41Sopenharmony_ci
37901cb0ef41Sopenharmony_ci  // for..in helpers
37911cb0ef41Sopenharmony_ci  void CheckPrototypeEnumCache(TNode<JSReceiver> receiver,
37921cb0ef41Sopenharmony_ci                               TNode<Map> receiver_map, Label* if_fast,
37931cb0ef41Sopenharmony_ci                               Label* if_slow);
37941cb0ef41Sopenharmony_ci  TNode<Map> CheckEnumCache(TNode<JSReceiver> receiver, Label* if_empty,
37951cb0ef41Sopenharmony_ci                            Label* if_runtime);
37961cb0ef41Sopenharmony_ci
37971cb0ef41Sopenharmony_ci  TNode<Object> GetArgumentValue(TorqueStructArguments args,
37981cb0ef41Sopenharmony_ci                                 TNode<IntPtrT> index);
37991cb0ef41Sopenharmony_ci
38001cb0ef41Sopenharmony_ci  enum class FrameArgumentsArgcType {
38011cb0ef41Sopenharmony_ci    kCountIncludesReceiver,
38021cb0ef41Sopenharmony_ci    kCountExcludesReceiver
38031cb0ef41Sopenharmony_ci  };
38041cb0ef41Sopenharmony_ci
38051cb0ef41Sopenharmony_ci  TorqueStructArguments GetFrameArguments(
38061cb0ef41Sopenharmony_ci      TNode<RawPtrT> frame, TNode<IntPtrT> argc,
38071cb0ef41Sopenharmony_ci      FrameArgumentsArgcType argc_type =
38081cb0ef41Sopenharmony_ci          FrameArgumentsArgcType::kCountExcludesReceiver);
38091cb0ef41Sopenharmony_ci
38101cb0ef41Sopenharmony_ci  inline TNode<Int32T> JSParameterCount(int argc_without_receiver) {
38111cb0ef41Sopenharmony_ci    return Int32Constant(argc_without_receiver + kJSArgcReceiverSlots);
38121cb0ef41Sopenharmony_ci  }
38131cb0ef41Sopenharmony_ci  inline TNode<Word32T> JSParameterCount(TNode<Word32T> argc_without_receiver) {
38141cb0ef41Sopenharmony_ci    return Int32Add(argc_without_receiver, Int32Constant(kJSArgcReceiverSlots));
38151cb0ef41Sopenharmony_ci  }
38161cb0ef41Sopenharmony_ci
38171cb0ef41Sopenharmony_ci  // Support for printf-style debugging
38181cb0ef41Sopenharmony_ci  void Print(const char* s);
38191cb0ef41Sopenharmony_ci  void Print(const char* prefix, TNode<MaybeObject> tagged_value);
38201cb0ef41Sopenharmony_ci  void Print(TNode<MaybeObject> tagged_value) {
38211cb0ef41Sopenharmony_ci    return Print(nullptr, tagged_value);
38221cb0ef41Sopenharmony_ci  }
38231cb0ef41Sopenharmony_ci
38241cb0ef41Sopenharmony_ci  template <class... TArgs>
38251cb0ef41Sopenharmony_ci  TNode<HeapObject> MakeTypeError(MessageTemplate message,
38261cb0ef41Sopenharmony_ci                                  TNode<Context> context, TArgs... args) {
38271cb0ef41Sopenharmony_ci    STATIC_ASSERT(sizeof...(TArgs) <= 3);
38281cb0ef41Sopenharmony_ci    return CAST(CallRuntime(Runtime::kNewTypeError, context,
38291cb0ef41Sopenharmony_ci                            SmiConstant(message), args...));
38301cb0ef41Sopenharmony_ci  }
38311cb0ef41Sopenharmony_ci
38321cb0ef41Sopenharmony_ci  void Abort(AbortReason reason) {
38331cb0ef41Sopenharmony_ci    CallRuntime(Runtime::kAbort, NoContextConstant(), SmiConstant(reason));
38341cb0ef41Sopenharmony_ci    Unreachable();
38351cb0ef41Sopenharmony_ci  }
38361cb0ef41Sopenharmony_ci
38371cb0ef41Sopenharmony_ci  bool ConstexprBoolNot(bool value) { return !value; }
38381cb0ef41Sopenharmony_ci  int31_t ConstexprIntegerLiteralToInt31(const IntegerLiteral& i) {
38391cb0ef41Sopenharmony_ci    return int31_t(i.To<int32_t>());
38401cb0ef41Sopenharmony_ci  }
38411cb0ef41Sopenharmony_ci  int32_t ConstexprIntegerLiteralToInt32(const IntegerLiteral& i) {
38421cb0ef41Sopenharmony_ci    return i.To<int32_t>();
38431cb0ef41Sopenharmony_ci  }
38441cb0ef41Sopenharmony_ci  uint32_t ConstexprIntegerLiteralToUint32(const IntegerLiteral& i) {
38451cb0ef41Sopenharmony_ci    return i.To<uint32_t>();
38461cb0ef41Sopenharmony_ci  }
38471cb0ef41Sopenharmony_ci  int8_t ConstexprIntegerLiteralToInt8(const IntegerLiteral& i) {
38481cb0ef41Sopenharmony_ci    return i.To<int8_t>();
38491cb0ef41Sopenharmony_ci  }
38501cb0ef41Sopenharmony_ci  uint8_t ConstexprIntegerLiteralToUint8(const IntegerLiteral& i) {
38511cb0ef41Sopenharmony_ci    return i.To<uint8_t>();
38521cb0ef41Sopenharmony_ci  }
38531cb0ef41Sopenharmony_ci  uint64_t ConstexprIntegerLiteralToUint64(const IntegerLiteral& i) {
38541cb0ef41Sopenharmony_ci    return i.To<uint64_t>();
38551cb0ef41Sopenharmony_ci  }
38561cb0ef41Sopenharmony_ci  intptr_t ConstexprIntegerLiteralToIntptr(const IntegerLiteral& i) {
38571cb0ef41Sopenharmony_ci    return i.To<intptr_t>();
38581cb0ef41Sopenharmony_ci  }
38591cb0ef41Sopenharmony_ci  uintptr_t ConstexprIntegerLiteralToUintptr(const IntegerLiteral& i) {
38601cb0ef41Sopenharmony_ci    return i.To<uintptr_t>();
38611cb0ef41Sopenharmony_ci  }
38621cb0ef41Sopenharmony_ci  double ConstexprIntegerLiteralToFloat64(const IntegerLiteral& i) {
38631cb0ef41Sopenharmony_ci    int64_t i_value = i.To<int64_t>();
38641cb0ef41Sopenharmony_ci    double d_value = static_cast<double>(i_value);
38651cb0ef41Sopenharmony_ci    CHECK_EQ(i_value, static_cast<int64_t>(d_value));
38661cb0ef41Sopenharmony_ci    return d_value;
38671cb0ef41Sopenharmony_ci  }
38681cb0ef41Sopenharmony_ci  bool ConstexprIntegerLiteralEqual(IntegerLiteral lhs, IntegerLiteral rhs) {
38691cb0ef41Sopenharmony_ci    return lhs == rhs;
38701cb0ef41Sopenharmony_ci  }
38711cb0ef41Sopenharmony_ci  IntegerLiteral ConstexprIntegerLiteralAdd(const IntegerLiteral& lhs,
38721cb0ef41Sopenharmony_ci                                            const IntegerLiteral& rhs);
38731cb0ef41Sopenharmony_ci  IntegerLiteral ConstexprIntegerLiteralLeftShift(const IntegerLiteral& lhs,
38741cb0ef41Sopenharmony_ci                                                  const IntegerLiteral& rhs);
38751cb0ef41Sopenharmony_ci  IntegerLiteral ConstexprIntegerLiteralBitwiseOr(const IntegerLiteral& lhs,
38761cb0ef41Sopenharmony_ci                                                  const IntegerLiteral& rhs);
38771cb0ef41Sopenharmony_ci
38781cb0ef41Sopenharmony_ci  bool ConstexprInt31Equal(int31_t a, int31_t b) { return a == b; }
38791cb0ef41Sopenharmony_ci  bool ConstexprInt31NotEqual(int31_t a, int31_t b) { return a != b; }
38801cb0ef41Sopenharmony_ci  bool ConstexprInt31GreaterThanEqual(int31_t a, int31_t b) { return a >= b; }
38811cb0ef41Sopenharmony_ci  bool ConstexprUint32Equal(uint32_t a, uint32_t b) { return a == b; }
38821cb0ef41Sopenharmony_ci  bool ConstexprUint32NotEqual(uint32_t a, uint32_t b) { return a != b; }
38831cb0ef41Sopenharmony_ci  bool ConstexprInt32Equal(int32_t a, int32_t b) { return a == b; }
38841cb0ef41Sopenharmony_ci  bool ConstexprInt32NotEqual(int32_t a, int32_t b) { return a != b; }
38851cb0ef41Sopenharmony_ci  bool ConstexprInt32GreaterThanEqual(int32_t a, int32_t b) { return a >= b; }
38861cb0ef41Sopenharmony_ci  uint32_t ConstexprUint32Add(uint32_t a, uint32_t b) { return a + b; }
38871cb0ef41Sopenharmony_ci  int32_t ConstexprUint32Sub(uint32_t a, uint32_t b) { return a - b; }
38881cb0ef41Sopenharmony_ci  int32_t ConstexprInt32Sub(int32_t a, int32_t b) { return a - b; }
38891cb0ef41Sopenharmony_ci  int32_t ConstexprInt32Add(int32_t a, int32_t b) { return a + b; }
38901cb0ef41Sopenharmony_ci  int31_t ConstexprInt31Add(int31_t a, int31_t b) {
38911cb0ef41Sopenharmony_ci    int32_t val;
38921cb0ef41Sopenharmony_ci    CHECK(!base::bits::SignedAddOverflow32(a, b, &val));
38931cb0ef41Sopenharmony_ci    return val;
38941cb0ef41Sopenharmony_ci  }
38951cb0ef41Sopenharmony_ci  int31_t ConstexprInt31Mul(int31_t a, int31_t b) {
38961cb0ef41Sopenharmony_ci    int32_t val;
38971cb0ef41Sopenharmony_ci    CHECK(!base::bits::SignedMulOverflow32(a, b, &val));
38981cb0ef41Sopenharmony_ci    return val;
38991cb0ef41Sopenharmony_ci  }
39001cb0ef41Sopenharmony_ci
39011cb0ef41Sopenharmony_ci  int32_t ConstexprWord32Or(int32_t a, int32_t b) { return a | b; }
39021cb0ef41Sopenharmony_ci  uint32_t ConstexprWord32Shl(uint32_t a, int32_t b) { return a << b; }
39031cb0ef41Sopenharmony_ci
39041cb0ef41Sopenharmony_ci  bool ConstexprUintPtrLessThan(uintptr_t a, uintptr_t b) { return a < b; }
39051cb0ef41Sopenharmony_ci
39061cb0ef41Sopenharmony_ci  // CSA does not support 64-bit types on 32-bit platforms so as a workaround
39071cb0ef41Sopenharmony_ci  // the kMaxSafeIntegerUint64 is defined as uintptr and allowed to be used only
39081cb0ef41Sopenharmony_ci  // inside if constexpr (Is64()) i.e. on 64-bit architectures.
39091cb0ef41Sopenharmony_ci  static uintptr_t MaxSafeIntegerUintPtr() {
39101cb0ef41Sopenharmony_ci#if defined(V8_HOST_ARCH_64_BIT)
39111cb0ef41Sopenharmony_ci    // This ifdef is required to avoid build issues on 32-bit MSVC which
39121cb0ef41Sopenharmony_ci    // complains about static_cast<uintptr_t>(kMaxSafeIntegerUint64).
39131cb0ef41Sopenharmony_ci    return kMaxSafeIntegerUint64;
39141cb0ef41Sopenharmony_ci#else
39151cb0ef41Sopenharmony_ci    UNREACHABLE();
39161cb0ef41Sopenharmony_ci#endif
39171cb0ef41Sopenharmony_ci  }
39181cb0ef41Sopenharmony_ci
39191cb0ef41Sopenharmony_ci  void PerformStackCheck(TNode<Context> context);
39201cb0ef41Sopenharmony_ci
39211cb0ef41Sopenharmony_ci  void SetPropertyLength(TNode<Context> context, TNode<Object> array,
39221cb0ef41Sopenharmony_ci                         TNode<Number> length);
39231cb0ef41Sopenharmony_ci
39241cb0ef41Sopenharmony_ci  // Implements DescriptorArray::Search().
39251cb0ef41Sopenharmony_ci  void DescriptorLookup(TNode<Name> unique_name,
39261cb0ef41Sopenharmony_ci                        TNode<DescriptorArray> descriptors,
39271cb0ef41Sopenharmony_ci                        TNode<Uint32T> bitfield3, Label* if_found,
39281cb0ef41Sopenharmony_ci                        TVariable<IntPtrT>* var_name_index,
39291cb0ef41Sopenharmony_ci                        Label* if_not_found);
39301cb0ef41Sopenharmony_ci
39311cb0ef41Sopenharmony_ci  // Implements TransitionArray::SearchName() - searches for first transition
39321cb0ef41Sopenharmony_ci  // entry with given name (note that there could be multiple entries with
39331cb0ef41Sopenharmony_ci  // the same name).
39341cb0ef41Sopenharmony_ci  void TransitionLookup(TNode<Name> unique_name,
39351cb0ef41Sopenharmony_ci                        TNode<TransitionArray> transitions, Label* if_found,
39361cb0ef41Sopenharmony_ci                        TVariable<IntPtrT>* var_name_index,
39371cb0ef41Sopenharmony_ci                        Label* if_not_found);
39381cb0ef41Sopenharmony_ci
39391cb0ef41Sopenharmony_ci  // Implements generic search procedure like i::Search<Array>().
39401cb0ef41Sopenharmony_ci  template <typename Array>
39411cb0ef41Sopenharmony_ci  void Lookup(TNode<Name> unique_name, TNode<Array> array,
39421cb0ef41Sopenharmony_ci              TNode<Uint32T> number_of_valid_entries, Label* if_found,
39431cb0ef41Sopenharmony_ci              TVariable<IntPtrT>* var_name_index, Label* if_not_found);
39441cb0ef41Sopenharmony_ci
39451cb0ef41Sopenharmony_ci  // Implements generic linear search procedure like i::LinearSearch<Array>().
39461cb0ef41Sopenharmony_ci  template <typename Array>
39471cb0ef41Sopenharmony_ci  void LookupLinear(TNode<Name> unique_name, TNode<Array> array,
39481cb0ef41Sopenharmony_ci                    TNode<Uint32T> number_of_valid_entries, Label* if_found,
39491cb0ef41Sopenharmony_ci                    TVariable<IntPtrT>* var_name_index, Label* if_not_found);
39501cb0ef41Sopenharmony_ci
39511cb0ef41Sopenharmony_ci  // Implements generic binary search procedure like i::BinarySearch<Array>().
39521cb0ef41Sopenharmony_ci  template <typename Array>
39531cb0ef41Sopenharmony_ci  void LookupBinary(TNode<Name> unique_name, TNode<Array> array,
39541cb0ef41Sopenharmony_ci                    TNode<Uint32T> number_of_valid_entries, Label* if_found,
39551cb0ef41Sopenharmony_ci                    TVariable<IntPtrT>* var_name_index, Label* if_not_found);
39561cb0ef41Sopenharmony_ci
39571cb0ef41Sopenharmony_ci  // Converts [Descriptor/Transition]Array entry number to a fixed array index.
39581cb0ef41Sopenharmony_ci  template <typename Array>
39591cb0ef41Sopenharmony_ci  TNode<IntPtrT> EntryIndexToIndex(TNode<Uint32T> entry_index);
39601cb0ef41Sopenharmony_ci
39611cb0ef41Sopenharmony_ci  // Implements [Descriptor/Transition]Array::ToKeyIndex.
39621cb0ef41Sopenharmony_ci  template <typename Array>
39631cb0ef41Sopenharmony_ci  TNode<IntPtrT> ToKeyIndex(TNode<Uint32T> entry_index);
39641cb0ef41Sopenharmony_ci
39651cb0ef41Sopenharmony_ci  // Implements [Descriptor/Transition]Array::GetKey.
39661cb0ef41Sopenharmony_ci  template <typename Array>
39671cb0ef41Sopenharmony_ci  TNode<Name> GetKey(TNode<Array> array, TNode<Uint32T> entry_index);
39681cb0ef41Sopenharmony_ci
39691cb0ef41Sopenharmony_ci  // Implements DescriptorArray::GetDetails.
39701cb0ef41Sopenharmony_ci  TNode<Uint32T> DescriptorArrayGetDetails(TNode<DescriptorArray> descriptors,
39711cb0ef41Sopenharmony_ci                                           TNode<Uint32T> descriptor_number);
39721cb0ef41Sopenharmony_ci
39731cb0ef41Sopenharmony_ci  using ForEachDescriptorBodyFunction =
39741cb0ef41Sopenharmony_ci      std::function<void(TNode<IntPtrT> descriptor_key_index)>;
39751cb0ef41Sopenharmony_ci
39761cb0ef41Sopenharmony_ci  // Descriptor array accessors based on key_index, which is equal to
39771cb0ef41Sopenharmony_ci  // DescriptorArray::ToKeyIndex(descriptor).
39781cb0ef41Sopenharmony_ci  TNode<Name> LoadKeyByKeyIndex(TNode<DescriptorArray> container,
39791cb0ef41Sopenharmony_ci                                TNode<IntPtrT> key_index);
39801cb0ef41Sopenharmony_ci  TNode<Uint32T> LoadDetailsByKeyIndex(TNode<DescriptorArray> container,
39811cb0ef41Sopenharmony_ci                                       TNode<IntPtrT> key_index);
39821cb0ef41Sopenharmony_ci  TNode<Object> LoadValueByKeyIndex(TNode<DescriptorArray> container,
39831cb0ef41Sopenharmony_ci                                    TNode<IntPtrT> key_index);
39841cb0ef41Sopenharmony_ci  TNode<MaybeObject> LoadFieldTypeByKeyIndex(TNode<DescriptorArray> container,
39851cb0ef41Sopenharmony_ci                                             TNode<IntPtrT> key_index);
39861cb0ef41Sopenharmony_ci
39871cb0ef41Sopenharmony_ci  TNode<IntPtrT> DescriptorEntryToIndex(TNode<IntPtrT> descriptor);
39881cb0ef41Sopenharmony_ci
39891cb0ef41Sopenharmony_ci  // Descriptor array accessors based on descriptor.
39901cb0ef41Sopenharmony_ci  TNode<Name> LoadKeyByDescriptorEntry(TNode<DescriptorArray> descriptors,
39911cb0ef41Sopenharmony_ci                                       TNode<IntPtrT> descriptor);
39921cb0ef41Sopenharmony_ci  TNode<Name> LoadKeyByDescriptorEntry(TNode<DescriptorArray> descriptors,
39931cb0ef41Sopenharmony_ci                                       int descriptor);
39941cb0ef41Sopenharmony_ci  TNode<Uint32T> LoadDetailsByDescriptorEntry(
39951cb0ef41Sopenharmony_ci      TNode<DescriptorArray> descriptors, TNode<IntPtrT> descriptor);
39961cb0ef41Sopenharmony_ci  TNode<Uint32T> LoadDetailsByDescriptorEntry(
39971cb0ef41Sopenharmony_ci      TNode<DescriptorArray> descriptors, int descriptor);
39981cb0ef41Sopenharmony_ci  TNode<Object> LoadValueByDescriptorEntry(TNode<DescriptorArray> descriptors,
39991cb0ef41Sopenharmony_ci                                           TNode<IntPtrT> descriptor);
40001cb0ef41Sopenharmony_ci  TNode<Object> LoadValueByDescriptorEntry(TNode<DescriptorArray> descriptors,
40011cb0ef41Sopenharmony_ci                                           int descriptor);
40021cb0ef41Sopenharmony_ci  TNode<MaybeObject> LoadFieldTypeByDescriptorEntry(
40031cb0ef41Sopenharmony_ci      TNode<DescriptorArray> descriptors, TNode<IntPtrT> descriptor);
40041cb0ef41Sopenharmony_ci
40051cb0ef41Sopenharmony_ci  using ForEachKeyValueFunction =
40061cb0ef41Sopenharmony_ci      std::function<void(TNode<Name> key, TNode<Object> value)>;
40071cb0ef41Sopenharmony_ci
40081cb0ef41Sopenharmony_ci  // For each JSObject property (in DescriptorArray order), check if the key is
40091cb0ef41Sopenharmony_ci  // enumerable, and if so, load the value from the receiver and evaluate the
40101cb0ef41Sopenharmony_ci  // closure.
40111cb0ef41Sopenharmony_ci  void ForEachEnumerableOwnProperty(TNode<Context> context, TNode<Map> map,
40121cb0ef41Sopenharmony_ci                                    TNode<JSObject> object,
40131cb0ef41Sopenharmony_ci                                    PropertiesEnumerationMode mode,
40141cb0ef41Sopenharmony_ci                                    const ForEachKeyValueFunction& body,
40151cb0ef41Sopenharmony_ci                                    Label* bailout);
40161cb0ef41Sopenharmony_ci
40171cb0ef41Sopenharmony_ci  TNode<Object> CallGetterIfAccessor(
40181cb0ef41Sopenharmony_ci      TNode<Object> value, TNode<HeapObject> holder, TNode<Uint32T> details,
40191cb0ef41Sopenharmony_ci      TNode<Context> context, TNode<Object> receiver, TNode<Object> name,
40201cb0ef41Sopenharmony_ci      Label* if_bailout,
40211cb0ef41Sopenharmony_ci      GetOwnPropertyMode mode = kCallJSGetterDontUseCachedName);
40221cb0ef41Sopenharmony_ci
40231cb0ef41Sopenharmony_ci  TNode<IntPtrT> TryToIntptr(TNode<Object> key, Label* if_not_intptr,
40241cb0ef41Sopenharmony_ci                             TVariable<Int32T>* var_instance_type = nullptr);
40251cb0ef41Sopenharmony_ci
40261cb0ef41Sopenharmony_ci  TNode<JSArray> ArrayCreate(TNode<Context> context, TNode<Number> length);
40271cb0ef41Sopenharmony_ci
40281cb0ef41Sopenharmony_ci  // Allocate a clone of a mutable primitive, if {object} is a mutable
40291cb0ef41Sopenharmony_ci  // HeapNumber.
40301cb0ef41Sopenharmony_ci  TNode<Object> CloneIfMutablePrimitive(TNode<Object> object);
40311cb0ef41Sopenharmony_ci
40321cb0ef41Sopenharmony_ci  TNode<Smi> RefillMathRandom(TNode<NativeContext> native_context);
40331cb0ef41Sopenharmony_ci
40341cb0ef41Sopenharmony_ci  void RemoveFinalizationRegistryCellFromUnregisterTokenMap(
40351cb0ef41Sopenharmony_ci      TNode<JSFinalizationRegistry> finalization_registry,
40361cb0ef41Sopenharmony_ci      TNode<WeakCell> weak_cell);
40371cb0ef41Sopenharmony_ci
40381cb0ef41Sopenharmony_ci  TNode<IntPtrT> FeedbackIteratorEntrySize() {
40391cb0ef41Sopenharmony_ci    return IntPtrConstant(FeedbackIterator::kEntrySize);
40401cb0ef41Sopenharmony_ci  }
40411cb0ef41Sopenharmony_ci
40421cb0ef41Sopenharmony_ci  TNode<IntPtrT> FeedbackIteratorHandlerOffset() {
40431cb0ef41Sopenharmony_ci    return IntPtrConstant(FeedbackIterator::kHandlerOffset);
40441cb0ef41Sopenharmony_ci  }
40451cb0ef41Sopenharmony_ci
40461cb0ef41Sopenharmony_ci  TNode<SwissNameDictionary> AllocateSwissNameDictionary(
40471cb0ef41Sopenharmony_ci      TNode<IntPtrT> at_least_space_for);
40481cb0ef41Sopenharmony_ci  TNode<SwissNameDictionary> AllocateSwissNameDictionary(
40491cb0ef41Sopenharmony_ci      int at_least_space_for);
40501cb0ef41Sopenharmony_ci
40511cb0ef41Sopenharmony_ci  TNode<SwissNameDictionary> AllocateSwissNameDictionaryWithCapacity(
40521cb0ef41Sopenharmony_ci      TNode<IntPtrT> capacity);
40531cb0ef41Sopenharmony_ci
40541cb0ef41Sopenharmony_ci  // MT stands for "minus tag".
40551cb0ef41Sopenharmony_ci  TNode<IntPtrT> SwissNameDictionaryOffsetIntoDataTableMT(
40561cb0ef41Sopenharmony_ci      TNode<SwissNameDictionary> dict, TNode<IntPtrT> index, int field_index);
40571cb0ef41Sopenharmony_ci
40581cb0ef41Sopenharmony_ci  // MT stands for "minus tag".
40591cb0ef41Sopenharmony_ci  TNode<IntPtrT> SwissNameDictionaryOffsetIntoPropertyDetailsTableMT(
40601cb0ef41Sopenharmony_ci      TNode<SwissNameDictionary> dict, TNode<IntPtrT> capacity,
40611cb0ef41Sopenharmony_ci      TNode<IntPtrT> index);
40621cb0ef41Sopenharmony_ci
40631cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadSwissNameDictionaryNumberOfElements(
40641cb0ef41Sopenharmony_ci      TNode<SwissNameDictionary> table, TNode<IntPtrT> capacity);
40651cb0ef41Sopenharmony_ci
40661cb0ef41Sopenharmony_ci  TNode<IntPtrT> LoadSwissNameDictionaryNumberOfDeletedElements(
40671cb0ef41Sopenharmony_ci      TNode<SwissNameDictionary> table, TNode<IntPtrT> capacity);
40681cb0ef41Sopenharmony_ci
40691cb0ef41Sopenharmony_ci  // Specialized operation to be used when adding entries:
40701cb0ef41Sopenharmony_ci  // If used capacity (= number of present + deleted elements) is less than
40711cb0ef41Sopenharmony_ci  // |max_usable|, increment the number of present entries and return the used
40721cb0ef41Sopenharmony_ci  // capacity value (prior to the incrementation). Otherwise, goto |bailout|.
40731cb0ef41Sopenharmony_ci  TNode<Uint32T> SwissNameDictionaryIncreaseElementCountOrBailout(
40741cb0ef41Sopenharmony_ci      TNode<ByteArray> meta_table, TNode<IntPtrT> capacity,
40751cb0ef41Sopenharmony_ci      TNode<Uint32T> max_usable_capacity, Label* bailout);
40761cb0ef41Sopenharmony_ci
40771cb0ef41Sopenharmony_ci  // Specialized operation to be used when deleting entries: Decreases the
40781cb0ef41Sopenharmony_ci  // number of present entries and increases the number of deleted ones. Returns
40791cb0ef41Sopenharmony_ci  // new (= decremented) number of present entries.
40801cb0ef41Sopenharmony_ci  TNode<Uint32T> SwissNameDictionaryUpdateCountsForDeletion(
40811cb0ef41Sopenharmony_ci      TNode<ByteArray> meta_table, TNode<IntPtrT> capacity);
40821cb0ef41Sopenharmony_ci
40831cb0ef41Sopenharmony_ci  void StoreSwissNameDictionaryCapacity(TNode<SwissNameDictionary> table,
40841cb0ef41Sopenharmony_ci                                        TNode<Int32T> capacity);
40851cb0ef41Sopenharmony_ci
40861cb0ef41Sopenharmony_ci  void StoreSwissNameDictionaryEnumToEntryMapping(
40871cb0ef41Sopenharmony_ci      TNode<SwissNameDictionary> table, TNode<IntPtrT> capacity,
40881cb0ef41Sopenharmony_ci      TNode<IntPtrT> enum_index, TNode<Int32T> entry);
40891cb0ef41Sopenharmony_ci
40901cb0ef41Sopenharmony_ci  TNode<Name> LoadSwissNameDictionaryKey(TNode<SwissNameDictionary> dict,
40911cb0ef41Sopenharmony_ci                                         TNode<IntPtrT> entry);
40921cb0ef41Sopenharmony_ci
40931cb0ef41Sopenharmony_ci  void StoreSwissNameDictionaryKeyAndValue(TNode<SwissNameDictionary> dict,
40941cb0ef41Sopenharmony_ci                                           TNode<IntPtrT> entry,
40951cb0ef41Sopenharmony_ci                                           TNode<Object> key,
40961cb0ef41Sopenharmony_ci                                           TNode<Object> value);
40971cb0ef41Sopenharmony_ci
40981cb0ef41Sopenharmony_ci  // Equivalent to SwissNameDictionary::SetCtrl, therefore preserves the copy of
40991cb0ef41Sopenharmony_ci  // the first group at the end of the control table.
41001cb0ef41Sopenharmony_ci  void SwissNameDictionarySetCtrl(TNode<SwissNameDictionary> table,
41011cb0ef41Sopenharmony_ci                                  TNode<IntPtrT> capacity, TNode<IntPtrT> entry,
41021cb0ef41Sopenharmony_ci                                  TNode<Uint8T> ctrl);
41031cb0ef41Sopenharmony_ci
41041cb0ef41Sopenharmony_ci  TNode<Uint64T> LoadSwissNameDictionaryCtrlTableGroup(TNode<IntPtrT> address);
41051cb0ef41Sopenharmony_ci
41061cb0ef41Sopenharmony_ci  TNode<Uint8T> LoadSwissNameDictionaryPropertyDetails(
41071cb0ef41Sopenharmony_ci      TNode<SwissNameDictionary> table, TNode<IntPtrT> capacity,
41081cb0ef41Sopenharmony_ci      TNode<IntPtrT> entry);
41091cb0ef41Sopenharmony_ci
41101cb0ef41Sopenharmony_ci  void StoreSwissNameDictionaryPropertyDetails(TNode<SwissNameDictionary> table,
41111cb0ef41Sopenharmony_ci                                               TNode<IntPtrT> capacity,
41121cb0ef41Sopenharmony_ci                                               TNode<IntPtrT> entry,
41131cb0ef41Sopenharmony_ci                                               TNode<Uint8T> details);
41141cb0ef41Sopenharmony_ci
41151cb0ef41Sopenharmony_ci  TNode<SwissNameDictionary> CopySwissNameDictionary(
41161cb0ef41Sopenharmony_ci      TNode<SwissNameDictionary> original);
41171cb0ef41Sopenharmony_ci
41181cb0ef41Sopenharmony_ci  void SwissNameDictionaryFindEntry(TNode<SwissNameDictionary> table,
41191cb0ef41Sopenharmony_ci                                    TNode<Name> key, Label* found,
41201cb0ef41Sopenharmony_ci                                    TVariable<IntPtrT>* var_found_entry,
41211cb0ef41Sopenharmony_ci                                    Label* not_found);
41221cb0ef41Sopenharmony_ci
41231cb0ef41Sopenharmony_ci  void SwissNameDictionaryAdd(TNode<SwissNameDictionary> table, TNode<Name> key,
41241cb0ef41Sopenharmony_ci                              TNode<Object> value,
41251cb0ef41Sopenharmony_ci                              TNode<Uint8T> property_details,
41261cb0ef41Sopenharmony_ci                              Label* needs_resize);
41271cb0ef41Sopenharmony_ci
41281cb0ef41Sopenharmony_ci private:
41291cb0ef41Sopenharmony_ci  friend class CodeStubArguments;
41301cb0ef41Sopenharmony_ci
41311cb0ef41Sopenharmony_ci  void HandleBreakOnNode();
41321cb0ef41Sopenharmony_ci
41331cb0ef41Sopenharmony_ci  TNode<HeapObject> AllocateRawDoubleAligned(TNode<IntPtrT> size_in_bytes,
41341cb0ef41Sopenharmony_ci                                             AllocationFlags flags,
41351cb0ef41Sopenharmony_ci                                             TNode<RawPtrT> top_address,
41361cb0ef41Sopenharmony_ci                                             TNode<RawPtrT> limit_address);
41371cb0ef41Sopenharmony_ci  TNode<HeapObject> AllocateRawUnaligned(TNode<IntPtrT> size_in_bytes,
41381cb0ef41Sopenharmony_ci                                         AllocationFlags flags,
41391cb0ef41Sopenharmony_ci                                         TNode<RawPtrT> top_address,
41401cb0ef41Sopenharmony_ci                                         TNode<RawPtrT> limit_address);
41411cb0ef41Sopenharmony_ci  TNode<HeapObject> AllocateRaw(TNode<IntPtrT> size_in_bytes,
41421cb0ef41Sopenharmony_ci                                AllocationFlags flags,
41431cb0ef41Sopenharmony_ci                                TNode<RawPtrT> top_address,
41441cb0ef41Sopenharmony_ci                                TNode<RawPtrT> limit_address);
41451cb0ef41Sopenharmony_ci
41461cb0ef41Sopenharmony_ci  // Allocate and return a JSArray of given total size in bytes with header
41471cb0ef41Sopenharmony_ci  // fields initialized.
41481cb0ef41Sopenharmony_ci  TNode<JSArray> AllocateUninitializedJSArray(
41491cb0ef41Sopenharmony_ci      TNode<Map> array_map, TNode<Smi> length,
41501cb0ef41Sopenharmony_ci      base::Optional<TNode<AllocationSite>> allocation_site,
41511cb0ef41Sopenharmony_ci      TNode<IntPtrT> size_in_bytes);
41521cb0ef41Sopenharmony_ci
41531cb0ef41Sopenharmony_ci  // Increases the provided capacity to the next valid value, if necessary.
41541cb0ef41Sopenharmony_ci  template <typename CollectionType>
41551cb0ef41Sopenharmony_ci  TNode<CollectionType> AllocateOrderedHashTable(TNode<IntPtrT> capacity);
41561cb0ef41Sopenharmony_ci
41571cb0ef41Sopenharmony_ci  // Uses the provided capacity (which must be valid) in verbatim.
41581cb0ef41Sopenharmony_ci  template <typename CollectionType>
41591cb0ef41Sopenharmony_ci  TNode<CollectionType> AllocateOrderedHashTableWithCapacity(
41601cb0ef41Sopenharmony_ci      TNode<IntPtrT> capacity);
41611cb0ef41Sopenharmony_ci
41621cb0ef41Sopenharmony_ci  TNode<IntPtrT> SmiShiftBitsConstant() {
41631cb0ef41Sopenharmony_ci    return IntPtrConstant(kSmiShiftSize + kSmiTagSize);
41641cb0ef41Sopenharmony_ci  }
41651cb0ef41Sopenharmony_ci  TNode<Int32T> SmiShiftBitsConstant32() {
41661cb0ef41Sopenharmony_ci    return Int32Constant(kSmiShiftSize + kSmiTagSize);
41671cb0ef41Sopenharmony_ci  }
41681cb0ef41Sopenharmony_ci
41691cb0ef41Sopenharmony_ci  TNode<String> AllocateSlicedString(RootIndex map_root_index,
41701cb0ef41Sopenharmony_ci                                     TNode<Uint32T> length,
41711cb0ef41Sopenharmony_ci                                     TNode<String> parent, TNode<Smi> offset);
41721cb0ef41Sopenharmony_ci
41731cb0ef41Sopenharmony_ci  // Implements [Descriptor/Transition]Array::number_of_entries.
41741cb0ef41Sopenharmony_ci  template <typename Array>
41751cb0ef41Sopenharmony_ci  TNode<Uint32T> NumberOfEntries(TNode<Array> array);
41761cb0ef41Sopenharmony_ci
41771cb0ef41Sopenharmony_ci  // Implements [Descriptor/Transition]Array::GetSortedKeyIndex.
41781cb0ef41Sopenharmony_ci  template <typename Array>
41791cb0ef41Sopenharmony_ci  TNode<Uint32T> GetSortedKeyIndex(TNode<Array> descriptors,
41801cb0ef41Sopenharmony_ci                                   TNode<Uint32T> entry_index);
41811cb0ef41Sopenharmony_ci
41821cb0ef41Sopenharmony_ci  TNode<Smi> CollectFeedbackForString(TNode<Int32T> instance_type);
41831cb0ef41Sopenharmony_ci  void GenerateEqual_Same(TNode<Object> value, Label* if_equal,
41841cb0ef41Sopenharmony_ci                          Label* if_notequal,
41851cb0ef41Sopenharmony_ci                          TVariable<Smi>* var_type_feedback = nullptr);
41861cb0ef41Sopenharmony_ci
41871cb0ef41Sopenharmony_ci  static const int kElementLoopUnrollThreshold = 8;
41881cb0ef41Sopenharmony_ci
41891cb0ef41Sopenharmony_ci  // {convert_bigint} is only meaningful when {mode} == kToNumber.
41901cb0ef41Sopenharmony_ci  TNode<Numeric> NonNumberToNumberOrNumeric(
41911cb0ef41Sopenharmony_ci      TNode<Context> context, TNode<HeapObject> input, Object::Conversion mode,
41921cb0ef41Sopenharmony_ci      BigIntHandling bigint_handling = BigIntHandling::kThrow);
41931cb0ef41Sopenharmony_ci
41941cb0ef41Sopenharmony_ci  void TaggedToNumeric(TNode<Context> context, TNode<Object> value,
41951cb0ef41Sopenharmony_ci                       TVariable<Numeric>* var_numeric,
41961cb0ef41Sopenharmony_ci                       TVariable<Smi>* var_feedback);
41971cb0ef41Sopenharmony_ci
41981cb0ef41Sopenharmony_ci  enum IsKnownTaggedPointer { kNo, kYes };
41991cb0ef41Sopenharmony_ci  template <Object::Conversion conversion>
42001cb0ef41Sopenharmony_ci  void TaggedToWord32OrBigIntImpl(TNode<Context> context, TNode<Object> value,
42011cb0ef41Sopenharmony_ci                                  Label* if_number,
42021cb0ef41Sopenharmony_ci                                  TVariable<Word32T>* var_word32,
42031cb0ef41Sopenharmony_ci                                  IsKnownTaggedPointer is_known_tagged_pointer,
42041cb0ef41Sopenharmony_ci                                  Label* if_bigint = nullptr,
42051cb0ef41Sopenharmony_ci                                  TVariable<BigInt>* var_maybe_bigint = nullptr,
42061cb0ef41Sopenharmony_ci                                  TVariable<Smi>* var_feedback = nullptr);
42071cb0ef41Sopenharmony_ci
42081cb0ef41Sopenharmony_ci  // Low-level accessors for Descriptor arrays.
42091cb0ef41Sopenharmony_ci  template <typename T>
42101cb0ef41Sopenharmony_ci  TNode<T> LoadDescriptorArrayElement(TNode<DescriptorArray> object,
42111cb0ef41Sopenharmony_ci                                      TNode<IntPtrT> index,
42121cb0ef41Sopenharmony_ci                                      int additional_offset);
42131cb0ef41Sopenharmony_ci
42141cb0ef41Sopenharmony_ci  // Hide LoadRoot for subclasses of CodeStubAssembler. If you get an error
42151cb0ef41Sopenharmony_ci  // complaining about this method, don't make it public, add your root to
42161cb0ef41Sopenharmony_ci  // HEAP_(IM)MUTABLE_IMMOVABLE_OBJECT_LIST instead. If you *really* need
42171cb0ef41Sopenharmony_ci  // LoadRoot, use CodeAssembler::LoadRoot.
42181cb0ef41Sopenharmony_ci  TNode<Object> LoadRoot(RootIndex root_index) {
42191cb0ef41Sopenharmony_ci    return CodeAssembler::LoadRoot(root_index);
42201cb0ef41Sopenharmony_ci  }
42211cb0ef41Sopenharmony_ci
42221cb0ef41Sopenharmony_ci  TNode<AnyTaggedT> LoadRootMapWord(RootIndex root_index) {
42231cb0ef41Sopenharmony_ci    return CodeAssembler::LoadRootMapWord(root_index);
42241cb0ef41Sopenharmony_ci  }
42251cb0ef41Sopenharmony_ci
42261cb0ef41Sopenharmony_ci  template <typename TIndex>
42271cb0ef41Sopenharmony_ci  void StoreFixedArrayOrPropertyArrayElement(
42281cb0ef41Sopenharmony_ci      TNode<UnionT<FixedArray, PropertyArray>> array, TNode<TIndex> index,
42291cb0ef41Sopenharmony_ci      TNode<Object> value, WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
42301cb0ef41Sopenharmony_ci      int additional_offset = 0);
42311cb0ef41Sopenharmony_ci
42321cb0ef41Sopenharmony_ci  template <typename TIndex>
42331cb0ef41Sopenharmony_ci  void StoreElementTypedArrayBigInt(TNode<RawPtrT> elements, ElementsKind kind,
42341cb0ef41Sopenharmony_ci                                    TNode<TIndex> index, TNode<BigInt> value);
42351cb0ef41Sopenharmony_ci
42361cb0ef41Sopenharmony_ci  template <typename TIndex>
42371cb0ef41Sopenharmony_ci  void StoreElementTypedArrayWord32(TNode<RawPtrT> elements, ElementsKind kind,
42381cb0ef41Sopenharmony_ci                                    TNode<TIndex> index, TNode<Word32T> value);
42391cb0ef41Sopenharmony_ci
42401cb0ef41Sopenharmony_ci  // Store value to an elements array with given elements kind.
42411cb0ef41Sopenharmony_ci  // TODO(turbofan): For BIGINT64_ELEMENTS and BIGUINT64_ELEMENTS
42421cb0ef41Sopenharmony_ci  // we pass {value} as BigInt object instead of int64_t. We should
42431cb0ef41Sopenharmony_ci  // teach TurboFan to handle int64_t on 32-bit platforms eventually.
42441cb0ef41Sopenharmony_ci  // TODO(solanes): This method can go away and simplify into only one version
42451cb0ef41Sopenharmony_ci  // of StoreElement once we have "if constexpr" available to use.
42461cb0ef41Sopenharmony_ci  template <typename TArray, typename TIndex, typename TValue>
42471cb0ef41Sopenharmony_ci  void StoreElementTypedArray(TNode<TArray> elements, ElementsKind kind,
42481cb0ef41Sopenharmony_ci                              TNode<TIndex> index, TNode<TValue> value);
42491cb0ef41Sopenharmony_ci
42501cb0ef41Sopenharmony_ci  template <typename TIndex>
42511cb0ef41Sopenharmony_ci  void StoreElement(TNode<FixedArrayBase> elements, ElementsKind kind,
42521cb0ef41Sopenharmony_ci                    TNode<TIndex> index, TNode<Object> value);
42531cb0ef41Sopenharmony_ci
42541cb0ef41Sopenharmony_ci  template <typename TIndex>
42551cb0ef41Sopenharmony_ci  void StoreElement(TNode<FixedArrayBase> elements, ElementsKind kind,
42561cb0ef41Sopenharmony_ci                    TNode<TIndex> index, TNode<Float64T> value);
42571cb0ef41Sopenharmony_ci
42581cb0ef41Sopenharmony_ci  // Converts {input} to a number if {input} is a plain primitve (i.e. String or
42591cb0ef41Sopenharmony_ci  // Oddball) and stores the result in {var_result}. Otherwise, it bails out to
42601cb0ef41Sopenharmony_ci  // {if_bailout}.
42611cb0ef41Sopenharmony_ci  void TryPlainPrimitiveNonNumberToNumber(TNode<HeapObject> input,
42621cb0ef41Sopenharmony_ci                                          TVariable<Number>* var_result,
42631cb0ef41Sopenharmony_ci                                          Label* if_bailout);
42641cb0ef41Sopenharmony_ci
42651cb0ef41Sopenharmony_ci  void DcheckHasValidMap(TNode<HeapObject> object);
42661cb0ef41Sopenharmony_ci
42671cb0ef41Sopenharmony_ci  template <typename TValue>
42681cb0ef41Sopenharmony_ci  void EmitElementStoreTypedArray(TNode<JSTypedArray> typed_array,
42691cb0ef41Sopenharmony_ci                                  TNode<IntPtrT> key, TNode<Object> value,
42701cb0ef41Sopenharmony_ci                                  ElementsKind elements_kind,
42711cb0ef41Sopenharmony_ci                                  KeyedAccessStoreMode store_mode,
42721cb0ef41Sopenharmony_ci                                  Label* bailout, TNode<Context> context,
42731cb0ef41Sopenharmony_ci                                  TVariable<Object>* maybe_converted_value);
42741cb0ef41Sopenharmony_ci
42751cb0ef41Sopenharmony_ci  template <typename TValue>
42761cb0ef41Sopenharmony_ci  void EmitElementStoreTypedArrayUpdateValue(
42771cb0ef41Sopenharmony_ci      TNode<Object> value, ElementsKind elements_kind,
42781cb0ef41Sopenharmony_ci      TNode<TValue> converted_value, TVariable<Object>* maybe_converted_value);
42791cb0ef41Sopenharmony_ci};
42801cb0ef41Sopenharmony_ci
42811cb0ef41Sopenharmony_ciclass V8_EXPORT_PRIVATE CodeStubArguments {
42821cb0ef41Sopenharmony_ci public:
42831cb0ef41Sopenharmony_ci  // |argc| specifies the number of arguments passed to the builtin excluding
42841cb0ef41Sopenharmony_ci  // the receiver. The arguments include the receiver.
42851cb0ef41Sopenharmony_ci  CodeStubArguments(CodeStubAssembler* assembler, TNode<IntPtrT> argc)
42861cb0ef41Sopenharmony_ci      : CodeStubArguments(assembler, argc, TNode<RawPtrT>()) {}
42871cb0ef41Sopenharmony_ci  CodeStubArguments(CodeStubAssembler* assembler, TNode<Int32T> argc)
42881cb0ef41Sopenharmony_ci      : CodeStubArguments(assembler, assembler->ChangeInt32ToIntPtr(argc)) {}
42891cb0ef41Sopenharmony_ci  CodeStubArguments(CodeStubAssembler* assembler, TNode<IntPtrT> argc,
42901cb0ef41Sopenharmony_ci                    TNode<RawPtrT> fp);
42911cb0ef41Sopenharmony_ci
42921cb0ef41Sopenharmony_ci  // Used by Torque to construct arguments based on a Torque-defined
42931cb0ef41Sopenharmony_ci  // struct of values.
42941cb0ef41Sopenharmony_ci  CodeStubArguments(CodeStubAssembler* assembler,
42951cb0ef41Sopenharmony_ci                    TorqueStructArguments torque_arguments)
42961cb0ef41Sopenharmony_ci      : assembler_(assembler),
42971cb0ef41Sopenharmony_ci        argc_(torque_arguments.actual_count),
42981cb0ef41Sopenharmony_ci        base_(torque_arguments.base),
42991cb0ef41Sopenharmony_ci        fp_(torque_arguments.frame) {}
43001cb0ef41Sopenharmony_ci
43011cb0ef41Sopenharmony_ci  TNode<Object> GetReceiver() const;
43021cb0ef41Sopenharmony_ci  // Replaces receiver argument on the expression stack. Should be used only
43031cb0ef41Sopenharmony_ci  // for manipulating arguments in trampoline builtins before tail calling
43041cb0ef41Sopenharmony_ci  // further with passing all the JS arguments as is.
43051cb0ef41Sopenharmony_ci  void SetReceiver(TNode<Object> object) const;
43061cb0ef41Sopenharmony_ci
43071cb0ef41Sopenharmony_ci  // Computes address of the index'th argument.
43081cb0ef41Sopenharmony_ci  TNode<RawPtrT> AtIndexPtr(TNode<IntPtrT> index) const;
43091cb0ef41Sopenharmony_ci
43101cb0ef41Sopenharmony_ci  // |index| is zero-based and does not include the receiver
43111cb0ef41Sopenharmony_ci  TNode<Object> AtIndex(TNode<IntPtrT> index) const;
43121cb0ef41Sopenharmony_ci  TNode<Object> AtIndex(int index) const;
43131cb0ef41Sopenharmony_ci
43141cb0ef41Sopenharmony_ci  // Return the number of arguments (excluding the receiver).
43151cb0ef41Sopenharmony_ci  TNode<IntPtrT> GetLengthWithoutReceiver() const;
43161cb0ef41Sopenharmony_ci  // Return the number of arguments (including the receiver).
43171cb0ef41Sopenharmony_ci  TNode<IntPtrT> GetLengthWithReceiver() const;
43181cb0ef41Sopenharmony_ci
43191cb0ef41Sopenharmony_ci  TorqueStructArguments GetTorqueArguments() const {
43201cb0ef41Sopenharmony_ci    return TorqueStructArguments{fp_, base_, GetLengthWithoutReceiver(), argc_};
43211cb0ef41Sopenharmony_ci  }
43221cb0ef41Sopenharmony_ci
43231cb0ef41Sopenharmony_ci  TNode<Object> GetOptionalArgumentValue(TNode<IntPtrT> index,
43241cb0ef41Sopenharmony_ci                                         TNode<Object> default_value);
43251cb0ef41Sopenharmony_ci  TNode<Object> GetOptionalArgumentValue(TNode<IntPtrT> index) {
43261cb0ef41Sopenharmony_ci    return GetOptionalArgumentValue(index, assembler_->UndefinedConstant());
43271cb0ef41Sopenharmony_ci  }
43281cb0ef41Sopenharmony_ci  TNode<Object> GetOptionalArgumentValue(int index) {
43291cb0ef41Sopenharmony_ci    return GetOptionalArgumentValue(assembler_->IntPtrConstant(index));
43301cb0ef41Sopenharmony_ci  }
43311cb0ef41Sopenharmony_ci
43321cb0ef41Sopenharmony_ci  // Iteration doesn't include the receiver. |first| and |last| are zero-based.
43331cb0ef41Sopenharmony_ci  using ForEachBodyFunction = std::function<void(TNode<Object> arg)>;
43341cb0ef41Sopenharmony_ci  void ForEach(const ForEachBodyFunction& body, TNode<IntPtrT> first = {},
43351cb0ef41Sopenharmony_ci               TNode<IntPtrT> last = {}) const {
43361cb0ef41Sopenharmony_ci    CodeStubAssembler::VariableList list(0, assembler_->zone());
43371cb0ef41Sopenharmony_ci    ForEach(list, body, first, last);
43381cb0ef41Sopenharmony_ci  }
43391cb0ef41Sopenharmony_ci  void ForEach(const CodeStubAssembler::VariableList& vars,
43401cb0ef41Sopenharmony_ci               const ForEachBodyFunction& body, TNode<IntPtrT> first = {},
43411cb0ef41Sopenharmony_ci               TNode<IntPtrT> last = {}) const;
43421cb0ef41Sopenharmony_ci
43431cb0ef41Sopenharmony_ci  void PopAndReturn(TNode<Object> value);
43441cb0ef41Sopenharmony_ci
43451cb0ef41Sopenharmony_ci private:
43461cb0ef41Sopenharmony_ci  CodeStubAssembler* assembler_;
43471cb0ef41Sopenharmony_ci  TNode<IntPtrT> argc_;
43481cb0ef41Sopenharmony_ci  TNode<RawPtrT> base_;
43491cb0ef41Sopenharmony_ci  TNode<RawPtrT> fp_;
43501cb0ef41Sopenharmony_ci};
43511cb0ef41Sopenharmony_ci
43521cb0ef41Sopenharmony_ciclass ToDirectStringAssembler : public CodeStubAssembler {
43531cb0ef41Sopenharmony_ci private:
43541cb0ef41Sopenharmony_ci  enum StringPointerKind { PTR_TO_DATA, PTR_TO_STRING };
43551cb0ef41Sopenharmony_ci
43561cb0ef41Sopenharmony_ci public:
43571cb0ef41Sopenharmony_ci  enum Flag {
43581cb0ef41Sopenharmony_ci    kDontUnpackSlicedStrings = 1 << 0,
43591cb0ef41Sopenharmony_ci  };
43601cb0ef41Sopenharmony_ci  using Flags = base::Flags<Flag>;
43611cb0ef41Sopenharmony_ci
43621cb0ef41Sopenharmony_ci  ToDirectStringAssembler(compiler::CodeAssemblerState* state,
43631cb0ef41Sopenharmony_ci                          TNode<String> string, Flags flags = Flags());
43641cb0ef41Sopenharmony_ci
43651cb0ef41Sopenharmony_ci  // Converts flat cons, thin, and sliced strings and returns the direct
43661cb0ef41Sopenharmony_ci  // string. The result can be either a sequential or external string.
43671cb0ef41Sopenharmony_ci  // Jumps to if_bailout if the string if the string is indirect and cannot
43681cb0ef41Sopenharmony_ci  // be unpacked.
43691cb0ef41Sopenharmony_ci  TNode<String> TryToDirect(Label* if_bailout);
43701cb0ef41Sopenharmony_ci
43711cb0ef41Sopenharmony_ci  // Returns a pointer to the beginning of the string data.
43721cb0ef41Sopenharmony_ci  // Jumps to if_bailout if the external string cannot be unpacked.
43731cb0ef41Sopenharmony_ci  TNode<RawPtrT> PointerToData(Label* if_bailout) {
43741cb0ef41Sopenharmony_ci    return TryToSequential(PTR_TO_DATA, if_bailout);
43751cb0ef41Sopenharmony_ci  }
43761cb0ef41Sopenharmony_ci
43771cb0ef41Sopenharmony_ci  // Returns a pointer that, offset-wise, looks like a String.
43781cb0ef41Sopenharmony_ci  // Jumps to if_bailout if the external string cannot be unpacked.
43791cb0ef41Sopenharmony_ci  TNode<RawPtrT> PointerToString(Label* if_bailout) {
43801cb0ef41Sopenharmony_ci    return TryToSequential(PTR_TO_STRING, if_bailout);
43811cb0ef41Sopenharmony_ci  }
43821cb0ef41Sopenharmony_ci
43831cb0ef41Sopenharmony_ci  TNode<String> string() { return var_string_.value(); }
43841cb0ef41Sopenharmony_ci  TNode<Int32T> instance_type() { return var_instance_type_.value(); }
43851cb0ef41Sopenharmony_ci  TNode<IntPtrT> offset() { return var_offset_.value(); }
43861cb0ef41Sopenharmony_ci  TNode<Word32T> is_external() { return var_is_external_.value(); }
43871cb0ef41Sopenharmony_ci
43881cb0ef41Sopenharmony_ci private:
43891cb0ef41Sopenharmony_ci  TNode<RawPtrT> TryToSequential(StringPointerKind ptr_kind, Label* if_bailout);
43901cb0ef41Sopenharmony_ci
43911cb0ef41Sopenharmony_ci  TVariable<String> var_string_;
43921cb0ef41Sopenharmony_ci  TVariable<Int32T> var_instance_type_;
43931cb0ef41Sopenharmony_ci  // TODO(v8:9880): Use UintPtrT here.
43941cb0ef41Sopenharmony_ci  TVariable<IntPtrT> var_offset_;
43951cb0ef41Sopenharmony_ci  TVariable<Word32T> var_is_external_;
43961cb0ef41Sopenharmony_ci
43971cb0ef41Sopenharmony_ci  const Flags flags_;
43981cb0ef41Sopenharmony_ci};
43991cb0ef41Sopenharmony_ci
44001cb0ef41Sopenharmony_ci// Performs checks on a given prototype (e.g. map identity, property
44011cb0ef41Sopenharmony_ci// verification), intended for use in fast path checks.
44021cb0ef41Sopenharmony_ciclass PrototypeCheckAssembler : public CodeStubAssembler {
44031cb0ef41Sopenharmony_ci public:
44041cb0ef41Sopenharmony_ci  enum Flag {
44051cb0ef41Sopenharmony_ci    kCheckPrototypePropertyConstness = 1 << 0,
44061cb0ef41Sopenharmony_ci    kCheckPrototypePropertyIdentity = 1 << 1,
44071cb0ef41Sopenharmony_ci    kCheckFull =
44081cb0ef41Sopenharmony_ci        kCheckPrototypePropertyConstness | kCheckPrototypePropertyIdentity,
44091cb0ef41Sopenharmony_ci  };
44101cb0ef41Sopenharmony_ci  using Flags = base::Flags<Flag>;
44111cb0ef41Sopenharmony_ci
44121cb0ef41Sopenharmony_ci  // A tuple describing a relevant property. It contains the descriptor index of
44131cb0ef41Sopenharmony_ci  // the property (within the descriptor array), the property's expected name
44141cb0ef41Sopenharmony_ci  // (stored as a root), and the property's expected value (stored on the native
44151cb0ef41Sopenharmony_ci  // context).
44161cb0ef41Sopenharmony_ci  struct DescriptorIndexNameValue {
44171cb0ef41Sopenharmony_ci    int descriptor_index;
44181cb0ef41Sopenharmony_ci    RootIndex name_root_index;
44191cb0ef41Sopenharmony_ci    int expected_value_context_index;
44201cb0ef41Sopenharmony_ci  };
44211cb0ef41Sopenharmony_ci
44221cb0ef41Sopenharmony_ci  PrototypeCheckAssembler(compiler::CodeAssemblerState* state, Flags flags,
44231cb0ef41Sopenharmony_ci                          TNode<NativeContext> native_context,
44241cb0ef41Sopenharmony_ci                          TNode<Map> initial_prototype_map,
44251cb0ef41Sopenharmony_ci                          base::Vector<DescriptorIndexNameValue> properties);
44261cb0ef41Sopenharmony_ci
44271cb0ef41Sopenharmony_ci  void CheckAndBranch(TNode<HeapObject> prototype, Label* if_unmodified,
44281cb0ef41Sopenharmony_ci                      Label* if_modified);
44291cb0ef41Sopenharmony_ci
44301cb0ef41Sopenharmony_ci private:
44311cb0ef41Sopenharmony_ci  const Flags flags_;
44321cb0ef41Sopenharmony_ci  const TNode<NativeContext> native_context_;
44331cb0ef41Sopenharmony_ci  const TNode<Map> initial_prototype_map_;
44341cb0ef41Sopenharmony_ci  const base::Vector<DescriptorIndexNameValue> properties_;
44351cb0ef41Sopenharmony_ci};
44361cb0ef41Sopenharmony_ci
44371cb0ef41Sopenharmony_ciDEFINE_OPERATORS_FOR_FLAGS(CodeStubAssembler::AllocationFlags)
44381cb0ef41Sopenharmony_ci
44391cb0ef41Sopenharmony_ci#define CLASS_MAP_CONSTANT_ADAPTER(V, rootIndexName, rootAccessorName,     \
44401cb0ef41Sopenharmony_ci                                   class_name)                             \
44411cb0ef41Sopenharmony_ci  template <>                                                              \
44421cb0ef41Sopenharmony_ci  inline bool CodeStubAssembler::ClassHasMapConstant<class_name>() {       \
44431cb0ef41Sopenharmony_ci    return true;                                                           \
44441cb0ef41Sopenharmony_ci  }                                                                        \
44451cb0ef41Sopenharmony_ci  template <>                                                              \
44461cb0ef41Sopenharmony_ci  inline TNode<Map> CodeStubAssembler::GetClassMapConstant<class_name>() { \
44471cb0ef41Sopenharmony_ci    return class_name##MapConstant();                                      \
44481cb0ef41Sopenharmony_ci  }
44491cb0ef41Sopenharmony_ci
44501cb0ef41Sopenharmony_ciUNIQUE_INSTANCE_TYPE_MAP_LIST_GENERATOR(CLASS_MAP_CONSTANT_ADAPTER, _)
44511cb0ef41Sopenharmony_ci
44521cb0ef41Sopenharmony_ci}  // namespace internal
44531cb0ef41Sopenharmony_ci}  // namespace v8
44541cb0ef41Sopenharmony_ci#endif  // V8_CODEGEN_CODE_STUB_ASSEMBLER_H_
4455