| // Copyright 2016 the V8 project authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef V8_CODEGEN_CODE_STUB_ASSEMBLER_H_ |
| #define V8_CODEGEN_CODE_STUB_ASSEMBLER_H_ |
| |
| #include <functional> |
| |
| #include "src/base/macros.h" |
| #include "src/codegen/bailout-reason.h" |
| #include "src/codegen/tnode.h" |
| #include "src/common/globals.h" |
| #include "src/common/message-template.h" |
| #include "src/compiler/code-assembler.h" |
| #include "src/numbers/integer-literal.h" |
| #include "src/objects/arguments.h" |
| #include "src/objects/bigint.h" |
| #include "src/objects/cell.h" |
| #include "src/objects/feedback-vector.h" |
| #include "src/objects/js-function.h" |
| #include "src/objects/js-generator.h" |
| #include "src/objects/js-promise.h" |
| #include "src/objects/objects.h" |
| #include "src/objects/promise.h" |
| #include "src/objects/shared-function-info.h" |
| #include "src/objects/smi.h" |
| #include "src/objects/swiss-name-dictionary.h" |
| #include "src/objects/tagged-index.h" |
| #include "src/roots/roots.h" |
| #include "src/sandbox/external-pointer.h" |
| #include "torque-generated/exported-macros-assembler.h" |
| |
| namespace v8 { |
| namespace internal { |
| |
| class CallInterfaceDescriptor; |
| class CodeStubArguments; |
| class CodeStubAssembler; |
| class StatsCounter; |
| class StubCache; |
| |
| enum class PrimitiveType { kBoolean, kNumber, kString, kSymbol }; |
| |
| #define HEAP_MUTABLE_IMMOVABLE_OBJECT_LIST(V) \ |
| V(ArrayIteratorProtector, array_iterator_protector, ArrayIteratorProtector) \ |
| V(ArraySpeciesProtector, array_species_protector, ArraySpeciesProtector) \ |
| V(AsyncFunctionAwaitRejectSharedFun, async_function_await_reject_shared_fun, \ |
| AsyncFunctionAwaitRejectSharedFun) \ |
| V(AsyncFunctionAwaitResolveSharedFun, \ |
| async_function_await_resolve_shared_fun, \ |
| AsyncFunctionAwaitResolveSharedFun) \ |
| V(AsyncGeneratorAwaitRejectSharedFun, \ |
| async_generator_await_reject_shared_fun, \ |
| AsyncGeneratorAwaitRejectSharedFun) \ |
| V(AsyncGeneratorAwaitResolveSharedFun, \ |
| async_generator_await_resolve_shared_fun, \ |
| AsyncGeneratorAwaitResolveSharedFun) \ |
| V(AsyncGeneratorReturnClosedRejectSharedFun, \ |
| async_generator_return_closed_reject_shared_fun, \ |
| AsyncGeneratorReturnClosedRejectSharedFun) \ |
| V(AsyncGeneratorReturnClosedResolveSharedFun, \ |
| async_generator_return_closed_resolve_shared_fun, \ |
| AsyncGeneratorReturnClosedResolveSharedFun) \ |
| V(AsyncGeneratorReturnResolveSharedFun, \ |
| async_generator_return_resolve_shared_fun, \ |
| AsyncGeneratorReturnResolveSharedFun) \ |
| V(AsyncGeneratorYieldResolveSharedFun, \ |
| async_generator_yield_resolve_shared_fun, \ |
| AsyncGeneratorYieldResolveSharedFun) \ |
| V(AsyncIteratorValueUnwrapSharedFun, async_iterator_value_unwrap_shared_fun, \ |
| AsyncIteratorValueUnwrapSharedFun) \ |
| V(IsConcatSpreadableProtector, is_concat_spreadable_protector, \ |
| IsConcatSpreadableProtector) \ |
| V(MapIteratorProtector, map_iterator_protector, MapIteratorProtector) \ |
| V(NoElementsProtector, no_elements_protector, NoElementsProtector) \ |
| V(MegaDOMProtector, mega_dom_protector, MegaDOMProtector) \ |
| V(NumberStringCache, number_string_cache, NumberStringCache) \ |
| V(PromiseAllResolveElementSharedFun, promise_all_resolve_element_shared_fun, \ |
| PromiseAllResolveElementSharedFun) \ |
| V(PromiseAllSettledRejectElementSharedFun, \ |
| promise_all_settled_reject_element_shared_fun, \ |
| PromiseAllSettledRejectElementSharedFun) \ |
| V(PromiseAllSettledResolveElementSharedFun, \ |
| promise_all_settled_resolve_element_shared_fun, \ |
| PromiseAllSettledResolveElementSharedFun) \ |
| V(PromiseAnyRejectElementSharedFun, promise_any_reject_element_shared_fun, \ |
| PromiseAnyRejectElementSharedFun) \ |
| V(PromiseCapabilityDefaultRejectSharedFun, \ |
| promise_capability_default_reject_shared_fun, \ |
| PromiseCapabilityDefaultRejectSharedFun) \ |
| V(PromiseCapabilityDefaultResolveSharedFun, \ |
| promise_capability_default_resolve_shared_fun, \ |
| PromiseCapabilityDefaultResolveSharedFun) \ |
| V(PromiseCatchFinallySharedFun, promise_catch_finally_shared_fun, \ |
| PromiseCatchFinallySharedFun) \ |
| V(PromiseGetCapabilitiesExecutorSharedFun, \ |
| promise_get_capabilities_executor_shared_fun, \ |
| PromiseGetCapabilitiesExecutorSharedFun) \ |
| V(PromiseResolveProtector, promise_resolve_protector, \ |
| PromiseResolveProtector) \ |
| V(PromiseSpeciesProtector, promise_species_protector, \ |
| PromiseSpeciesProtector) \ |
| V(PromiseThenFinallySharedFun, promise_then_finally_shared_fun, \ |
| PromiseThenFinallySharedFun) \ |
| V(PromiseThenProtector, promise_then_protector, PromiseThenProtector) \ |
| V(PromiseThrowerFinallySharedFun, promise_thrower_finally_shared_fun, \ |
| PromiseThrowerFinallySharedFun) \ |
| V(PromiseValueThunkFinallySharedFun, promise_value_thunk_finally_shared_fun, \ |
| PromiseValueThunkFinallySharedFun) \ |
| V(ProxyRevokeSharedFun, proxy_revoke_shared_fun, ProxyRevokeSharedFun) \ |
| V(RegExpSpeciesProtector, regexp_species_protector, RegExpSpeciesProtector) \ |
| V(SetIteratorProtector, set_iterator_protector, SetIteratorProtector) \ |
| V(SingleCharacterStringCache, single_character_string_cache, \ |
| SingleCharacterStringCache) \ |
| V(StringIteratorProtector, string_iterator_protector, \ |
| StringIteratorProtector) \ |
| V(TypedArraySpeciesProtector, typed_array_species_protector, \ |
| TypedArraySpeciesProtector) |
| |
| #define UNIQUE_INSTANCE_TYPE_IMMUTABLE_IMMOVABLE_MAP_ADAPTER( \ |
| V, rootIndexName, rootAccessorName, class_name) \ |
| V(rootIndexName, rootAccessorName, class_name##Map) |
| |
| #define HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(V) \ |
| V(AllocationSiteWithoutWeakNextMap, allocation_site_without_weaknext_map, \ |
| AllocationSiteWithoutWeakNextMap) \ |
| V(AllocationSiteWithWeakNextMap, allocation_site_map, AllocationSiteMap) \ |
| V(arguments_to_string, arguments_to_string, ArgumentsToString) \ |
| V(Array_string, Array_string, ArrayString) \ |
| V(array_to_string, array_to_string, ArrayToString) \ |
| V(BooleanMap, boolean_map, BooleanMap) \ |
| V(boolean_to_string, boolean_to_string, BooleanToString) \ |
| V(ConsOneByteStringMap, cons_one_byte_string_map, ConsOneByteStringMap) \ |
| V(ConsStringMap, cons_string_map, ConsStringMap) \ |
| V(constructor_string, constructor_string, ConstructorString) \ |
| V(date_to_string, date_to_string, DateToString) \ |
| V(default_string, default_string, DefaultString) \ |
| V(EmptyByteArray, empty_byte_array, EmptyByteArray) \ |
| V(EmptyFixedArray, empty_fixed_array, EmptyFixedArray) \ |
| V(EmptyScopeInfo, empty_scope_info, EmptyScopeInfo) \ |
| V(EmptyPropertyDictionary, empty_property_dictionary, \ |
| EmptyPropertyDictionary) \ |
| V(EmptyOrderedPropertyDictionary, empty_ordered_property_dictionary, \ |
| EmptyOrderedPropertyDictionary) \ |
| V(EmptySwissPropertyDictionary, empty_swiss_property_dictionary, \ |
| EmptySwissPropertyDictionary) \ |
| V(EmptySlowElementDictionary, empty_slow_element_dictionary, \ |
| EmptySlowElementDictionary) \ |
| V(empty_string, empty_string, EmptyString) \ |
| V(error_to_string, error_to_string, ErrorToString) \ |
| V(errors_string, errors_string, ErrorsString) \ |
| V(FalseValue, false_value, False) \ |
| V(FixedArrayMap, fixed_array_map, FixedArrayMap) \ |
| V(FixedCOWArrayMap, fixed_cow_array_map, FixedCOWArrayMap) \ |
| V(Function_string, function_string, FunctionString) \ |
| V(function_to_string, function_to_string, FunctionToString) \ |
| V(GlobalPropertyCellMap, global_property_cell_map, PropertyCellMap) \ |
| V(has_instance_symbol, has_instance_symbol, HasInstanceSymbol) \ |
| V(Infinity_string, Infinity_string, InfinityString) \ |
| V(is_concat_spreadable_symbol, is_concat_spreadable_symbol, \ |
| IsConcatSpreadableSymbol) \ |
| V(iterator_symbol, iterator_symbol, IteratorSymbol) \ |
| V(length_string, length_string, LengthString) \ |
| V(ManyClosuresCellMap, many_closures_cell_map, ManyClosuresCellMap) \ |
| V(match_symbol, match_symbol, MatchSymbol) \ |
| V(megamorphic_symbol, megamorphic_symbol, MegamorphicSymbol) \ |
| V(mega_dom_symbol, mega_dom_symbol, MegaDOMSymbol) \ |
| V(message_string, message_string, MessageString) \ |
| V(minus_Infinity_string, minus_Infinity_string, MinusInfinityString) \ |
| V(MinusZeroValue, minus_zero_value, MinusZero) \ |
| V(name_string, name_string, NameString) \ |
| V(NanValue, nan_value, Nan) \ |
| V(NaN_string, NaN_string, NaNString) \ |
| V(next_string, next_string, NextString) \ |
| V(NoClosuresCellMap, no_closures_cell_map, NoClosuresCellMap) \ |
| V(null_to_string, null_to_string, NullToString) \ |
| V(NullValue, null_value, Null) \ |
| V(number_string, number_string, NumberString) \ |
| V(number_to_string, number_to_string, NumberToString) \ |
| V(Object_string, Object_string, ObjectString) \ |
| V(object_to_string, object_to_string, ObjectToString) \ |
| V(OneByteStringMap, one_byte_string_map, OneByteStringMap) \ |
| V(OneClosureCellMap, one_closure_cell_map, OneClosureCellMap) \ |
| V(OnePointerFillerMap, one_pointer_filler_map, OnePointerFillerMap) \ |
| V(PromiseCapabilityMap, promise_capability_map, PromiseCapabilityMap) \ |
| V(promise_forwarding_handler_symbol, promise_forwarding_handler_symbol, \ |
| PromiseForwardingHandlerSymbol) \ |
| V(PromiseFulfillReactionJobTaskMap, promise_fulfill_reaction_job_task_map, \ |
| PromiseFulfillReactionJobTaskMap) \ |
| V(promise_handled_by_symbol, promise_handled_by_symbol, \ |
| PromiseHandledBySymbol) \ |
| V(PromiseReactionMap, promise_reaction_map, PromiseReactionMap) \ |
| V(PromiseRejectReactionJobTaskMap, promise_reject_reaction_job_task_map, \ |
| PromiseRejectReactionJobTaskMap) \ |
| V(PromiseResolveThenableJobTaskMap, promise_resolve_thenable_job_task_map, \ |
| PromiseResolveThenableJobTaskMap) \ |
| V(prototype_string, prototype_string, PrototypeString) \ |
| V(replace_symbol, replace_symbol, ReplaceSymbol) \ |
| V(regexp_to_string, regexp_to_string, RegexpToString) \ |
| V(resolve_string, resolve_string, ResolveString) \ |
| V(return_string, return_string, ReturnString) \ |
| V(search_symbol, search_symbol, SearchSymbol) \ |
| V(species_symbol, species_symbol, SpeciesSymbol) \ |
| V(StaleRegister, stale_register, StaleRegister) \ |
| V(StoreHandler0Map, store_handler0_map, StoreHandler0Map) \ |
| V(string_string, string_string, StringString) \ |
| V(string_to_string, string_to_string, StringToString) \ |
| V(StringMap, string_map, StringMap) \ |
| V(TheHoleValue, the_hole_value, TheHole) \ |
| V(then_string, then_string, ThenString) \ |
| V(toString_string, toString_string, ToStringString) \ |
| V(to_primitive_symbol, to_primitive_symbol, ToPrimitiveSymbol) \ |
| V(to_string_tag_symbol, to_string_tag_symbol, ToStringTagSymbol) \ |
| V(TrueValue, true_value, True) \ |
| V(undefined_to_string, undefined_to_string, UndefinedToString) \ |
| V(UndefinedValue, undefined_value, Undefined) \ |
| V(uninitialized_symbol, uninitialized_symbol, UninitializedSymbol) \ |
| V(valueOf_string, valueOf_string, ValueOfString) \ |
| V(wasm_wrapped_object_symbol, wasm_wrapped_object_symbol, \ |
| WasmWrappedObjectSymbol) \ |
| V(zero_string, zero_string, ZeroString) \ |
| UNIQUE_INSTANCE_TYPE_MAP_LIST_GENERATOR( \ |
| UNIQUE_INSTANCE_TYPE_IMMUTABLE_IMMOVABLE_MAP_ADAPTER, V) |
| |
| #define HEAP_IMMOVABLE_OBJECT_LIST(V) \ |
| HEAP_MUTABLE_IMMOVABLE_OBJECT_LIST(V) \ |
| HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(V) |
| |
| #ifdef DEBUG |
| #define CSA_CHECK(csa, x) \ |
| (csa)->Check([&]() -> TNode<BoolT> { return x; }, #x, __FILE__, __LINE__) |
| #else |
| #define CSA_CHECK(csa, x) (csa)->FastCheck(x) |
| #endif |
| |
| #ifdef DEBUG |
| // CSA_DCHECK_ARGS generates an |
| // std::initializer_list<CodeStubAssembler::ExtraNode> from __VA_ARGS__. It |
| // currently supports between 0 and 2 arguments. |
| |
| // clang-format off |
| #define CSA_DCHECK_0_ARGS(...) {} |
| #define CSA_DCHECK_1_ARG(a, ...) {{a, #a}} |
| #define CSA_DCHECK_2_ARGS(a, b, ...) {{a, #a}, {b, #b}} |
| // clang-format on |
| #define SWITCH_CSA_DCHECK_ARGS(dummy, a, b, FUNC, ...) FUNC(a, b) |
| #define CSA_DCHECK_ARGS(...) \ |
| CALL(SWITCH_CSA_DCHECK_ARGS, (, ##__VA_ARGS__, CSA_DCHECK_2_ARGS, \ |
| CSA_DCHECK_1_ARG, CSA_DCHECK_0_ARGS)) |
| // Workaround for MSVC to skip comma in empty __VA_ARGS__. |
| #define CALL(x, y) x y |
| |
| // CSA_DCHECK(csa, <condition>, <extra values to print...>) |
| |
| #define CSA_DCHECK(csa, condition_node, ...) \ |
| (csa)->Dcheck(condition_node, #condition_node, __FILE__, __LINE__, \ |
| CSA_DCHECK_ARGS(__VA_ARGS__)) |
| |
| // CSA_DCHECK_BRANCH(csa, [](Label* ok, Label* not_ok) {...}, |
| // <extra values to print...>) |
| |
| #define CSA_DCHECK_BRANCH(csa, gen, ...) \ |
| (csa)->Dcheck(gen, #gen, __FILE__, __LINE__, CSA_DCHECK_ARGS(__VA_ARGS__)) |
| |
| #define CSA_DCHECK_JS_ARGC_OP(csa, Op, op, expected) \ |
| (csa)->Dcheck( \ |
| [&]() -> TNode<BoolT> { \ |
| const TNode<Word32T> argc = (csa)->UncheckedParameter<Word32T>( \ |
| Descriptor::kJSActualArgumentsCount); \ |
| return (csa)->Op(argc, \ |
| (csa)->Int32Constant(i::JSParameterCount(expected))); \ |
| }, \ |
| "argc " #op " " #expected, __FILE__, __LINE__, \ |
| {{SmiFromInt32((csa)->UncheckedParameter<Int32T>( \ |
| Descriptor::kJSActualArgumentsCount)), \ |
| "argc"}}) |
| |
| #define CSA_DCHECK_JS_ARGC_EQ(csa, expected) \ |
| CSA_DCHECK_JS_ARGC_OP(csa, Word32Equal, ==, expected) |
| |
| #define CSA_DEBUG_INFO(name) \ |
| { #name, __FILE__, __LINE__ } |
| #define BIND(label) Bind(label, CSA_DEBUG_INFO(label)) |
| #define TYPED_VARIABLE_DEF(type, name, ...) \ |
| TVariable<type> name(CSA_DEBUG_INFO(name), __VA_ARGS__) |
| #define TYPED_VARIABLE_CONSTRUCTOR(name, ...) \ |
| name(CSA_DEBUG_INFO(name), __VA_ARGS__) |
| #else // DEBUG |
| #define CSA_DCHECK(csa, ...) ((void)0) |
| #define CSA_DCHECK_BRANCH(csa, ...) ((void)0) |
| #define CSA_DCHECK_JS_ARGC_EQ(csa, expected) ((void)0) |
| #define BIND(label) Bind(label) |
| #define TYPED_VARIABLE_DEF(type, name, ...) TVariable<type> name(__VA_ARGS__) |
| #define TYPED_VARIABLE_CONSTRUCTOR(name, ...) name(__VA_ARGS__) |
| #endif // DEBUG |
| |
| #define TVARIABLE(...) EXPAND(TYPED_VARIABLE_DEF(__VA_ARGS__, this)) |
| #define TVARIABLE_CONSTRUCTOR(...) \ |
| EXPAND(TYPED_VARIABLE_CONSTRUCTOR(__VA_ARGS__, this)) |
| |
| #ifdef ENABLE_SLOW_DCHECKS |
| #define CSA_SLOW_DCHECK(csa, ...) \ |
| if (FLAG_enable_slow_asserts) { \ |
| CSA_DCHECK(csa, __VA_ARGS__); \ |
| } |
| #else |
| #define CSA_SLOW_DCHECK(csa, ...) ((void)0) |
| #endif |
| |
| // Provides JavaScript-specific "macro-assembler" functionality on top of the |
| // CodeAssembler. By factoring the JavaScript-isms out of the CodeAssembler, |
| // it's possible to add JavaScript-specific useful CodeAssembler "macros" |
| // without modifying files in the compiler directory (and requiring a review |
| // from a compiler directory OWNER). |
| class V8_EXPORT_PRIVATE CodeStubAssembler |
| : public compiler::CodeAssembler, |
| public TorqueGeneratedExportedMacrosAssembler { |
| public: |
| using ScopedExceptionHandler = compiler::ScopedExceptionHandler; |
| |
| template <typename T> |
| using LazyNode = std::function<TNode<T>()>; |
| |
| explicit CodeStubAssembler(compiler::CodeAssemblerState* state); |
| |
| enum class AllocationFlag : uint8_t { |
| kNone = 0, |
| kDoubleAlignment = 1, |
| kPretenured = 1 << 1, |
| kAllowLargeObjectAllocation = 1 << 2, |
| }; |
| |
| enum SlackTrackingMode { kWithSlackTracking, kNoSlackTracking }; |
| |
| using AllocationFlags = base::Flags<AllocationFlag>; |
| |
| TNode<IntPtrT> ParameterToIntPtr(TNode<Smi> value) { return SmiUntag(value); } |
| TNode<IntPtrT> ParameterToIntPtr(TNode<IntPtrT> value) { return value; } |
| TNode<IntPtrT> ParameterToIntPtr(TNode<UintPtrT> value) { |
| return Signed(value); |
| } |
| |
| enum InitializationMode { |
| kUninitialized, |
| kInitializeToZero, |
| kInitializeToNull |
| }; |
| |
| TNode<Smi> ParameterToTagged(TNode<Smi> value) { return value; } |
| |
| TNode<Smi> ParameterToTagged(TNode<IntPtrT> value) { return SmiTag(value); } |
| |
| template <typename TIndex> |
| TNode<TIndex> TaggedToParameter(TNode<Smi> value); |
| |
| bool ToParameterConstant(TNode<Smi> node, intptr_t* out) { |
| if (TryToIntPtrConstant(node, out)) { |
| return true; |
| } |
| return false; |
| } |
| |
| bool ToParameterConstant(TNode<IntPtrT> node, intptr_t* out) { |
| intptr_t constant; |
| if (TryToIntPtrConstant(node, &constant)) { |
| *out = constant; |
| return true; |
| } |
| return false; |
| } |
| |
| #if defined(BINT_IS_SMI) |
| TNode<Smi> BIntToSmi(TNode<BInt> source) { return source; } |
| TNode<IntPtrT> BIntToIntPtr(TNode<BInt> source) { |
| return SmiToIntPtr(source); |
| } |
| TNode<BInt> SmiToBInt(TNode<Smi> source) { return source; } |
| TNode<BInt> IntPtrToBInt(TNode<IntPtrT> source) { |
| return SmiFromIntPtr(source); |
| } |
| #elif defined(BINT_IS_INTPTR) |
| TNode<Smi> BIntToSmi(TNode<BInt> source) { return SmiFromIntPtr(source); } |
| TNode<IntPtrT> BIntToIntPtr(TNode<BInt> source) { return source; } |
| TNode<BInt> SmiToBInt(TNode<Smi> source) { return SmiToIntPtr(source); } |
| TNode<BInt> IntPtrToBInt(TNode<IntPtrT> source) { return source; } |
| #else |
| #error Unknown architecture. |
| #endif |
| |
| TNode<IntPtrT> TaggedIndexToIntPtr(TNode<TaggedIndex> value); |
| TNode<TaggedIndex> IntPtrToTaggedIndex(TNode<IntPtrT> value); |
| // TODO(v8:10047): Get rid of these convertions eventually. |
| TNode<Smi> TaggedIndexToSmi(TNode<TaggedIndex> value); |
| TNode<TaggedIndex> SmiToTaggedIndex(TNode<Smi> value); |
| |
| // Pointer compression specific. Ensures that the upper 32 bits of a Smi |
| // contain the sign of a lower 32 bits so that the Smi can be directly used |
| // as an index in element offset computation. |
| TNode<Smi> NormalizeSmiIndex(TNode<Smi> smi_index); |
| |
| TNode<Smi> TaggedToSmi(TNode<Object> value, Label* fail) { |
| GotoIf(TaggedIsNotSmi(value), fail); |
| return UncheckedCast<Smi>(value); |
| } |
| |
| TNode<Smi> TaggedToPositiveSmi(TNode<Object> value, Label* fail) { |
| GotoIfNot(TaggedIsPositiveSmi(value), fail); |
| return UncheckedCast<Smi>(value); |
| } |
| |
| TNode<String> TaggedToDirectString(TNode<Object> value, Label* fail); |
| |
| TNode<HeapObject> TaggedToHeapObject(TNode<Object> value, Label* fail) { |
| GotoIf(TaggedIsSmi(value), fail); |
| return UncheckedCast<HeapObject>(value); |
| } |
| |
| TNode<Uint16T> Uint16Constant(uint16_t t) { |
| return UncheckedCast<Uint16T>(Int32Constant(t)); |
| } |
| |
| TNode<JSDataView> HeapObjectToJSDataView(TNode<HeapObject> heap_object, |
| Label* fail) { |
| GotoIfNot(IsJSDataView(heap_object), fail); |
| return CAST(heap_object); |
| } |
| |
| TNode<JSProxy> HeapObjectToJSProxy(TNode<HeapObject> heap_object, |
| Label* fail) { |
| GotoIfNot(IsJSProxy(heap_object), fail); |
| return CAST(heap_object); |
| } |
| |
| TNode<JSStringIterator> HeapObjectToJSStringIterator( |
| TNode<HeapObject> heap_object, Label* fail) { |
| GotoIfNot(IsJSStringIterator(heap_object), fail); |
| return CAST(heap_object); |
| } |
| |
| TNode<JSReceiver> HeapObjectToCallable(TNode<HeapObject> heap_object, |
| Label* fail) { |
| GotoIfNot(IsCallable(heap_object), fail); |
| return CAST(heap_object); |
| } |
| |
| TNode<String> HeapObjectToString(TNode<HeapObject> heap_object, Label* fail) { |
| GotoIfNot(IsString(heap_object), fail); |
| return CAST(heap_object); |
| } |
| |
| TNode<JSReceiver> HeapObjectToConstructor(TNode<HeapObject> heap_object, |
| Label* fail) { |
| GotoIfNot(IsConstructor(heap_object), fail); |
| return CAST(heap_object); |
| } |
| |
| TNode<JSFunction> HeapObjectToJSFunctionWithPrototypeSlot( |
| TNode<HeapObject> heap_object, Label* fail) { |
| GotoIfNot(IsJSFunctionWithPrototypeSlot(heap_object), fail); |
| return CAST(heap_object); |
| } |
| |
| template <typename T> |
| TNode<T> RunLazy(LazyNode<T> lazy) { |
| return lazy(); |
| } |
| |
| #define PARAMETER_BINOP(OpName, IntPtrOpName, SmiOpName) \ |
| TNode<Smi> OpName(TNode<Smi> a, TNode<Smi> b) { return SmiOpName(a, b); } \ |
| TNode<IntPtrT> OpName(TNode<IntPtrT> a, TNode<IntPtrT> b) { \ |
| return IntPtrOpName(a, b); \ |
| } \ |
| TNode<UintPtrT> OpName(TNode<UintPtrT> a, TNode<UintPtrT> b) { \ |
| return Unsigned(IntPtrOpName(Signed(a), Signed(b))); \ |
| } \ |
| TNode<RawPtrT> OpName(TNode<RawPtrT> a, TNode<RawPtrT> b) { \ |
| return ReinterpretCast<RawPtrT>(IntPtrOpName( \ |
| ReinterpretCast<IntPtrT>(a), ReinterpretCast<IntPtrT>(b))); \ |
| } |
| // TODO(v8:9708): Define BInt operations once all uses are ported. |
| PARAMETER_BINOP(IntPtrOrSmiAdd, IntPtrAdd, SmiAdd) |
| PARAMETER_BINOP(IntPtrOrSmiSub, IntPtrSub, SmiSub) |
| #undef PARAMETER_BINOP |
| |
| #define PARAMETER_BINOP(OpName, IntPtrOpName, SmiOpName) \ |
| TNode<BoolT> OpName(TNode<Smi> a, TNode<Smi> b) { return SmiOpName(a, b); } \ |
| TNode<BoolT> OpName(TNode<IntPtrT> a, TNode<IntPtrT> b) { \ |
| return IntPtrOpName(a, b); \ |
| } \ |
| TNode<BoolT> OpName(TNode<UintPtrT> a, TNode<UintPtrT> b) { \ |
| return IntPtrOpName(Signed(a), Signed(b)); \ |
| } \ |
| TNode<BoolT> OpName(TNode<RawPtrT> a, TNode<RawPtrT> b) { \ |
| return IntPtrOpName(a, b); \ |
| } |
| // TODO(v8:9708): Define BInt operations once all uses are ported. |
| PARAMETER_BINOP(IntPtrOrSmiEqual, WordEqual, SmiEqual) |
| PARAMETER_BINOP(IntPtrOrSmiNotEqual, WordNotEqual, SmiNotEqual) |
| PARAMETER_BINOP(IntPtrOrSmiLessThanOrEqual, IntPtrLessThanOrEqual, |
| SmiLessThanOrEqual) |
| PARAMETER_BINOP(IntPtrOrSmiGreaterThan, IntPtrGreaterThan, SmiGreaterThan) |
| PARAMETER_BINOP(UintPtrOrSmiLessThan, UintPtrLessThan, SmiBelow) |
| PARAMETER_BINOP(UintPtrOrSmiGreaterThanOrEqual, UintPtrGreaterThanOrEqual, |
| SmiAboveOrEqual) |
| #undef PARAMETER_BINOP |
| |
| uintptr_t ConstexprUintPtrShl(uintptr_t a, int32_t b) { return a << b; } |
| uintptr_t ConstexprUintPtrShr(uintptr_t a, int32_t b) { return a >> b; } |
| intptr_t ConstexprIntPtrAdd(intptr_t a, intptr_t b) { return a + b; } |
| uintptr_t ConstexprUintPtrAdd(uintptr_t a, uintptr_t b) { return a + b; } |
| intptr_t ConstexprWordNot(intptr_t a) { return ~a; } |
| uintptr_t ConstexprWordNot(uintptr_t a) { return ~a; } |
| |
| TNode<BoolT> TaggedEqual(TNode<AnyTaggedT> a, TNode<AnyTaggedT> b) { |
| if (COMPRESS_POINTERS_BOOL) { |
| return Word32Equal(ReinterpretCast<Word32T>(a), |
| ReinterpretCast<Word32T>(b)); |
| } else { |
| return WordEqual(ReinterpretCast<WordT>(a), ReinterpretCast<WordT>(b)); |
| } |
| } |
| |
| TNode<BoolT> TaggedNotEqual(TNode<AnyTaggedT> a, TNode<AnyTaggedT> b) { |
| return Word32BinaryNot(TaggedEqual(a, b)); |
| } |
| |
| TNode<Smi> NoContextConstant(); |
| |
| #define HEAP_CONSTANT_ACCESSOR(rootIndexName, rootAccessorName, name) \ |
| TNode<std::remove_pointer<std::remove_reference<decltype( \ |
| std::declval<ReadOnlyRoots>().rootAccessorName())>::type>::type> \ |
| name##Constant(); |
| HEAP_IMMUTABLE_IMMOVABLE_OBJECT_LIST(HEAP_CONSTANT_ACCESSOR) |
| #undef HEAP_CONSTANT_ACCESSOR |
| |
| #define HEAP_CONSTANT_ACCESSOR(rootIndexName, rootAccessorName, name) \ |
| TNode<std::remove_pointer<std::remove_reference<decltype( \ |
| std::declval<Heap>().rootAccessorName())>::type>::type> \ |
| name##Constant(); |
| HEAP_MUTABLE_IMMOVABLE_OBJECT_LIST(HEAP_CONSTANT_ACCESSOR) |
| #undef HEAP_CONSTANT_ACCESSOR |
| |
| #define HEAP_CONSTANT_TEST(rootIndexName, rootAccessorName, name) \ |
| TNode<BoolT> Is##name(TNode<Object> value); \ |
| TNode<BoolT> IsNot##name(TNode<Object> value); |
| HEAP_IMMOVABLE_OBJECT_LIST(HEAP_CONSTANT_TEST) |
| #undef HEAP_CONSTANT_TEST |
| |
| TNode<BInt> BIntConstant(int value); |
| |
| template <typename TIndex> |
| TNode<TIndex> IntPtrOrSmiConstant(int value); |
| |
| bool TryGetIntPtrOrSmiConstantValue(TNode<Smi> maybe_constant, int* value); |
| bool TryGetIntPtrOrSmiConstantValue(TNode<IntPtrT> maybe_constant, |
| int* value); |
| |
| TNode<IntPtrT> PopulationCountFallback(TNode<UintPtrT> value); |
| TNode<Int64T> PopulationCount64(TNode<Word64T> value); |
| TNode<Int32T> PopulationCount32(TNode<Word32T> value); |
| TNode<Int64T> CountTrailingZeros64(TNode<Word64T> value); |
| TNode<Int32T> CountTrailingZeros32(TNode<Word32T> value); |
| TNode<Int64T> CountLeadingZeros64(TNode<Word64T> value); |
| TNode<Int32T> CountLeadingZeros32(TNode<Word32T> value); |
| |
| // Round the 32bits payload of the provided word up to the next power of two. |
| TNode<IntPtrT> IntPtrRoundUpToPowerOfTwo32(TNode<IntPtrT> value); |
| // Select the maximum of the two provided IntPtr values. |
| TNode<IntPtrT> IntPtrMax(TNode<IntPtrT> left, TNode<IntPtrT> right); |
| // Select the minimum of the two provided IntPtr values. |
| TNode<IntPtrT> IntPtrMin(TNode<IntPtrT> left, TNode<IntPtrT> right); |
| TNode<UintPtrT> UintPtrMin(TNode<UintPtrT> left, TNode<UintPtrT> right); |
| |
| // Float64 operations. |
| TNode<Float64T> Float64Ceil(TNode<Float64T> x); |
| TNode<Float64T> Float64Floor(TNode<Float64T> x); |
| TNode<Float64T> Float64Round(TNode<Float64T> x); |
| TNode<Float64T> Float64RoundToEven(TNode<Float64T> x); |
| TNode<Float64T> Float64Trunc(TNode<Float64T> x); |
| // Select the minimum of the two provided Number values. |
| TNode<Number> NumberMax(TNode<Number> left, TNode<Number> right); |
| // Select the minimum of the two provided Number values. |
| TNode<Number> NumberMin(TNode<Number> left, TNode<Number> right); |
| |
| // Returns true iff the given value fits into smi range and is >= 0. |
| TNode<BoolT> IsValidPositiveSmi(TNode<IntPtrT> value); |
| |
| // Tag an IntPtr as a Smi value. |
| TNode<Smi> SmiTag(TNode<IntPtrT> value); |
| // Untag a Smi value as an IntPtr. |
| TNode<IntPtrT> SmiUntag(TNode<Smi> value); |
| |
| // Smi conversions. |
| TNode<Float64T> SmiToFloat64(TNode<Smi> value); |
| TNode<Smi> SmiFromIntPtr(TNode<IntPtrT> value) { return SmiTag(value); } |
| TNode<Smi> SmiFromInt32(TNode<Int32T> value); |
| TNode<Smi> SmiFromUint32(TNode<Uint32T> value); |
| TNode<IntPtrT> SmiToIntPtr(TNode<Smi> value) { return SmiUntag(value); } |
| TNode<Int32T> SmiToInt32(TNode<Smi> value); |
| |
| // Smi operations. |
| #define SMI_ARITHMETIC_BINOP(SmiOpName, IntPtrOpName, Int32OpName) \ |
| TNode<Smi> SmiOpName(TNode<Smi> a, TNode<Smi> b) { \ |
| if (SmiValuesAre32Bits()) { \ |
| return BitcastWordToTaggedSigned( \ |
| IntPtrOpName(BitcastTaggedToWordForTagAndSmiBits(a), \ |
| BitcastTaggedToWordForTagAndSmiBits(b))); \ |
| } else { \ |
| DCHECK(SmiValuesAre31Bits()); \ |
| return BitcastWordToTaggedSigned(ChangeInt32ToIntPtr(Int32OpName( \ |
| TruncateIntPtrToInt32(BitcastTaggedToWordForTagAndSmiBits(a)), \ |
| TruncateIntPtrToInt32(BitcastTaggedToWordForTagAndSmiBits(b))))); \ |
| } \ |
| } |
| SMI_ARITHMETIC_BINOP(SmiAdd, IntPtrAdd, Int32Add) |
| SMI_ARITHMETIC_BINOP(SmiSub, IntPtrSub, Int32Sub) |
| SMI_ARITHMETIC_BINOP(SmiAnd, WordAnd, Word32And) |
| SMI_ARITHMETIC_BINOP(SmiOr, WordOr, Word32Or) |
| SMI_ARITHMETIC_BINOP(SmiXor, WordXor, Word32Xor) |
| #undef SMI_ARITHMETIC_BINOP |
| |
| TNode<IntPtrT> TryIntPtrAdd(TNode<IntPtrT> a, TNode<IntPtrT> b, |
| Label* if_overflow); |
| TNode<IntPtrT> TryIntPtrSub(TNode<IntPtrT> a, TNode<IntPtrT> b, |
| Label* if_overflow); |
| TNode<Int32T> TryInt32Mul(TNode<Int32T> a, TNode<Int32T> b, |
| Label* if_overflow); |
| TNode<Smi> TrySmiAdd(TNode<Smi> a, TNode<Smi> b, Label* if_overflow); |
| TNode<Smi> TrySmiSub(TNode<Smi> a, TNode<Smi> b, Label* if_overflow); |
| TNode<Smi> TrySmiAbs(TNode<Smi> a, Label* if_overflow); |
| |
| TNode<Smi> SmiShl(TNode<Smi> a, int shift) { |
| TNode<Smi> result = BitcastWordToTaggedSigned( |
| WordShl(BitcastTaggedToWordForTagAndSmiBits(a), shift)); |
| // Smi shift have different result to int32 shift when the inputs are not |
| // strictly limited. The CSA_DCHECK is to ensure valid inputs. |
| CSA_DCHECK( |
| this, TaggedEqual(result, BitwiseOp(SmiToInt32(a), Int32Constant(shift), |
| Operation::kShiftLeft))); |
| return result; |
| } |
| |
| TNode<Smi> SmiShr(TNode<Smi> a, int shift) { |
| TNode<Smi> result; |
| if (kTaggedSize == kInt64Size) { |
| result = BitcastWordToTaggedSigned( |
| WordAnd(WordShr(BitcastTaggedToWordForTagAndSmiBits(a), shift), |
| BitcastTaggedToWordForTagAndSmiBits(SmiConstant(-1)))); |
| } else { |
| // For pointer compressed Smis, we want to make sure that we truncate to |
| // int32 before shifting, to avoid the values of the top 32-bits from |
| // leaking into the sign bit of the smi. |
| result = BitcastWordToTaggedSigned(WordAnd( |
| ChangeInt32ToIntPtr(Word32Shr( |
| TruncateWordToInt32(BitcastTaggedToWordForTagAndSmiBits(a)), |
| shift)), |
| BitcastTaggedToWordForTagAndSmiBits(SmiConstant(-1)))); |
| } |
| // Smi shift have different result to int32 shift when the inputs are not |
| // strictly limited. The CSA_DCHECK is to ensure valid inputs. |
| CSA_DCHECK( |
| this, TaggedEqual(result, BitwiseOp(SmiToInt32(a), Int32Constant(shift), |
| Operation::kShiftRightLogical))); |
| return result; |
| } |
| |
| TNode<Smi> SmiSar(TNode<Smi> a, int shift) { |
| // The number of shift bits is |shift % 64| for 64-bits value and |shift % |
| // 32| for 32-bits value. The DCHECK is to ensure valid inputs. |
| DCHECK_LT(shift, 32); |
| if (kTaggedSize == kInt64Size) { |
| return BitcastWordToTaggedSigned( |
| WordAnd(WordSar(BitcastTaggedToWordForTagAndSmiBits(a), shift), |
| BitcastTaggedToWordForTagAndSmiBits(SmiConstant(-1)))); |
| } else { |
| // For pointer compressed Smis, we want to make sure that we truncate to |
| // int32 before shifting, to avoid the values of the top 32-bits from |
| // changing the sign bit of the smi. |
| return BitcastWordToTaggedSigned(WordAnd( |
| ChangeInt32ToIntPtr(Word32Sar( |
| TruncateWordToInt32(BitcastTaggedToWordForTagAndSmiBits(a)), |
| shift)), |
| BitcastTaggedToWordForTagAndSmiBits(SmiConstant(-1)))); |
| } |
| } |
| |
| TNode<Smi> WordOrSmiShr(TNode<Smi> a, int shift) { return SmiShr(a, shift); } |
| |
| TNode<IntPtrT> WordOrSmiShr(TNode<IntPtrT> a, int shift) { |
| return WordShr(a, shift); |
| } |
| |
| #define SMI_COMPARISON_OP(SmiOpName, IntPtrOpName, Int32OpName) \ |
| TNode<BoolT> SmiOpName(TNode<Smi> a, TNode<Smi> b) { \ |
| if (kTaggedSize == kInt64Size) { \ |
| return IntPtrOpName(BitcastTaggedToWordForTagAndSmiBits(a), \ |
| BitcastTaggedToWordForTagAndSmiBits(b)); \ |
| } else { \ |
| DCHECK_EQ(kTaggedSize, kInt32Size); \ |
| DCHECK(SmiValuesAre31Bits()); \ |
| return Int32OpName( \ |
| TruncateIntPtrToInt32(BitcastTaggedToWordForTagAndSmiBits(a)), \ |
| TruncateIntPtrToInt32(BitcastTaggedToWordForTagAndSmiBits(b))); \ |
| } \ |
| } |
| SMI_COMPARISON_OP(SmiEqual, WordEqual, Word32Equal) |
| SMI_COMPARISON_OP(SmiNotEqual, WordNotEqual, Word32NotEqual) |
| SMI_COMPARISON_OP(SmiAbove, UintPtrGreaterThan, Uint32GreaterThan) |
| SMI_COMPARISON_OP(SmiAboveOrEqual, UintPtrGreaterThanOrEqual, |
| Uint32GreaterThanOrEqual) |
| SMI_COMPARISON_OP(SmiBelow, UintPtrLessThan, Uint32LessThan) |
| SMI_COMPARISON_OP(SmiLessThan, IntPtrLessThan, Int32LessThan) |
| SMI_COMPARISON_OP(SmiLessThanOrEqual, IntPtrLessThanOrEqual, |
| Int32LessThanOrEqual) |
| SMI_COMPARISON_OP(SmiGreaterThan, IntPtrGreaterThan, Int32GreaterThan) |
| SMI_COMPARISON_OP(SmiGreaterThanOrEqual, IntPtrGreaterThanOrEqual, |
| Int32GreaterThanOrEqual) |
| #undef SMI_COMPARISON_OP |
| TNode<Smi> SmiMax(TNode<Smi> a, TNode<Smi> b); |
| TNode<Smi> SmiMin(TNode<Smi> a, TNode<Smi> b); |
| // Computes a % b for Smi inputs a and b; result is not necessarily a Smi. |
| TNode<Number> SmiMod(TNode<Smi> a, TNode<Smi> b); |
| // Computes a * b for Smi inputs a and b; result is not necessarily a Smi. |
| TNode<Number> SmiMul(TNode<Smi> a, TNode<Smi> b); |
| // Tries to compute dividend / divisor for Smi inputs; branching to bailout |
| // if the division needs to be performed as a floating point operation. |
| TNode<Smi> TrySmiDiv(TNode<Smi> dividend, TNode<Smi> divisor, Label* bailout); |
| |
| // Compares two Smis a and b as if they were converted to strings and then |
| // compared lexicographically. Returns: |
| // -1 iff x < y. |
| // 0 iff x == y. |
| // 1 iff x > y. |
| TNode<Smi> SmiLexicographicCompare(TNode<Smi> x, TNode<Smi> y); |
| |
| #ifdef BINT_IS_SMI |
| #define BINT_COMPARISON_OP(BIntOpName, SmiOpName, IntPtrOpName) \ |
| TNode<BoolT> BIntOpName(TNode<BInt> a, TNode<BInt> b) { \ |
| return SmiOpName(a, b); \ |
| } |
| #else |
| #define BINT_COMPARISON_OP(BIntOpName, SmiOpName, IntPtrOpName) \ |
| TNode<BoolT> BIntOpName(TNode<BInt> a, TNode<BInt> b) { \ |
| return IntPtrOpName(a, b); \ |
| } |
| #endif |
| BINT_COMPARISON_OP(BIntEqual, SmiEqual, WordEqual) |
| BINT_COMPARISON_OP(BIntNotEqual, SmiNotEqual, WordNotEqual) |
| BINT_COMPARISON_OP(BIntAbove, SmiAbove, UintPtrGreaterThan) |
| BINT_COMPARISON_OP(BIntAboveOrEqual, SmiAboveOrEqual, |
| UintPtrGreaterThanOrEqual) |
| BINT_COMPARISON_OP(BIntBelow, SmiBelow, UintPtrLessThan) |
| BINT_COMPARISON_OP(BIntLessThan, SmiLessThan, IntPtrLessThan) |
| BINT_COMPARISON_OP(BIntLessThanOrEqual, SmiLessThanOrEqual, |
| IntPtrLessThanOrEqual) |
| BINT_COMPARISON_OP(BIntGreaterThan, SmiGreaterThan, IntPtrGreaterThan) |
| BINT_COMPARISON_OP(BIntGreaterThanOrEqual, SmiGreaterThanOrEqual, |
| IntPtrGreaterThanOrEqual) |
| #undef BINT_COMPARISON_OP |
| |
| // Smi | HeapNumber operations. |
| TNode<Number> NumberInc(TNode<Number> value); |
| TNode<Number> NumberDec(TNode<Number> value); |
| TNode<Number> NumberAdd(TNode<Number> a, TNode<Number> b); |
| TNode<Number> NumberSub(TNode<Number> a, TNode<Number> b); |
| void GotoIfNotNumber(TNode<Object> value, Label* is_not_number); |
| void GotoIfNumber(TNode<Object> value, Label* is_number); |
| TNode<Number> SmiToNumber(TNode<Smi> v) { return v; } |
| |
| TNode<Number> BitwiseOp(TNode<Word32T> left32, TNode<Word32T> right32, |
| Operation bitwise_op); |
| TNode<Number> BitwiseSmiOp(TNode<Smi> left32, TNode<Smi> right32, |
| Operation bitwise_op); |
| |
| // Allocate an object of the given size. |
| TNode<HeapObject> AllocateInNewSpace( |
| TNode<IntPtrT> size, AllocationFlags flags = AllocationFlag::kNone); |
| TNode<HeapObject> AllocateInNewSpace( |
| int size, AllocationFlags flags = AllocationFlag::kNone); |
| TNode<HeapObject> Allocate(TNode<IntPtrT> size, |
| AllocationFlags flags = AllocationFlag::kNone); |
| |
| TNode<HeapObject> Allocate(int size, |
| AllocationFlags flags = AllocationFlag::kNone); |
| |
| TNode<BoolT> IsRegularHeapObjectSize(TNode<IntPtrT> size); |
| |
| using BranchGenerator = std::function<void(Label*, Label*)>; |
| template <typename T> |
| using NodeGenerator = std::function<TNode<T>()>; |
| using ExtraNode = std::pair<TNode<Object>, const char*>; |
| |
| void Dcheck(const BranchGenerator& branch, const char* message, |
| const char* file, int line, |
| std::initializer_list<ExtraNode> extra_nodes = {}); |
| void Dcheck(const NodeGenerator<BoolT>& condition_body, const char* message, |
| const char* file, int line, |
| std::initializer_list<ExtraNode> extra_nodes = {}); |
| void Dcheck(TNode<Word32T> condition_node, const char* message, |
| const char* file, int line, |
| std::initializer_list<ExtraNode> extra_nodes = {}); |
| void Check(const BranchGenerator& branch, const char* message, |
| const char* file, int line, |
| std::initializer_list<ExtraNode> extra_nodes = {}); |
| void Check(const NodeGenerator<BoolT>& condition_body, const char* message, |
| const char* file, int line, |
| std::initializer_list<ExtraNode> extra_nodes = {}); |
| void Check(TNode<Word32T> condition_node, const char* message, |
| const char* file, int line, |
| std::initializer_list<ExtraNode> extra_nodes = {}); |
| void FailAssert(const char* message, |
| const std::vector<FileAndLine>& files_and_lines, |
| std::initializer_list<ExtraNode> extra_nodes = {}); |
| |
| void FastCheck(TNode<BoolT> condition); |
| |
| TNode<BoolT> IsCodeTMap(TNode<Map> map) { |
| return V8_EXTERNAL_CODE_SPACE_BOOL ? IsCodeDataContainerMap(map) |
| : IsCodeMap(map); |
| } |
| TNode<BoolT> IsCodeT(TNode<HeapObject> object) { |
| return IsCodeTMap(LoadMap(object)); |
| } |
| |
| // TODO(v8:11880): remove once Code::bytecode_or_interpreter_data field |
| // is cached in or moved to CodeT. |
| TNode<Code> FromCodeT(TNode<CodeT> code) { |
| #ifdef V8_EXTERNAL_CODE_SPACE |
| #if V8_TARGET_BIG_ENDIAN |
| #error "This code requires updating for big-endian architectures" |
| #endif |
| // Given the fields layout we can read the Code reference as a full word. |
| STATIC_ASSERT(CodeDataContainer::kCodeCageBaseUpper32BitsOffset == |
| CodeDataContainer::kCodeOffset + kTaggedSize); |
| TNode<Object> o = BitcastWordToTagged(Load<RawPtrT>( |
| code, IntPtrConstant(CodeDataContainer::kCodeOffset - kHeapObjectTag))); |
| return CAST(o); |
| #else |
| return code; |
| #endif |
| } |
| |
| TNode<CodeDataContainer> CodeDataContainerFromCodeT(TNode<CodeT> code) { |
| #ifdef V8_EXTERNAL_CODE_SPACE |
| return code; |
| #else |
| return LoadObjectField<CodeDataContainer>(code, |
| Code::kCodeDataContainerOffset); |
| #endif |
| } |
| |
| TNode<CodeT> ToCodeT(TNode<Code> code) { |
| #ifdef V8_EXTERNAL_CODE_SPACE |
| return LoadObjectField<CodeDataContainer>(code, |
| Code::kCodeDataContainerOffset); |
| #else |
| return code; |
| #endif |
| } |
| |
| TNode<CodeT> ToCodeT(TNode<Code> code, |
| TNode<CodeDataContainer> code_data_container) { |
| #ifdef V8_EXTERNAL_CODE_SPACE |
| return code_data_container; |
| #else |
| return code; |
| #endif |
| } |
| |
| TNode<RawPtrT> GetCodeEntry(TNode<CodeT> code); |
| |
| // The following Call wrappers call an object according to the semantics that |
| // one finds in the EcmaScript spec, operating on an Callable (e.g. a |
| // JSFunction or proxy) rather than a Code object. |
| template <class... TArgs> |
| TNode<Object> Call(TNode<Context> context, TNode<Object> callable, |
| TNode<JSReceiver> receiver, TArgs... args) { |
| return CallJS( |
| CodeFactory::Call(isolate(), ConvertReceiverMode::kNotNullOrUndefined), |
| context, callable, receiver, args...); |
| } |
| template <class... TArgs> |
| TNode<Object> Call(TNode<Context> context, TNode<Object> callable, |
| TNode<Object> receiver, TArgs... args) { |
| if (IsUndefinedConstant(receiver) || IsNullConstant(receiver)) { |
| return CallJS( |
| CodeFactory::Call(isolate(), ConvertReceiverMode::kNullOrUndefined), |
| context, callable, receiver, args...); |
| } |
| return CallJS(CodeFactory::Call(isolate()), context, callable, receiver, |
| args...); |
| } |
| |
| TNode<Object> CallApiCallback(TNode<Object> context, TNode<RawPtrT> callback, |
| TNode<IntPtrT> argc, TNode<Object> data, |
| TNode<Object> holder, TNode<Object> receiver); |
| |
| TNode<Object> CallApiCallback(TNode<Object> context, TNode<RawPtrT> callback, |
| TNode<IntPtrT> argc, TNode<Object> data, |
| TNode<Object> holder, TNode<Object> receiver, |
| TNode<Object> value); |
| |
| TNode<Object> CallRuntimeNewArray(TNode<Context> context, |
| TNode<Object> receiver, |
| TNode<Object> length, |
| TNode<Object> new_target, |
| TNode<Object> allocation_site); |
| |
| void TailCallRuntimeNewArray(TNode<Context> context, TNode<Object> receiver, |
| TNode<Object> length, TNode<Object> new_target, |
| TNode<Object> allocation_site); |
| |
| template <class... TArgs> |
| TNode<JSReceiver> ConstructWithTarget(TNode<Context> context, |
| TNode<JSReceiver> target, |
| TNode<JSReceiver> new_target, |
| TArgs... args) { |
| return CAST(ConstructJSWithTarget(CodeFactory::Construct(isolate()), |
| context, target, new_target, |
| implicit_cast<TNode<Object>>(args)...)); |
| } |
| template <class... TArgs> |
| TNode<JSReceiver> Construct(TNode<Context> context, |
| TNode<JSReceiver> new_target, TArgs... args) { |
| return ConstructWithTarget(context, new_target, new_target, args...); |
| } |
| |
| template <typename T> |
| TNode<T> Select(TNode<BoolT> condition, const NodeGenerator<T>& true_body, |
| const NodeGenerator<T>& false_body) { |
| TVARIABLE(T, value); |
| Label vtrue(this), vfalse(this), end(this); |
| Branch(condition, &vtrue, &vfalse); |
| |
| BIND(&vtrue); |
| { |
| value = true_body(); |
| Goto(&end); |
| } |
| BIND(&vfalse); |
| { |
| value = false_body(); |
| Goto(&end); |
| } |
| |
| BIND(&end); |
| return value.value(); |
| } |
| |
| template <class A> |
| TNode<A> SelectConstant(TNode<BoolT> condition, TNode<A> true_value, |
| TNode<A> false_value) { |
| return Select<A>( |
| condition, [=] { return true_value; }, [=] { return false_value; }); |
| } |
| |
| TNode<Int32T> SelectInt32Constant(TNode<BoolT> condition, int true_value, |
| int false_value); |
| TNode<IntPtrT> SelectIntPtrConstant(TNode<BoolT> condition, int true_value, |
| int false_value); |
| TNode<Oddball> SelectBooleanConstant(TNode<BoolT> condition); |
| TNode<Smi> SelectSmiConstant(TNode<BoolT> condition, Smi true_value, |
| Smi false_value); |
| TNode<Smi> SelectSmiConstant(TNode<BoolT> condition, int true_value, |
| Smi false_value) { |
| return SelectSmiConstant(condition, Smi::FromInt(true_value), false_value); |
| } |
| TNode<Smi> SelectSmiConstant(TNode<BoolT> condition, Smi true_value, |
| int false_value) { |
| return SelectSmiConstant(condition, true_value, Smi::FromInt(false_value)); |
| } |
| TNode<Smi> SelectSmiConstant(TNode<BoolT> condition, int true_value, |
| int false_value) { |
| return SelectSmiConstant(condition, Smi::FromInt(true_value), |
| Smi::FromInt(false_value)); |
| } |
| |
| TNode<String> SingleCharacterStringConstant(char const* single_char) { |
| DCHECK_EQ(strlen(single_char), 1); |
| return HeapConstant( |
| isolate()->factory()->LookupSingleCharacterStringFromCode( |
| single_char[0])); |
| } |
| |
| TNode<Int32T> TruncateWordToInt32(TNode<WordT> value); |
| TNode<Int32T> TruncateIntPtrToInt32(TNode<IntPtrT> value); |
| |
| // Check a value for smi-ness |
| TNode<BoolT> TaggedIsSmi(TNode<MaybeObject> a); |
| TNode<BoolT> TaggedIsNotSmi(TNode<MaybeObject> a); |
| |
| // Check that the value is a non-negative smi. |
| TNode<BoolT> TaggedIsPositiveSmi(TNode<Object> a); |
| // Check that a word has a word-aligned address. |
| TNode<BoolT> WordIsAligned(TNode<WordT> word, size_t alignment); |
| TNode<BoolT> WordIsPowerOfTwo(TNode<IntPtrT> value); |
| |
| // Check if lower_limit <= value <= higher_limit. |
| template <typename U> |
| TNode<BoolT> IsInRange(TNode<Word32T> value, U lower_limit, U higher_limit) { |
| DCHECK_LE(lower_limit, higher_limit); |
| STATIC_ASSERT(sizeof(U) <= kInt32Size); |
| return Uint32LessThanOrEqual(Int32Sub(value, Int32Constant(lower_limit)), |
| Int32Constant(higher_limit - lower_limit)); |
| } |
| |
| TNode<BoolT> IsInRange(TNode<WordT> value, intptr_t lower_limit, |
| intptr_t higher_limit) { |
| DCHECK_LE(lower_limit, higher_limit); |
| return UintPtrLessThanOrEqual(IntPtrSub(value, IntPtrConstant(lower_limit)), |
| IntPtrConstant(higher_limit - lower_limit)); |
| } |
| |
| #if DEBUG |
| void Bind(Label* label, AssemblerDebugInfo debug_info); |
| #endif // DEBUG |
| void Bind(Label* label); |
| |
| template <class... T> |
| void Bind(compiler::CodeAssemblerParameterizedLabel<T...>* label, |
| TNode<T>*... phis) { |
| CodeAssembler::Bind(label, phis...); |
| } |
| |
| void BranchIfSmiEqual(TNode<Smi> a, TNode<Smi> b, Label* if_true, |
| Label* if_false) { |
| Branch(SmiEqual(a, b), if_true, if_false); |
| } |
| |
| void BranchIfSmiLessThan(TNode<Smi> a, TNode<Smi> b, Label* if_true, |
| Label* if_false) { |
| Branch(SmiLessThan(a, b), if_true, if_false); |
| } |
| |
| void BranchIfSmiLessThanOrEqual(TNode<Smi> a, TNode<Smi> b, Label* if_true, |
| Label* if_false) { |
| Branch(SmiLessThanOrEqual(a, b), if_true, if_false); |
| } |
| |
| void BranchIfFloat64IsNaN(TNode<Float64T> value, Label* if_true, |
| Label* if_false) { |
| Branch(Float64Equal(value, value), if_false, if_true); |
| } |
| |
| // Branches to {if_true} if ToBoolean applied to {value} yields true, |
| // otherwise goes to {if_false}. |
| void BranchIfToBooleanIsTrue(TNode<Object> value, Label* if_true, |
| Label* if_false); |
| |
| // Branches to {if_false} if ToBoolean applied to {value} yields false, |
| // otherwise goes to {if_true}. |
| void BranchIfToBooleanIsFalse(TNode<Object> value, Label* if_false, |
| Label* if_true) { |
| BranchIfToBooleanIsTrue(value, if_true, if_false); |
| } |
| |
| void BranchIfJSReceiver(TNode<Object> object, Label* if_true, |
| Label* if_false); |
| |
| // Branches to {if_true} when --force-slow-path flag has been passed. |
| // It's used for testing to ensure that slow path implementation behave |
| // equivalent to corresponding fast paths (where applicable). |
| // |
| // Works only with V8_ENABLE_FORCE_SLOW_PATH compile time flag. Nop otherwise. |
| void GotoIfForceSlowPath(Label* if_true); |
| |
| // |
| // Caged pointer related functionality. |
| // |
| |
| // Load a caged pointer value from an object. |
| TNode<RawPtrT> LoadSandboxedPointerFromObject(TNode<HeapObject> object, |
| int offset) { |
| return LoadSandboxedPointerFromObject(object, IntPtrConstant(offset)); |
| } |
| |
| TNode<RawPtrT> LoadSandboxedPointerFromObject(TNode<HeapObject> object, |
| TNode<IntPtrT> offset); |
| |
| // Stored a caged pointer value to an object. |
| void StoreSandboxedPointerToObject(TNode<HeapObject> object, int offset, |
| TNode<RawPtrT> pointer) { |
| StoreSandboxedPointerToObject(object, IntPtrConstant(offset), pointer); |
| } |
| |
| void StoreSandboxedPointerToObject(TNode<HeapObject> object, |
| TNode<IntPtrT> offset, |
| TNode<RawPtrT> pointer); |
| |
| TNode<RawPtrT> EmptyBackingStoreBufferConstant(); |
| |
| // |
| // ExternalPointerT-related functionality. |
| // |
| |
| #ifdef V8_SANDBOXED_EXTERNAL_POINTERS |
| TNode<ExternalPointerT> ChangeIndexToExternalPointer(TNode<Uint32T> index); |
| TNode<Uint32T> ChangeExternalPointerToIndex(TNode<ExternalPointerT> pointer); |
| #endif // V8_SANDBOXED_EXTERNAL_POINTERS |
| |
| // Initialize an external pointer field in an object. |
| void InitializeExternalPointerField(TNode<HeapObject> object, int offset) { |
| InitializeExternalPointerField(object, IntPtrConstant(offset)); |
| } |
| void InitializeExternalPointerField(TNode<HeapObject> object, |
| TNode<IntPtrT> offset); |
| |
| // Initialize an external pointer field in an object with given value. |
| void InitializeExternalPointerField(TNode<HeapObject> object, int offset, |
| TNode<RawPtrT> pointer, |
| ExternalPointerTag tag) { |
| InitializeExternalPointerField(object, IntPtrConstant(offset), pointer, |
| tag); |
| } |
| |
| void InitializeExternalPointerField(TNode<HeapObject> object, |
| TNode<IntPtrT> offset, |
| TNode<RawPtrT> pointer, |
| ExternalPointerTag tag) { |
| InitializeExternalPointerField(object, offset); |
| StoreExternalPointerToObject(object, offset, pointer, tag); |
| } |
| |
| // Load an external pointer value from an object. |
| TNode<RawPtrT> LoadExternalPointerFromObject(TNode<HeapObject> object, |
| int offset, |
| ExternalPointerTag tag) { |
| return LoadExternalPointerFromObject(object, IntPtrConstant(offset), tag); |
| } |
| |
| TNode<RawPtrT> LoadExternalPointerFromObject(TNode<HeapObject> object, |
| TNode<IntPtrT> offset, |
| ExternalPointerTag tag); |
| |
| // Store external object pointer to object. |
| void StoreExternalPointerToObject(TNode<HeapObject> object, int offset, |
| TNode<RawPtrT> pointer, |
| ExternalPointerTag tag) { |
| StoreExternalPointerToObject(object, IntPtrConstant(offset), pointer, tag); |
| } |
| |
| void StoreExternalPointerToObject(TNode<HeapObject> object, |
| TNode<IntPtrT> offset, |
| TNode<RawPtrT> pointer, |
| ExternalPointerTag tag); |
| |
| TNode<RawPtrT> LoadForeignForeignAddressPtr(TNode<Foreign> object) { |
| return LoadExternalPointerFromObject(object, Foreign::kForeignAddressOffset, |
| kForeignForeignAddressTag); |
| } |
| |
| TNode<RawPtrT> LoadExternalStringResourcePtr(TNode<ExternalString> object) { |
| return LoadExternalPointerFromObject( |
| object, ExternalString::kResourceOffset, kExternalStringResourceTag); |
| } |
| |
| TNode<RawPtrT> LoadExternalStringResourceDataPtr( |
| TNode<ExternalString> object) { |
| // This is only valid for ExternalStrings where the resource data |
| // pointer is cached (i.e. no uncached external strings). |
| CSA_DCHECK(this, Word32NotEqual( |
| Word32And(LoadInstanceType(object), |
| Int32Constant(kUncachedExternalStringMask)), |
| Int32Constant(kUncachedExternalStringTag))); |
| return LoadExternalPointerFromObject(object, |
| ExternalString::kResourceDataOffset, |
| kExternalStringResourceDataTag); |
| } |
| |
| TNode<RawPtrT> LoadJSTypedArrayExternalPointerPtr( |
| TNode<JSTypedArray> holder) { |
| return LoadSandboxedPointerFromObject(holder, |
| JSTypedArray::kExternalPointerOffset); |
| } |
| |
| void StoreJSTypedArrayExternalPointerPtr(TNode<JSTypedArray> holder, |
| TNode<RawPtrT> value) { |
| StoreSandboxedPointerToObject(holder, JSTypedArray::kExternalPointerOffset, |
| value); |
| } |
| |
| // Load value from current parent frame by given offset in bytes. |
| TNode<Object> LoadFromParentFrame(int offset); |
| |
| // Load an object pointer from a buffer that isn't in the heap. |
| TNode<Object> LoadBufferObject(TNode<RawPtrT> buffer, int offset) { |
| return LoadFullTagged(buffer, IntPtrConstant(offset)); |
| } |
| template <typename T> |
| TNode<T> LoadBufferData(TNode<RawPtrT> buffer, int offset) { |
| return UncheckedCast<T>( |
| Load(MachineTypeOf<T>::value, buffer, IntPtrConstant(offset))); |
| } |
| TNode<RawPtrT> LoadBufferPointer(TNode<RawPtrT> buffer, int offset) { |
| return LoadBufferData<RawPtrT>(buffer, offset); |
| } |
| TNode<Smi> LoadBufferSmi(TNode<RawPtrT> buffer, int offset) { |
| return CAST(LoadBufferObject(buffer, offset)); |
| } |
| TNode<IntPtrT> LoadBufferIntptr(TNode<RawPtrT> buffer, int offset) { |
| return LoadBufferData<IntPtrT>(buffer, offset); |
| } |
| TNode<Uint8T> LoadUint8Ptr(TNode<RawPtrT> ptr, TNode<IntPtrT> offset); |
| |
| // Load a field from an object on the heap. |
| template <class T, typename std::enable_if< |
| std::is_convertible<TNode<T>, TNode<Object>>::value && |
| std::is_base_of<T, Map>::value, |
| int>::type = 0> |
| TNode<T> LoadObjectField(TNode<HeapObject> object, int offset) { |
| const MachineType machine_type = offset == HeapObject::kMapOffset |
| ? MachineType::MapInHeader() |
| : MachineTypeOf<T>::value; |
| return CAST(LoadFromObject(machine_type, object, |
| IntPtrConstant(offset - kHeapObjectTag))); |
| } |
| template <class T, typename std::enable_if< |
| std::is_convertible<TNode<T>, TNode<Object>>::value && |
| !std::is_base_of<T, Map>::value, |
| int>::type = 0> |
| TNode<T> LoadObjectField(TNode<HeapObject> object, int offset) { |
| return CAST(LoadFromObject(MachineTypeOf<T>::value, object, |
| IntPtrConstant(offset - kHeapObjectTag))); |
| } |
| template <class T, typename std::enable_if< |
| std::is_convertible<TNode<T>, TNode<UntaggedT>>::value, |
| int>::type = 0> |
| TNode<T> LoadObjectField(TNode<HeapObject> object, int offset) { |
| return UncheckedCast<T>( |
| LoadFromObject(MachineTypeOf<T>::value, object, |
| IntPtrConstant(offset - kHeapObjectTag))); |
| } |
| TNode<Object> LoadObjectField(TNode<HeapObject> object, int offset) { |
| return UncheckedCast<Object>( |
| LoadFromObject(MachineType::AnyTagged(), object, |
| IntPtrConstant(offset - kHeapObjectTag))); |
| } |
| TNode<Object> LoadObjectField(TNode<HeapObject> object, |
| TNode<IntPtrT> offset) { |
| return UncheckedCast<Object>( |
| LoadFromObject(MachineType::AnyTagged(), object, |
| IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)))); |
| } |
| template <class T, typename std::enable_if< |
| std::is_convertible<TNode<T>, TNode<UntaggedT>>::value, |
| int>::type = 0> |
| TNode<T> LoadObjectField(TNode<HeapObject> object, TNode<IntPtrT> offset) { |
| return UncheckedCast<T>( |
| LoadFromObject(MachineTypeOf<T>::value, object, |
| IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)))); |
| } |
| // Load a SMI field and untag it. |
| TNode<IntPtrT> LoadAndUntagObjectField(TNode<HeapObject> object, int offset); |
| // Load a SMI field, untag it, and convert to Word32. |
| TNode<Int32T> LoadAndUntagToWord32ObjectField(TNode<HeapObject> object, |
| int offset); |
| |
| TNode<MaybeObject> LoadMaybeWeakObjectField(TNode<HeapObject> object, |
| int offset) { |
| return UncheckedCast<MaybeObject>(LoadObjectField(object, offset)); |
| } |
| |
| TNode<Object> LoadConstructorOrBackPointer(TNode<Map> map) { |
| return LoadObjectField(map, |
| Map::kConstructorOrBackPointerOrNativeContextOffset); |
| } |
| |
| TNode<Simd128T> LoadSimd128(TNode<IntPtrT> ptr) { |
| return Load<Simd128T>(ptr); |
| } |
| |
| // Reference is the CSA-equivalent of a Torque reference value, representing |
| // an inner pointer into a HeapObject. |
| // |
| // The object can be a HeapObject or an all-zero bitpattern. The latter is |
| // used for off-heap data, in which case the offset holds the actual address |
| // and the data must be untagged (i.e. accessed via the Load-/StoreReference |
| // overloads for TNode<UntaggedT>-convertible types below). |
| // |
| // TODO(gsps): Remove in favor of flattened {Load,Store}Reference interface. |
| struct Reference { |
| TNode<Object> object; |
| TNode<IntPtrT> offset; |
| |
| std::tuple<TNode<Object>, TNode<IntPtrT>> Flatten() const { |
| return std::make_tuple(object, offset); |
| } |
| }; |
| |
| template <class T, typename std::enable_if< |
| std::is_convertible<TNode<T>, TNode<Object>>::value, |
| int>::type = 0> |
| TNode<T> LoadReference(Reference reference) { |
| if (IsMapOffsetConstant(reference.offset)) { |
| TNode<Map> map = LoadMap(CAST(reference.object)); |
| DCHECK((std::is_base_of<T, Map>::value)); |
| return ReinterpretCast<T>(map); |
| } |
| |
| TNode<IntPtrT> offset = |
| IntPtrSub(reference.offset, IntPtrConstant(kHeapObjectTag)); |
| CSA_DCHECK(this, TaggedIsNotSmi(reference.object)); |
| return CAST( |
| LoadFromObject(MachineTypeOf<T>::value, reference.object, offset)); |
| } |
| template <class T, |
| typename std::enable_if< |
| std::is_convertible<TNode<T>, TNode<UntaggedT>>::value || |
| std::is_same<T, MaybeObject>::value, |
| int>::type = 0> |
| TNode<T> LoadReference(Reference reference) { |
| DCHECK(!IsMapOffsetConstant(reference.offset)); |
| TNode<IntPtrT> offset = |
| IntPtrSub(reference.offset, IntPtrConstant(kHeapObjectTag)); |
| return UncheckedCast<T>( |
| LoadFromObject(MachineTypeOf<T>::value, reference.object, offset)); |
| } |
| template <class T, typename std::enable_if< |
| std::is_convertible<TNode<T>, TNode<Object>>::value || |
| std::is_same<T, MaybeObject>::value, |
| int>::type = 0> |
| void StoreReference(Reference reference, TNode<T> value) { |
| if (IsMapOffsetConstant(reference.offset)) { |
| DCHECK((std::is_base_of<T, Map>::value)); |
| return StoreMap(CAST(reference.object), ReinterpretCast<Map>(value)); |
| } |
| MachineRepresentation rep = MachineRepresentationOf<T>::value; |
| StoreToObjectWriteBarrier write_barrier = StoreToObjectWriteBarrier::kFull; |
| if (std::is_same<T, Smi>::value) { |
| write_barrier = StoreToObjectWriteBarrier::kNone; |
| } else if (std::is_same<T, Map>::value) { |
| write_barrier = StoreToObjectWriteBarrier::kMap; |
| } |
| TNode<IntPtrT> offset = |
| IntPtrSub(reference.offset, IntPtrConstant(kHeapObjectTag)); |
| CSA_DCHECK(this, TaggedIsNotSmi(reference.object)); |
| StoreToObject(rep, reference.object, offset, value, write_barrier); |
| } |
| template <class T, typename std::enable_if< |
| std::is_convertible<TNode<T>, TNode<UntaggedT>>::value, |
| int>::type = 0> |
| void StoreReference(Reference reference, TNode<T> value) { |
| DCHECK(!IsMapOffsetConstant(reference.offset)); |
| TNode<IntPtrT> offset = |
| IntPtrSub(reference.offset, IntPtrConstant(kHeapObjectTag)); |
| StoreToObject(MachineRepresentationOf<T>::value, reference.object, offset, |
| value, StoreToObjectWriteBarrier::kNone); |
| } |
| |
| TNode<RawPtrT> GCUnsafeReferenceToRawPtr(TNode<Object> object, |
| TNode<IntPtrT> offset) { |
| return ReinterpretCast<RawPtrT>( |
| IntPtrAdd(BitcastTaggedToWord(object), |
| IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)))); |
| } |
| |
| // Load the floating point value of a HeapNumber. |
| TNode<Float64T> LoadHeapNumberValue(TNode<HeapObject> object); |
| // Load the Map of an HeapObject. |
| TNode<Map> LoadMap(TNode<HeapObject> object); |
| // Load the instance type of an HeapObject. |
| TNode<Uint16T> LoadInstanceType(TNode<HeapObject> object); |
| // Compare the instance the type of the object against the provided one. |
| TNode<BoolT> HasInstanceType(TNode<HeapObject> object, InstanceType type); |
| TNode<BoolT> DoesntHaveInstanceType(TNode<HeapObject> object, |
| InstanceType type); |
| TNode<BoolT> TaggedDoesntHaveInstanceType(TNode<HeapObject> any_tagged, |
| InstanceType type); |
| |
| TNode<Word32T> IsStringWrapperElementsKind(TNode<Map> map); |
| void GotoIfMapHasSlowProperties(TNode<Map> map, Label* if_slow); |
| |
| // Load the properties backing store of a JSReceiver. |
| TNode<HeapObject> LoadSlowProperties(TNode<JSReceiver> object); |
| TNode<HeapObject> LoadFastProperties(TNode<JSReceiver> object); |
| // Load the elements backing store of a JSObject. |
| TNode<FixedArrayBase> LoadElements(TNode<JSObject> object) { |
| return LoadJSObjectElements(object); |
| } |
| // Load the length of a JSArray instance. |
| TNode<Object> LoadJSArgumentsObjectLength(TNode<Context> context, |
| TNode<JSArgumentsObject> array); |
| // Load the length of a fast JSArray instance. Returns a positive Smi. |
| TNode<Smi> LoadFastJSArrayLength(TNode<JSArray> array); |
| // Load the length of a fixed array base instance. |
| TNode<Smi> LoadFixedArrayBaseLength(TNode<FixedArrayBase> array); |
| // Load the length of a fixed array base instance. |
| TNode<IntPtrT> LoadAndUntagFixedArrayBaseLength(TNode<FixedArrayBase> array); |
| // Load the length of a WeakFixedArray. |
| TNode<Smi> LoadWeakFixedArrayLength(TNode<WeakFixedArray> array); |
| TNode<IntPtrT> LoadAndUntagWeakFixedArrayLength(TNode<WeakFixedArray> array); |
| // Load the number of descriptors in DescriptorArray. |
| TNode<Int32T> LoadNumberOfDescriptors(TNode<DescriptorArray> array); |
| // Load the number of own descriptors of a map. |
| TNode<Int32T> LoadNumberOfOwnDescriptors(TNode<Map> map); |
| // Load the bit field of a Map. |
| TNode<Int32T> LoadMapBitField(TNode<Map> map); |
| // Load bit field 2 of a map. |
| TNode<Int32T> LoadMapBitField2(TNode<Map> map); |
| // Load bit field 3 of a map. |
| TNode<Uint32T> LoadMapBitField3(TNode<Map> map); |
| // Load the instance type of a map. |
| TNode<Uint16T> LoadMapInstanceType(TNode<Map> map); |
| // Load the ElementsKind of a map. |
| TNode<Int32T> LoadMapElementsKind(TNode<Map> map); |
| TNode<Int32T> LoadElementsKind(TNode<HeapObject> object); |
| // Load the instance descriptors of a map. |
| TNode<DescriptorArray> LoadMapDescriptors(TNode<Map> map); |
| // Load the prototype of a map. |
| TNode<HeapObject> LoadMapPrototype(TNode<Map> map); |
| // Load the instance size of a Map. |
| TNode<IntPtrT> LoadMapInstanceSizeInWords(TNode<Map> map); |
| // Load the inobject properties start of a Map (valid only for JSObjects). |
| TNode<IntPtrT> LoadMapInobjectPropertiesStartInWords(TNode<Map> map); |
| // Load the constructor function index of a Map (only for primitive maps). |
| TNode<IntPtrT> LoadMapConstructorFunctionIndex(TNode<Map> map); |
| // Load the constructor of a Map (equivalent to Map::GetConstructor()). |
| TNode<Object> LoadMapConstructor(TNode<Map> map); |
| // Load the EnumLength of a Map. |
| TNode<WordT> LoadMapEnumLength(TNode<Map> map); |
| // Load the back-pointer of a Map. |
| TNode<Object> LoadMapBackPointer(TNode<Map> map); |
| // Checks that |map| has only simple properties, returns bitfield3. |
| TNode<Uint32T> EnsureOnlyHasSimpleProperties(TNode<Map> map, |
| TNode<Int32T> instance_type, |
| Label* bailout); |
| // Load the identity hash of a JSRececiver. |
| TNode<IntPtrT> LoadJSReceiverIdentityHash(TNode<JSReceiver> receiver, |
| Label* if_no_hash = nullptr); |
| |
| // This is only used on a newly allocated PropertyArray which |
| // doesn't have an existing hash. |
| void InitializePropertyArrayLength(TNode<PropertyArray> property_array, |
| TNode<IntPtrT> length); |
| |
| // Check if the map is set for slow properties. |
| TNode<BoolT> IsDictionaryMap(TNode<Map> map); |
| |
| // Load the Name::hash() value of a name as an uint32 value. |
| // If {if_hash_not_computed} label is specified then it also checks if |
| // hash is actually computed. |
| TNode<Uint32T> LoadNameHash(TNode<Name> name, |
| Label* if_hash_not_computed = nullptr); |
| TNode<Uint32T> LoadNameHashAssumeComputed(TNode<Name> name); |
| |
| // Load length field of a String object as Smi value. |
| TNode<Smi> LoadStringLengthAsSmi(TNode<String> string); |
| // Load length field of a String object as intptr_t value. |
| TNode<IntPtrT> LoadStringLengthAsWord(TNode<String> string); |
| // Load length field of a String object as uint32_t value. |
| TNode<Uint32T> LoadStringLengthAsWord32(TNode<String> string); |
| // Load value field of a JSPrimitiveWrapper object. |
| TNode<Object> LoadJSPrimitiveWrapperValue(TNode<JSPrimitiveWrapper> object); |
| |
| // Figures out whether the value of maybe_object is: |
| // - a SMI (jump to "if_smi", "extracted" will be the SMI value) |
| // - a cleared weak reference (jump to "if_cleared", "extracted" will be |
| // untouched) |
| // - a weak reference (jump to "if_weak", "extracted" will be the object |
| // pointed to) |
| // - a strong reference (jump to "if_strong", "extracted" will be the object |
| // pointed to) |
| void DispatchMaybeObject(TNode<MaybeObject> maybe_object, Label* if_smi, |
| Label* if_cleared, Label* if_weak, Label* if_strong, |
| TVariable<Object>* extracted); |
| // See MaybeObject for semantics of these functions. |
| TNode<BoolT> IsStrong(TNode<MaybeObject> value); |
| TNode<HeapObject> GetHeapObjectIfStrong(TNode<MaybeObject> value, |
| Label* if_not_strong); |
| |
| TNode<BoolT> IsWeakOrCleared(TNode<MaybeObject> value); |
| TNode<BoolT> IsCleared(TNode<MaybeObject> value); |
| TNode<BoolT> IsNotCleared(TNode<MaybeObject> value) { |
| return Word32BinaryNot(IsCleared(value)); |
| } |
| |
| // Removes the weak bit + asserts it was set. |
| TNode<HeapObject> GetHeapObjectAssumeWeak(TNode<MaybeObject> value); |
| |
| TNode<HeapObject> GetHeapObjectAssumeWeak(TNode<MaybeObject> value, |
| Label* if_cleared); |
| |
| // Checks if |maybe_object| is a weak reference to given |heap_object|. |
| // Works for both any tagged |maybe_object| values. |
| TNode<BoolT> IsWeakReferenceTo(TNode<MaybeObject> maybe_object, |
| TNode<HeapObject> heap_object); |
| // Returns true if the |object| is a HeapObject and |maybe_object| is a weak |
| // reference to |object|. |
| // The |maybe_object| must not be a Smi. |
| TNode<BoolT> IsWeakReferenceToObject(TNode<MaybeObject> maybe_object, |
| TNode<Object> object); |
| |
| TNode<MaybeObject> MakeWeak(TNode<HeapObject> value); |
| |
| void FixedArrayBoundsCheck(TNode<FixedArrayBase> array, TNode<Smi> index, |
| int additional_offset); |
| |
| void FixedArrayBoundsCheck(TNode<FixedArrayBase> array, TNode<IntPtrT> index, |
| int additional_offset); |
| |
| void FixedArrayBoundsCheck(TNode<FixedArrayBase> array, TNode<UintPtrT> index, |
| int additional_offset) { |
| FixedArrayBoundsCheck(array, Signed(index), additional_offset); |
| } |
| |
| // Array is any array-like type that has a fixed header followed by |
| // tagged elements. |
| template <typename Array> |
| TNode<IntPtrT> LoadArrayLength(TNode<Array> array); |
| |
| // Array is any array-like type that has a fixed header followed by |
| // tagged elements. |
| template <typename Array, typename TIndex, typename TValue = MaybeObject> |
| TNode<TValue> LoadArrayElement(TNode<Array> array, int array_header_size, |
| TNode<TIndex> index, |
| int additional_offset = 0); |
| |
| template <typename TIndex> |
| TNode<Object> LoadFixedArrayElement( |
| TNode<FixedArray> object, TNode<TIndex> index, int additional_offset = 0, |
| CheckBounds check_bounds = CheckBounds::kAlways); |
| |
| // This doesn't emit a bounds-check. As part of the security-performance |
| // tradeoff, only use it if it is performance critical. |
| TNode<Object> UnsafeLoadFixedArrayElement(TNode<FixedArray> object, |
| TNode<IntPtrT> index, |
| int additional_offset = 0) { |
| return LoadFixedArrayElement(object, index, additional_offset, |
| CheckBounds::kDebugOnly); |
| } |
| |
| TNode<Object> LoadFixedArrayElement(TNode<FixedArray> object, int index, |
| int additional_offset = 0) { |
| return LoadFixedArrayElement(object, IntPtrConstant(index), |
| additional_offset); |
| } |
| // This doesn't emit a bounds-check. As part of the security-performance |
| // tradeoff, only use it if it is performance critical. |
| TNode<Object> UnsafeLoadFixedArrayElement(TNode<FixedArray> object, int index, |
| int additional_offset = 0) { |
| return LoadFixedArrayElement(object, IntPtrConstant(index), |
| additional_offset, CheckBounds::kDebugOnly); |
| } |
| |
| TNode<Object> LoadPropertyArrayElement(TNode<PropertyArray> object, |
| TNode<IntPtrT> index); |
| TNode<IntPtrT> LoadPropertyArrayLength(TNode<PropertyArray> object); |
| |
| // Load an element from an array and untag it and return it as Word32. |
| // Array is any array-like type that has a fixed header followed by |
| // tagged elements. |
| template <typename Array> |
| TNode<Int32T> LoadAndUntagToWord32ArrayElement(TNode<Array> array, |
| int array_header_size, |
| TNode<IntPtrT> index, |
| int additional_offset = 0); |
| |
| // Load an array element from a FixedArray, untag it and return it as Word32. |
| TNode<Int32T> LoadAndUntagToWord32FixedArrayElement( |
| TNode<FixedArray> object, TNode<IntPtrT> index, |
| int additional_offset = 0); |
| |
| // Load an array element from a WeakFixedArray. |
| TNode<MaybeObject> LoadWeakFixedArrayElement(TNode<WeakFixedArray> object, |
| TNode<IntPtrT> index, |
| int additional_offset = 0); |
| |
| // Load an array element from a FixedDoubleArray. |
| TNode<Float64T> LoadFixedDoubleArrayElement( |
| TNode<FixedDoubleArray> object, TNode<IntPtrT> index, |
| Label* if_hole = nullptr, |
| MachineType machine_type = MachineType::Float64()); |
| |
| // Load an array element from a FixedArray, FixedDoubleArray or a |
| // NumberDictionary (depending on the |elements_kind|) and return |
| // it as a tagged value. Assumes that the |index| passed a length |
| // check before. Bails out to |if_accessor| if the element that |
| // was found is an accessor, or to |if_hole| if the element at |
| // the given |index| is not found in |elements|. |
| TNode<Object> LoadFixedArrayBaseElementAsTagged( |
| TNode<FixedArrayBase> elements, TNode<IntPtrT> index, |
| TNode<Int32T> elements_kind, Label* if_accessor, Label* if_hole); |
| |
| // Load a feedback slot from a FeedbackVector. |
| template <typename TIndex> |
| TNode<MaybeObject> LoadFeedbackVectorSlot( |
| TNode<FeedbackVector> feedback_vector, TNode<TIndex> slot, |
| int additional_offset = 0); |
| |
| TNode<IntPtrT> LoadFeedbackVectorLength(TNode<FeedbackVector>); |
| TNode<Float64T> LoadDoubleWithHoleCheck(TNode<FixedDoubleArray> array, |
| TNode<IntPtrT> index, |
| Label* if_hole = nullptr); |
| |
| TNode<BoolT> IsDoubleHole(TNode<Object> base, TNode<IntPtrT> offset); |
| // Load Float64 value by |base| + |offset| address. If the value is a double |
| // hole then jump to |if_hole|. If |machine_type| is None then only the hole |
| // check is generated. |
| TNode<Float64T> LoadDoubleWithHoleCheck( |
| TNode<Object> base, TNode<IntPtrT> offset, Label* if_hole, |
| MachineType machine_type = MachineType::Float64()); |
| TNode<Numeric> LoadFixedTypedArrayElementAsTagged(TNode<RawPtrT> data_pointer, |
| TNode<UintPtrT> index, |
| ElementsKind elements_kind); |
| TNode<Numeric> LoadFixedTypedArrayElementAsTagged( |
| TNode<RawPtrT> data_pointer, TNode<UintPtrT> index, |
| TNode<Int32T> elements_kind); |
| // Parts of the above, factored out for readability: |
| TNode<BigInt> LoadFixedBigInt64ArrayElementAsTagged( |
| TNode<RawPtrT> data_pointer, TNode<IntPtrT> offset); |
| TNode<BigInt> LoadFixedBigUint64ArrayElementAsTagged( |
| TNode<RawPtrT> data_pointer, TNode<IntPtrT> offset); |
| // 64-bit platforms only: |
| TNode<BigInt> BigIntFromInt64(TNode<IntPtrT> value); |
| TNode<BigInt> BigIntFromUint64(TNode<UintPtrT> value); |
| // 32-bit platforms only: |
| TNode<BigInt> BigIntFromInt32Pair(TNode<IntPtrT> low, TNode<IntPtrT> high); |
| TNode<BigInt> BigIntFromUint32Pair(TNode<UintPtrT> low, TNode<UintPtrT> high); |
| |
| // ScopeInfo: |
| TNode<ScopeInfo> LoadScopeInfo(TNode<Context> context); |
| TNode<BoolT> LoadScopeInfoHasExtensionField(TNode<ScopeInfo> scope_info); |
| |
| // Context manipulation: |
| void StoreContextElementNoWriteBarrier(TNode<Context> context, int slot_index, |
| TNode<Object> value); |
| TNode<NativeContext> LoadNativeContext(TNode<Context> context); |
| // Calling this is only valid if there's a module context in the chain. |
| TNode<Context> LoadModuleContext(TNode<Context> context); |
| |
| TNode<Object> GetImportMetaObject(TNode<Context> context); |
| |
| void GotoIfContextElementEqual(TNode<Object> value, |
| TNode<NativeContext> native_context, |
| int slot_index, Label* if_equal) { |
| GotoIf(TaggedEqual(value, LoadContextElement(native_context, slot_index)), |
| if_equal); |
| } |
| |
| // Loads the initial map of the the Object constructor. |
| TNode<Map> LoadObjectFunctionInitialMap(TNode<NativeContext> native_context); |
| TNode<Map> LoadSlowObjectWithNullPrototypeMap( |
| TNode<NativeContext> native_context); |
| |
| TNode<Map> LoadJSArrayElementsMap(ElementsKind kind, |
| TNode<NativeContext> native_context); |
| TNode<Map> LoadJSArrayElementsMap(TNode<Int32T> kind, |
| TNode<NativeContext> native_context); |
| |
| TNode<BoolT> IsJSFunctionWithPrototypeSlot(TNode<HeapObject> object); |
| TNode<BoolT> IsGeneratorFunction(TNode<JSFunction> function); |
| void BranchIfHasPrototypeProperty(TNode<JSFunction> function, |
| TNode<Int32T> function_map_bit_field, |
| Label* if_true, Label* if_false); |
| void GotoIfPrototypeRequiresRuntimeLookup(TNode<JSFunction> function, |
| TNode<Map> map, Label* runtime); |
| // Load the "prototype" property of a JSFunction. |
| TNode<HeapObject> LoadJSFunctionPrototype(TNode<JSFunction> function, |
| Label* if_bailout); |
| |
| TNode<BytecodeArray> LoadSharedFunctionInfoBytecodeArray( |
| TNode<SharedFunctionInfo> shared); |
| |
| void StoreObjectByteNoWriteBarrier(TNode<HeapObject> object, int offset, |
| TNode<Word32T> value); |
| |
| // Store the floating point value of a HeapNumber. |
| void StoreHeapNumberValue(TNode<HeapNumber> object, TNode<Float64T> value); |
| |
| // Store a field to an object on the heap. |
| void StoreObjectField(TNode<HeapObject> object, int offset, TNode<Smi> value); |
| void StoreObjectField(TNode<HeapObject> object, TNode<IntPtrT> offset, |
| TNode<Smi> value); |
| void StoreObjectField(TNode<HeapObject> object, int offset, |
| TNode<Object> value); |
| void StoreObjectField(TNode<HeapObject> object, TNode<IntPtrT> offset, |
| TNode<Object> value); |
| template <class T> |
| void StoreObjectFieldNoWriteBarrier(TNode<HeapObject> object, |
| TNode<IntPtrT> offset, TNode<T> value) { |
| int const_offset; |
| if (TryToInt32Constant(offset, &const_offset)) { |
| return StoreObjectFieldNoWriteBarrier<T>(object, const_offset, value); |
| } |
| StoreNoWriteBarrier(MachineRepresentationOf<T>::value, object, |
| IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)), |
| value); |
| } |
| template <class T> |
| void StoreObjectFieldNoWriteBarrier(TNode<HeapObject> object, int offset, |
| TNode<T> value) { |
| if (CanBeTaggedPointer(MachineRepresentationOf<T>::value)) { |
| OptimizedStoreFieldAssertNoWriteBarrier(MachineRepresentationOf<T>::value, |
| object, offset, value); |
| } else { |
| OptimizedStoreFieldUnsafeNoWriteBarrier(MachineRepresentationOf<T>::value, |
| object, offset, value); |
| } |
| } |
| |
| void UnsafeStoreObjectFieldNoWriteBarrier(TNode<HeapObject> object, |
| int offset, TNode<Object> value); |
| |
| // Store the Map of an HeapObject. |
| void StoreMap(TNode<HeapObject> object, TNode<Map> map); |
| void StoreMapNoWriteBarrier(TNode<HeapObject> object, |
| RootIndex map_root_index); |
| void StoreMapNoWriteBarrier(TNode<HeapObject> object, TNode<Map> map); |
| void StoreObjectFieldRoot(TNode<HeapObject> object, int offset, |
| RootIndex root); |
| |
| // Store an array element to a FixedArray. |
| void StoreFixedArrayElement( |
| TNode<FixedArray> object, int index, TNode<Object> value, |
| WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
| CheckBounds check_bounds = CheckBounds::kAlways) { |
| return StoreFixedArrayElement(object, IntPtrConstant(index), value, |
| barrier_mode, 0, check_bounds); |
| } |
| |
| void StoreFixedArrayElement(TNode<FixedArray> object, int index, |
| TNode<Smi> value, |
| CheckBounds check_bounds = CheckBounds::kAlways) { |
| return StoreFixedArrayElement(object, IntPtrConstant(index), |
| TNode<Object>{value}, |
| UNSAFE_SKIP_WRITE_BARRIER, 0, check_bounds); |
| } |
| |
| template <typename TIndex> |
| void StoreFixedArrayElement( |
| TNode<FixedArray> array, TNode<TIndex> index, TNode<Object> value, |
| WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
| int additional_offset = 0, |
| CheckBounds check_bounds = CheckBounds::kAlways) { |
| // TODO(v8:9708): Do we want to keep both IntPtrT and UintPtrT variants? |
| static_assert(std::is_same<TIndex, Smi>::value || |
| std::is_same<TIndex, UintPtrT>::value || |
| std::is_same<TIndex, IntPtrT>::value, |
| "Only Smi, UintPtrT or IntPtrT index is allowed"); |
| if (NeedsBoundsCheck(check_bounds)) { |
| FixedArrayBoundsCheck(array, index, additional_offset); |
| } |
| StoreFixedArrayOrPropertyArrayElement(array, index, value, barrier_mode, |
| additional_offset); |
| } |
| |
| template <typename TIndex> |
| void StoreFixedArrayElement(TNode<FixedArray> array, TNode<TIndex> index, |
| TNode<Smi> value, int additional_offset = 0) { |
| static_assert(std::is_same<TIndex, Smi>::value || |
| std::is_same<TIndex, IntPtrT>::value, |
| "Only Smi or IntPtrT indeces is allowed"); |
| StoreFixedArrayElement(array, index, TNode<Object>{value}, |
| UNSAFE_SKIP_WRITE_BARRIER, additional_offset); |
| } |
| |
| // These don't emit a bounds-check. As part of the security-performance |
| // tradeoff, only use it if it is performance critical. |
| void UnsafeStoreFixedArrayElement( |
| TNode<FixedArray> object, int index, TNode<Object> value, |
| WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER) { |
| return StoreFixedArrayElement(object, IntPtrConstant(index), value, |
| barrier_mode, 0, CheckBounds::kDebugOnly); |
| } |
| |
| void UnsafeStoreFixedArrayElement(TNode<FixedArray> object, int index, |
| TNode<Smi> value) { |
| return StoreFixedArrayElement(object, IntPtrConstant(index), value, |
| UNSAFE_SKIP_WRITE_BARRIER, 0, |
| CheckBounds::kDebugOnly); |
| } |
| |
| void UnsafeStoreFixedArrayElement( |
| TNode<FixedArray> array, TNode<IntPtrT> index, TNode<Object> value, |
| WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
| int additional_offset = 0) { |
| return StoreFixedArrayElement(array, index, value, barrier_mode, |
| additional_offset, CheckBounds::kDebugOnly); |
| } |
| |
| void UnsafeStoreFixedArrayElement(TNode<FixedArray> array, |
| TNode<IntPtrT> index, TNode<Smi> value, |
| int additional_offset) { |
| return StoreFixedArrayElement(array, index, value, |
| UNSAFE_SKIP_WRITE_BARRIER, additional_offset, |
| CheckBounds::kDebugOnly); |
| } |
| |
| void StorePropertyArrayElement(TNode<PropertyArray> array, |
| TNode<IntPtrT> index, TNode<Object> value) { |
| StoreFixedArrayOrPropertyArrayElement(array, index, value, |
| UPDATE_WRITE_BARRIER); |
| } |
| |
| template <typename TIndex> |
| void StoreFixedDoubleArrayElement( |
| TNode<FixedDoubleArray> object, TNode<TIndex> index, |
| TNode<Float64T> value, CheckBounds check_bounds = CheckBounds::kAlways); |
| |
| void StoreDoubleHole(TNode<HeapObject> object, TNode<IntPtrT> offset); |
| void StoreFixedDoubleArrayHole(TNode<FixedDoubleArray> array, |
| TNode<IntPtrT> index); |
| void StoreFeedbackVectorSlot( |
| TNode<FeedbackVector> feedback_vector, TNode<UintPtrT> slot, |
| TNode<AnyTaggedT> value, |
| WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
| int additional_offset = 0); |
| |
| void StoreJSSharedStructInObjectField(TNode<HeapObject> object, |
| TNode<IntPtrT> offset, |
| TNode<Object> value); |
| |
| void StoreJSSharedStructPropertyArrayElement(TNode<PropertyArray> array, |
| TNode<IntPtrT> index, |
| TNode<Object> value) { |
| // JSSharedStructs are allocated in the shared old space, which is currently |
| // collected by stopping the world, so the incremental write barrier is not |
| // needed. They can only store Smis and other HeapObjects in the shared old |
| // space, so the generational write barrier is also not needed. |
| // TODO(v8:12547): Add a safer, shared variant of SKIP_WRITE_BARRIER. |
| StoreFixedArrayOrPropertyArrayElement(array, index, value, |
| UNSAFE_SKIP_WRITE_BARRIER); |
| } |
| |
| // EnsureArrayPushable verifies that receiver with this map is: |
| // 1. Is not a prototype. |
| // 2. Is not a dictionary. |
| // 3. Has a writeable length property. |
| // It returns ElementsKind as a node for further division into cases. |
| TNode<Int32T> EnsureArrayPushable(TNode<Context> context, TNode<Map> map, |
| Label* bailout); |
| |
| void TryStoreArrayElement(ElementsKind kind, Label* bailout, |
| TNode<FixedArrayBase> elements, TNode<BInt> index, |
| TNode<Object> value); |
| // Consumes args into the array, and returns tagged new length. |
| TNode<Smi> BuildAppendJSArray(ElementsKind kind, TNode<JSArray> array, |
| CodeStubArguments* args, |
| TVariable<IntPtrT>* arg_index, Label* bailout); |
| // Pushes value onto the end of array. |
| void BuildAppendJSArray(ElementsKind kind, TNode<JSArray> array, |
| TNode<Object> value, Label* bailout); |
| |
| void StoreFieldsNoWriteBarrier(TNode<IntPtrT> start_address, |
| TNode<IntPtrT> end_address, |
| TNode<Object> value); |
| |
| // Marks the FixedArray copy-on-write without moving it. |
| void MakeFixedArrayCOW(TNode<FixedArray> array); |
| |
| TNode<Cell> AllocateCellWithValue( |
| TNode<Object> value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
| TNode<Cell> AllocateSmiCell(int value = 0) { |
| return AllocateCellWithValue(SmiConstant(value), SKIP_WRITE_BARRIER); |
| } |
| |
| TNode<Object> LoadCellValue(TNode<Cell> cell); |
| |
| void StoreCellValue(TNode<Cell> cell, TNode<Object> value, |
| WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
| |
| // Allocate a HeapNumber without initializing its value. |
| TNode<HeapNumber> AllocateHeapNumber(); |
| // Allocate a HeapNumber with a specific value. |
| TNode<HeapNumber> AllocateHeapNumberWithValue(TNode<Float64T> value); |
| TNode<HeapNumber> AllocateHeapNumberWithValue(double value) { |
| return AllocateHeapNumberWithValue(Float64Constant(value)); |
| } |
| |
| // Allocate a BigInt with {length} digits. Sets the sign bit to {false}. |
| // Does not initialize the digits. |
| TNode<BigInt> AllocateBigInt(TNode<IntPtrT> length); |
| // Like above, but allowing custom bitfield initialization. |
| TNode<BigInt> AllocateRawBigInt(TNode<IntPtrT> length); |
| void StoreBigIntBitfield(TNode<BigInt> bigint, TNode<Word32T> bitfield); |
| void StoreBigIntDigit(TNode<BigInt> bigint, intptr_t digit_index, |
| TNode<UintPtrT> digit); |
| void StoreBigIntDigit(TNode<BigInt> bigint, TNode<IntPtrT> digit_index, |
| TNode<UintPtrT> digit); |
| |
| TNode<Word32T> LoadBigIntBitfield(TNode<BigInt> bigint); |
| TNode<UintPtrT> LoadBigIntDigit(TNode<BigInt> bigint, intptr_t digit_index); |
| TNode<UintPtrT> LoadBigIntDigit(TNode<BigInt> bigint, |
| TNode<IntPtrT> digit_index); |
| |
| // Allocate a ByteArray with the given non-zero length. |
| TNode<ByteArray> AllocateNonEmptyByteArray(TNode<UintPtrT> length, |
| AllocationFlags flags); |
| |
| // Allocate a ByteArray with the given length. |
| TNode<ByteArray> AllocateByteArray( |
| TNode<UintPtrT> length, AllocationFlags flags = AllocationFlag::kNone); |
| |
| // Allocate a SeqOneByteString with the given length. |
| TNode<String> AllocateSeqOneByteString( |
| uint32_t length, AllocationFlags flags = AllocationFlag::kNone); |
| using TorqueGeneratedExportedMacrosAssembler::AllocateSeqOneByteString; |
| |
| // Allocate a SeqTwoByteString with the given length. |
| TNode<String> AllocateSeqTwoByteString( |
| uint32_t length, AllocationFlags flags = AllocationFlag::kNone); |
| using TorqueGeneratedExportedMacrosAssembler::AllocateSeqTwoByteString; |
| |
| // Allocate a SlicedOneByteString with the given length, parent and offset. |
| // |length| and |offset| are expected to be tagged. |
| |
| TNode<String> AllocateSlicedOneByteString(TNode<Uint32T> length, |
| TNode<String> parent, |
| TNode<Smi> offset); |
| // Allocate a SlicedTwoByteString with the given length, parent and offset. |
| // |length| and |offset| are expected to be tagged. |
| TNode<String> AllocateSlicedTwoByteString(TNode<Uint32T> length, |
| TNode<String> parent, |
| TNode<Smi> offset); |
| |
| TNode<NameDictionary> AllocateNameDictionary(int at_least_space_for); |
| TNode<NameDictionary> AllocateNameDictionary( |
| TNode<IntPtrT> at_least_space_for, |
| AllocationFlags = AllocationFlag::kNone); |
| TNode<NameDictionary> AllocateNameDictionaryWithCapacity( |
| TNode<IntPtrT> capacity, AllocationFlags = AllocationFlag::kNone); |
| TNode<NameDictionary> CopyNameDictionary(TNode<NameDictionary> dictionary, |
| Label* large_object_fallback); |
| |
| TNode<OrderedHashSet> AllocateOrderedHashSet(); |
| |
| TNode<OrderedHashMap> AllocateOrderedHashMap(); |
| |
| // Allocates an OrderedNameDictionary of the given capacity. This guarantees |
| // that |capacity| entries can be added without reallocating. |
| TNode<OrderedNameDictionary> AllocateOrderedNameDictionary( |
| TNode<IntPtrT> capacity); |
| TNode<OrderedNameDictionary> AllocateOrderedNameDictionary(int capacity); |
| |
| TNode<JSObject> AllocateJSObjectFromMap( |
| TNode<Map> map, |
| base::Optional<TNode<HeapObject>> properties = base::nullopt, |
| base::Optional<TNode<FixedArray>> elements = base::nullopt, |
| AllocationFlags flags = AllocationFlag::kNone, |
| SlackTrackingMode slack_tracking_mode = kNoSlackTracking); |
| |
| void InitializeJSObjectFromMap( |
| TNode<HeapObject> object, TNode<Map> map, TNode<IntPtrT> instance_size, |
| base::Optional<TNode<HeapObject>> properties = base::nullopt, |
| base::Optional<TNode<FixedArray>> elements = base::nullopt, |
| SlackTrackingMode slack_tracking_mode = kNoSlackTracking); |
| |
| void InitializeJSObjectBodyWithSlackTracking(TNode<HeapObject> object, |
| TNode<Map> map, |
| TNode<IntPtrT> instance_size); |
| void InitializeJSObjectBodyNoSlackTracking( |
| TNode<HeapObject> object, TNode<Map> map, TNode<IntPtrT> instance_size, |
| int start_offset = JSObject::kHeaderSize); |
| |
| TNode<BoolT> IsValidFastJSArrayCapacity(TNode<IntPtrT> capacity); |
| |
| // |
| // Allocate and return a JSArray with initialized header fields and its |
| // uninitialized elements. |
| std::pair<TNode<JSArray>, TNode<FixedArrayBase>> |
| AllocateUninitializedJSArrayWithElements( |
| ElementsKind kind, TNode<Map> array_map, TNode<Smi> length, |
| base::Optional<TNode<AllocationSite>> allocation_site, |
| TNode<IntPtrT> capacity, |
| AllocationFlags allocation_flags = AllocationFlag::kNone, |
| int array_header_size = JSArray::kHeaderSize); |
| |
| // Allocate a JSArray and fill elements with the hole. |
| TNode<JSArray> AllocateJSArray( |
| ElementsKind kind, TNode<Map> array_map, TNode<IntPtrT> capacity, |
| TNode<Smi> length, base::Optional<TNode<AllocationSite>> allocation_site, |
| AllocationFlags allocation_flags = AllocationFlag::kNone); |
| TNode<JSArray> AllocateJSArray( |
| ElementsKind kind, TNode<Map> array_map, TNode<Smi> capacity, |
| TNode<Smi> length, base::Optional<TNode<AllocationSite>> allocation_site, |
| AllocationFlags allocation_flags = AllocationFlag::kNone) { |
| return AllocateJSArray(kind, array_map, SmiUntag(capacity), length, |
| allocation_site, allocation_flags); |
| } |
| TNode<JSArray> AllocateJSArray( |
| ElementsKind kind, TNode<Map> array_map, TNode<Smi> capacity, |
| TNode<Smi> length, |
| AllocationFlags allocation_flags = AllocationFlag::kNone) { |
| return AllocateJSArray(kind, array_map, SmiUntag(capacity), length, |
| base::nullopt, allocation_flags); |
| } |
| TNode<JSArray> AllocateJSArray( |
| ElementsKind kind, TNode<Map> array_map, TNode<IntPtrT> capacity, |
| TNode<Smi> length, |
| AllocationFlags allocation_flags = AllocationFlag::kNone) { |
| return AllocateJSArray(kind, array_map, capacity, length, base::nullopt, |
| allocation_flags); |
| } |
| |
| // Allocate a JSArray and initialize the header fields. |
| TNode<JSArray> AllocateJSArray( |
| TNode<Map> array_map, TNode<FixedArrayBase> elements, TNode<Smi> length, |
| base::Optional<TNode<AllocationSite>> allocation_site = base::nullopt, |
| int array_header_size = JSArray::kHeaderSize); |
| |
| enum class HoleConversionMode { kDontConvert, kConvertToUndefined }; |
| // Clone a fast JSArray |array| into a new fast JSArray. |
| // |convert_holes| tells the function to convert holes into undefined or not. |
| // If |convert_holes| is set to kConvertToUndefined, but the function did not |
| // find any hole in |array|, the resulting array will have the same elements |
| // kind as |array|. If the function did find a hole, it will convert holes in |
| // |array| to undefined in the resulting array, who will now have |
| // PACKED_ELEMENTS kind. |
| // If |convert_holes| is set kDontConvert, holes are also copied to the |
| // resulting array, who will have the same elements kind as |array|. The |
| // function generates significantly less code in this case. |
| TNode<JSArray> CloneFastJSArray( |
| TNode<Context> context, TNode<JSArray> array, |
| base::Optional<TNode<AllocationSite>> allocation_site = base::nullopt, |
| HoleConversionMode convert_holes = HoleConversionMode::kDontConvert); |
| |
| TNode<JSArray> ExtractFastJSArray(TNode<Context> context, |
| TNode<JSArray> array, TNode<BInt> begin, |
| TNode<BInt> count); |
| |
| template <typename TIndex> |
| TNode<FixedArrayBase> AllocateFixedArray( |
| ElementsKind kind, TNode<TIndex> capacity, |
| AllocationFlags flags = AllocationFlag::kNone, |
| base::Optional<TNode<Map>> fixed_array_map = base::nullopt); |
| |
| TNode<NativeContext> GetCreationContext(TNode<JSReceiver> receiver, |
| Label* if_bailout); |
| TNode<NativeContext> GetFunctionRealm(TNode<Context> context, |
| TNode<JSReceiver> receiver, |
| Label* if_bailout); |
| TNode<Object> GetConstructor(TNode<Map> map); |
| |
| TNode<Map> GetInstanceTypeMap(InstanceType instance_type); |
| |
| TNode<FixedArray> AllocateUninitializedFixedArray(intptr_t capacity) { |
| return UncheckedCast<FixedArray>(AllocateFixedArray( |
| PACKED_ELEMENTS, IntPtrConstant(capacity), AllocationFlag::kNone)); |
| } |
| |
| TNode<FixedArray> AllocateZeroedFixedArray(TNode<IntPtrT> capacity) { |
| TNode<FixedArray> result = UncheckedCast<FixedArray>( |
| AllocateFixedArray(PACKED_ELEMENTS, capacity, |
| AllocationFlag::kAllowLargeObjectAllocation)); |
| FillFixedArrayWithSmiZero(result, capacity); |
| return result; |
| } |
| |
| TNode<FixedDoubleArray> AllocateZeroedFixedDoubleArray( |
| TNode<IntPtrT> capacity) { |
| TNode<FixedDoubleArray> result = UncheckedCast<FixedDoubleArray>( |
| AllocateFixedArray(PACKED_DOUBLE_ELEMENTS, capacity, |
| AllocationFlag::kAllowLargeObjectAllocation)); |
| FillFixedDoubleArrayWithZero(result, capacity); |
| return result; |
| } |
| |
| TNode<FixedArray> AllocateFixedArrayWithHoles(TNode<IntPtrT> capacity, |
| AllocationFlags flags) { |
| TNode<FixedArray> result = UncheckedCast<FixedArray>( |
| AllocateFixedArray(PACKED_ELEMENTS, capacity, flags)); |
| FillFixedArrayWithValue(PACKED_ELEMENTS, result, IntPtrConstant(0), |
| capacity, RootIndex::kTheHoleValue); |
| return result; |
| } |
| |
| TNode<FixedDoubleArray> AllocateFixedDoubleArrayWithHoles( |
| TNode<IntPtrT> capacity, AllocationFlags flags) { |
| TNode<FixedDoubleArray> result = UncheckedCast<FixedDoubleArray>( |
| AllocateFixedArray(PACKED_DOUBLE_ELEMENTS, capacity, flags)); |
| FillFixedArrayWithValue(PACKED_DOUBLE_ELEMENTS, result, IntPtrConstant(0), |
| capacity, RootIndex::kTheHoleValue); |
| return result; |
| } |
| |
| TNode<PropertyArray> AllocatePropertyArray(TNode<IntPtrT> capacity); |
| |
| TNode<HeapObject> AllocateWasmArray(TNode<IntPtrT> size_in_bytes, |
| int initialization); |
| |
| // TODO(v8:9722): Return type should be JSIteratorResult |
| TNode<JSObject> AllocateJSIteratorResult(TNode<Context> context, |
| TNode<Object> value, |
| TNode<Oddball> done); |
| |
| // TODO(v8:9722): Return type should be JSIteratorResult |
| TNode<JSObject> AllocateJSIteratorResultForEntry(TNode<Context> context, |
| TNode<Object> key, |
| TNode<Object> value); |
| |
| TNode<JSReceiver> ArraySpeciesCreate(TNode<Context> context, |
| TNode<Object> originalArray, |
| TNode<Number> len); |
| |
| template <typename TIndex> |
| void FillFixedArrayWithValue(ElementsKind kind, TNode<FixedArrayBase> array, |
| TNode<TIndex> from_index, TNode<TIndex> to_index, |
| RootIndex value_root_index); |
| |
| // Uses memset to effectively initialize the given FixedArray with zeroes. |
| void FillFixedArrayWithSmiZero(TNode<FixedArray> array, |
| TNode<IntPtrT> length); |
| void FillFixedDoubleArrayWithZero(TNode<FixedDoubleArray> array, |
| TNode<IntPtrT> length); |
| |
| void FillPropertyArrayWithUndefined(TNode<PropertyArray> array, |
| TNode<IntPtrT> from_index, |
| TNode<IntPtrT> to_index); |
| |
| enum class DestroySource { kNo, kYes }; |
| |
| // Increment the call count for a CALL_IC or construct call. |
| // The call count is located at feedback_vector[slot_id + 1]. |
| void IncrementCallCount(TNode<FeedbackVector> feedback_vector, |
| TNode<UintPtrT> slot_id); |
| |
| // Specify DestroySource::kYes if {from_array} is being supplanted by |
| // {to_array}. This offers a slight performance benefit by simply copying the |
| // array word by word. The source may be destroyed at the end of this macro. |
| // |
| // Otherwise, specify DestroySource::kNo for operations where an Object is |
| // being cloned, to ensure that mutable HeapNumbers are unique between the |
| // source and cloned object. |
| void CopyPropertyArrayValues(TNode<HeapObject> from_array, |
| TNode<PropertyArray> to_array, |
| TNode<IntPtrT> length, |
| WriteBarrierMode barrier_mode, |
| DestroySource destroy_source); |
| |
| // Copies all elements from |from_array| of |length| size to |
| // |to_array| of the same size respecting the elements kind. |
| template <typename TIndex> |
| void CopyFixedArrayElements( |
| ElementsKind kind, TNode<FixedArrayBase> from_array, |
| TNode<FixedArrayBase> to_array, TNode<TIndex> length, |
| WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER) { |
| CopyFixedArrayElements(kind, from_array, kind, to_array, |
| IntPtrOrSmiConstant<TIndex>(0), length, length, |
| barrier_mode); |
| } |
| |
| // Copies |element_count| elements from |from_array| starting from element |
| // zero to |to_array| of |capacity| size respecting both array's elements |
| // kinds. |
| template <typename TIndex> |
| void CopyFixedArrayElements( |
| ElementsKind from_kind, TNode<FixedArrayBase> from_array, |
| ElementsKind to_kind, TNode<FixedArrayBase> to_array, |
| TNode<TIndex> element_count, TNode<TIndex> capacity, |
| WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER) { |
| CopyFixedArrayElements(from_kind, from_array, to_kind, to_array, |
| IntPtrOrSmiConstant<TIndex>(0), element_count, |
| capacity, barrier_mode); |
| } |
| |
| // Copies |element_count| elements from |from_array| starting from element |
| // |first_element| to |to_array| of |capacity| size respecting both array's |
| // elements kinds. |
| // |convert_holes| tells the function whether to convert holes to undefined. |
| // |var_holes_converted| can be used to signify that the conversion happened |
| // (i.e. that there were holes). If |convert_holes_to_undefined| is |
| // HoleConversionMode::kConvertToUndefined, then it must not be the case that |
| // IsDoubleElementsKind(to_kind). |
| template <typename TIndex> |
| void CopyFixedArrayElements( |
| ElementsKind from_kind, TNode<FixedArrayBase> from_array, |
| ElementsKind to_kind, TNode<FixedArrayBase> to_array, |
| TNode<TIndex> first_element, TNode<TIndex> element_count, |
| TNode<TIndex> capacity, |
| WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER, |
| HoleConversionMode convert_holes = HoleConversionMode::kDontConvert, |
| TVariable<BoolT>* var_holes_converted = nullptr); |
| |
| void JumpIfPointersFromHereAreInteresting(TNode<Object> object, |
| Label* interesting); |
| |
| // Efficiently copy elements within a single array. The regions |
| // [src_index, src_index + length) and [dst_index, dst_index + length) |
| // can be overlapping. |
| void MoveElements(ElementsKind kind, TNode<FixedArrayBase> elements, |
| TNode<IntPtrT> dst_index, TNode<IntPtrT> src_index, |
| TNode<IntPtrT> length); |
| |
| // Efficiently copy elements from one array to another. The ElementsKind |
| // needs to be the same. Copy from src_elements at |
| // [src_index, src_index + length) to dst_elements at |
| // [dst_index, dst_index + length). |
| // The function decides whether it can use memcpy. In case it cannot, |
| // |write_barrier| can help it to skip write barrier. SKIP_WRITE_BARRIER is |
| // only safe when copying to new space, or when copying to old space and the |
| // array does not contain object pointers. |
| void CopyElements(ElementsKind kind, TNode<FixedArrayBase> dst_elements, |
| TNode<IntPtrT> dst_index, |
| TNode<FixedArrayBase> src_elements, |
| TNode<IntPtrT> src_index, TNode<IntPtrT> length, |
| WriteBarrierMode write_barrier = UPDATE_WRITE_BARRIER); |
| |
| TNode<FixedArray> HeapObjectToFixedArray(TNode<HeapObject> base, |
| Label* cast_fail); |
| |
| TNode<FixedDoubleArray> HeapObjectToFixedDoubleArray(TNode<HeapObject> base, |
| Label* cast_fail) { |
| GotoIf(TaggedNotEqual(LoadMap(base), FixedDoubleArrayMapConstant()), |
| cast_fail); |
| return UncheckedCast<FixedDoubleArray>(base); |
| } |
| |
| template <typename T> |
| bool ClassHasMapConstant() { |
| return false; |
| } |
| |
| template <typename T> |
| TNode<Map> GetClassMapConstant() { |
| UNREACHABLE(); |
| return TNode<Map>(); |
| } |
| |
| enum class ExtractFixedArrayFlag { |
| kFixedArrays = 1, |
| kFixedDoubleArrays = 2, |
| kDontCopyCOW = 4, |
| kAllFixedArrays = kFixedArrays | kFixedDoubleArrays, |
| kAllFixedArraysDontCopyCOW = kAllFixedArrays | kDontCopyCOW |
| }; |
| |
| using ExtractFixedArrayFlags = base::Flags<ExtractFixedArrayFlag>; |
| |
| // Copy a portion of an existing FixedArray or FixedDoubleArray into a new |
| // array, including special appropriate handling for empty arrays and COW |
| // arrays. The result array will be of the same type as the original array. |
| // |
| // * |source| is either a FixedArray or FixedDoubleArray from which to copy |
| // elements. |
| // * |first| is the starting element index to copy from, if nullptr is passed |
| // then index zero is used by default. |
| // * |count| is the number of elements to copy out of the source array |
| // starting from and including the element indexed by |start|. If |count| is |
| // nullptr, then all of the elements from |start| to the end of |source| are |
| // copied. |
| // * |capacity| determines the size of the allocated result array, with |
| // |capacity| >= |count|. If |capacity| is nullptr, then |count| is used as |
| // the destination array's capacity. |
| // * |extract_flags| determines whether FixedArrays, FixedDoubleArrays or both |
| // are detected and copied. Although it's always correct to pass |
| // kAllFixedArrays, the generated code is more compact and efficient if the |
| // caller can specify whether only FixedArrays or FixedDoubleArrays will be |
| // passed as the |source| parameter. |
| // * |parameter_mode| determines the parameter mode of |first|, |count| and |
| // |capacity|. |
| // * If |var_holes_converted| is given, any holes will be converted to |
| // undefined and the variable will be set according to whether or not there |
| // were any hole. |
| // * If |source_elements_kind| is given, the function will try to use the |
| // runtime elements kind of source to make copy faster. More specifically, it |
| // can skip write barriers. |
| template <typename TIndex> |
| TNode<FixedArrayBase> ExtractFixedArray( |
| TNode<FixedArrayBase> source, base::Optional<TNode<TIndex>> first, |
| base::Optional<TNode<TIndex>> count = base::nullopt, |
| base::Optional<TNode<TIndex>> capacity = base::nullopt, |
| ExtractFixedArrayFlags extract_flags = |
| ExtractFixedArrayFlag::kAllFixedArrays, |
| TVariable<BoolT>* var_holes_converted = nullptr, |
| base::Optional<TNode<Int32T>> source_elements_kind = base::nullopt); |
| |
| // Copy a portion of an existing FixedArray or FixedDoubleArray into a new |
| // FixedArray, including special appropriate handling for COW arrays. |
| // * |source| is either a FixedArray or FixedDoubleArray from which to copy |
| // elements. |source| is assumed to be non-empty. |
| // * |first| is the starting element index to copy from. |
| // * |count| is the number of elements to copy out of the source array |
| // starting from and including the element indexed by |start|. |
| // * |capacity| determines the size of the allocated result array, with |
| // |capacity| >= |count|. |
| // * |source_map| is the map of the |source|. |
| // * |from_kind| is the elements kind that is consistent with |source| being |
| // a FixedArray or FixedDoubleArray. This function only cares about double vs. |
| // non-double, so as to distinguish FixedDoubleArray vs. FixedArray. It does |
| // not care about holeyness. For example, when |source| is a FixedArray, |
| // PACKED/HOLEY_ELEMENTS can be used, but not PACKED_DOUBLE_ELEMENTS. |
| // * |allocation_flags| and |extract_flags| influence how the target |
| // FixedArray is allocated. |
| // * |convert_holes| is used to signify that the target array should use |
| // undefined in places of holes. |
| // * If |convert_holes| is true and |var_holes_converted| not nullptr, then |
| // |var_holes_converted| is used to signal whether any holes were found and |
| // converted. The caller should use this information to decide which map is |
| // compatible with the result array. For example, if the input was of |
| // HOLEY_SMI_ELEMENTS kind, and a conversion took place, the result will be |
| // compatible only with HOLEY_ELEMENTS and PACKED_ELEMENTS. |
| template <typename TIndex> |
| TNode<FixedArray> ExtractToFixedArray( |
| TNode<FixedArrayBase> source, TNode<TIndex> first, TNode<TIndex> count, |
| TNode<TIndex> capacity, TNode<Map> source_map, ElementsKind from_kind, |
| AllocationFlags allocation_flags, ExtractFixedArrayFlags extract_flags, |
| HoleConversionMode convert_holes, |
| TVariable<BoolT>* var_holes_converted = nullptr, |
| base::Optional<TNode<Int32T>> source_runtime_kind = base::nullopt); |
| |
| // Attempt to copy a FixedDoubleArray to another FixedDoubleArray. In the case |
| // where the source array has a hole, produce a FixedArray instead where holes |
| // are replaced with undefined. |
| // * |source| is a FixedDoubleArray from which to copy elements. |
| // * |first| is the starting element index to copy from. |
| // * |count| is the number of elements to copy out of the source array |
| // starting from and including the element indexed by |start|. |
| // * |capacity| determines the size of the allocated result array, with |
| // |capacity| >= |count|. |
| // * |source_map| is the map of |source|. It will be used as the map of the |
| // target array if the target can stay a FixedDoubleArray. Otherwise if the |
| // target array needs to be a FixedArray, the FixedArrayMap will be used. |
| // * |var_holes_converted| is used to signal whether a FixedAray |
| // is produced or not. |
| // * |allocation_flags| and |extract_flags| influence how the target array is |
| // allocated. |
| template <typename TIndex> |
| TNode<FixedArrayBase> ExtractFixedDoubleArrayFillingHoles( |
| TNode<FixedArrayBase> source, TNode<TIndex> first, TNode<TIndex> count, |
| TNode<TIndex> capacity, TNode<Map> source_map, |
| TVariable<BoolT>* var_holes_converted, AllocationFlags allocation_flags, |
| ExtractFixedArrayFlags extract_flags); |
| |
| // Copy the entire contents of a FixedArray or FixedDoubleArray to a new |
| // array, including special appropriate handling for empty arrays and COW |
| // arrays. |
| // |
| // * |source| is either a FixedArray or FixedDoubleArray from which to copy |
| // elements. |
| // * |extract_flags| determines whether FixedArrays, FixedDoubleArrays or both |
| // are detected and copied. Although it's always correct to pass |
| // kAllFixedArrays, the generated code is more compact and efficient if the |
| // caller can specify whether only FixedArrays or FixedDoubleArrays will be |
| // passed as the |source| parameter. |
| TNode<FixedArrayBase> CloneFixedArray( |
| TNode<FixedArrayBase> source, |
| ExtractFixedArrayFlags flags = |
| ExtractFixedArrayFlag::kAllFixedArraysDontCopyCOW); |
| |
| // Loads an element from |array| of |from_kind| elements by given |offset| |
| // (NOTE: not index!), does a hole check if |if_hole| is provided and |
| // converts the value so that it becomes ready for storing to array of |
| // |to_kind| elements. |
| template <typename TResult> |
| TNode<TResult> LoadElementAndPrepareForStore(TNode<FixedArrayBase> array, |
| TNode<IntPtrT> offset, |
| ElementsKind from_kind, |
| ElementsKind to_kind, |
| Label* if_hole); |
| |
| template <typename TIndex> |
| TNode<TIndex> CalculateNewElementsCapacity(TNode<TIndex> old_capacity); |
| |
| // Tries to grow the |elements| array of given |object| to store the |key| |
| // or bails out if the growing gap is too big. Returns new elements. |
| TNode<FixedArrayBase> TryGrowElementsCapacity(TNode<HeapObject> object, |
| TNode<FixedArrayBase> elements, |
| ElementsKind kind, |
| TNode<Smi> key, Label* bailout); |
| |
| // Tries to grow the |capacity|-length |elements| array of given |object| |
| // to store the |key| or bails out if the growing gap is too big. Returns |
| // new elements. |
| template <typename TIndex> |
| TNode<FixedArrayBase> TryGrowElementsCapacity(TNode<HeapObject> object, |
| TNode<FixedArrayBase> elements, |
| ElementsKind kind, |
| TNode<TIndex> key, |
| TNode<TIndex> capacity, |
| Label* bailout); |
| |
| // Grows elements capacity of given object. Returns new elements. |
| template <typename TIndex> |
| TNode<FixedArrayBase> GrowElementsCapacity( |
| TNode<HeapObject> object, TNode<FixedArrayBase> elements, |
| ElementsKind from_kind, ElementsKind to_kind, TNode<TIndex> capacity, |
| TNode<TIndex> new_capacity, Label* bailout); |
| |
| // Given a need to grow by |growth|, allocate an appropriate new capacity |
| // if necessary, and return a new elements FixedArray object. Label |bailout| |
| // is followed for allocation failure. |
| void PossiblyGrowElementsCapacity(ElementsKind kind, TNode<HeapObject> array, |
| TNode<BInt> length, |
| TVariable<FixedArrayBase>* var_elements, |
| TNode<BInt> growth, Label* bailout); |
| |
| // Allocation site manipulation |
| void InitializeAllocationMemento(TNode<HeapObject> base, |
| TNode<IntPtrT> base_allocation_size, |
| TNode<AllocationSite> allocation_site); |
| |
| TNode<IntPtrT> TryTaggedToInt32AsIntPtr(TNode<Object> value, |
| Label* if_not_possible); |
| TNode<Float64T> TryTaggedToFloat64(TNode<Object> value, |
| Label* if_valueisnotnumber); |
| TNode<Float64T> TruncateTaggedToFloat64(TNode<Context> context, |
| TNode<Object> value); |
| TNode<Word32T> TruncateTaggedToWord32(TNode<Context> context, |
| TNode<Object> value); |
| void TaggedToWord32OrBigInt(TNode<Context> context, TNode<Object> value, |
| Label* if_number, TVariable<Word32T>* var_word32, |
| Label* if_bigint, |
| TVariable<BigInt>* var_maybe_bigint); |
| void TaggedToWord32OrBigIntWithFeedback(TNode<Context> context, |
| TNode<Object> value, Label* if_number, |
| TVariable<Word32T>* var_word32, |
| Label* if_bigint, |
| TVariable<BigInt>* var_maybe_bigint, |
| TVariable<Smi>* var_feedback); |
| void TaggedPointerToWord32OrBigIntWithFeedback( |
| TNode<Context> context, TNode<HeapObject> pointer, Label* if_number, |
| TVariable<Word32T>* var_word32, Label* if_bigint, |
| TVariable<BigInt>* var_maybe_bigint, TVariable<Smi>* var_feedback); |
| |
| TNode<Int32T> TruncateNumberToWord32(TNode<Number> value); |
| // Truncate the floating point value of a HeapNumber to an Int32. |
| TNode<Int32T> TruncateHeapNumberValueToWord32(TNode<HeapNumber> object); |
| |
| // Conversions. |
| void TryHeapNumberToSmi(TNode<HeapNumber> number, TVariable<Smi>* output, |
| Label* if_smi); |
| void TryFloat32ToSmi(TNode<Float32T> number, TVariable<Smi>* output, |
| Label* if_smi); |
| void TryFloat64ToSmi(TNode<Float64T> number, TVariable<Smi>* output, |
| Label* if_smi); |
| TNode<Number> ChangeFloat32ToTagged(TNode<Float32T> value); |
| TNode<Number> ChangeFloat64ToTagged(TNode<Float64T> value); |
| TNode<Number> ChangeInt32ToTagged(TNode<Int32T> value); |
| TNode<Number> ChangeInt32ToTaggedNoOverflow(TNode<Int32T> value); |
| TNode<Number> ChangeUint32ToTagged(TNode<Uint32T> value); |
| TNode<Number> ChangeUintPtrToTagged(TNode<UintPtrT> value); |
| TNode<Uint32T> ChangeNumberToUint32(TNode<Number> value); |
| TNode<Float64T> ChangeNumberToFloat64(TNode<Number> value); |
| |
| TNode<Int32T> ChangeTaggedNonSmiToInt32(TNode<Context> context, |
| TNode<HeapObject> input); |
| TNode<Float64T> ChangeTaggedToFloat64(TNode<Context> context, |
| TNode<Object> input); |
| |
| TNode<Int32T> ChangeBoolToInt32(TNode<BoolT> b); |
| |
| void TaggedToNumeric(TNode<Context> context, TNode<Object> value, |
| TVariable<Numeric>* var_numeric); |
| void TaggedToNumericWithFeedback(TNode<Context> context, TNode<Object> value, |
| TVariable<Numeric>* var_numeric, |
| TVariable<Smi>* var_feedback); |
| |
| // Ensures that {var_shared_value} is shareable across Isolates, and throws if |
| // not. |
| void SharedValueBarrier(TNode<Context> context, |
| TVariable<Object>* var_shared_value); |
| |
| TNode<WordT> TimesSystemPointerSize(TNode<WordT> value); |
| TNode<IntPtrT> TimesSystemPointerSize(TNode<IntPtrT> value) { |
| return Signed(TimesSystemPointerSize(implicit_cast<TNode<WordT>>(value))); |
| } |
| TNode<UintPtrT> TimesSystemPointerSize(TNode<UintPtrT> value) { |
| return Unsigned(TimesSystemPointerSize(implicit_cast<TNode<WordT>>(value))); |
| } |
| |
| TNode<WordT> TimesTaggedSize(TNode<WordT> value); |
| TNode<IntPtrT> TimesTaggedSize(TNode<IntPtrT> value) { |
| return Signed(TimesTaggedSize(implicit_cast<TNode<WordT>>(value))); |
| } |
| TNode<UintPtrT> TimesTaggedSize(TNode<UintPtrT> value) { |
| return Unsigned(TimesTaggedSize(implicit_cast<TNode<WordT>>(value))); |
| } |
| |
| TNode<WordT> TimesDoubleSize(TNode<WordT> value); |
| TNode<UintPtrT> TimesDoubleSize(TNode<UintPtrT> value) { |
| return Unsigned(TimesDoubleSize(implicit_cast<TNode<WordT>>(value))); |
| } |
| TNode<IntPtrT> TimesDoubleSize(TNode<IntPtrT> value) { |
| return Signed(TimesDoubleSize(implicit_cast<TNode<WordT>>(value))); |
| } |
| |
| // Type conversions. |
| // Throws a TypeError for {method_name} if {value} is not coercible to Object, |
| // or returns the {value} converted to a String otherwise. |
| TNode<String> ToThisString(TNode<Context> context, TNode<Object>
|