[SharedFunctionInfo] Add available_baseline_code flag
Checks that flags1 are ReadOnly after SFI is finalised. Bug: v8:12054 Change-Id: Ia2518b8f136a81aa076fd429bf4fcaf742a314e3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3263897 Commit-Queue: Victor Gomes <victorgomes@chromium.org> Reviewed-by: Nico Hartmann <nicohartmann@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/main@{#77816}
This commit is contained in:
parent
604ebab1b5
commit
5e16d853d9
@ -604,6 +604,10 @@ void InstallUnoptimizedCode(UnoptimizedCompilationInfo* compilation_info,
|
||||
#else
|
||||
UNREACHABLE();
|
||||
#endif // V8_ENABLE_WEBASSEMBLY
|
||||
|
||||
#ifdef DEBUG
|
||||
shared_info->set_finalized(true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -361,6 +361,9 @@ Handle<SharedFunctionInfo> FactoryBase<Impl>::NewSharedFunctionInfo(
|
||||
Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo();
|
||||
DisallowGarbageCollection no_gc;
|
||||
SharedFunctionInfo raw = *shared;
|
||||
#ifdef DEBUG
|
||||
raw.set_finalized(false);
|
||||
#endif
|
||||
// Function names are assumed to be flat elsewhere.
|
||||
Handle<String> shared_name;
|
||||
bool has_shared_name = maybe_name.ToHandle(&shared_name);
|
||||
|
@ -2586,7 +2586,7 @@ IGNITION_HANDLER(CreateMappedArguments, InterpreterAssembler) {
|
||||
TNode<SharedFunctionInfo> shared_info = LoadObjectField<SharedFunctionInfo>(
|
||||
closure, JSFunction::kSharedFunctionInfoOffset);
|
||||
TNode<Uint32T> flags =
|
||||
LoadObjectField<Uint32T>(shared_info, SharedFunctionInfo::kFlagsOffset);
|
||||
LoadObjectField<Uint32T>(shared_info, SharedFunctionInfo::kFlags2Offset);
|
||||
TNode<BoolT> has_duplicate_parameters =
|
||||
IsSetWord32<SharedFunctionInfo::HasDuplicateParametersBit>(flags);
|
||||
Branch(has_duplicate_parameters, &if_duplicate_parameters,
|
||||
|
@ -144,6 +144,8 @@ int32_t SharedFunctionInfo::relaxed_flags() const {
|
||||
return flags(kRelaxedLoad);
|
||||
}
|
||||
void SharedFunctionInfo::set_relaxed_flags(int32_t flags) {
|
||||
// These flags should be read only, once SFI is finalized.
|
||||
DCHECK(!finalized());
|
||||
return set_flags(flags, kRelaxedStore);
|
||||
}
|
||||
|
||||
@ -256,10 +258,11 @@ SharedFunctionInfo::Inlineability SharedFunctionInfo::GetInlineability(
|
||||
return kIsInlineable;
|
||||
}
|
||||
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags2, class_scope_has_private_brand,
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, relaxed_flags,
|
||||
class_scope_has_private_brand,
|
||||
SharedFunctionInfo::ClassScopeHasPrivateBrandBit)
|
||||
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags2,
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, relaxed_flags,
|
||||
has_static_private_methods_or_accessors,
|
||||
SharedFunctionInfo::HasStaticPrivateMethodsOrAccessorsBit)
|
||||
|
||||
@ -268,21 +271,20 @@ BIT_FIELD_ACCESSORS(SharedFunctionInfo, relaxed_flags, syntax_kind,
|
||||
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, relaxed_flags, allows_lazy_compilation,
|
||||
SharedFunctionInfo::AllowLazyCompilationBit)
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, relaxed_flags, has_duplicate_parameters,
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags2, has_duplicate_parameters,
|
||||
SharedFunctionInfo::HasDuplicateParametersBit)
|
||||
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, relaxed_flags, native,
|
||||
SharedFunctionInfo::IsNativeBit)
|
||||
#if V8_ENABLE_WEBASSEMBLY
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, relaxed_flags, is_asm_wasm_broken,
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags2, is_asm_wasm_broken,
|
||||
SharedFunctionInfo::IsAsmWasmBrokenBit)
|
||||
#endif // V8_ENABLE_WEBASSEMBLY
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, relaxed_flags,
|
||||
requires_instance_members_initializer,
|
||||
SharedFunctionInfo::RequiresInstanceMembersInitializerBit)
|
||||
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, relaxed_flags,
|
||||
name_should_print_as_anonymous,
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags2, name_should_print_as_anonymous,
|
||||
SharedFunctionInfo::NameShouldPrintAsAnonymousBit)
|
||||
BIT_FIELD_ACCESSORS(SharedFunctionInfo, relaxed_flags,
|
||||
has_reported_binary_coverage,
|
||||
@ -296,12 +298,21 @@ BIT_FIELD_ACCESSORS(SharedFunctionInfo, relaxed_flags,
|
||||
private_name_lookup_skips_outer_class,
|
||||
SharedFunctionInfo::PrivateNameLookupSkipsOuterClassBit)
|
||||
|
||||
bool SharedFunctionInfo::available_baseline_code() const {
|
||||
return AvailableBaselineCodeBit::decode(flags(kRelaxedLoad));
|
||||
}
|
||||
|
||||
void SharedFunctionInfo::set_available_baseline_code(bool value) {
|
||||
set_flags(AvailableBaselineCodeBit::update(flags(kRelaxedLoad), value),
|
||||
kRelaxedStore);
|
||||
}
|
||||
|
||||
bool SharedFunctionInfo::optimization_disabled() const {
|
||||
return disabled_optimization_reason() != BailoutReason::kNoReason;
|
||||
}
|
||||
|
||||
BailoutReason SharedFunctionInfo::disabled_optimization_reason() const {
|
||||
return DisabledOptimizationReasonBits::decode(flags(kRelaxedLoad));
|
||||
return DisabledOptimizationReasonBits::decode(flags2());
|
||||
}
|
||||
|
||||
LanguageMode SharedFunctionInfo::language_mode() const {
|
||||
|
@ -228,6 +228,9 @@ void SharedFunctionInfo::SetScript(ReadOnlyRoots roots,
|
||||
|
||||
void SharedFunctionInfo::CopyFrom(SharedFunctionInfo other) {
|
||||
PtrComprCageBase cage_base = GetPtrComprCageBase(*this);
|
||||
#ifdef DEBUG
|
||||
set_finalized(false);
|
||||
#endif
|
||||
set_function_data(other.function_data(cage_base, kAcquireLoad),
|
||||
kReleaseStore);
|
||||
set_name_or_scope_info(other.name_or_scope_info(cage_base, kAcquireLoad),
|
||||
@ -248,6 +251,10 @@ void SharedFunctionInfo::CopyFrom(SharedFunctionInfo other) {
|
||||
set_unique_id(other.unique_id());
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
set_finalized(other.finalized());
|
||||
#endif
|
||||
|
||||
// This should now be byte-for-byte identical to the input.
|
||||
DCHECK_EQ(memcmp(reinterpret_cast<void*>(address()),
|
||||
reinterpret_cast<void*>(other.address()),
|
||||
@ -465,9 +472,7 @@ std::ostream& operator<<(std::ostream& os, const SourceCodeOf& v) {
|
||||
|
||||
void SharedFunctionInfo::DisableOptimization(BailoutReason reason) {
|
||||
DCHECK_NE(reason, BailoutReason::kNoReason);
|
||||
|
||||
set_flags(DisabledOptimizationReasonBits::update(flags(kRelaxedLoad), reason),
|
||||
kRelaxedStore);
|
||||
set_flags2(DisabledOptimizationReasonBits::update(flags2(), reason));
|
||||
// Code should be the lazy compilation stub or else interpreted.
|
||||
Isolate* isolate = GetIsolate();
|
||||
DCHECK(abstract_code(isolate).kind() == CodeKind::INTERPRETED_FUNCTION ||
|
||||
|
@ -399,6 +399,9 @@ class SharedFunctionInfo
|
||||
using TorqueGeneratedSharedFunctionInfo::set_function_token_offset;
|
||||
|
||||
public:
|
||||
inline bool available_baseline_code() const;
|
||||
inline void set_available_baseline_code(bool value);
|
||||
|
||||
// The position of the 'function' token in the script source. Can return
|
||||
// kNoSourcePosition if raw_function_token_offset() returns
|
||||
// kFunctionTokenOutOfRange.
|
||||
@ -407,10 +410,6 @@ class SharedFunctionInfo
|
||||
// Returns true if the function has shared name.
|
||||
inline bool HasSharedName() const;
|
||||
|
||||
// [flags] Bit field containing various flags about the function.
|
||||
DECL_RELAXED_INT32_ACCESSORS(flags)
|
||||
DECL_UINT8_ACCESSORS(flags2)
|
||||
|
||||
// True if the outer class scope contains a private brand for
|
||||
// private instance methdos.
|
||||
DECL_BOOLEAN_ACCESSORS(class_scope_has_private_brand)
|
||||
@ -670,6 +669,10 @@ class SharedFunctionInfo
|
||||
|
||||
inline uint16_t get_property_estimate_from_literal(FunctionLiteral* literal);
|
||||
|
||||
// [flags] Bit field containing various flags about the function.
|
||||
DECL_RELAXED_INT32_ACCESSORS(flags)
|
||||
DECL_UINT8_ACCESSORS(flags2)
|
||||
|
||||
// For ease of use of the BITFIELD macro.
|
||||
inline int32_t relaxed_flags() const;
|
||||
inline void set_relaxed_flags(int32_t flags);
|
||||
|
@ -18,6 +18,9 @@ type FunctionKind extends uint8 constexpr 'FunctionKind';
|
||||
type FunctionSyntaxKind extends uint8 constexpr 'FunctionSyntaxKind';
|
||||
type BailoutReason extends uint8 constexpr 'BailoutReason';
|
||||
|
||||
// These flags are ReadOnly after SFI is fully inialized,
|
||||
// except available_sparkplug_code which is set by the concurrent
|
||||
// Sparkplug compiler.
|
||||
bitfield struct SharedFunctionInfoFlags extends uint32 {
|
||||
// Have FunctionKind first to make it cheaper to access.
|
||||
function_kind: FunctionKind: 5 bit;
|
||||
@ -25,23 +28,24 @@ bitfield struct SharedFunctionInfoFlags extends uint32 {
|
||||
is_strict: bool: 1 bit;
|
||||
function_syntax_kind: FunctionSyntaxKind: 3 bit;
|
||||
is_class_constructor: bool: 1 bit;
|
||||
has_duplicate_parameters: bool: 1 bit;
|
||||
allow_lazy_compilation: bool: 1 bit;
|
||||
is_asm_wasm_broken: bool: 1 bit;
|
||||
function_map_index: uint32: 5 bit;
|
||||
disabled_optimization_reason: BailoutReason: 4 bit;
|
||||
requires_instance_members_initializer: bool: 1 bit;
|
||||
construct_as_builtin: bool: 1 bit;
|
||||
name_should_print_as_anonymous: bool: 1 bit;
|
||||
has_reported_binary_coverage: bool: 1 bit;
|
||||
is_top_level: bool: 1 bit;
|
||||
properties_are_final: bool: 1 bit;
|
||||
private_name_lookup_skips_outer_class: bool: 1 bit;
|
||||
class_scope_has_private_brand: bool: 1 bit;
|
||||
has_static_private_methods_or_accessors: bool: 1 bit;
|
||||
available_baseline_code: bool: 1 bit;
|
||||
}
|
||||
|
||||
bitfield struct SharedFunctionInfoFlags2 extends uint8 {
|
||||
class_scope_has_private_brand: bool: 1 bit;
|
||||
has_static_private_methods_or_accessors: bool: 1 bit;
|
||||
disabled_optimization_reason: BailoutReason: 4 bit;
|
||||
is_asm_wasm_broken: bool: 1 bit;
|
||||
name_should_print_as_anonymous: bool: 1 bit;
|
||||
has_duplicate_parameters: bool: 1 bit;
|
||||
}
|
||||
|
||||
@generateBodyDescriptor
|
||||
@ -79,6 +83,7 @@ extern class SharedFunctionInfo extends HeapObject {
|
||||
// [unique_id] - For --log-maps purposes, an identifier that's persistent
|
||||
// even if the GC moves this SharedFunctionInfo.
|
||||
@if(V8_SFI_HAS_UNIQUE_ID) unique_id: int32;
|
||||
@if(DEBUG) finalized: int8;
|
||||
}
|
||||
|
||||
const kDontAdaptArgumentsSentinel: constexpr int32
|
||||
|
@ -45,6 +45,7 @@ struct EnumEntry {
|
||||
class BuildFlags : public ContextualClass<BuildFlags> {
|
||||
public:
|
||||
BuildFlags() {
|
||||
build_flags_["DEBUG"] = DEBUG_BOOL;
|
||||
build_flags_["V8_SFI_HAS_UNIQUE_ID"] = V8_SFI_HAS_UNIQUE_ID;
|
||||
build_flags_["V8_EXTERNAL_CODE_SPACE"] = V8_EXTERNAL_CODE_SPACE_BOOL;
|
||||
build_flags_["TAGGED_SIZE_8_BYTES"] = TAGGED_SIZE_8_BYTES;
|
||||
|
Loading…
Reference in New Issue
Block a user