Commit bf52459d authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by V8 LUCI CQ

[compiler] Add release/acquire accessors for SFI::feedback_metadata

Bug: v8:7790, chromium:1239122
Change-Id: Id2f72035c968fba859be8b4685385b3f543eee2a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3094008
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76319}
parent 589f5264
......@@ -583,7 +583,7 @@ void InstallUnoptimizedCode(UnoptimizedCompilationInfo* compilation_info,
Handle<FeedbackMetadata> feedback_metadata = FeedbackMetadata::New(
isolate, compilation_info->feedback_vector_spec());
shared_info->set_feedback_metadata(*feedback_metadata);
shared_info->set_feedback_metadata(*feedback_metadata, kReleaseStore);
} else {
#if V8_ENABLE_WEBASSEMBLY
DCHECK(compilation_info->has_asm_wasm_data());
......@@ -591,7 +591,7 @@ void InstallUnoptimizedCode(UnoptimizedCompilationInfo* compilation_info,
DCHECK((std::is_same<IsolateT, Isolate>::value));
shared_info->set_asm_wasm_data(*compilation_info->asm_wasm_data());
shared_info->set_feedback_metadata(
ReadOnlyRoots(isolate).empty_feedback_metadata());
ReadOnlyRoots(isolate).empty_feedback_metadata(), kReleaseStore);
#else
UNREACHABLE();
#endif // V8_ENABLE_WEBASSEMBLY
......
......@@ -112,6 +112,10 @@ FeedbackMetadata FeedbackVector::metadata() const {
return shared_function_info().feedback_metadata();
}
FeedbackMetadata FeedbackVector::metadata(AcquireLoadTag tag) const {
return shared_function_info().feedback_metadata(tag);
}
RELAXED_INT32_ACCESSORS(FeedbackVector, invocation_count,
kInvocationCountOffset)
......
......@@ -4,6 +4,7 @@
#include "src/objects/feedback-vector.h"
#include "src/common/globals.h"
#include "src/deoptimizer/deoptimizer.h"
#include "src/diagnostics/code-tracer.h"
#include "src/heap/heap-inl.h"
......@@ -207,6 +208,12 @@ FeedbackSlotKind FeedbackVector::GetKind(FeedbackSlot slot) const {
return metadata().GetKind(slot);
}
FeedbackSlotKind FeedbackVector::GetKind(FeedbackSlot slot,
AcquireLoadTag tag) const {
DCHECK(!is_empty());
return metadata(tag).GetKind(slot);
}
FeedbackSlot FeedbackVector::GetTypeProfileSlot() const {
DCHECK(metadata().HasTypeProfileSlot());
FeedbackSlot slot =
......@@ -562,7 +569,7 @@ FeedbackNexus::FeedbackNexus(Handle<FeedbackVector> vector, FeedbackSlot slot,
const NexusConfig& config)
: vector_handle_(vector),
slot_(slot),
kind_(vector->GetKind(slot)),
kind_(vector->GetKind(slot, kAcquireLoad)),
config_(config) {}
Handle<WeakFixedArray> FeedbackNexus::CreateArrayOfSize(int length) {
......
......@@ -215,6 +215,7 @@ class FeedbackVector
inline bool is_empty() const;
inline FeedbackMetadata metadata() const;
inline FeedbackMetadata metadata(AcquireLoadTag tag) const;
// Increment profiler ticks, saturating at the maximal value.
void SaturatingIncrementProfilerTicks();
......@@ -273,6 +274,8 @@ class FeedbackVector
// Returns slot kind for given slot.
V8_EXPORT_PRIVATE FeedbackSlotKind GetKind(FeedbackSlot slot) const;
V8_EXPORT_PRIVATE FeedbackSlotKind GetKind(FeedbackSlot slot,
AcquireLoadTag tag) const;
FeedbackSlot GetTypeProfileSlot() const;
......
......@@ -123,6 +123,14 @@ RELEASE_ACQUIRE_ACCESSORS(SharedFunctionInfo, script_or_debug_info, HeapObject,
RENAME_TORQUE_ACCESSORS(SharedFunctionInfo,
raw_outer_scope_info_or_feedback_metadata,
outer_scope_info_or_feedback_metadata, HeapObject)
DEF_ACQUIRE_GETTER(SharedFunctionInfo,
raw_outer_scope_info_or_feedback_metadata, HeapObject) {
HeapObject value =
TaggedField<HeapObject, kOuterScopeInfoOrFeedbackMetadataOffset>::
Acquire_Load(cage_base, *this);
return value;
}
RENAME_UINT16_TORQUE_ACCESSORS(SharedFunctionInfo,
internal_formal_parameter_count,
formal_parameter_count)
......@@ -457,17 +465,21 @@ bool SharedFunctionInfo::HasFeedbackMetadata() const {
return raw_outer_scope_info_or_feedback_metadata().IsFeedbackMetadata();
}
bool SharedFunctionInfo::HasFeedbackMetadata(AcquireLoadTag tag) const {
return raw_outer_scope_info_or_feedback_metadata(tag).IsFeedbackMetadata();
}
FeedbackMetadata SharedFunctionInfo::feedback_metadata() const {
DCHECK(HasFeedbackMetadata());
return FeedbackMetadata::cast(raw_outer_scope_info_or_feedback_metadata());
}
void SharedFunctionInfo::set_feedback_metadata(FeedbackMetadata value,
WriteBarrierMode mode) {
DCHECK(!HasFeedbackMetadata());
DCHECK(value.IsFeedbackMetadata());
set_raw_outer_scope_info_or_feedback_metadata(value, mode);
}
RELEASE_ACQUIRE_ACCESSORS_CHECKED2(SharedFunctionInfo, feedback_metadata,
FeedbackMetadata,
kOuterScopeInfoOrFeedbackMetadataOffset,
HasFeedbackMetadata(kAcquireLoad),
!HasFeedbackMetadata(kAcquireLoad) &&
value.IsFeedbackMetadata())
bool SharedFunctionInfo::is_compiled() const {
Object data = function_data(kAcquireLoad);
......
......@@ -243,6 +243,7 @@ class SharedFunctionInfo
// [outer scope info | feedback metadata] Shared storage for outer scope info
// (on uncompiled functions) and feedback metadata (on compiled functions).
DECL_ACCESSORS(raw_outer_scope_info_or_feedback_metadata, HeapObject)
DECL_ACQUIRE_GETTER(raw_outer_scope_info_or_feedback_metadata, HeapObject)
private:
using TorqueGeneratedSharedFunctionInfo::
outer_scope_info_or_feedback_metadata;
......@@ -257,7 +258,9 @@ class SharedFunctionInfo
// [feedback metadata] Metadata template for feedback vectors of instances of
// this function.
inline bool HasFeedbackMetadata() const;
DECL_ACCESSORS(feedback_metadata, FeedbackMetadata)
inline bool HasFeedbackMetadata(AcquireLoadTag tag) const;
inline FeedbackMetadata feedback_metadata() const;
DECL_RELEASE_ACQUIRE_ACCESSORS(feedback_metadata, FeedbackMetadata)
// Returns if this function has been compiled yet. Note: with bytecode
// flushing, any GC after this call is made could cause the function
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment