#ifndef V8_OBJECTS_SHARED_FUNCTION_INFO_H_
#define V8_OBJECTS_SHARED_FUNCTION_INFO_H_
#include <memory>
#include <optional>
#include "src/base/bit-field.h"
#include "src/base/macros.h"
#include "src/builtins/builtins.h"
#include "src/codegen/bailout-reason.h"
#include "src/common/globals.h"
#include "src/objects/compressed-slots.h"
#include "src/objects/function-kind.h"
#include "src/objects/function-syntax-kind.h"
#include "src/objects/name.h"
#include "src/objects/objects.h"
#include "src/objects/script.h"
#include "src/objects/slots.h"
#include "src/objects/smi.h"
#include "src/objects/struct.h"
#include "src/objects/tagged-field.h"
#include "src/objects/trusted-object.h"
#include "src/roots/roots.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
#include "torque-generated/bit-fields.h"
#include "src/objects/object-macros.h"
namespace v8::internal {
class AsmWasmData;
class BytecodeArray;
class CoverageInfo;
class DebugInfo;
class IsCompiledScope;
template <typename>
class Signature;
class WasmFunctionData;
class WasmCapiFunctionData;
class WasmExportedFunctionData;
class WasmJSFunctionData;
class WasmResumeData;
#if V8_ENABLE_WEBASSEMBLY
namespace wasm {
class CanonicalValueType;
struct WasmModule;
class ValueType;
}
#endif
#include "torque-generated/src/objects/shared-function-info-tq.inc"
enum class CreateSourcePositions { kNo, kYes };
V8_OBJECT class PreparseData : public HeapObjectLayout {
public:
int32_t data_length() const { return data_length_; }
void set_data_length(int32_t value) { data_length_ = value; }
int32_t children_length() const { return children_length_; }
void set_children_length(int32_t value) { children_length_ = value; }
inline uint8_t get(int index) const;
inline void set(int index, uint8_t value);
inline void copy_in(int index, const uint8_t* buffer, int length);
inline Tagged<PreparseData> get_child(int index) const;
inline void set_child(int index, Tagged<PreparseData> value,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline void clear_padding();
DECL_PRINTER(PreparseData)
DECL_VERIFIER(PreparseData)
class BodyDescriptor;
static inline int SizeFor(int data_length, int children_length);
private:
friend class TorqueGeneratedPreparseDataAsserts;
template <typename Impl>
friend class FactoryBase;
static int ChildrenOffsetInData(int data_length) {
return RoundUp(data_length * kByteSize, kTaggedSize);
}
uint8_t* data() { return reinterpret_cast<uint8_t*>(data_and_children()); }
const uint8_t* data() const {
return reinterpret_cast<const uint8_t*>(data_and_children());
}
TaggedMember<PreparseData>* children() {
return reinterpret_cast<TaggedMember<PreparseData>*>(
&data_and_children()[ChildrenOffsetInData(data_length())]);
}
const TaggedMember<PreparseData>* children() const {
return reinterpret_cast<const TaggedMember<PreparseData>*>(
&data_and_children()[ChildrenOffsetInData(data_length())]);
}
inline int children_start_offset() const;
int32_t data_length_;
int32_t children_length_;
FLEXIBLE_ARRAY_MEMBER(char, data_and_children);
} V8_OBJECT_END;
static_assert(IsAligned(OFFSET_OF_DATA_START(PreparseData),
alignof(TaggedMember<PreparseData>)));
V8_OBJECT class UncompiledData : public ExposedTrustedObjectLayout {
public:
inline Tagged<String> inferred_name() const;
inline void set_inferred_name(Tagged<String> value,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline int32_t start_position() const { return start_position_; }
inline void set_start_position(int32_t value) { start_position_ = value; }
inline int32_t end_position() const { return end_position_; }
inline void set_end_position(int32_t value) { end_position_ = value; }
inline void InitAfterBytecodeFlush(
Isolate* isolate, Tagged<String> inferred_name, int start_position,
int end_position,
std::function<void(Tagged<HeapObject> object, ObjectSlot slot,
Tagged<HeapObject> target)>
gc_notify_updated_slot);
DECL_VERIFIER(UncompiledData)
friend class Torque;
friend struct OffsetsForDebug;
TaggedMember<String> inferred_name_;
int32_t start_position_;
int32_t end_position_;
} V8_OBJECT_END;
V8_OBJECT class UncompiledDataWithoutPreparseData : public UncompiledData {
public:
DECL_PRINTER(UncompiledDataWithoutPreparseData)
DECL_VERIFIER(UncompiledDataWithoutPreparseData)
class BodyDescriptor;
} V8_OBJECT_END;
V8_OBJECT class UncompiledDataWithPreparseData : public UncompiledData {
public:
inline Tagged<PreparseData> preparse_data() const;
inline void set_preparse_data(Tagged<PreparseData> value,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
DECL_PRINTER(UncompiledDataWithPreparseData)
DECL_VERIFIER(UncompiledDataWithPreparseData)
class BodyDescriptor;
TaggedMember<PreparseData> preparse_data_;
} V8_OBJECT_END;
V8_OBJECT class UncompiledDataWithoutPreparseDataWithJob
: public UncompiledDataWithoutPreparseData {
public:
inline Address job() const { return job_; }
inline void set_job(Address value) { job_ = value; }
DECL_PRINTER(UncompiledDataWithoutPreparseDataWithJob)
DECL_VERIFIER(UncompiledDataWithoutPreparseDataWithJob)
class BodyDescriptor;
Address job_;
} V8_OBJECT_END;
V8_OBJECT class UncompiledDataWithPreparseDataAndJob
: public UncompiledDataWithPreparseData {
public:
inline Address job() const { return job_; }
inline void set_job(Address value) { job_ = value; }
DECL_PRINTER(UncompiledDataWithPreparseDataAndJob)
DECL_VERIFIER(UncompiledDataWithPreparseDataAndJob)
class BodyDescriptor;
Address job_;
} V8_OBJECT_END;
V8_OBJECT class InterpreterData : public ExposedTrustedObjectLayout {
public:
inline Tagged<BytecodeArray> bytecode_array() const;
inline void set_bytecode_array(Tagged<BytecodeArray> value,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline bool has_bytecode_array() const;
inline void clear_bytecode_array();
inline Tagged<Code> interpreter_trampoline() const;
inline void set_interpreter_trampoline(
Tagged<Code> value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline bool has_interpreter_trampoline() const;
inline void clear_interpreter_trampoline();
DECL_VERIFIER(InterpreterData)
DECL_PRINTER(InterpreterData)
class BodyDescriptor;
private:
friend class TorqueGeneratedInterpreterDataAsserts;
friend class MacroAssembler;
friend class CodeStubAssembler;
ProtectedTaggedMember<BytecodeArray> bytecode_array_;
ProtectedTaggedMember<Code> interpreter_trampoline_;
} V8_OBJECT_END;
using NameOrScopeInfoT = UnionOf<Smi, String, ScopeInfo>;
class SharedFunctionInfo
: public TorqueGeneratedSharedFunctionInfo<SharedFunctionInfo, HeapObject> {
public:
DEFINE_TORQUE_GENERATED_SHARED_FUNCTION_INFO_FLAGS()
DEFINE_TORQUE_GENERATED_SHARED_FUNCTION_INFO_FLAGS2()
void Init(ReadOnlyRoots roots, int unique_id);
V8_EXPORT_PRIVATE static constexpr Tagged<Smi> const kNoSharedNameSentinel =
Smi::zero();
inline Tagged<String> Name() const;
inline void SetName(Tagged<String> name);
V8_EXPORT_PRIVATE Tagged<Code> GetCode(Isolate* isolate) const;
inline Tagged<AbstractCode> abstract_code(Isolate* isolate);
V8_EXPORT_PRIVATE void SetScript(IsolateForSandbox isolate,
ReadOnlyRoots roots,
Tagged<HeapObject> script_object,
int function_literal_id,
bool reset_preparsed_scope_data = true);
void CopyFrom(Tagged<SharedFunctionInfo> other, IsolateForSandbox isolate);
static const int kEntriesStart = 0;
static const int kContextOffset = 0;
static const int kCachedCodeOffset = 1;
static const int kEntryLength = 2;
static const int kInitialLength = kEntriesStart + kEntryLength;
static const int kNotFound = -1;
static constexpr int kAgeSize = kAgeOffsetEnd - kAgeOffset + 1;
static constexpr uint16_t kMaxAge = UINT16_MAX;
DECL_ACQUIRE_GETTER(scope_info, Tagged<ScopeInfo>)
DECL_GETTER(scope_info, Tagged<ScopeInfo>)
inline Tagged<ScopeInfo> EarlyScopeInfo(AcquireLoadTag tag);
inline void set_raw_scope_info(Tagged<ScopeInfo> scope_info,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline void SetScopeInfo(Tagged<ScopeInfo> scope_info,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline bool is_script() const;
inline bool needs_script_context() const;
V8_EXPORT_PRIVATE int EndPosition() const;
V8_EXPORT_PRIVATE int StartPosition() const;
V8_EXPORT_PRIVATE void UpdateFromFunctionLiteralForLiveEdit(
IsolateForSandbox isolate, FunctionLiteral* lit);
DECL_ACCESSORS(raw_outer_scope_info_or_feedback_metadata,
Tagged<UnionOf<ScopeInfo, FeedbackMetadata, TheHole>>)
DECL_ACQUIRE_GETTER(raw_outer_scope_info_or_feedback_metadata,
Tagged<UnionOf<ScopeInfo, FeedbackMetadata, TheHole>>)
private:
using TorqueGeneratedSharedFunctionInfo::
outer_scope_info_or_feedback_metadata;
using TorqueGeneratedSharedFunctionInfo::
set_outer_scope_info_or_feedback_metadata;
public:
inline bool HasOuterScopeInfo() const;
inline Tagged<ScopeInfo> GetOuterScopeInfo() const;
inline bool HasFeedbackMetadata() const;
inline bool HasFeedbackMetadata(AcquireLoadTag tag) const;
DECL_GETTER(feedback_metadata, Tagged<FeedbackMetadata>)
DECL_RELEASE_ACQUIRE_ACCESSORS(feedback_metadata, Tagged<FeedbackMetadata>)
inline bool is_compiled() const;
template <typename IsolateT>
inline IsCompiledScope is_compiled_scope(IsolateT* isolate) const;
inline void set_internal_formal_parameter_count(int value);
inline uint16_t internal_formal_parameter_count_with_receiver() const;
inline uint16_t internal_formal_parameter_count_without_receiver() const;
inline uint32_t unused_parameter_bits() const;
inline bool CanOnlyAccessFixedFormalParameters() const;
inline bool IsSloppyNormalJSFunction() const;
private:
using TorqueGeneratedSharedFunctionInfo::formal_parameter_count;
using TorqueGeneratedSharedFunctionInfo::set_formal_parameter_count;
public:
inline void DontAdaptArguments();
inline Tagged<Object> GetTrustedData(IsolateForSandbox isolate) const;
inline Tagged<Object> GetUntrustedData() const;
template <typename T, IndirectPointerTag tag>
inline Tagged<T> GetTrustedData(IsolateForSandbox isolate) const;
inline bool HasUnpublishedTrustedData(IsolateForSandbox isolate) const;
private:
inline void SetTrustedData(Tagged<ExposedTrustedObject> value,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline void SetUntrustedData(Tagged<Object> value,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline bool HasTrustedData() const;
inline bool HasUntrustedData() const;
public:
inline bool IsApiFunction() const;
inline bool is_class_constructor() const;
DECL_ACCESSORS(api_func_data, Tagged<FunctionTemplateInfo>)
DECL_GETTER(HasBytecodeArray, bool)
template <typename IsolateT>
inline Tagged<BytecodeArray> GetBytecodeArray(IsolateT* isolate) const;
inline void set_bytecode_array(Tagged<BytecodeArray> bytecode);
inline void overwrite_bytecode_array(Tagged<BytecodeArray> bytecode);
inline Tagged<Code> InterpreterTrampoline(IsolateForSandbox isolate) const;
inline bool HasInterpreterData(IsolateForSandbox isolate) const;
inline Tagged<InterpreterData> interpreter_data(
IsolateForSandbox isolate) const;
inline void set_interpreter_data(
Isolate* isolate, Tagged<InterpreterData> interpreter_data,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
DECL_GETTER(HasBaselineCode, bool)
DECL_RELEASE_ACQUIRE_ACCESSORS(baseline_code, Tagged<Code>)
inline void FlushBaselineCode();
inline Tagged<BytecodeArray> GetActiveBytecodeArray(Isolate* isolate) const;
inline void SetActiveBytecodeArray(Tagged<BytecodeArray> bytecode,
IsolateForSandbox isolate);
#if V8_ENABLE_WEBASSEMBLY
inline bool HasAsmWasmData() const;
inline bool HasWasmFunctionData(IsolateForSandbox) const;
inline bool HasWasmExportedFunctionData(IsolateForSandbox) const;
inline bool HasWasmJSFunctionData(IsolateForSandbox) const;
inline bool HasWasmCapiFunctionData(IsolateForSandbox) const;
inline bool HasWasmResumeData() const;
DECL_ACCESSORS(asm_wasm_data, Tagged<AsmWasmData>)
DECL_GETTER(wasm_function_data, Tagged<WasmFunctionData>)
DECL_GETTER(wasm_exported_function_data, Tagged<WasmExportedFunctionData>)
DECL_GETTER(wasm_js_function_data, Tagged<WasmJSFunctionData>)
DECL_GETTER(wasm_capi_function_data, Tagged<WasmCapiFunctionData>)
DECL_GETTER(wasm_resume_data, Tagged<WasmResumeData>)
#endif
inline bool HasBuiltinId() const;
DECL_PRIMITIVE_ACCESSORS(builtin_id, Builtin)
inline bool HasUncompiledData(IsolateForSandbox isolate) const;
inline Tagged<UncompiledData> uncompiled_data(
IsolateForSandbox isolate) const;
inline void set_uncompiled_data(Tagged<UncompiledData> data,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline bool HasUncompiledDataWithPreparseData(
IsolateForSandbox isolate) const;
inline Tagged<UncompiledDataWithPreparseData>
uncompiled_data_with_preparse_data(IsolateForSandbox isolate) const;
inline void set_uncompiled_data_with_preparse_data(
Tagged<UncompiledDataWithPreparseData> data,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
inline bool HasUncompiledDataWithoutPreparseData(
IsolateForSandbox isolate) const;
inline void ClearUncompiledDataJobPointer(IsolateForSandbox isolate);
inline void ClearPreparseData(IsolateForSandbox isolate);
inline bool HasInferredName();
DECL_GETTER(inferred_name, Tagged<String>)
bool HasDebugInfo(Isolate* isolate) const;
V8_EXPORT_PRIVATE Tagged<DebugInfo> GetDebugInfo(Isolate* isolate) const;
V8_EXPORT_PRIVATE std::optional<Tagged<DebugInfo>> TryGetDebugInfo(
Isolate* isolate) const;
V8_EXPORT_PRIVATE bool HasBreakInfo(Isolate* isolate) const;
bool BreakAtEntry(Isolate* isolate) const;
bool HasCoverageInfo(Isolate* isolate) const;
Tagged<CoverageInfo> GetCoverageInfo(Isolate* isolate) const;
std::unique_ptr<char[]> DebugNameCStr() const;
static Handle<String> DebugName(Isolate* isolate,
DirectHandle<SharedFunctionInfo> shared);
bool PassesFilter(const char* raw_filter);
DECL_RELEASE_ACQUIRE_ACCESSORS(script, Tagged<HeapObject>)
DECL_RELEASE_ACQUIRE_ACCESSORS(raw_script, Tagged<Object>)
inline Tagged<HeapObject> script() const;
inline Tagged<HeapObject> script(PtrComprCageBase cage_base) const;
inline bool has_script(AcquireLoadTag tag) const;
inline bool is_repl_mode() const;
DECL_UINT16_ACCESSORS(raw_function_token_offset)
private:
using TorqueGeneratedSharedFunctionInfo::function_token_offset;
using TorqueGeneratedSharedFunctionInfo::set_function_token_offset;
public:
inline int function_token_position() const;
inline bool HasSharedName() const;
DECL_RELAXED_INT32_ACCESSORS(flags)
DECL_RELAXED_INT32_ACCESSORS(function_literal_id)
DECL_UINT8_ACCESSORS(flags2)
DECL_UINT16_ACCESSORS(age)
DECL_BOOLEAN_ACCESSORS(class_scope_has_private_brand)
DECL_BOOLEAN_ACCESSORS(has_static_private_methods_or_accessors)
DECL_BOOLEAN_ACCESSORS(is_sparkplug_compiling)
DECL_BOOLEAN_ACCESSORS(maglev_compilation_failed)
CachedTieringDecision cached_tiering_decision();
void set_cached_tiering_decision(CachedTieringDecision decision);
DECL_BOOLEAN_ACCESSORS(function_context_independent_compiled)
DECL_BOOLEAN_ACCESSORS(is_toplevel)
DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation)
inline LanguageMode language_mode() const;
inline void set_language_mode(LanguageMode language_mode);
DECL_PRIMITIVE_ACCESSORS(syntax_kind, FunctionSyntaxKind)
inline bool is_wrapped() const;
DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters)
DECL_BOOLEAN_ACCESSORS(native)
#if V8_ENABLE_WEBASSEMBLY
DECL_BOOLEAN_ACCESSORS(is_asm_wasm_broken)
#endif
DECL_BOOLEAN_ACCESSORS(name_should_print_as_anonymous)
DECL_BOOLEAN_ACCESSORS(are_properties_final)
DECL_BOOLEAN_ACCESSORS(has_reported_binary_coverage)
DECL_BOOLEAN_ACCESSORS(private_name_lookup_skips_outer_class)
DECL_BOOLEAN_ACCESSORS(live_edited)
inline FunctionKind kind() const;
int UniqueIdInScript() const;
DECL_INT_ACCESSORS(function_map_index)
inline void clear_padding();
inline void UpdateFunctionMapIndex();
inline bool optimization_disabled(CodeKind kind) const;
inline bool all_optimization_disabled() const;
inline BailoutReason disabled_optimization_reason() const;
void DisableOptimization(Isolate* isolate, BailoutReason reason);
DECL_BOOLEAN_ACCESSORS(requires_instance_members_initializer)
bool HasSourceCode() const;
static DirectHandle<Object> GetSourceCode(
Isolate* isolate, DirectHandle<SharedFunctionInfo> shared);
static Handle<Object> GetSourceCodeHarmony(
Isolate* isolate, DirectHandle<SharedFunctionInfo> shared);
inline bool IsSubjectToDebugging() const;
inline bool IsUserJavaScript() const;
inline bool CanDiscardCompiled() const;
V8_EXPORT_PRIVATE static void DiscardCompiled(
Isolate* isolate, DirectHandle<SharedFunctionInfo> shared_info);
void DiscardCompiledMetadata(
Isolate* isolate,
std::function<void(Tagged<HeapObject> object, ObjectSlot slot,
Tagged<HeapObject> target)>
gc_notify_updated_slot = [](Tagged<HeapObject> object,
ObjectSlot slot,
Tagged<HeapObject> target) {});
inline bool ShouldFlushCode(base::EnumSet<CodeFlushMode> code_flush_mode);
enum Inlineability {
kHasNoScript,
kNeedsBinaryCoverage,
kIsBuiltin,
kIsNotUserCode,
kHasNoBytecode,
kExceedsBytecodeLimit,
kMayContainBreakPoints,
kHasOptimizationDisabled,
kIsInlineable,
};
template <typename IsolateT>
Inlineability GetInlineability(CodeKind code_kind, IsolateT* isolate) const;
int SourceSize();
inline bool has_simple_parameters() const;
template <typename IsolateT>
static void InitFromFunctionLiteral(IsolateT* isolate,
FunctionLiteral* lit, bool is_toplevel);
template <typename IsolateT>
static void CreateAndSetUncompiledData(IsolateT* isolate,
FunctionLiteral* lit);
void UpdateExpectedNofPropertiesFromEstimate(FunctionLiteral* literal);
void UpdateAndFinalizeExpectedNofPropertiesFromEstimate(
FunctionLiteral* literal);
void SetFunctionTokenPosition(int function_token_position,
int start_position);
static void EnsureBytecodeArrayAvailable(
Isolate* isolate, Handle<SharedFunctionInfo> shared_info,
IsCompiledScope* is_compiled_scope,
CreateSourcePositions flag = CreateSourcePositions::kNo);
inline bool CanCollectSourcePosition(Isolate* isolate);
static void EnsureSourcePositionsAvailable(
Isolate* isolate, DirectHandle<SharedFunctionInfo> shared_info);
template <typename IsolateT>
bool AreSourcePositionsAvailable(IsolateT* isolate) const;
V8_EXPORT_PRIVATE uint32_t Hash();
inline bool construct_as_builtin() const;
inline void CalculateConstructAsBuiltin();
inline uint16_t CompareExchangeAge(uint16_t expected_age, uint16_t new_age);
V8_EXPORT_PRIVATE static void EnsureOldForTesting(
Tagged<SharedFunctionInfo> sfu);
DECL_PRINTER(SharedFunctionInfo)
DECL_VERIFIER(SharedFunctionInfo)
#ifdef VERIFY_HEAP
void SharedFunctionInfoVerify(LocalIsolate* isolate);
#endif
#ifdef OBJECT_PRINT
void PrintSourceCode(std::ostream& os);
#endif
class ScriptIterator {
public:
V8_EXPORT_PRIVATE ScriptIterator(Isolate* isolate, Tagged<Script> script);
explicit ScriptIterator(Handle<WeakFixedArray> infos);
ScriptIterator(const ScriptIterator&) = delete;
ScriptIterator& operator=(const ScriptIterator&) = delete;
V8_EXPORT_PRIVATE Tagged<SharedFunctionInfo> Next();
int CurrentIndex() const { return index_ - 1; }
void Reset(Isolate* isolate, Tagged<Script> script);
private:
Handle<WeakFixedArray> infos_;
int index_;
};
static const int kMaximumFunctionTokenOffset = kMaxUInt16 - 1;
static const uint16_t kFunctionTokenOutOfRange = static_cast<uint16_t>(-1);
static_assert(kMaximumFunctionTokenOffset + 1 == kFunctionTokenOutOfRange);
static_assert(kSize % kTaggedSize == 0);
class BodyDescriptor;
static_assert(DisabledOptimizationReasonBits::is_valid(
BailoutReason::kLastErrorMessage));
static_assert(FunctionKindBits::is_valid(FunctionKind::kLastFunctionKind));
static_assert(FunctionSyntaxKindBits::is_valid(
FunctionSyntaxKind::kLastFunctionSyntaxKind));
static void InstallDebugBytecode(DirectHandle<SharedFunctionInfo> shared,
Isolate* isolate);
static void UninstallDebugBytecode(Tagged<SharedFunctionInfo> shared,
Isolate* isolate);
#ifdef DEBUG
static bool UniqueIdsAreUnique(Isolate* isolate);
#endif
private:
#ifdef VERIFY_HEAP
void SharedFunctionInfoVerify(ReadOnlyRoots roots);
#endif
DECL_RELEASE_ACQUIRE_ACCESSORS(name_or_scope_info, Tagged<NameOrScopeInfoT>)
DECL_ACCESSORS(outer_scope_info, Tagged<UnionOf<ScopeInfo, TheHole>>)
DECL_BOOLEAN_ACCESSORS(properties_are_final)
inline void set_kind(FunctionKind kind);
inline uint16_t get_property_estimate_from_literal(FunctionLiteral* literal);
inline int32_t relaxed_flags() const;
inline void set_relaxed_flags(int32_t flags);
template <typename Impl>
friend class FactoryBase;
friend class V8HeapExplorer;
FRIEND_TEST(PreParserTest, LazyFunctionLength);
TQ_OBJECT_CONSTRUCTORS(SharedFunctionInfo)
};
std::ostream& operator<<(std::ostream& os, SharedFunctionInfo::Inlineability i);
class SharedFunctionInfoWrapper : public TrustedObject {
public:
DECL_ACCESSORS(shared_info, Tagged<SharedFunctionInfo>)
DECL_PRINTER(SharedFunctionInfoWrapper)
DECL_VERIFIER(SharedFunctionInfoWrapper)
#define FIELD_LIST(V) \
V(kSharedInfoOffset, kTaggedSize) \
V(kHeaderSize, 0) \
V(kSize, 0)
DEFINE_FIELD_OFFSET_CONSTANTS(TrustedObject::kHeaderSize, FIELD_LIST)
#undef FIELD_LIST
class BodyDescriptor;
OBJECT_CONSTRUCTORS(SharedFunctionInfoWrapper, TrustedObject);
};
static constexpr int kStaticRootsSFISize = 48;
#ifdef V8_STATIC_ROOTS
static_assert(SharedFunctionInfo::kSize == kStaticRootsSFISize);
#endif
struct SourceCodeOf {
explicit SourceCodeOf(Tagged<SharedFunctionInfo> v, int max = -1)
: value(v), max_length(max) {}
const Tagged<SharedFunctionInfo> value;
int max_length;
};
class V8_NODISCARD IsCompiledScope {
public:
inline IsCompiledScope(const Tagged<SharedFunctionInfo> shared,
Isolate* isolate);
inline IsCompiledScope(const Tagged<SharedFunctionInfo> shared,
LocalIsolate* isolate);
inline IsCompiledScope() = default;
inline bool is_compiled() const { return is_compiled_; }
private:
MaybeHandle<HeapObject> retain_code_ = {};
bool is_compiled_ = false;
};
class V8_NODISCARD IsBaselineCompiledScope {
public:
inline IsBaselineCompiledScope(const Tagged<SharedFunctionInfo> shared,
Isolate* isolate);
inline IsBaselineCompiledScope() = default;
inline bool is_compiled() const { return is_compiled_; }
private:
MaybeHandle<Code> retain_code_ = {};
bool is_compiled_ = false;
};
std::ostream& operator<<(std::ostream& os, const SourceCodeOf& v);
}
#include "src/objects/object-macros-undef.h"
#endif