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

[cleanup] Remove synchronized_ from slot_count and used accessors

Continuing the cleanups and using the tags rather than synchronized_
in the name of the accessors.

Bug: v8:7790
Change-Id: I3fe942b1decae3b248f8662547d793777acd0e8d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2897096
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74700}
parent bd329976
......@@ -982,7 +982,7 @@ void GlobalLexicalScopeNames(v8::Local<v8::Context> v8_context,
i::Handle<i::ScriptContextTable> table(
context->global_object().native_context().script_context_table(),
isolate);
for (int i = 0; i < table->synchronized_used(); i++) {
for (int i = 0; i < table->used(kAcquireLoad); i++) {
i::Handle<i::Context> context =
i::ScriptContextTable::GetContext(isolate, table, i);
DCHECK(context->IsScriptContext());
......
......@@ -732,7 +732,7 @@ void ScopeIterator::VisitScriptScope(const Visitor& visitor) const {
// Skip the first script since that just declares 'this'.
for (int context_index = 1;
context_index < script_contexts->synchronized_used(); context_index++) {
context_index < script_contexts->used(kAcquireLoad); context_index++) {
Handle<Context> context = ScriptContextTable::GetContext(
isolate_, script_contexts, context_index);
Handle<ScopeInfo> scope_info(context->scope_info(), isolate_);
......
......@@ -1110,7 +1110,7 @@ Handle<ScriptContextTable> Factory::NewScriptContextTable() {
Handle<ScriptContextTable> context_table = Handle<ScriptContextTable>::cast(
NewFixedArrayWithMap(read_only_roots().script_context_table_map_handle(),
ScriptContextTable::kMinLength));
context_table->synchronized_set_used(0);
context_table->set_used(0, kReleaseStore);
return context_table;
}
......
......@@ -5,6 +5,7 @@
#ifndef V8_OBJECTS_CONTEXTS_INL_H_
#define V8_OBJECTS_CONTEXTS_INL_H_
#include "src/common/globals.h"
#include "src/heap/heap-write-barrier.h"
#include "src/objects/contexts.h"
#include "src/objects/dictionary-inl.h"
......@@ -30,12 +31,12 @@ namespace internal {
OBJECT_CONSTRUCTORS_IMPL(ScriptContextTable, FixedArray)
CAST_ACCESSOR(ScriptContextTable)
int ScriptContextTable::synchronized_used() const {
return Smi::ToInt(get(kUsedSlotIndex, kAcquireLoad));
int ScriptContextTable::used(AcquireLoadTag tag) const {
return Smi::ToInt(get(kUsedSlotIndex, tag));
}
void ScriptContextTable::synchronized_set_used(int used) {
set(kUsedSlotIndex, Smi::FromInt(used), kReleaseStore);
void ScriptContextTable::set_used(int used, ReleaseStoreTag tag) {
set(kUsedSlotIndex, Smi::FromInt(used), tag);
}
// static
......@@ -46,7 +47,7 @@ Handle<Context> ScriptContextTable::GetContext(Isolate* isolate,
}
Context ScriptContextTable::get_context(int i) const {
DCHECK_LT(i, synchronized_used());
DCHECK_LT(i, used(kAcquireLoad));
return Context::cast(this->get(i + kFirstContextSlotIndex));
}
......
......@@ -17,7 +17,7 @@ namespace internal {
Handle<ScriptContextTable> ScriptContextTable::Extend(
Handle<ScriptContextTable> table, Handle<Context> script_context) {
Handle<ScriptContextTable> result;
int used = table->synchronized_used();
int used = table->used(kAcquireLoad);
int length = table->length();
CHECK(used >= 0 && length > 0 && used < length);
if (used + kFirstContextSlotIndex == length) {
......@@ -33,7 +33,7 @@ Handle<ScriptContextTable> ScriptContextTable::Extend(
DCHECK(script_context->IsScriptContext());
result->set(used + kFirstContextSlotIndex, *script_context);
result->synchronized_set_used(used + 1);
result->set_used(used + 1, kReleaseStore);
return result;
}
......@@ -51,7 +51,7 @@ bool ScriptContextTable::Lookup(Isolate* isolate, ScriptContextTable table,
String name, VariableLookupResult* result) {
DisallowGarbageCollection no_gc;
// Static variables cannot be in script contexts.
for (int i = 0; i < table.synchronized_used(); i++) {
for (int i = 0; i < table.used(kAcquireLoad); i++) {
Context context = table.get_context(i);
DCHECK(context.IsScriptContext());
int slot_index =
......
......@@ -358,8 +358,7 @@ class ScriptContextTable : public FixedArray {
public:
DECL_CAST(ScriptContextTable)
inline int synchronized_used() const;
inline void synchronized_set_used(int used);
DECL_RELEASE_ACQUIRE_INT_ACCESSORS(used)
static inline Handle<Context> GetContext(Isolate* isolate,
Handle<ScriptContextTable> table,
......
......@@ -41,9 +41,8 @@ INT32_ACCESSORS(FeedbackMetadata, create_closure_slot_count,
RELEASE_ACQUIRE_WEAK_ACCESSORS(FeedbackVector, maybe_optimized_code,
kMaybeOptimizedCodeOffset)
int32_t FeedbackMetadata::synchronized_slot_count() const {
return base::Acquire_Load(
reinterpret_cast<const base::Atomic32*>(field_address(kSlotCountOffset)));
int32_t FeedbackMetadata::slot_count(AcquireLoadTag) const {
return ACQUIRE_READ_INT32_FIELD(*this, kSlotCountOffset);
}
int32_t FeedbackMetadata::get(int index) const {
......
......@@ -522,7 +522,7 @@ class FeedbackMetadata : public HeapObject {
DECL_INT32_ACCESSORS(create_closure_slot_count)
// Get slot_count using an acquire load.
inline int32_t synchronized_slot_count() const;
inline int32_t slot_count(AcquireLoadTag) const;
// Returns number of feedback vector elements used by given slot kind.
static inline int GetSlotSize(FeedbackSlotKind kind);
......
......@@ -492,7 +492,7 @@ class FeedbackMetadata::BodyDescriptor final : public BodyDescriptorBase {
static inline int SizeOf(Map map, HeapObject obj) {
return FeedbackMetadata::SizeFor(
FeedbackMetadata::cast(obj).synchronized_slot_count());
FeedbackMetadata::cast(obj).slot_count(kAcquireLoad));
}
};
......
......@@ -2295,7 +2295,7 @@ int HeapObject::SizeFromMap(Map map) const {
}
if (instance_type == FEEDBACK_METADATA_TYPE) {
return FeedbackMetadata::SizeFor(
FeedbackMetadata::unchecked_cast(*this).synchronized_slot_count());
FeedbackMetadata::unchecked_cast(*this).slot_count(kAcquireLoad));
}
if (base::IsInRange(instance_type, FIRST_DESCRIPTOR_ARRAY_TYPE,
LAST_DESCRIPTOR_ARRAY_TYPE)) {
......
......@@ -41,7 +41,7 @@ class ScriptContextTableAccessUsedThread final : public v8::base::Thread {
sema_started_->Signal();
for (int i = 0; i < script_context_table_->synchronized_used(); ++i) {
for (int i = 0; i < script_context_table_->used(kAcquireLoad); ++i) {
Context context = script_context_table_->get_context(i);
CHECK(context.IsScriptContext());
}
......
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