[ubsan] Port MaybeObject to new design
This CL applies the equivalent of the Object -> ObjectPtr transformation to MaybeObject and HeapObjectReference. We need no renaming in this case because we can just migrate them both in one go. Bug: v8:3770 Change-Id: Ie1259c3e8c556eff00f8bcf534d7270ca9fe00e1 Reviewed-on: https://chromium-review.googlesource.com/c/1298386 Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Reviewed-by: Toon Verwaest <verwaest@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#57010}
This commit is contained in:
parent
199af6622d
commit
e7b8699910
@ -1846,8 +1846,8 @@ void CodeStubAssembler::DispatchMaybeObject(TNode<MaybeObject> maybe_object,
|
||||
GotoIf(TaggedIsSmi(maybe_object), &inner_if_smi);
|
||||
|
||||
GotoIf(WordEqual(BitcastMaybeObjectToWord(maybe_object),
|
||||
IntPtrConstant(reinterpret_cast<intptr_t>(
|
||||
HeapObjectReference::ClearedValue()))),
|
||||
IntPtrConstant(static_cast<intptr_t>(
|
||||
HeapObjectReference::ClearedValue().ptr()))),
|
||||
if_cleared);
|
||||
|
||||
GotoIf(WordEqual(WordAnd(BitcastMaybeObjectToWord(maybe_object),
|
||||
|
@ -842,7 +842,7 @@ void FeedbackVectorData::SerializeSlots(JSHeapBroker* broker) {
|
||||
DCHECK(feedback_.empty());
|
||||
feedback_.reserve(vector->length());
|
||||
for (int i = 0; i < vector->length(); ++i) {
|
||||
MaybeObject* value = vector->get(i);
|
||||
MaybeObject value = vector->get(i);
|
||||
ObjectData* slot_value =
|
||||
value->IsObject() ? broker->GetOrCreateData(value->cast<Object>())
|
||||
: nullptr;
|
||||
|
@ -115,14 +115,14 @@ void FeedbackVector::increment_deopt_count() {
|
||||
}
|
||||
|
||||
Code* FeedbackVector::optimized_code() const {
|
||||
MaybeObject* slot = optimized_code_weak_or_smi();
|
||||
MaybeObject slot = optimized_code_weak_or_smi();
|
||||
DCHECK(slot->IsSmi() || slot->IsWeakOrCleared());
|
||||
HeapObject* heap_object;
|
||||
return slot->GetHeapObject(&heap_object) ? Code::cast(heap_object) : nullptr;
|
||||
}
|
||||
|
||||
OptimizationMarker FeedbackVector::optimization_marker() const {
|
||||
MaybeObject* slot = optimized_code_weak_or_smi();
|
||||
MaybeObject slot = optimized_code_weak_or_smi();
|
||||
Smi* value;
|
||||
if (!slot->ToSmi(&value)) return OptimizationMarker::kNone;
|
||||
return static_cast<OptimizationMarker>(value->value());
|
||||
@ -144,23 +144,23 @@ FeedbackSlot FeedbackVector::ToSlot(int index) {
|
||||
return FeedbackSlot(index);
|
||||
}
|
||||
|
||||
MaybeObject* FeedbackVector::Get(FeedbackSlot slot) const {
|
||||
MaybeObject FeedbackVector::Get(FeedbackSlot slot) const {
|
||||
return get(GetIndex(slot));
|
||||
}
|
||||
|
||||
MaybeObject* FeedbackVector::get(int index) const {
|
||||
MaybeObject FeedbackVector::get(int index) const {
|
||||
DCHECK_GE(index, 0);
|
||||
DCHECK_LT(index, this->length());
|
||||
int offset = kFeedbackSlotsOffset + index * kPointerSize;
|
||||
return RELAXED_READ_WEAK_FIELD(this, offset);
|
||||
}
|
||||
|
||||
void FeedbackVector::Set(FeedbackSlot slot, MaybeObject* value,
|
||||
void FeedbackVector::Set(FeedbackSlot slot, MaybeObject value,
|
||||
WriteBarrierMode mode) {
|
||||
set(GetIndex(slot), value, mode);
|
||||
}
|
||||
|
||||
void FeedbackVector::set(int index, MaybeObject* value, WriteBarrierMode mode) {
|
||||
void FeedbackVector::set(int index, MaybeObject value, WriteBarrierMode mode) {
|
||||
DCHECK_GE(index, 0);
|
||||
DCHECK_LT(index, this->length());
|
||||
int offset = kFeedbackSlotsOffset + index * kPointerSize;
|
||||
@ -250,7 +250,7 @@ ForInHint ForInHintFromFeedback(int type_feedback) {
|
||||
|
||||
void FeedbackVector::ComputeCounts(int* with_type_info, int* generic,
|
||||
int* vector_ic_count) {
|
||||
MaybeObject* megamorphic_sentinel = MaybeObject::FromObject(
|
||||
MaybeObject megamorphic_sentinel = MaybeObject::FromObject(
|
||||
*FeedbackVector::MegamorphicSentinel(GetIsolate()));
|
||||
int with = 0;
|
||||
int gen = 0;
|
||||
@ -260,7 +260,7 @@ void FeedbackVector::ComputeCounts(int* with_type_info, int* generic,
|
||||
FeedbackSlot slot = iter.Next();
|
||||
FeedbackSlotKind kind = iter.kind();
|
||||
|
||||
MaybeObject* const obj = Get(slot);
|
||||
MaybeObject const obj = Get(slot);
|
||||
AssertNoLegacyTypes(obj);
|
||||
switch (kind) {
|
||||
case FeedbackSlotKind::kCall:
|
||||
@ -388,13 +388,13 @@ int FeedbackMetadataIterator::entry_size() const {
|
||||
return FeedbackMetadata::GetSlotSize(kind());
|
||||
}
|
||||
|
||||
MaybeObject* FeedbackNexus::GetFeedback() const {
|
||||
MaybeObject* feedback = vector()->Get(slot());
|
||||
MaybeObject FeedbackNexus::GetFeedback() const {
|
||||
MaybeObject feedback = vector()->Get(slot());
|
||||
FeedbackVector::AssertNoLegacyTypes(feedback);
|
||||
return feedback;
|
||||
}
|
||||
|
||||
MaybeObject* FeedbackNexus::GetFeedbackExtra() const {
|
||||
MaybeObject FeedbackNexus::GetFeedbackExtra() const {
|
||||
#ifdef DEBUG
|
||||
FeedbackSlotKind kind = vector()->GetKind(slot());
|
||||
DCHECK_LT(1, FeedbackMetadata::GetSlotSize(kind));
|
||||
@ -407,7 +407,7 @@ void FeedbackNexus::SetFeedback(Object* feedback, WriteBarrierMode mode) {
|
||||
SetFeedback(MaybeObject::FromObject(feedback));
|
||||
}
|
||||
|
||||
void FeedbackNexus::SetFeedback(MaybeObject* feedback, WriteBarrierMode mode) {
|
||||
void FeedbackNexus::SetFeedback(MaybeObject feedback, WriteBarrierMode mode) {
|
||||
FeedbackVector::AssertNoLegacyTypes(feedback);
|
||||
vector()->Set(slot(), feedback, mode);
|
||||
}
|
||||
@ -423,7 +423,7 @@ void FeedbackNexus::SetFeedbackExtra(Object* feedback_extra,
|
||||
vector()->set(index, MaybeObject::FromObject(feedback_extra), mode);
|
||||
}
|
||||
|
||||
void FeedbackNexus::SetFeedbackExtra(MaybeObject* feedback_extra,
|
||||
void FeedbackNexus::SetFeedbackExtra(MaybeObject feedback_extra,
|
||||
WriteBarrierMode mode) {
|
||||
#ifdef DEBUG
|
||||
FeedbackVector::AssertNoLegacyTypes(feedback_extra);
|
||||
|
@ -40,7 +40,7 @@ bool FeedbackVectorSpec::HasTypeProfileSlot() const {
|
||||
return GetKind(slot) == FeedbackSlotKind::kTypeProfile;
|
||||
}
|
||||
|
||||
static bool IsPropertyNameFeedback(MaybeObject* feedback) {
|
||||
static bool IsPropertyNameFeedback(MaybeObject feedback) {
|
||||
HeapObject* heap_object;
|
||||
if (!feedback->GetHeapObjectIfStrong(&heap_object)) return false;
|
||||
if (heap_object->IsString()) return true;
|
||||
@ -326,7 +326,7 @@ void FeedbackVector::SetOptimizationMarker(OptimizationMarker marker) {
|
||||
|
||||
void FeedbackVector::EvictOptimizedCodeMarkedForDeoptimization(
|
||||
SharedFunctionInfo* shared, const char* reason) {
|
||||
MaybeObject* slot = optimized_code_weak_or_smi();
|
||||
MaybeObject slot = optimized_code_weak_or_smi();
|
||||
if (slot->IsSmi()) {
|
||||
return;
|
||||
}
|
||||
@ -353,7 +353,7 @@ void FeedbackVector::EvictOptimizedCodeMarkedForDeoptimization(
|
||||
}
|
||||
|
||||
bool FeedbackVector::ClearSlots(Isolate* isolate) {
|
||||
MaybeObject* uninitialized_sentinel = MaybeObject::FromObject(
|
||||
MaybeObject uninitialized_sentinel = MaybeObject::FromObject(
|
||||
FeedbackVector::RawUninitializedSentinel(isolate));
|
||||
|
||||
bool feedback_updated = false;
|
||||
@ -361,7 +361,7 @@ bool FeedbackVector::ClearSlots(Isolate* isolate) {
|
||||
while (iter.HasNext()) {
|
||||
FeedbackSlot slot = iter.Next();
|
||||
|
||||
MaybeObject* obj = Get(slot);
|
||||
MaybeObject obj = Get(slot);
|
||||
if (obj != uninitialized_sentinel) {
|
||||
FeedbackNexus nexus(this, slot);
|
||||
feedback_updated |= nexus.Clear();
|
||||
@ -370,7 +370,7 @@ bool FeedbackVector::ClearSlots(Isolate* isolate) {
|
||||
return feedback_updated;
|
||||
}
|
||||
|
||||
void FeedbackVector::AssertNoLegacyTypes(MaybeObject* object) {
|
||||
void FeedbackVector::AssertNoLegacyTypes(MaybeObject object) {
|
||||
#ifdef DEBUG
|
||||
HeapObject* heap_object;
|
||||
if (object->GetHeapObject(&heap_object)) {
|
||||
@ -510,7 +510,7 @@ void FeedbackNexus::ConfigurePremonomorphic(Handle<Map> receiver_map) {
|
||||
bool FeedbackNexus::ConfigureMegamorphic() {
|
||||
DisallowHeapAllocation no_gc;
|
||||
Isolate* isolate = GetIsolate();
|
||||
MaybeObject* sentinel =
|
||||
MaybeObject sentinel =
|
||||
MaybeObject::FromObject(*FeedbackVector::MegamorphicSentinel(isolate));
|
||||
if (GetFeedback() != sentinel) {
|
||||
SetFeedback(sentinel, SKIP_WRITE_BARRIER);
|
||||
@ -525,7 +525,7 @@ bool FeedbackNexus::ConfigureMegamorphic(IcCheckType property_type) {
|
||||
DisallowHeapAllocation no_gc;
|
||||
Isolate* isolate = GetIsolate();
|
||||
bool changed = false;
|
||||
MaybeObject* sentinel =
|
||||
MaybeObject sentinel =
|
||||
MaybeObject::FromObject(*FeedbackVector::MegamorphicSentinel(isolate));
|
||||
if (GetFeedback() != sentinel) {
|
||||
SetFeedback(sentinel, SKIP_WRITE_BARRIER);
|
||||
@ -542,7 +542,7 @@ bool FeedbackNexus::ConfigureMegamorphic(IcCheckType property_type) {
|
||||
|
||||
InlineCacheState FeedbackNexus::StateFromFeedback() const {
|
||||
Isolate* isolate = GetIsolate();
|
||||
MaybeObject* feedback = GetFeedback();
|
||||
MaybeObject feedback = GetFeedback();
|
||||
|
||||
switch (kind()) {
|
||||
case FeedbackSlotKind::kCreateClosure:
|
||||
@ -559,7 +559,7 @@ InlineCacheState FeedbackNexus::StateFromFeedback() const {
|
||||
if (feedback->IsSmi()) return MONOMORPHIC;
|
||||
|
||||
DCHECK(feedback->IsWeakOrCleared());
|
||||
MaybeObject* extra = GetFeedbackExtra();
|
||||
MaybeObject extra = GetFeedbackExtra();
|
||||
if (!feedback->IsCleared() ||
|
||||
extra != MaybeObject::FromObject(
|
||||
*FeedbackVector::UninitializedSentinel(isolate))) {
|
||||
@ -744,7 +744,7 @@ void FeedbackNexus::ConfigureHandlerMode(const MaybeObjectHandle& handler) {
|
||||
void FeedbackNexus::ConfigureCloneObject(Handle<Map> source_map,
|
||||
Handle<Map> result_map) {
|
||||
Isolate* isolate = GetIsolate();
|
||||
MaybeObject* maybe_feedback = GetFeedback();
|
||||
MaybeObject maybe_feedback = GetFeedback();
|
||||
Handle<HeapObject> feedback(maybe_feedback->IsStrongOrWeak()
|
||||
? maybe_feedback->GetHeapObject()
|
||||
: nullptr,
|
||||
@ -778,7 +778,7 @@ void FeedbackNexus::ConfigureCloneObject(Handle<Map> source_map,
|
||||
Handle<WeakFixedArray> array = Handle<WeakFixedArray>::cast(feedback);
|
||||
int i = 0;
|
||||
for (; i < array->length(); i += kCloneObjectPolymorphicEntrySize) {
|
||||
MaybeObject* feedback = array->Get(i);
|
||||
MaybeObject feedback = array->Get(i);
|
||||
if (feedback->IsCleared()) break;
|
||||
Handle<Map> cached_map(Map::cast(feedback->GetHeapObject()), isolate);
|
||||
if (cached_map.is_identical_to(source_map) ||
|
||||
@ -789,7 +789,7 @@ void FeedbackNexus::ConfigureCloneObject(Handle<Map> source_map,
|
||||
if (i >= array->length()) {
|
||||
if (i == kMaxElements) {
|
||||
// Transition to MEGAMORPHIC.
|
||||
MaybeObject* sentinel = MaybeObject::FromObject(
|
||||
MaybeObject sentinel = MaybeObject::FromObject(
|
||||
*FeedbackVector::MegamorphicSentinel(isolate));
|
||||
SetFeedback(sentinel, SKIP_WRITE_BARRIER);
|
||||
SetFeedbackExtra(HeapObjectReference::ClearedValue());
|
||||
@ -907,7 +907,7 @@ int FeedbackNexus::ExtractMaps(MapHandles* maps) const {
|
||||
IsStoreInArrayLiteralICKind(kind()));
|
||||
|
||||
Isolate* isolate = GetIsolate();
|
||||
MaybeObject* feedback = GetFeedback();
|
||||
MaybeObject feedback = GetFeedback();
|
||||
bool is_named_feedback = IsPropertyNameFeedback(feedback);
|
||||
HeapObject* heap_object;
|
||||
if ((feedback->GetHeapObjectIfStrong(&heap_object) &&
|
||||
@ -954,7 +954,7 @@ MaybeObjectHandle FeedbackNexus::FindHandlerForMap(Handle<Map> map) const {
|
||||
IsKeyedLoadICKind(kind()) || IsKeyedStoreICKind(kind()) ||
|
||||
IsStoreOwnICKind(kind()) || IsStoreDataPropertyInLiteralKind(kind()));
|
||||
|
||||
MaybeObject* feedback = GetFeedback();
|
||||
MaybeObject feedback = GetFeedback();
|
||||
Isolate* isolate = GetIsolate();
|
||||
bool is_named_feedback = IsPropertyNameFeedback(feedback);
|
||||
HeapObject* heap_object;
|
||||
@ -975,7 +975,7 @@ MaybeObjectHandle FeedbackNexus::FindHandlerForMap(Handle<Map> map) const {
|
||||
if (array->Get(i)->GetHeapObjectIfWeak(&heap_object)) {
|
||||
Map* array_map = Map::cast(heap_object);
|
||||
if (array_map == *map && !array->Get(i + increment - 1)->IsCleared()) {
|
||||
MaybeObject* handler = array->Get(i + increment - 1);
|
||||
MaybeObject handler = array->Get(i + increment - 1);
|
||||
DCHECK(IC::IsHandler(handler));
|
||||
return handle(handler, isolate);
|
||||
}
|
||||
@ -984,7 +984,7 @@ MaybeObjectHandle FeedbackNexus::FindHandlerForMap(Handle<Map> map) const {
|
||||
} else if (feedback->GetHeapObjectIfWeak(&heap_object)) {
|
||||
Map* cell_map = Map::cast(heap_object);
|
||||
if (cell_map == *map && !GetFeedbackExtra()->IsCleared()) {
|
||||
MaybeObject* handler = GetFeedbackExtra();
|
||||
MaybeObject handler = GetFeedbackExtra();
|
||||
DCHECK(IC::IsHandler(handler));
|
||||
return handle(handler, isolate);
|
||||
}
|
||||
@ -1000,7 +1000,7 @@ bool FeedbackNexus::FindHandlers(MaybeObjectHandles* code_list,
|
||||
IsStoreOwnICKind(kind()) || IsStoreDataPropertyInLiteralKind(kind()) ||
|
||||
IsStoreInArrayLiteralICKind(kind()));
|
||||
|
||||
MaybeObject* feedback = GetFeedback();
|
||||
MaybeObject feedback = GetFeedback();
|
||||
Isolate* isolate = GetIsolate();
|
||||
int count = 0;
|
||||
bool is_named_feedback = IsPropertyNameFeedback(feedback);
|
||||
@ -1022,14 +1022,14 @@ bool FeedbackNexus::FindHandlers(MaybeObjectHandles* code_list,
|
||||
DCHECK(array->Get(i)->IsWeakOrCleared());
|
||||
if (array->Get(i)->GetHeapObjectIfWeak(&heap_object) &&
|
||||
!array->Get(i + increment - 1)->IsCleared()) {
|
||||
MaybeObject* handler = array->Get(i + increment - 1);
|
||||
MaybeObject handler = array->Get(i + increment - 1);
|
||||
DCHECK(IC::IsHandler(handler));
|
||||
code_list->push_back(handle(handler, isolate));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
} else if (feedback->GetHeapObjectIfWeak(&heap_object)) {
|
||||
MaybeObject* extra = GetFeedbackExtra();
|
||||
MaybeObject extra = GetFeedbackExtra();
|
||||
if (!extra->IsCleared()) {
|
||||
DCHECK(IC::IsHandler(extra));
|
||||
code_list->push_back(handle(extra, isolate));
|
||||
@ -1041,7 +1041,7 @@ bool FeedbackNexus::FindHandlers(MaybeObjectHandles* code_list,
|
||||
|
||||
Name* FeedbackNexus::FindFirstName() const {
|
||||
if (IsKeyedStoreICKind(kind()) || IsKeyedLoadICKind(kind())) {
|
||||
MaybeObject* feedback = GetFeedback();
|
||||
MaybeObject feedback = GetFeedback();
|
||||
if (IsPropertyNameFeedback(feedback)) {
|
||||
return Name::cast(feedback->GetHeapObjectAssumeStrong());
|
||||
}
|
||||
@ -1114,7 +1114,7 @@ KeyedAccessStoreMode FeedbackNexus::GetKeyedAccessStoreMode() const {
|
||||
IcCheckType FeedbackNexus::GetKeyType() const {
|
||||
DCHECK(IsKeyedStoreICKind(kind()) || IsKeyedLoadICKind(kind()) ||
|
||||
IsStoreInArrayLiteralICKind(kind()));
|
||||
MaybeObject* feedback = GetFeedback();
|
||||
MaybeObject feedback = GetFeedback();
|
||||
if (feedback == MaybeObject::FromObject(
|
||||
*FeedbackVector::MegamorphicSentinel(GetIsolate()))) {
|
||||
return static_cast<IcCheckType>(
|
||||
@ -1150,7 +1150,7 @@ Handle<FeedbackCell> FeedbackNexus::GetFeedbackCell() const {
|
||||
MaybeHandle<JSObject> FeedbackNexus::GetConstructorFeedback() const {
|
||||
DCHECK_EQ(kind(), FeedbackSlotKind::kInstanceOf);
|
||||
Isolate* isolate = GetIsolate();
|
||||
MaybeObject* feedback = GetFeedback();
|
||||
MaybeObject feedback = GetFeedback();
|
||||
HeapObject* heap_object;
|
||||
if (feedback->GetHeapObjectIfWeak(&heap_object)) {
|
||||
return handle(JSObject::cast(heap_object), isolate);
|
||||
@ -1176,7 +1176,7 @@ void FeedbackNexus::Collect(Handle<String> type, int position) {
|
||||
DCHECK_GE(position, 0);
|
||||
Isolate* isolate = GetIsolate();
|
||||
|
||||
MaybeObject* const feedback = GetFeedback();
|
||||
MaybeObject const feedback = GetFeedback();
|
||||
|
||||
// Map source position to collection of types
|
||||
Handle<SimpleNumberDictionary> types;
|
||||
@ -1216,7 +1216,7 @@ std::vector<int> FeedbackNexus::GetSourcePositions() const {
|
||||
std::vector<int> source_positions;
|
||||
Isolate* isolate = GetIsolate();
|
||||
|
||||
MaybeObject* const feedback = GetFeedback();
|
||||
MaybeObject const feedback = GetFeedback();
|
||||
|
||||
if (feedback == MaybeObject::FromObject(
|
||||
*FeedbackVector::UninitializedSentinel(isolate))) {
|
||||
@ -1244,7 +1244,7 @@ std::vector<Handle<String>> FeedbackNexus::GetTypesForSourcePositions(
|
||||
DCHECK(IsTypeProfileKind(kind()));
|
||||
Isolate* isolate = GetIsolate();
|
||||
|
||||
MaybeObject* const feedback = GetFeedback();
|
||||
MaybeObject const feedback = GetFeedback();
|
||||
std::vector<Handle<String>> types_for_position;
|
||||
if (feedback == MaybeObject::FromObject(
|
||||
*FeedbackVector::UninitializedSentinel(isolate))) {
|
||||
@ -1304,7 +1304,7 @@ JSObject* FeedbackNexus::GetTypeProfile() const {
|
||||
DCHECK(IsTypeProfileKind(kind()));
|
||||
Isolate* isolate = GetIsolate();
|
||||
|
||||
MaybeObject* const feedback = GetFeedback();
|
||||
MaybeObject const feedback = GetFeedback();
|
||||
|
||||
if (feedback == MaybeObject::FromObject(
|
||||
*FeedbackVector::UninitializedSentinel(isolate))) {
|
||||
|
@ -163,7 +163,7 @@ class FeedbackVector : public HeapObject, public NeverReadOnlySpaceObject {
|
||||
|
||||
// [optimized_code_weak_or_smi]: weak reference to optimized code or a Smi
|
||||
// marker defining optimization behaviour.
|
||||
DECL_ACCESSORS(optimized_code_weak_or_smi, MaybeObject)
|
||||
DECL_ACCESSORS2(optimized_code_weak_or_smi, MaybeObject)
|
||||
|
||||
// [length]: The length of the feedback vector (not including the header, i.e.
|
||||
// the number of feedback slots).
|
||||
@ -201,11 +201,11 @@ class FeedbackVector : public HeapObject, public NeverReadOnlySpaceObject {
|
||||
|
||||
// Conversion from an integer index to the underlying array to a slot.
|
||||
static inline FeedbackSlot ToSlot(int index);
|
||||
inline MaybeObject* Get(FeedbackSlot slot) const;
|
||||
inline MaybeObject* get(int index) const;
|
||||
inline void Set(FeedbackSlot slot, MaybeObject* value,
|
||||
inline MaybeObject Get(FeedbackSlot slot) const;
|
||||
inline MaybeObject get(int index) const;
|
||||
inline void Set(FeedbackSlot slot, MaybeObject value,
|
||||
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
||||
inline void set(int index, MaybeObject* value,
|
||||
inline void set(int index, MaybeObject value,
|
||||
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
||||
inline void Set(FeedbackSlot slot, Object* value,
|
||||
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
||||
@ -248,7 +248,7 @@ class FeedbackVector : public HeapObject, public NeverReadOnlySpaceObject {
|
||||
return GetLanguageModeFromSlotKind(GetKind(slot));
|
||||
}
|
||||
|
||||
static void AssertNoLegacyTypes(MaybeObject* object);
|
||||
static void AssertNoLegacyTypes(MaybeObject object);
|
||||
|
||||
DECL_PRINTER(FeedbackVector)
|
||||
DECL_VERIFIER(FeedbackVector)
|
||||
@ -625,8 +625,8 @@ class FeedbackNexus final {
|
||||
bool ConfigureMegamorphic();
|
||||
bool ConfigureMegamorphic(IcCheckType property_type);
|
||||
|
||||
inline MaybeObject* GetFeedback() const;
|
||||
inline MaybeObject* GetFeedbackExtra() const;
|
||||
inline MaybeObject GetFeedback() const;
|
||||
inline MaybeObject GetFeedbackExtra() const;
|
||||
|
||||
inline Isolate* GetIsolate() const;
|
||||
|
||||
@ -703,11 +703,11 @@ class FeedbackNexus final {
|
||||
|
||||
inline void SetFeedback(Object* feedback,
|
||||
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
||||
inline void SetFeedback(MaybeObject* feedback,
|
||||
inline void SetFeedback(MaybeObject feedback,
|
||||
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
||||
inline void SetFeedbackExtra(Object* feedback_extra,
|
||||
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
||||
inline void SetFeedbackExtra(MaybeObject* feedback_extra,
|
||||
inline void SetFeedbackExtra(MaybeObject feedback_extra,
|
||||
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
||||
|
||||
Handle<WeakFixedArray> EnsureArrayOfSize(int length);
|
||||
|
@ -426,8 +426,8 @@ constexpr int kCodeAlignmentBits = 5;
|
||||
constexpr intptr_t kCodeAlignment = 1 << kCodeAlignmentBits;
|
||||
constexpr intptr_t kCodeAlignmentMask = kCodeAlignment - 1;
|
||||
|
||||
const intptr_t kWeakHeapObjectMask = 1 << 1;
|
||||
const intptr_t kClearedWeakHeapObject = 3;
|
||||
const Address kWeakHeapObjectMask = 1 << 1;
|
||||
const Address kClearedWeakHeapObject = 3;
|
||||
|
||||
// Zap-value: The value used for zapping dead objects.
|
||||
// Should be a recognizable hex value tagged as a failure.
|
||||
@ -782,10 +782,10 @@ constexpr int kIeeeDoubleExponentWordOffset = 0;
|
||||
// Testers for test.
|
||||
|
||||
#define HAS_SMI_TAG(value) \
|
||||
((reinterpret_cast<intptr_t>(value) & ::i::kSmiTagMask) == ::i::kSmiTag)
|
||||
((static_cast<intptr_t>(value) & ::i::kSmiTagMask) == ::i::kSmiTag)
|
||||
|
||||
#define HAS_HEAP_OBJECT_TAG(value) \
|
||||
(((reinterpret_cast<intptr_t>(value) & ::i::kHeapObjectTagMask) == \
|
||||
#define HAS_HEAP_OBJECT_TAG(value) \
|
||||
(((static_cast<intptr_t>(value) & ::i::kHeapObjectTagMask) == \
|
||||
::i::kHeapObjectTag))
|
||||
|
||||
// OBJECT_POINTER_ALIGN returns the value aligned as a HeapObject pointer
|
||||
@ -1533,8 +1533,9 @@ enum IsolateAddressId {
|
||||
kIsolateAddressCount
|
||||
};
|
||||
|
||||
V8_INLINE static bool HasWeakHeapObjectTag(const internal::MaybeObject* value) {
|
||||
return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
|
||||
V8_INLINE static bool HasWeakHeapObjectTag(Address value) {
|
||||
// TODO(jkummerow): Consolidate integer types here.
|
||||
return ((static_cast<intptr_t>(value) & kHeapObjectTagMask) ==
|
||||
kWeakHeapObjectTag);
|
||||
}
|
||||
|
||||
@ -1545,30 +1546,6 @@ V8_INLINE static bool HasWeakHeapObjectTag(const Object* value) {
|
||||
kWeakHeapObjectTag);
|
||||
}
|
||||
|
||||
V8_INLINE static bool HasWeakHeapObjectTag(const Address value) {
|
||||
return (value & kHeapObjectTagMask) == kWeakHeapObjectTag;
|
||||
}
|
||||
|
||||
V8_INLINE static bool IsClearedWeakHeapObject(const MaybeObject* value) {
|
||||
return reinterpret_cast<intptr_t>(value) == kClearedWeakHeapObject;
|
||||
}
|
||||
|
||||
V8_INLINE static HeapObject* RemoveWeakHeapObjectMask(
|
||||
HeapObjectReference* value) {
|
||||
return reinterpret_cast<HeapObject*>(reinterpret_cast<intptr_t>(value) &
|
||||
~kWeakHeapObjectMask);
|
||||
}
|
||||
|
||||
V8_INLINE static HeapObjectReference* AddWeakHeapObjectMask(Object* value) {
|
||||
return reinterpret_cast<HeapObjectReference*>(
|
||||
reinterpret_cast<intptr_t>(value) | kWeakHeapObjectMask);
|
||||
}
|
||||
|
||||
V8_INLINE static MaybeObject* AddWeakHeapObjectMask(MaybeObject* value) {
|
||||
return reinterpret_cast<MaybeObject*>(reinterpret_cast<intptr_t>(value) |
|
||||
kWeakHeapObjectMask);
|
||||
}
|
||||
|
||||
enum class HeapObjectReferenceType {
|
||||
WEAK,
|
||||
STRONG,
|
||||
|
@ -152,7 +152,7 @@ class ConcurrentMarkingVisitor final
|
||||
void VisitPointers(HeapObject* host, MaybeObjectSlot start,
|
||||
MaybeObjectSlot end) override {
|
||||
for (MaybeObjectSlot slot = start; slot < end; ++slot) {
|
||||
MaybeObject* object = slot.Relaxed_Load();
|
||||
MaybeObject object = slot.Relaxed_Load();
|
||||
HeapObject* heap_object;
|
||||
if (object->GetHeapObjectIfStrong(&heap_object)) {
|
||||
// If the reference changes concurrently from strong to weak, the write
|
||||
|
@ -3738,7 +3738,7 @@ Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<NativeContext> context,
|
||||
} else {
|
||||
// Check to see whether there is a matching element in the cache.
|
||||
Handle<WeakFixedArray> cache = Handle<WeakFixedArray>::cast(maybe_cache);
|
||||
MaybeObject* result = cache->Get(cache_index);
|
||||
MaybeObject result = cache->Get(cache_index);
|
||||
HeapObject* heap_object;
|
||||
if (result->GetHeapObjectIfWeak(&heap_object)) {
|
||||
Map* map = Map::cast(heap_object);
|
||||
|
@ -352,7 +352,7 @@ bool Heap::InNewSpace(Object* object) {
|
||||
}
|
||||
|
||||
// static
|
||||
bool Heap::InNewSpace(MaybeObject* object) {
|
||||
bool Heap::InNewSpace(MaybeObject object) {
|
||||
HeapObject* heap_object;
|
||||
return object->GetHeapObject(&heap_object) && InNewSpace(heap_object);
|
||||
}
|
||||
@ -395,7 +395,7 @@ bool Heap::InFromSpace(Object* object) {
|
||||
}
|
||||
|
||||
// static
|
||||
bool Heap::InFromSpace(MaybeObject* object) {
|
||||
bool Heap::InFromSpace(MaybeObject object) {
|
||||
HeapObject* heap_object;
|
||||
return object->GetHeapObject(&heap_object) && InFromSpace(heap_object);
|
||||
}
|
||||
@ -413,7 +413,7 @@ bool Heap::InToSpace(Object* object) {
|
||||
}
|
||||
|
||||
// static
|
||||
bool Heap::InToSpace(MaybeObject* object) {
|
||||
bool Heap::InToSpace(MaybeObject object) {
|
||||
HeapObject* heap_object;
|
||||
return object->GetHeapObject(&heap_object) && InToSpace(heap_object);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ inline void GenerationalBarrier(HeapObject* object, ObjectSlot slot,
|
||||
}
|
||||
|
||||
inline void GenerationalBarrier(HeapObject* object, MaybeObjectSlot slot,
|
||||
MaybeObject* value) {
|
||||
MaybeObject value) {
|
||||
HeapObject* value_heap_object;
|
||||
if (!value->GetHeapObject(&value_heap_object)) return;
|
||||
heap_internals::GenerationalBarrierInternal(object, slot.address(),
|
||||
@ -139,7 +139,7 @@ inline void MarkingBarrier(HeapObject* object, ObjectSlot slot, Object* value) {
|
||||
}
|
||||
|
||||
inline void MarkingBarrier(HeapObject* object, MaybeObjectSlot slot,
|
||||
MaybeObject* value) {
|
||||
MaybeObject value) {
|
||||
HeapObject* value_heap_object;
|
||||
if (!value->GetHeapObject(&value_heap_object)) return;
|
||||
heap_internals::MarkingBarrierInternal(object, slot.address(),
|
||||
|
@ -38,7 +38,7 @@ void WriteBarrierForCode(Code* host);
|
||||
// Generational write barrier.
|
||||
void GenerationalBarrier(HeapObject* object, ObjectSlot slot, Object* value);
|
||||
void GenerationalBarrier(HeapObject* object, MaybeObjectSlot slot,
|
||||
MaybeObject* value);
|
||||
MaybeObject value);
|
||||
// This takes a HeapObjectPtr* (as opposed to a plain HeapObjectPtr)
|
||||
// to keep the WRITE_BARRIER macro syntax-compatible to the HeapObject*
|
||||
// version above.
|
||||
@ -52,7 +52,7 @@ void GenerationalBarrierForCode(Code* host, RelocInfo* rinfo,
|
||||
// Marking write barrier.
|
||||
void MarkingBarrier(HeapObject* object, ObjectSlot slot, Object* value);
|
||||
void MarkingBarrier(HeapObject* object, MaybeObjectSlot slot,
|
||||
MaybeObject* value);
|
||||
MaybeObject value);
|
||||
// This takes a HeapObjectPtr* (as opposed to a plain HeapObjectPtr)
|
||||
// to keep the WRITE_BARRIER macro syntax-compatible to the HeapObject*
|
||||
// version above.
|
||||
|
@ -431,9 +431,9 @@ bool Heap::IsRetainingPathTarget(HeapObject* object,
|
||||
RetainingPathOption* option) {
|
||||
WeakArrayList* targets = retaining_path_targets();
|
||||
int length = targets->length();
|
||||
MaybeObject* object_to_check = HeapObjectReference::Weak(object);
|
||||
MaybeObject object_to_check = HeapObjectReference::Weak(object);
|
||||
for (int i = 0; i < length; i++) {
|
||||
MaybeObject* target = targets->Get(i);
|
||||
MaybeObject target = targets->Get(i);
|
||||
DCHECK(target->IsWeakOrCleared());
|
||||
if (target == object_to_check) {
|
||||
DCHECK(retaining_path_target_option_.count(i));
|
||||
@ -3518,8 +3518,7 @@ class SlotVerifyingVisitor : public ObjectVisitor {
|
||||
std::set<std::pair<SlotType, Address> >* typed)
|
||||
: untyped_(untyped), typed_(typed) {}
|
||||
|
||||
virtual bool ShouldHaveBeenRecorded(HeapObject* host,
|
||||
MaybeObject* target) = 0;
|
||||
virtual bool ShouldHaveBeenRecorded(HeapObject* host, MaybeObject target) = 0;
|
||||
|
||||
void VisitPointers(HeapObject* host, ObjectSlot start,
|
||||
ObjectSlot end) override {
|
||||
@ -3573,7 +3572,7 @@ class OldToNewSlotVerifyingVisitor : public SlotVerifyingVisitor {
|
||||
std::set<std::pair<SlotType, Address>>* typed)
|
||||
: SlotVerifyingVisitor(untyped, typed) {}
|
||||
|
||||
bool ShouldHaveBeenRecorded(HeapObject* host, MaybeObject* target) override {
|
||||
bool ShouldHaveBeenRecorded(HeapObject* host, MaybeObject target) override {
|
||||
DCHECK_IMPLIES(target->IsStrongOrWeak() && Heap::InNewSpace(target),
|
||||
Heap::InToSpace(target));
|
||||
return target->IsStrongOrWeak() && Heap::InNewSpace(target) &&
|
||||
@ -4734,7 +4733,7 @@ Handle<WeakArrayList> CompactWeakArrayList(Heap* heap,
|
||||
// fill in the new array.
|
||||
int copy_to = 0;
|
||||
for (int i = 0; i < array->length(); i++) {
|
||||
MaybeObject* element = array->Get(i);
|
||||
MaybeObject element = array->Get(i);
|
||||
if (element->IsCleared()) continue;
|
||||
new_array->Set(copy_to++, element);
|
||||
}
|
||||
@ -4808,14 +4807,14 @@ void Heap::CompactRetainedMaps(WeakArrayList* retained_maps) {
|
||||
int new_number_of_disposed_maps = 0;
|
||||
// This loop compacts the array by removing cleared weak cells.
|
||||
for (int i = 0; i < length; i += 2) {
|
||||
MaybeObject* maybe_object = retained_maps->Get(i);
|
||||
MaybeObject maybe_object = retained_maps->Get(i);
|
||||
if (maybe_object->IsCleared()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DCHECK(maybe_object->IsWeak());
|
||||
|
||||
MaybeObject* age = retained_maps->Get(i + 1);
|
||||
MaybeObject age = retained_maps->Get(i + 1);
|
||||
DCHECK(age->IsSmi());
|
||||
if (i != new_length) {
|
||||
retained_maps->Set(new_length, maybe_object);
|
||||
|
@ -903,14 +903,14 @@ class Heap {
|
||||
|
||||
// Returns whether the object resides in new space.
|
||||
static inline bool InNewSpace(Object* object);
|
||||
static inline bool InNewSpace(MaybeObject* object);
|
||||
static inline bool InNewSpace(MaybeObject object);
|
||||
static inline bool InNewSpace(HeapObject* heap_object);
|
||||
static inline bool InNewSpace(HeapObjectPtr heap_object);
|
||||
static inline bool InFromSpace(Object* object);
|
||||
static inline bool InFromSpace(MaybeObject* object);
|
||||
static inline bool InFromSpace(MaybeObject object);
|
||||
static inline bool InFromSpace(HeapObject* heap_object);
|
||||
static inline bool InToSpace(Object* object);
|
||||
static inline bool InToSpace(MaybeObject* object);
|
||||
static inline bool InToSpace(MaybeObject object);
|
||||
static inline bool InToSpace(HeapObject* heap_object);
|
||||
static inline bool InToSpace(HeapObjectPtr heap_object);
|
||||
|
||||
|
@ -44,7 +44,7 @@ void IncrementalMarking::RecordWrite(HeapObject* obj, ObjectSlot slot,
|
||||
|
||||
void IncrementalMarking::RecordMaybeWeakWrite(HeapObject* obj,
|
||||
MaybeObjectSlot slot,
|
||||
MaybeObject* value) {
|
||||
MaybeObject value) {
|
||||
// When writing a weak reference, treat it as strong for the purposes of the
|
||||
// marking barrier.
|
||||
HeapObject* heap_object;
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "src/heap/objects-visiting.h"
|
||||
#include "src/heap/sweeper.h"
|
||||
#include "src/objects/hash-table-inl.h"
|
||||
#include "src/objects/slots.h"
|
||||
#include "src/objects/slots-inl.h"
|
||||
#include "src/tracing/trace-event.h"
|
||||
#include "src/v8.h"
|
||||
#include "src/visitors.h"
|
||||
@ -496,7 +496,7 @@ void IncrementalMarking::RetainMaps() {
|
||||
// We do not age and retain disposed maps to avoid memory leaks.
|
||||
int number_of_disposed_maps = heap()->number_of_disposed_maps_;
|
||||
for (int i = 0; i < length; i += 2) {
|
||||
MaybeObject* value = retained_maps->Get(i);
|
||||
MaybeObject value = retained_maps->Get(i);
|
||||
HeapObject* map_heap_object;
|
||||
if (!value->GetHeapObjectIfWeak(&map_heap_object)) {
|
||||
continue;
|
||||
|
@ -193,7 +193,7 @@ class V8_EXPORT_PRIVATE IncrementalMarking {
|
||||
V8_INLINE bool BaseRecordWrite(HeapObject* obj, Object* value);
|
||||
V8_INLINE void RecordWrite(HeapObject* obj, ObjectSlot slot, Object* value);
|
||||
V8_INLINE void RecordMaybeWeakWrite(HeapObject* obj, MaybeObjectSlot slot,
|
||||
MaybeObject* value);
|
||||
MaybeObject value);
|
||||
void RevisitObject(HeapObject* obj);
|
||||
|
||||
void RecordWriteSlow(HeapObject* obj, HeapObjectSlot slot, Object* value);
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "src/heap/remembered-set.h"
|
||||
#include "src/objects/js-collection-inl.h"
|
||||
#include "src/objects/js-weak-refs-inl.h"
|
||||
#include "src/objects/slots.h"
|
||||
#include "src/objects/slots-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "src/ic/stub-cache.h"
|
||||
#include "src/objects/hash-table-inl.h"
|
||||
#include "src/objects/js-objects-inl.h"
|
||||
#include "src/objects/maybe-object.h"
|
||||
#include "src/objects/slots-inl.h"
|
||||
#include "src/transitions-inl.h"
|
||||
#include "src/utils-inl.h"
|
||||
@ -1042,7 +1043,7 @@ class RecordMigratedSlotVisitor : public ObjectVisitor {
|
||||
|
||||
inline void VisitPointer(HeapObject* host, ObjectSlot p) final {
|
||||
DCHECK(!HasWeakHeapObjectTag(*p));
|
||||
RecordMigratedSlot(host, reinterpret_cast<MaybeObject*>(*p), p.address());
|
||||
RecordMigratedSlot(host, MaybeObject::FromObject(*p), p.address());
|
||||
}
|
||||
|
||||
inline void VisitPointer(HeapObject* host, MaybeObjectSlot p) final {
|
||||
@ -1090,10 +1091,10 @@ class RecordMigratedSlotVisitor : public ObjectVisitor {
|
||||
inline void VisitInternalReference(Code* host, RelocInfo* rinfo) final {}
|
||||
|
||||
protected:
|
||||
inline virtual void RecordMigratedSlot(HeapObject* host, MaybeObject* value,
|
||||
inline virtual void RecordMigratedSlot(HeapObject* host, MaybeObject value,
|
||||
Address slot) {
|
||||
if (value->IsStrongOrWeak()) {
|
||||
Page* p = Page::FromAddress(reinterpret_cast<Address>(value));
|
||||
Page* p = Page::FromAddress(value.ptr());
|
||||
if (p->InNewSpace()) {
|
||||
DCHECK_IMPLIES(p->InToSpace(),
|
||||
p->IsFlagSet(Page::PAGE_NEW_NEW_PROMOTION));
|
||||
@ -1974,7 +1975,7 @@ bool MarkCompactCollector::CompactTransitionArray(
|
||||
transitions->SetKey(transition_index, key);
|
||||
HeapObjectSlot key_slot = transitions->GetKeySlot(transition_index);
|
||||
RecordSlot(transitions, key_slot, key);
|
||||
MaybeObject* raw_target = transitions->GetRawTarget(i);
|
||||
MaybeObject raw_target = transitions->GetRawTarget(i);
|
||||
transitions->SetRawTarget(transition_index, raw_target);
|
||||
HeapObjectSlot target_slot =
|
||||
transitions->GetTargetSlot(transition_index);
|
||||
@ -2147,6 +2148,10 @@ void MarkCompactCollector::AbortWeakObjects() {
|
||||
weak_objects_.js_weak_cells.Clear();
|
||||
}
|
||||
|
||||
bool MarkCompactCollector::IsOnEvacuationCandidate(MaybeObject obj) {
|
||||
return Page::FromAddress(obj.ptr())->IsEvacuationCandidate();
|
||||
}
|
||||
|
||||
void MarkCompactCollector::RecordRelocSlot(Code* host, RelocInfo* rinfo,
|
||||
Object* target) {
|
||||
Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target));
|
||||
@ -2173,7 +2178,7 @@ void MarkCompactCollector::RecordRelocSlot(Code* host, RelocInfo* rinfo,
|
||||
|
||||
template <AccessMode access_mode>
|
||||
static inline SlotCallbackResult UpdateSlot(
|
||||
MaybeObjectSlot slot, MaybeObject* old, HeapObject* heap_obj,
|
||||
MaybeObjectSlot slot, MaybeObject old, HeapObject* heap_obj,
|
||||
HeapObjectReferenceType reference_type) {
|
||||
MapWord map_word = heap_obj->map_word();
|
||||
if (map_word.IsForwardingAddress()) {
|
||||
@ -2181,7 +2186,7 @@ static inline SlotCallbackResult UpdateSlot(
|
||||
MarkCompactCollector::IsOnEvacuationCandidate(heap_obj) ||
|
||||
Page::FromAddress(heap_obj->address())
|
||||
->IsFlagSet(Page::COMPACTION_WAS_ABORTED));
|
||||
MaybeObject* target =
|
||||
MaybeObject target =
|
||||
reference_type == HeapObjectReferenceType::WEAK
|
||||
? HeapObjectReference::Weak(map_word.ToForwardingAddress())
|
||||
: HeapObjectReference::Strong(map_word.ToForwardingAddress());
|
||||
@ -2201,7 +2206,7 @@ static inline SlotCallbackResult UpdateSlot(
|
||||
|
||||
template <AccessMode access_mode>
|
||||
static inline SlotCallbackResult UpdateSlot(MaybeObjectSlot slot) {
|
||||
MaybeObject* obj = slot.Relaxed_Load();
|
||||
MaybeObject obj = slot.Relaxed_Load();
|
||||
HeapObject* heap_obj;
|
||||
if (obj->GetHeapObjectIfWeak(&heap_obj)) {
|
||||
UpdateSlot<access_mode>(slot, obj, heap_obj, HeapObjectReferenceType::WEAK);
|
||||
@ -3615,7 +3620,7 @@ class YoungGenerationMarkingVisitor final
|
||||
}
|
||||
|
||||
V8_INLINE void VisitPointer(HeapObject* host, MaybeObjectSlot slot) final {
|
||||
MaybeObject* target = *slot;
|
||||
MaybeObject target = *slot;
|
||||
if (Heap::InNewSpace(target)) {
|
||||
HeapObject* target_object;
|
||||
// Treat weak references as strong. TODO(marja): Proper weakness handling
|
||||
@ -3722,10 +3727,10 @@ class YoungGenerationRecordMigratedSlotVisitor final
|
||||
return collector_->non_atomic_marking_state()->IsBlack(object);
|
||||
}
|
||||
|
||||
inline void RecordMigratedSlot(HeapObject* host, MaybeObject* value,
|
||||
inline void RecordMigratedSlot(HeapObject* host, MaybeObject value,
|
||||
Address slot) final {
|
||||
if (value->IsStrongOrWeak()) {
|
||||
Page* p = Page::FromAddress(reinterpret_cast<Address>(value));
|
||||
Page* p = Page::FromAddress(value.ptr());
|
||||
if (p->InNewSpace()) {
|
||||
DCHECK_IMPLIES(p->InToSpace(),
|
||||
p->IsFlagSet(Page::PAGE_NEW_NEW_PROMOTION));
|
||||
@ -4173,7 +4178,7 @@ class PageMarkingItem : public MarkingItem {
|
||||
|
||||
SlotCallbackResult CheckAndMarkObject(YoungGenerationMarkingTask* task,
|
||||
MaybeObjectSlot slot) {
|
||||
MaybeObject* object = *slot;
|
||||
MaybeObject object = *slot;
|
||||
if (Heap::InNewSpace(object)) {
|
||||
// Marking happens before flipping the young generation, so the object
|
||||
// has to be in ToSpace.
|
||||
|
@ -622,10 +622,7 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
|
||||
->IsEvacuationCandidate();
|
||||
}
|
||||
|
||||
static inline bool IsOnEvacuationCandidate(MaybeObject* obj) {
|
||||
return Page::FromAddress(reinterpret_cast<Address>(obj))
|
||||
->IsEvacuationCandidate();
|
||||
}
|
||||
static bool IsOnEvacuationCandidate(MaybeObject obj);
|
||||
|
||||
void RecordRelocSlot(Code* host, RelocInfo* rinfo, Object* target);
|
||||
V8_INLINE static void RecordSlot(HeapObject* object, ObjectSlot slot,
|
||||
|
@ -548,7 +548,7 @@ void ObjectStatsCollectorImpl::RecordVirtualJSObjectDetails(JSObject* object) {
|
||||
}
|
||||
|
||||
static ObjectStats::VirtualInstanceType GetFeedbackSlotType(
|
||||
MaybeObject* maybe_obj, FeedbackSlotKind kind, Isolate* isolate) {
|
||||
MaybeObject maybe_obj, FeedbackSlotKind kind, Isolate* isolate) {
|
||||
if (maybe_obj->IsCleared())
|
||||
return ObjectStats::FEEDBACK_VECTOR_SLOT_OTHER_TYPE;
|
||||
Object* obj = maybe_obj->GetHeapObjectOrSmi();
|
||||
@ -623,7 +623,7 @@ void ObjectStatsCollectorImpl::RecordVirtualFeedbackVectorDetails(
|
||||
|
||||
// Log the monomorphic/polymorphic helper objects that this slot owns.
|
||||
for (int i = 0; i < it.entry_size(); i++) {
|
||||
MaybeObject* raw_object = vector->get(slot.ToInt() + i);
|
||||
MaybeObject raw_object = vector->get(slot.ToInt() + i);
|
||||
HeapObject* object;
|
||||
if (raw_object->GetHeapObject(&object)) {
|
||||
if (object->IsCell() || object->IsWeakFixedArray()) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "src/heap/local-allocator-inl.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/objects/map.h"
|
||||
#include "src/objects/slots.h"
|
||||
#include "src/objects/slots-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -110,7 +110,7 @@ bool Scavenger::ContainsOnlyData(VisitorId visitor_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Scavenger::PageMemoryFence(MaybeObject* object) {
|
||||
void Scavenger::PageMemoryFence(MaybeObject object) {
|
||||
#ifdef THREAD_SANITIZER
|
||||
// Perform a dummy acquire load to tell TSAN that there is no data race
|
||||
// with page initialization.
|
||||
@ -390,7 +390,7 @@ SlotCallbackResult Scavenger::ScavengeObject(HeapObjectSlot p,
|
||||
|
||||
SlotCallbackResult Scavenger::CheckAndScavengeObject(Heap* heap,
|
||||
MaybeObjectSlot slot) {
|
||||
MaybeObject* object = *slot;
|
||||
MaybeObject object = *slot;
|
||||
if (Heap::InFromSpace(object)) {
|
||||
HeapObject* heap_object = object->GetHeapObject();
|
||||
DCHECK(heap_object->IsHeapObject());
|
||||
@ -422,7 +422,7 @@ void ScavengeVisitor::VisitPointers(HeapObject* host, ObjectSlot start,
|
||||
void ScavengeVisitor::VisitPointers(HeapObject* host, MaybeObjectSlot start,
|
||||
MaybeObjectSlot end) {
|
||||
for (MaybeObjectSlot p = start; p < end; ++p) {
|
||||
MaybeObject* object = *p;
|
||||
MaybeObject object = *p;
|
||||
if (!Heap::InNewSpace(object)) continue;
|
||||
// Treat the weak reference as strong.
|
||||
HeapObject* heap_object;
|
||||
|
@ -92,7 +92,7 @@ class IterateAndScavengePromotedObjectsVisitor final : public ObjectVisitor {
|
||||
// Treat weak references as strong. TODO(marja): Proper weakness handling in
|
||||
// the young generation.
|
||||
for (MaybeObjectSlot slot = start; slot < end; ++slot) {
|
||||
MaybeObject* target = *slot;
|
||||
MaybeObject target = *slot;
|
||||
HeapObject* heap_object;
|
||||
if (target->GetHeapObject(&heap_object)) {
|
||||
HandleSlot(host, HeapObjectSlot(slot), heap_object);
|
||||
@ -102,7 +102,7 @@ class IterateAndScavengePromotedObjectsVisitor final : public ObjectVisitor {
|
||||
|
||||
inline void HandleSlot(HeapObject* host, HeapObjectSlot slot,
|
||||
HeapObject* target) {
|
||||
scavenger_->PageMemoryFence(reinterpret_cast<MaybeObject*>(target));
|
||||
scavenger_->PageMemoryFence(MaybeObject::FromObject(target));
|
||||
|
||||
if (Heap::InFromSpace(target)) {
|
||||
SlotCallbackResult result = scavenger_->ScavengeObject(slot, target);
|
||||
|
@ -134,7 +134,7 @@ class Scavenger {
|
||||
|
||||
inline Heap* heap() { return heap_; }
|
||||
|
||||
inline void PageMemoryFence(MaybeObject* object);
|
||||
inline void PageMemoryFence(MaybeObject object);
|
||||
|
||||
void AddPageToSweeperIfNecessary(MemoryChunk* page);
|
||||
|
||||
|
@ -165,7 +165,7 @@ Handle<Object> LoadHandler::LoadFullChain(Isolate* isolate,
|
||||
}
|
||||
|
||||
// static
|
||||
KeyedAccessLoadMode LoadHandler::GetKeyedAccessLoadMode(MaybeObject* handler) {
|
||||
KeyedAccessLoadMode LoadHandler::GetKeyedAccessLoadMode(MaybeObject handler) {
|
||||
DisallowHeapAllocation no_gc;
|
||||
if (handler->IsSmi()) {
|
||||
int const raw_handler = handler->cast<Smi>()->value();
|
||||
|
@ -178,7 +178,7 @@ class LoadHandler final : public DataHandler {
|
||||
KeyedAccessLoadMode load_mode);
|
||||
|
||||
// Decodes the KeyedAccessLoadMode from a {handler}.
|
||||
static KeyedAccessLoadMode GetKeyedAccessLoadMode(MaybeObject* handler);
|
||||
static KeyedAccessLoadMode GetKeyedAccessLoadMode(MaybeObject handler);
|
||||
};
|
||||
|
||||
// A set of bit fields representing Smi handlers for stores and a HeapObject
|
||||
|
@ -47,9 +47,9 @@ void IC::update_receiver_map(Handle<Object> receiver) {
|
||||
}
|
||||
}
|
||||
|
||||
bool IC::IsHandler(MaybeObject* object) {
|
||||
bool IC::IsHandler(MaybeObject object) {
|
||||
HeapObject* heap_object;
|
||||
return (object->IsSmi() && (object != nullptr)) ||
|
||||
return (object->IsSmi() && (object.ptr() != kNullAddress)) ||
|
||||
(object->GetHeapObjectIfWeak(&heap_object) &&
|
||||
(heap_object->IsMap() || heap_object->IsPropertyCell())) ||
|
||||
(object->GetHeapObjectIfStrong(&heap_object) &&
|
||||
|
@ -58,7 +58,7 @@ class IC {
|
||||
IsKeyedStoreIC() || IsStoreInArrayLiteralICKind(kind());
|
||||
}
|
||||
|
||||
static inline bool IsHandler(MaybeObject* object);
|
||||
static inline bool IsHandler(MaybeObject object);
|
||||
|
||||
// Nofity the IC system that a feedback has changed.
|
||||
static void OnFeedbackChanged(Isolate* isolate, FeedbackVector* vector,
|
||||
|
@ -16,7 +16,7 @@ namespace internal {
|
||||
StubCache::StubCache(Isolate* isolate) : isolate_(isolate) {
|
||||
// Ensure the nullptr (aka Smi::kZero) which StubCache::Get() returns
|
||||
// when the entry is not found is not considered as a handler.
|
||||
DCHECK(!IC::IsHandler(nullptr));
|
||||
DCHECK(!IC::IsHandler(MaybeObject()));
|
||||
}
|
||||
|
||||
void StubCache::Initialize() {
|
||||
@ -58,27 +58,27 @@ int StubCache::SecondaryOffset(Name* name, int seed) {
|
||||
namespace {
|
||||
|
||||
bool CommonStubCacheChecks(StubCache* stub_cache, Name* name, Map* map,
|
||||
MaybeObject* handler) {
|
||||
MaybeObject handler) {
|
||||
// Validate that the name and handler do not move on scavenge, and that we
|
||||
// can use identity checks instead of structural equality checks.
|
||||
DCHECK(!Heap::InNewSpace(name));
|
||||
DCHECK(!Heap::InNewSpace(handler));
|
||||
DCHECK(name->IsUniqueName());
|
||||
DCHECK(name->HasHashCode());
|
||||
if (handler) DCHECK(IC::IsHandler(handler));
|
||||
if (handler->ptr() != kNullAddress) DCHECK(IC::IsHandler(handler));
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
MaybeObject* StubCache::Set(Name* name, Map* map, MaybeObject* handler) {
|
||||
void StubCache::Set(Name* name, Map* map, MaybeObject handler) {
|
||||
DCHECK(CommonStubCacheChecks(this, name, map, handler));
|
||||
|
||||
// Compute the primary entry.
|
||||
int primary_offset = PrimaryOffset(name, map);
|
||||
Entry* primary = entry(primary_, primary_offset);
|
||||
MaybeObject* old_handler = primary->value;
|
||||
MaybeObject old_handler(primary->value);
|
||||
|
||||
// If the primary entry has useful data in it, we retire it to the
|
||||
// secondary cache before overwriting it.
|
||||
@ -93,41 +93,40 @@ MaybeObject* StubCache::Set(Name* name, Map* map, MaybeObject* handler) {
|
||||
|
||||
// Update primary cache.
|
||||
primary->key = name;
|
||||
primary->value = handler;
|
||||
primary->value = handler.ptr();
|
||||
primary->map = map;
|
||||
isolate()->counters()->megamorphic_stub_cache_updates()->Increment();
|
||||
return handler;
|
||||
}
|
||||
|
||||
MaybeObject* StubCache::Get(Name* name, Map* map) {
|
||||
DCHECK(CommonStubCacheChecks(this, name, map, nullptr));
|
||||
MaybeObject StubCache::Get(Name* name, Map* map) {
|
||||
DCHECK(CommonStubCacheChecks(this, name, map, MaybeObject()));
|
||||
int primary_offset = PrimaryOffset(name, map);
|
||||
Entry* primary = entry(primary_, primary_offset);
|
||||
if (primary->key == name && primary->map == map) {
|
||||
return primary->value;
|
||||
return MaybeObject(primary->value);
|
||||
}
|
||||
int secondary_offset = SecondaryOffset(name, primary_offset);
|
||||
Entry* secondary = entry(secondary_, secondary_offset);
|
||||
if (secondary->key == name && secondary->map == map) {
|
||||
return secondary->value;
|
||||
return MaybeObject(secondary->value);
|
||||
}
|
||||
return nullptr;
|
||||
return MaybeObject();
|
||||
}
|
||||
|
||||
|
||||
void StubCache::Clear() {
|
||||
MaybeObject* empty = MaybeObject::FromObject(
|
||||
MaybeObject empty = MaybeObject::FromObject(
|
||||
isolate_->builtins()->builtin(Builtins::kIllegal));
|
||||
Name* empty_string = ReadOnlyRoots(isolate()).empty_string();
|
||||
for (int i = 0; i < kPrimaryTableSize; i++) {
|
||||
primary_[i].key = empty_string;
|
||||
primary_[i].map = nullptr;
|
||||
primary_[i].value = empty;
|
||||
primary_[i].value = empty.ptr();
|
||||
}
|
||||
for (int j = 0; j < kSecondaryTableSize; j++) {
|
||||
secondary_[j].key = empty_string;
|
||||
secondary_[j].map = nullptr;
|
||||
secondary_[j].value = empty;
|
||||
secondary_[j].value = empty.ptr();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,14 +33,18 @@ class StubCache {
|
||||
public:
|
||||
struct Entry {
|
||||
Name* key;
|
||||
MaybeObject* value;
|
||||
// {value} is a tagged heap object reference (weak or strong), equivalent
|
||||
// to a MaybeObject's payload. It has a plain Address type because it is
|
||||
// read directly from generated code. As a nice side effect, this keeps
|
||||
// #includes lightweight.
|
||||
Address value;
|
||||
Map* map;
|
||||
};
|
||||
|
||||
void Initialize();
|
||||
// Access cache for entry hash(name, map).
|
||||
MaybeObject* Set(Name* name, Map* map, MaybeObject* handler);
|
||||
MaybeObject* Get(Name* name, Map* map);
|
||||
void Set(Name* name, Map* map, MaybeObject handler);
|
||||
MaybeObject Get(Name* name, Map* map);
|
||||
// Clear the lookup table (@ mark compact collection).
|
||||
void Clear();
|
||||
|
||||
|
@ -4269,7 +4269,7 @@ void Isolate::CheckDetachedContextsAfterGC() {
|
||||
int new_length = 0;
|
||||
for (int i = 0; i < length; i += 2) {
|
||||
int mark_sweeps = Smi::ToInt(detached_contexts->Get(i)->cast<Smi>());
|
||||
MaybeObject* context = detached_contexts->Get(i + 1);
|
||||
MaybeObject context = detached_contexts->Get(i + 1);
|
||||
DCHECK(context->IsWeakOrCleared());
|
||||
if (!context->IsCleared()) {
|
||||
detached_contexts->Set(
|
||||
@ -4289,11 +4289,11 @@ void Isolate::CheckDetachedContextsAfterGC() {
|
||||
length - new_length, length);
|
||||
for (int i = 0; i < new_length; i += 2) {
|
||||
int mark_sweeps = Smi::ToInt(detached_contexts->Get(i)->cast<Smi>());
|
||||
MaybeObject* context = detached_contexts->Get(i + 1);
|
||||
MaybeObject context = detached_contexts->Get(i + 1);
|
||||
DCHECK(context->IsWeakOrCleared());
|
||||
if (mark_sweeps > 3) {
|
||||
PrintF("detached context %p\n survived %d GCs (leak?)\n",
|
||||
static_cast<void*>(context), mark_sweeps);
|
||||
reinterpret_cast<void*>(context.ptr()), mark_sweeps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ MaybeObjectHandle::MaybeObjectHandle()
|
||||
: reference_type_(HeapObjectReferenceType::STRONG),
|
||||
handle_(Handle<Object>::null()) {}
|
||||
|
||||
MaybeObjectHandle::MaybeObjectHandle(MaybeObject* object, Isolate* isolate) {
|
||||
MaybeObjectHandle::MaybeObjectHandle(MaybeObject object, Isolate* isolate) {
|
||||
HeapObject* heap_object;
|
||||
DCHECK(!object->IsCleared());
|
||||
if (object->GetHeapObjectIfWeak(&heap_object)) {
|
||||
@ -56,7 +56,7 @@ MaybeObjectHandle MaybeObjectHandle::Weak(Object* object, Isolate* isolate) {
|
||||
return MaybeObjectHandle(object, HeapObjectReferenceType::WEAK, isolate);
|
||||
}
|
||||
|
||||
MaybeObject* MaybeObjectHandle::operator*() const {
|
||||
MaybeObject MaybeObjectHandle::operator*() const {
|
||||
if (reference_type_ == HeapObjectReferenceType::WEAK) {
|
||||
return HeapObjectReference::Weak(*handle_.ToHandleChecked());
|
||||
} else {
|
||||
@ -64,7 +64,7 @@ MaybeObject* MaybeObjectHandle::operator*() const {
|
||||
}
|
||||
}
|
||||
|
||||
MaybeObject* MaybeObjectHandle::operator->() const {
|
||||
MaybeObject MaybeObjectHandle::operator->() const {
|
||||
if (reference_type_ == HeapObjectReferenceType::WEAK) {
|
||||
return HeapObjectReference::Weak(*handle_.ToHandleChecked());
|
||||
} else {
|
||||
@ -76,7 +76,7 @@ Handle<Object> MaybeObjectHandle::object() const {
|
||||
return handle_.ToHandleChecked();
|
||||
}
|
||||
|
||||
inline MaybeObjectHandle handle(MaybeObject* object, Isolate* isolate) {
|
||||
inline MaybeObjectHandle handle(MaybeObject object, Isolate* isolate) {
|
||||
return MaybeObjectHandle(object, isolate);
|
||||
}
|
||||
|
||||
|
@ -81,15 +81,15 @@ class MaybeHandle final {
|
||||
class MaybeObjectHandle {
|
||||
public:
|
||||
inline MaybeObjectHandle();
|
||||
inline MaybeObjectHandle(MaybeObject* object, Isolate* isolate);
|
||||
inline MaybeObjectHandle(MaybeObject object, Isolate* isolate);
|
||||
inline MaybeObjectHandle(Object* object, Isolate* isolate);
|
||||
inline explicit MaybeObjectHandle(Handle<Object> object);
|
||||
|
||||
static inline MaybeObjectHandle Weak(Object* object, Isolate* isolate);
|
||||
static inline MaybeObjectHandle Weak(Handle<Object> object);
|
||||
|
||||
inline MaybeObject* operator*() const;
|
||||
inline MaybeObject* operator->() const;
|
||||
inline MaybeObject operator*() const;
|
||||
inline MaybeObject operator->() const;
|
||||
inline Handle<Object> object() const;
|
||||
|
||||
bool is_identical_to(const MaybeObjectHandle& other) const {
|
||||
|
@ -98,7 +98,7 @@ void Object::VerifyPointer(Isolate* isolate, Object* p) {
|
||||
}
|
||||
}
|
||||
|
||||
void MaybeObject::VerifyMaybeObjectPointer(Isolate* isolate, MaybeObject* p) {
|
||||
void MaybeObject::VerifyMaybeObjectPointer(Isolate* isolate, MaybeObject p) {
|
||||
HeapObject* heap_object;
|
||||
if (p->GetHeapObject(&heap_object)) {
|
||||
HeapObject::VerifyHeapPointer(isolate, heap_object);
|
||||
@ -472,7 +472,7 @@ void FeedbackCell::FeedbackCellVerify(Isolate* isolate) {
|
||||
|
||||
void FeedbackVector::FeedbackVectorVerify(Isolate* isolate) {
|
||||
CHECK(IsFeedbackVector());
|
||||
MaybeObject* code = optimized_code_weak_or_smi();
|
||||
MaybeObject code = optimized_code_weak_or_smi();
|
||||
MaybeObject::VerifyMaybeObjectPointer(isolate, code);
|
||||
CHECK(code->IsSmi() || code->IsWeakOrCleared());
|
||||
}
|
||||
@ -750,7 +750,7 @@ void DescriptorArray::DescriptorArrayVerify(Isolate* isolate) {
|
||||
if (Name::cast(key)->IsPrivate()) {
|
||||
CHECK_NE(details.attributes() & DONT_ENUM, 0);
|
||||
}
|
||||
MaybeObject* value = get(ToValueIndex(descriptor));
|
||||
MaybeObject value = get(ToValueIndex(descriptor));
|
||||
HeapObject* heap_object;
|
||||
if (details.location() == kField) {
|
||||
CHECK(
|
||||
@ -1669,7 +1669,7 @@ void PrototypeUsers::Verify(WeakArrayList* array) {
|
||||
int weak_maps_count = 0;
|
||||
for (int i = kFirstIndex; i < array->length(); ++i) {
|
||||
HeapObject* heap_object;
|
||||
MaybeObject* object = array->Get(i);
|
||||
MaybeObject object = array->Get(i);
|
||||
if ((object->GetHeapObjectIfWeak(&heap_object) && heap_object->IsMap()) ||
|
||||
object->IsCleared()) {
|
||||
++weak_maps_count;
|
||||
@ -1883,7 +1883,7 @@ void Script::ScriptVerify(Isolate* isolate) {
|
||||
VerifyPointer(isolate, name());
|
||||
VerifyPointer(isolate, line_ends());
|
||||
for (int i = 0; i < shared_function_infos()->length(); ++i) {
|
||||
MaybeObject* maybe_object = shared_function_infos()->Get(i);
|
||||
MaybeObject maybe_object = shared_function_infos()->Get(i);
|
||||
HeapObject* heap_object;
|
||||
CHECK(maybe_object->IsWeak() || maybe_object->IsCleared() ||
|
||||
(maybe_object->GetHeapObjectIfStrong(&heap_object) &&
|
||||
@ -1895,7 +1895,7 @@ void NormalizedMapCache::NormalizedMapCacheVerify(Isolate* isolate) {
|
||||
WeakFixedArray::cast(this)->WeakFixedArrayVerify(isolate);
|
||||
if (FLAG_enable_slow_asserts) {
|
||||
for (int i = 0; i < length(); i++) {
|
||||
MaybeObject* e = WeakFixedArray::Get(i);
|
||||
MaybeObject e = WeakFixedArray::Get(i);
|
||||
HeapObject* heap_object;
|
||||
if (e->GetHeapObjectIfWeak(&heap_object)) {
|
||||
Map::cast(heap_object)->DictionaryMapVerify(isolate);
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "src/objects/maybe-object-inl.h"
|
||||
#include "src/objects/regexp-match-info.h"
|
||||
#include "src/objects/scope-info.h"
|
||||
#include "src/objects/slots.h"
|
||||
#include "src/objects/slots-inl.h"
|
||||
#include "src/objects/template-objects.h"
|
||||
#include "src/objects/templates.h"
|
||||
#include "src/property-details.h"
|
||||
@ -749,10 +749,7 @@ MapWord MapWord::FromMap(const Map* map) {
|
||||
|
||||
Map* MapWord::ToMap() const { return reinterpret_cast<Map*>(value_); }
|
||||
|
||||
bool MapWord::IsForwardingAddress() const {
|
||||
return HAS_SMI_TAG(reinterpret_cast<Object*>(value_));
|
||||
}
|
||||
|
||||
bool MapWord::IsForwardingAddress() const { return HAS_SMI_TAG(value_); }
|
||||
|
||||
MapWord MapWord::FromForwardingAddress(HeapObject* object) {
|
||||
Address raw = reinterpret_cast<Address>(object) - kHeapObjectTag;
|
||||
@ -1321,14 +1318,14 @@ void DescriptorArray::SetValue(int descriptor_index, Object* value) {
|
||||
set(ToValueIndex(descriptor_index), MaybeObject::FromObject(value));
|
||||
}
|
||||
|
||||
MaybeObject* DescriptorArray::GetValue(int descriptor_number) {
|
||||
MaybeObject DescriptorArray::GetValue(int descriptor_number) {
|
||||
DCHECK_LT(descriptor_number, number_of_descriptors());
|
||||
return get(ToValueIndex(descriptor_number));
|
||||
}
|
||||
|
||||
PropertyDetails DescriptorArray::GetDetails(int descriptor_number) {
|
||||
DCHECK(descriptor_number < number_of_descriptors());
|
||||
MaybeObject* details = get(ToDetailsIndex(descriptor_number));
|
||||
MaybeObject details = get(ToDetailsIndex(descriptor_number));
|
||||
return PropertyDetails(details->cast<Smi>());
|
||||
}
|
||||
|
||||
@ -1339,11 +1336,11 @@ int DescriptorArray::GetFieldIndex(int descriptor_number) {
|
||||
|
||||
FieldType* DescriptorArray::GetFieldType(int descriptor_number) {
|
||||
DCHECK_EQ(GetDetails(descriptor_number).location(), kField);
|
||||
MaybeObject* wrapped_type = GetValue(descriptor_number);
|
||||
MaybeObject wrapped_type = GetValue(descriptor_number);
|
||||
return Map::UnwrapFieldType(wrapped_type);
|
||||
}
|
||||
|
||||
void DescriptorArray::Set(int descriptor_number, Name* key, MaybeObject* value,
|
||||
void DescriptorArray::Set(int descriptor_number, Name* key, MaybeObject value,
|
||||
PropertyDetails details) {
|
||||
// Range check.
|
||||
DCHECK(descriptor_number < number_of_descriptors());
|
||||
@ -1355,7 +1352,7 @@ void DescriptorArray::Set(int descriptor_number, Name* key, MaybeObject* value,
|
||||
|
||||
void DescriptorArray::Set(int descriptor_number, Descriptor* desc) {
|
||||
Name* key = *desc->GetKey();
|
||||
MaybeObject* value = *desc->GetValue();
|
||||
MaybeObject value = *desc->GetValue();
|
||||
Set(descriptor_number, key, value, desc->GetDetails());
|
||||
}
|
||||
|
||||
@ -1386,11 +1383,11 @@ void DescriptorArray::SwapSortedKeys(int first, int second) {
|
||||
SetSortedKey(second, first_key);
|
||||
}
|
||||
|
||||
MaybeObject* DescriptorArray::get(int index) const {
|
||||
MaybeObject DescriptorArray::get(int index) const {
|
||||
return WeakFixedArray::Get(index);
|
||||
}
|
||||
|
||||
void DescriptorArray::set(int index, MaybeObject* value) {
|
||||
void DescriptorArray::set(int index, MaybeObject value) {
|
||||
WeakFixedArray::Set(index, value);
|
||||
}
|
||||
|
||||
|
@ -947,8 +947,9 @@ void PrintHashTableWithHeader(std::ostream& os, T* table, const char* type) {
|
||||
template <typename T>
|
||||
void PrintWeakArrayElements(std::ostream& os, T* array) {
|
||||
// Print in array notation for non-sparse arrays.
|
||||
MaybeObject* previous_value = array->length() > 0 ? array->Get(0) : nullptr;
|
||||
MaybeObject* value = nullptr;
|
||||
MaybeObject previous_value =
|
||||
array->length() > 0 ? array->Get(0) : MaybeObject(kNullAddress);
|
||||
MaybeObject value;
|
||||
int previous_index = 0;
|
||||
int i;
|
||||
for (i = 1; i <= array->length(); i++) {
|
||||
|
@ -2550,23 +2550,22 @@ void Object::ShortPrint(std::ostream& os) { os << Brief(this); }
|
||||
|
||||
void MaybeObject::ShortPrint(FILE* out) {
|
||||
OFStream os(out);
|
||||
os << Brief(this);
|
||||
os << Brief(*this);
|
||||
}
|
||||
|
||||
void MaybeObject::ShortPrint(StringStream* accumulator) {
|
||||
std::ostringstream os;
|
||||
os << Brief(this);
|
||||
os << Brief(*this);
|
||||
accumulator->Add(os.str().c_str());
|
||||
}
|
||||
|
||||
void MaybeObject::ShortPrint(std::ostream& os) { os << Brief(this); }
|
||||
void MaybeObject::ShortPrint(std::ostream& os) { os << Brief(*this); }
|
||||
|
||||
Brief::Brief(const Object* v)
|
||||
: value(MaybeObject::FromObject(const_cast<Object*>(v))) {}
|
||||
Brief::Brief(const Object* v) : value(reinterpret_cast<Address>(v)) {}
|
||||
Brief::Brief(const MaybeObject v) : value(v.ptr()) {}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Brief& v) {
|
||||
// TODO(marja): const-correct HeapObjectShortPrint.
|
||||
MaybeObject* maybe_object = const_cast<MaybeObject*>(v.value);
|
||||
MaybeObject maybe_object(v.value);
|
||||
Smi* smi;
|
||||
HeapObject* heap_object;
|
||||
if (maybe_object->ToSmi(&smi)) {
|
||||
@ -3987,7 +3986,7 @@ MaybeObjectHandle Map::WrapFieldType(Isolate* isolate, Handle<FieldType> type) {
|
||||
}
|
||||
|
||||
// static
|
||||
FieldType* Map::UnwrapFieldType(MaybeObject* wrapped_type) {
|
||||
FieldType* Map::UnwrapFieldType(MaybeObject wrapped_type) {
|
||||
if (wrapped_type->IsCleared()) {
|
||||
return FieldType::None();
|
||||
}
|
||||
@ -6458,7 +6457,7 @@ Handle<NormalizedMapCache> NormalizedMapCache::New(Isolate* isolate) {
|
||||
MaybeHandle<Map> NormalizedMapCache::Get(Handle<Map> fast_map,
|
||||
PropertyNormalizationMode mode) {
|
||||
DisallowHeapAllocation no_gc;
|
||||
MaybeObject* value = WeakFixedArray::Get(GetIndex(fast_map));
|
||||
MaybeObject value = WeakFixedArray::Get(GetIndex(fast_map));
|
||||
HeapObject* heap_object;
|
||||
if (!value->GetHeapObjectIfWeak(&heap_object)) {
|
||||
return MaybeHandle<Map>();
|
||||
@ -10137,7 +10136,7 @@ Handle<DescriptorArray> DescriptorArray::CopyUpToAddAttributes(
|
||||
|
||||
if (attributes != NONE) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
MaybeObject* value_or_field_type = desc->GetValue(i);
|
||||
MaybeObject value_or_field_type = desc->GetValue(i);
|
||||
Name* key = desc->GetKey(i);
|
||||
PropertyDetails details = desc->GetDetails(i);
|
||||
// Bulk attribute changes never affect private properties.
|
||||
@ -10194,7 +10193,7 @@ Handle<DescriptorArray> DescriptorArray::CopyForFastObjectClone(
|
||||
details.field_index());
|
||||
// Do not propagate the field type of normal object fields from the
|
||||
// original descriptors since FieldType changes don't create new maps.
|
||||
MaybeObject* type = src->GetValue(i);
|
||||
MaybeObject type = src->GetValue(i);
|
||||
if (details.location() == PropertyLocation::kField) {
|
||||
type = MaybeObject::FromObject(FieldType::Any());
|
||||
}
|
||||
@ -10535,7 +10534,7 @@ WeakArrayList* PrototypeUsers::Compact(Handle<WeakArrayList> array, Heap* heap,
|
||||
// cleared weak heap objects. Count the number of live objects again.
|
||||
int copy_to = kFirstIndex;
|
||||
for (int i = kFirstIndex; i < array->length(); i++) {
|
||||
MaybeObject* element = array->Get(i);
|
||||
MaybeObject element = array->Get(i);
|
||||
HeapObject* value;
|
||||
if (element->GetHeapObjectIfWeak(&value)) {
|
||||
callback(value, i, copy_to);
|
||||
@ -13723,8 +13722,7 @@ MaybeHandle<SharedFunctionInfo> Script::FindSharedFunctionInfo(
|
||||
// AstTraversalVisitor doesn't recurse properly in the construct which
|
||||
// triggers the mismatch.
|
||||
CHECK_LT(fun->function_literal_id(), shared_function_infos()->length());
|
||||
MaybeObject* shared =
|
||||
shared_function_infos()->Get(fun->function_literal_id());
|
||||
MaybeObject shared = shared_function_infos()->Get(fun->function_literal_id());
|
||||
HeapObject* heap_object;
|
||||
if (!shared->GetHeapObject(&heap_object) ||
|
||||
heap_object->IsUndefined(isolate)) {
|
||||
@ -13804,7 +13802,7 @@ SharedFunctionInfo::ScriptIterator::ScriptIterator(
|
||||
|
||||
SharedFunctionInfo* SharedFunctionInfo::ScriptIterator::Next() {
|
||||
while (index_ < shared_function_infos_->length()) {
|
||||
MaybeObject* raw = shared_function_infos_->Get(index_++);
|
||||
MaybeObject raw = shared_function_infos_->Get(index_++);
|
||||
HeapObject* heap_object;
|
||||
if (!raw->GetHeapObject(&heap_object) ||
|
||||
heap_object->IsUndefined(isolate_)) {
|
||||
@ -13860,7 +13858,7 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
|
||||
handle(script->shared_function_infos(), isolate);
|
||||
#ifdef DEBUG
|
||||
DCHECK_LT(function_literal_id, list->length());
|
||||
MaybeObject* maybe_object = list->Get(function_literal_id);
|
||||
MaybeObject maybe_object = list->Get(function_literal_id);
|
||||
HeapObject* heap_object;
|
||||
if (maybe_object->GetHeapObjectIfWeak(&heap_object)) {
|
||||
DCHECK_EQ(heap_object, *shared);
|
||||
@ -13899,7 +13897,7 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
|
||||
// about the SharedFunctionInfo, so we have to guard against that.
|
||||
Handle<WeakFixedArray> infos(old_script->shared_function_infos(), isolate);
|
||||
if (function_literal_id < infos->length()) {
|
||||
MaybeObject* raw =
|
||||
MaybeObject raw =
|
||||
old_script->shared_function_infos()->Get(function_literal_id);
|
||||
HeapObject* heap_object;
|
||||
if (raw->GetHeapObjectIfWeak(&heap_object) && heap_object == *shared) {
|
||||
@ -15320,7 +15318,7 @@ bool DependentCode::Compact() {
|
||||
int old_count = count();
|
||||
int new_count = 0;
|
||||
for (int i = 0; i < old_count; i++) {
|
||||
MaybeObject* obj = object_at(i);
|
||||
MaybeObject obj = object_at(i);
|
||||
if (!obj->IsCleared()) {
|
||||
if (i != new_count) {
|
||||
copy(i, new_count);
|
||||
@ -15352,7 +15350,7 @@ bool DependentCode::MarkCodeForDeoptimization(
|
||||
bool marked = false;
|
||||
int count = this->count();
|
||||
for (int i = 0; i < count; i++) {
|
||||
MaybeObject* obj = object_at(i);
|
||||
MaybeObject obj = object_at(i);
|
||||
if (obj->IsCleared()) continue;
|
||||
Code* code = Code::cast(obj->GetHeapObjectAssumeWeak());
|
||||
if (!code->marked_for_deoptimization()) {
|
||||
@ -17513,7 +17511,7 @@ void AddToFeedbackCellsMap(Handle<CompilationCacheTable> cache, int cache_entry,
|
||||
|
||||
#ifdef DEBUG
|
||||
for (int i = 0; i < new_literals_map->length(); i += kLiteralEntryLength) {
|
||||
MaybeObject* object = new_literals_map->Get(i + kLiteralContextOffset);
|
||||
MaybeObject object = new_literals_map->Get(i + kLiteralContextOffset);
|
||||
DCHECK(object->IsCleared() ||
|
||||
object->GetHeapObjectAssumeWeak()->IsNativeContext());
|
||||
object = new_literals_map->Get(i + kLiteralLiteralsOffset);
|
||||
@ -17536,7 +17534,7 @@ FeedbackCell* SearchLiteralsMap(CompilationCacheTable* cache, int cache_entry,
|
||||
WeakFixedArray* literals_map =
|
||||
WeakFixedArray::cast(cache->get(cache_entry));
|
||||
DCHECK_LE(entry + kLiteralEntryLength, literals_map->length());
|
||||
MaybeObject* object = literals_map->Get(entry + kLiteralLiteralsOffset);
|
||||
MaybeObject object = literals_map->Get(entry + kLiteralLiteralsOffset);
|
||||
|
||||
result = object->IsCleared()
|
||||
? nullptr
|
||||
|
@ -1459,17 +1459,19 @@ class Object {
|
||||
};
|
||||
|
||||
// In objects.h to be usable without objects-inl.h inclusion.
|
||||
bool Object::IsSmi() const { return HAS_SMI_TAG(this); }
|
||||
bool Object::IsSmi() const { return HAS_SMI_TAG(ptr()); }
|
||||
bool Object::IsHeapObject() const {
|
||||
DCHECK_EQ(!IsSmi(),
|
||||
Internals::HasHeapObjectTag(reinterpret_cast<Address>(this)));
|
||||
DCHECK_EQ(!IsSmi(), Internals::HasHeapObjectTag(ptr()));
|
||||
return !IsSmi();
|
||||
}
|
||||
|
||||
struct Brief {
|
||||
V8_EXPORT_PRIVATE explicit Brief(const Object* v);
|
||||
explicit Brief(const MaybeObject* v) : value(v) {}
|
||||
const MaybeObject* value;
|
||||
explicit Brief(const MaybeObject v);
|
||||
// {value} is a tagged heap object reference (weak or strong), equivalent to
|
||||
// a MaybeObject's payload. It has a plain Address type to keep #includes
|
||||
// lightweight.
|
||||
const Address value;
|
||||
};
|
||||
|
||||
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const Brief& v);
|
||||
|
@ -162,11 +162,11 @@ DependentCode::DependencyGroup DependentCode::group() {
|
||||
return static_cast<DependencyGroup>(GroupField::decode(flags()));
|
||||
}
|
||||
|
||||
void DependentCode::set_object_at(int i, MaybeObject* object) {
|
||||
void DependentCode::set_object_at(int i, MaybeObject object) {
|
||||
Set(kCodesStartIndex + i, object);
|
||||
}
|
||||
|
||||
MaybeObject* DependentCode::object_at(int i) {
|
||||
MaybeObject DependentCode::object_at(int i) {
|
||||
return Get(kCodesStartIndex + i);
|
||||
}
|
||||
|
||||
@ -190,10 +190,10 @@ CODE_ACCESSORS(code_data_container, CodeDataContainer, kCodeDataContainerOffset)
|
||||
#undef CODE_ACCESSORS
|
||||
|
||||
void Code::WipeOutHeader() {
|
||||
WRITE_FIELD(this, kRelocationInfoOffset, nullptr);
|
||||
WRITE_FIELD(this, kDeoptimizationDataOffset, nullptr);
|
||||
WRITE_FIELD(this, kSourcePositionTableOffset, nullptr);
|
||||
WRITE_FIELD(this, kCodeDataContainerOffset, nullptr);
|
||||
WRITE_FIELD(this, kRelocationInfoOffset, Smi::FromInt(0));
|
||||
WRITE_FIELD(this, kDeoptimizationDataOffset, Smi::FromInt(0));
|
||||
WRITE_FIELD(this, kSourcePositionTableOffset, Smi::FromInt(0));
|
||||
WRITE_FIELD(this, kCodeDataContainerOffset, Smi::FromInt(0));
|
||||
}
|
||||
|
||||
void Code::clear_padding() {
|
||||
|
@ -620,7 +620,7 @@ class DependentCode : public WeakFixedArray {
|
||||
|
||||
// The following low-level accessors are exposed only for tests.
|
||||
inline DependencyGroup group();
|
||||
inline MaybeObject* object_at(int i);
|
||||
inline MaybeObject object_at(int i);
|
||||
inline int count();
|
||||
inline DependentCode* next_link();
|
||||
|
||||
@ -658,7 +658,7 @@ class DependentCode : public WeakFixedArray {
|
||||
|
||||
inline void set_next_link(DependentCode* next);
|
||||
inline void set_count(int value);
|
||||
inline void set_object_at(int i, MaybeObject* object);
|
||||
inline void set_object_at(int i, MaybeObject object);
|
||||
inline void clear_at(int i);
|
||||
inline void copy(int from, int to);
|
||||
|
||||
|
@ -31,9 +31,9 @@ class DataHandler : public Struct {
|
||||
|
||||
// [data1-3]: These are optional general-purpose fields whose content and
|
||||
// presence depends on the handler kind.
|
||||
DECL_ACCESSORS(data1, MaybeObject)
|
||||
DECL_ACCESSORS(data2, MaybeObject)
|
||||
DECL_ACCESSORS(data3, MaybeObject)
|
||||
DECL_ACCESSORS2(data1, MaybeObject)
|
||||
DECL_ACCESSORS2(data2, MaybeObject)
|
||||
DECL_ACCESSORS2(data3, MaybeObject)
|
||||
|
||||
// Layout description.
|
||||
#define DATA_HANDLER_FIELDS(V) \
|
||||
|
@ -72,7 +72,7 @@ class DescriptorArray : public WeakFixedArray {
|
||||
inline ObjectSlot GetKeySlot(int descriptor_number);
|
||||
inline Object* GetStrongValue(int descriptor_number);
|
||||
inline void SetValue(int descriptor_number, Object* value);
|
||||
inline MaybeObject* GetValue(int descriptor_number);
|
||||
inline MaybeObject GetValue(int descriptor_number);
|
||||
inline MaybeObjectSlot GetValueSlot(int descriptor_number);
|
||||
static inline int GetValueOffset(int descriptor_number);
|
||||
inline MaybeObjectSlot GetDescriptorStartSlot(int descriptor_number);
|
||||
@ -87,7 +87,7 @@ class DescriptorArray : public WeakFixedArray {
|
||||
|
||||
// Accessor for complete descriptor.
|
||||
inline void Set(int descriptor_number, Descriptor* desc);
|
||||
inline void Set(int descriptor_number, Name* key, MaybeObject* value,
|
||||
inline void Set(int descriptor_number, Name* key, MaybeObject value,
|
||||
PropertyDetails details);
|
||||
void Replace(int descriptor_number, Descriptor* descriptor);
|
||||
|
||||
@ -188,8 +188,8 @@ class DescriptorArray : public WeakFixedArray {
|
||||
}
|
||||
|
||||
private:
|
||||
inline MaybeObject* get(int index) const;
|
||||
inline void set(int index, MaybeObject* value);
|
||||
inline MaybeObject get(int index) const;
|
||||
inline void set(int index, MaybeObject value);
|
||||
|
||||
// Transfer a complete descriptor from the src descriptor array to this
|
||||
// descriptor array.
|
||||
|
@ -243,12 +243,12 @@ void FixedDoubleArray::FillWithHoles(int from, int to) {
|
||||
}
|
||||
}
|
||||
|
||||
MaybeObject* WeakFixedArray::Get(int index) const {
|
||||
MaybeObject WeakFixedArray::Get(int index) const {
|
||||
DCHECK(index >= 0 && index < this->length());
|
||||
return RELAXED_READ_WEAK_FIELD(this, OffsetOfElementAt(index));
|
||||
}
|
||||
|
||||
void WeakFixedArray::Set(int index, MaybeObject* value) {
|
||||
void WeakFixedArray::Set(int index, MaybeObject value) {
|
||||
DCHECK_GE(index, 0);
|
||||
DCHECK_LT(index, length());
|
||||
int offset = OffsetOfElementAt(index);
|
||||
@ -256,7 +256,7 @@ void WeakFixedArray::Set(int index, MaybeObject* value) {
|
||||
WEAK_WRITE_BARRIER(this, offset, value);
|
||||
}
|
||||
|
||||
void WeakFixedArray::Set(int index, MaybeObject* value, WriteBarrierMode mode) {
|
||||
void WeakFixedArray::Set(int index, MaybeObject value, WriteBarrierMode mode) {
|
||||
DCHECK_GE(index, 0);
|
||||
DCHECK_LT(index, length());
|
||||
int offset = OffsetOfElementAt(index);
|
||||
@ -272,12 +272,12 @@ MaybeObjectSlot WeakFixedArray::RawFieldOfElementAt(int index) {
|
||||
return HeapObject::RawMaybeWeakField(this, OffsetOfElementAt(index));
|
||||
}
|
||||
|
||||
MaybeObject* WeakArrayList::Get(int index) const {
|
||||
MaybeObject WeakArrayList::Get(int index) const {
|
||||
DCHECK(index >= 0 && index < this->capacity());
|
||||
return RELAXED_READ_WEAK_FIELD(this, OffsetOfElementAt(index));
|
||||
}
|
||||
|
||||
void WeakArrayList::Set(int index, MaybeObject* value, WriteBarrierMode mode) {
|
||||
void WeakArrayList::Set(int index, MaybeObject value, WriteBarrierMode mode) {
|
||||
DCHECK_GE(index, 0);
|
||||
DCHECK_LT(index, this->capacity());
|
||||
int offset = OffsetOfElementAt(index);
|
||||
@ -292,7 +292,7 @@ MaybeObjectSlot WeakArrayList::data_start() {
|
||||
HeapObject* WeakArrayList::Iterator::Next() {
|
||||
if (array_ != nullptr) {
|
||||
while (index_ < array_->length()) {
|
||||
MaybeObject* item = array_->Get(index_++);
|
||||
MaybeObject item = array_->Get(index_++);
|
||||
DCHECK(item->IsWeakOrCleared());
|
||||
if (!item->IsCleared()) return item->GetHeapObjectAssumeWeak();
|
||||
}
|
||||
|
@ -264,18 +264,18 @@ class FixedDoubleArray : public FixedArrayBase {
|
||||
};
|
||||
|
||||
// WeakFixedArray describes fixed-sized arrays with element type
|
||||
// MaybeObject*.
|
||||
// MaybeObject.
|
||||
class WeakFixedArray : public HeapObject {
|
||||
public:
|
||||
DECL_CAST(WeakFixedArray)
|
||||
|
||||
inline MaybeObject* Get(int index) const;
|
||||
inline MaybeObject Get(int index) const;
|
||||
|
||||
// Setter that uses write barrier.
|
||||
inline void Set(int index, MaybeObject* value);
|
||||
inline void Set(int index, MaybeObject value);
|
||||
|
||||
// Setter with explicit barrier mode.
|
||||
inline void Set(int index, MaybeObject* value, WriteBarrierMode mode);
|
||||
inline void Set(int index, MaybeObject value, WriteBarrierMode mode);
|
||||
|
||||
static constexpr int SizeFor(int length) {
|
||||
return kHeaderSize + length * kPointerSize;
|
||||
@ -333,12 +333,12 @@ class WeakArrayList : public HeapObject {
|
||||
Handle<WeakArrayList> array,
|
||||
const MaybeObjectHandle& value);
|
||||
|
||||
inline MaybeObject* Get(int index) const;
|
||||
inline MaybeObject Get(int index) const;
|
||||
|
||||
// Set the element at index to obj. The underlying array must be large enough.
|
||||
// If you need to grow the WeakArrayList, use the static AddToEnd() method
|
||||
// instead.
|
||||
inline void Set(int index, MaybeObject* value,
|
||||
inline void Set(int index, MaybeObject value,
|
||||
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
||||
|
||||
static constexpr int SizeForCapacity(int capacity) {
|
||||
|
@ -416,7 +416,7 @@ class Map : public HeapObject {
|
||||
// [raw_transitions]: Provides access to the transitions storage field.
|
||||
// Don't call set_raw_transitions() directly to overwrite transitions, use
|
||||
// the TransitionArray::ReplaceTransitions() wrapper instead!
|
||||
DECL_ACCESSORS(raw_transitions, MaybeObject)
|
||||
DECL_ACCESSORS2(raw_transitions, MaybeObject)
|
||||
// [prototype_info]: Per-prototype metadata. Aliased with transitions
|
||||
// (which prototype maps don't have).
|
||||
DECL_ACCESSORS(prototype_info, Object)
|
||||
@ -653,7 +653,7 @@ class Map : public HeapObject {
|
||||
|
||||
static MaybeObjectHandle WrapFieldType(Isolate* isolate,
|
||||
Handle<FieldType> type);
|
||||
static FieldType* UnwrapFieldType(MaybeObject* wrapped_type);
|
||||
static FieldType* UnwrapFieldType(MaybeObject wrapped_type);
|
||||
|
||||
V8_WARN_UNUSED_RESULT static MaybeHandle<Map> CopyWithField(
|
||||
Isolate* isolate, Handle<Map> map, Handle<Name> name,
|
||||
|
@ -8,13 +8,14 @@
|
||||
#include "src/objects/maybe-object.h"
|
||||
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/objects/slots-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
bool MaybeObject::ToSmi(Smi** value) {
|
||||
if (HAS_SMI_TAG(this)) {
|
||||
*value = Smi::cast(reinterpret_cast<Object*>(this));
|
||||
if (HAS_SMI_TAG(ptr_)) {
|
||||
*value = Smi::cast(reinterpret_cast<Object*>(ptr_));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -27,7 +28,7 @@ bool MaybeObject::IsStrongOrWeak() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MaybeObject::GetHeapObject(HeapObject** result) {
|
||||
bool MaybeObject::GetHeapObject(HeapObject** result) const {
|
||||
if (IsSmi() || IsCleared()) {
|
||||
return false;
|
||||
}
|
||||
@ -36,11 +37,11 @@ bool MaybeObject::GetHeapObject(HeapObject** result) {
|
||||
}
|
||||
|
||||
bool MaybeObject::GetHeapObject(HeapObject** result,
|
||||
HeapObjectReferenceType* reference_type) {
|
||||
HeapObjectReferenceType* reference_type) const {
|
||||
if (IsSmi() || IsCleared()) {
|
||||
return false;
|
||||
}
|
||||
*reference_type = HasWeakHeapObjectTag(this)
|
||||
*reference_type = HasWeakHeapObjectTag(ptr_)
|
||||
? HeapObjectReferenceType::WEAK
|
||||
: HeapObjectReferenceType::STRONG;
|
||||
*result = GetHeapObject();
|
||||
@ -48,29 +49,29 @@ bool MaybeObject::GetHeapObject(HeapObject** result,
|
||||
}
|
||||
|
||||
bool MaybeObject::IsStrong() const {
|
||||
return !HasWeakHeapObjectTag(this) && !IsSmi();
|
||||
return !HasWeakHeapObjectTag(ptr_) && !IsSmi();
|
||||
}
|
||||
|
||||
bool MaybeObject::GetHeapObjectIfStrong(HeapObject** result) {
|
||||
if (!HasWeakHeapObjectTag(this) && !IsSmi()) {
|
||||
*result = reinterpret_cast<HeapObject*>(this);
|
||||
bool MaybeObject::GetHeapObjectIfStrong(HeapObject** result) const {
|
||||
if (!HasWeakHeapObjectTag(ptr_) && !IsSmi()) {
|
||||
*result = reinterpret_cast<HeapObject*>(ptr_);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
HeapObject* MaybeObject::GetHeapObjectAssumeStrong() {
|
||||
HeapObject* MaybeObject::GetHeapObjectAssumeStrong() const {
|
||||
DCHECK(IsStrong());
|
||||
return reinterpret_cast<HeapObject*>(this);
|
||||
return reinterpret_cast<HeapObject*>(ptr_);
|
||||
}
|
||||
|
||||
bool MaybeObject::IsWeak() const {
|
||||
return HasWeakHeapObjectTag(this) && !IsCleared();
|
||||
return HasWeakHeapObjectTag(ptr_) && !IsCleared();
|
||||
}
|
||||
|
||||
bool MaybeObject::IsWeakOrCleared() const { return HasWeakHeapObjectTag(this); }
|
||||
bool MaybeObject::IsWeakOrCleared() const { return HasWeakHeapObjectTag(ptr_); }
|
||||
|
||||
bool MaybeObject::GetHeapObjectIfWeak(HeapObject** result) {
|
||||
bool MaybeObject::GetHeapObjectIfWeak(HeapObject** result) const {
|
||||
if (IsWeak()) {
|
||||
*result = GetHeapObject();
|
||||
return true;
|
||||
@ -78,29 +79,48 @@ bool MaybeObject::GetHeapObjectIfWeak(HeapObject** result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HeapObject* MaybeObject::GetHeapObjectAssumeWeak() {
|
||||
HeapObject* MaybeObject::GetHeapObjectAssumeWeak() const {
|
||||
DCHECK(IsWeak());
|
||||
return GetHeapObject();
|
||||
}
|
||||
|
||||
HeapObject* MaybeObject::GetHeapObject() {
|
||||
HeapObject* MaybeObject::GetHeapObject() const {
|
||||
DCHECK(!IsSmi());
|
||||
DCHECK(!IsCleared());
|
||||
return RemoveWeakHeapObjectMask(reinterpret_cast<HeapObjectReference*>(this));
|
||||
return reinterpret_cast<HeapObject*>(ptr_ & ~kWeakHeapObjectMask);
|
||||
}
|
||||
|
||||
Object* MaybeObject::GetHeapObjectOrSmi() {
|
||||
Object* MaybeObject::GetHeapObjectOrSmi() const {
|
||||
if (IsSmi()) {
|
||||
return reinterpret_cast<Object*>(this);
|
||||
return reinterpret_cast<Object*>(ptr_);
|
||||
}
|
||||
return GetHeapObject();
|
||||
}
|
||||
|
||||
bool MaybeObject::IsObject() const { return IsSmi() || IsStrong(); }
|
||||
|
||||
MaybeObject* MaybeObject::MakeWeak(MaybeObject* object) {
|
||||
DCHECK(object->IsStrongOrWeak());
|
||||
return AddWeakHeapObjectMask(object);
|
||||
MaybeObject MaybeObject::MakeWeak(MaybeObject object) {
|
||||
DCHECK(object.IsStrongOrWeak());
|
||||
return MaybeObject(object.ptr_ | kWeakHeapObjectMask);
|
||||
}
|
||||
|
||||
void HeapObjectReference::Update(HeapObjectSlot slot, HeapObject* value) {
|
||||
Address old_value = (*slot).ptr();
|
||||
DCHECK(!HAS_SMI_TAG(old_value));
|
||||
Address new_value = value->ptr();
|
||||
DCHECK(Internals::HasHeapObjectTag(new_value));
|
||||
|
||||
#ifdef DEBUG
|
||||
bool weak_before = HasWeakHeapObjectTag(old_value);
|
||||
#endif
|
||||
|
||||
slot.store(
|
||||
HeapObjectReference(new_value | (old_value & kWeakHeapObjectMask)));
|
||||
|
||||
#ifdef DEBUG
|
||||
bool weak_after = HasWeakHeapObjectTag((*slot).ptr());
|
||||
DCHECK_EQ(weak_before, weak_after);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -23,70 +23,80 @@ class StringStream;
|
||||
// implementing in-place weak references (see design doc: goo.gl/j6SdcK )
|
||||
class MaybeObject {
|
||||
public:
|
||||
bool IsSmi() const { return HAS_SMI_TAG(this); }
|
||||
MaybeObject() : ptr_(kNullAddress) {}
|
||||
explicit MaybeObject(Address ptr) : ptr_(ptr) {}
|
||||
|
||||
bool operator==(const MaybeObject& other) const { return ptr_ == other.ptr_; }
|
||||
bool operator!=(const MaybeObject& other) const { return ptr_ != other.ptr_; }
|
||||
|
||||
Address ptr() const { return ptr_; }
|
||||
|
||||
// Enable incremental transition of client code.
|
||||
MaybeObject* operator->() { return this; }
|
||||
const MaybeObject* operator->() const { return this; }
|
||||
|
||||
bool IsSmi() const { return HAS_SMI_TAG(ptr_); }
|
||||
inline bool ToSmi(Smi** value);
|
||||
|
||||
bool IsCleared() const {
|
||||
return ::v8::internal::IsClearedWeakHeapObject(this);
|
||||
}
|
||||
bool IsCleared() const { return ptr_ == kClearedWeakHeapObject; }
|
||||
|
||||
inline bool IsStrongOrWeak() const;
|
||||
inline bool IsStrong() const;
|
||||
|
||||
// If this MaybeObject is a strong pointer to a HeapObject, returns true and
|
||||
// sets *result. Otherwise returns false.
|
||||
inline bool GetHeapObjectIfStrong(HeapObject** result);
|
||||
inline bool GetHeapObjectIfStrong(HeapObject** result) const;
|
||||
|
||||
// DCHECKs that this MaybeObject is a strong pointer to a HeapObject and
|
||||
// returns the HeapObject.
|
||||
inline HeapObject* GetHeapObjectAssumeStrong();
|
||||
inline HeapObject* GetHeapObjectAssumeStrong() const;
|
||||
|
||||
inline bool IsWeak() const;
|
||||
inline bool IsWeakOrCleared() const;
|
||||
|
||||
// If this MaybeObject is a weak pointer to a HeapObject, returns true and
|
||||
// sets *result. Otherwise returns false.
|
||||
inline bool GetHeapObjectIfWeak(HeapObject** result);
|
||||
inline bool GetHeapObjectIfWeak(HeapObject** result) const;
|
||||
|
||||
// DCHECKs that this MaybeObject is a weak pointer to a HeapObject and
|
||||
// returns the HeapObject.
|
||||
inline HeapObject* GetHeapObjectAssumeWeak();
|
||||
inline HeapObject* GetHeapObjectAssumeWeak() const;
|
||||
|
||||
// If this MaybeObject is a strong or weak pointer to a HeapObject, returns
|
||||
// true and sets *result. Otherwise returns false.
|
||||
inline bool GetHeapObject(HeapObject** result);
|
||||
inline bool GetHeapObject(HeapObject** result) const;
|
||||
inline bool GetHeapObject(HeapObject** result,
|
||||
HeapObjectReferenceType* reference_type);
|
||||
HeapObjectReferenceType* reference_type) const;
|
||||
|
||||
// DCHECKs that this MaybeObject is a strong or a weak pointer to a HeapObject
|
||||
// and returns the HeapObject.
|
||||
inline HeapObject* GetHeapObject();
|
||||
inline HeapObject* GetHeapObject() const;
|
||||
|
||||
// DCHECKs that this MaybeObject is a strong or a weak pointer to a HeapObject
|
||||
// or a SMI and returns the HeapObject or SMI.
|
||||
inline Object* GetHeapObjectOrSmi();
|
||||
inline Object* GetHeapObjectOrSmi() const;
|
||||
|
||||
inline bool IsObject() const;
|
||||
template <typename T>
|
||||
T* cast() {
|
||||
DCHECK(!HasWeakHeapObjectTag(this));
|
||||
return T::cast(reinterpret_cast<Object*>(this));
|
||||
T* cast() const {
|
||||
DCHECK(!HasWeakHeapObjectTag(ptr_));
|
||||
return T::cast(reinterpret_cast<Object*>(ptr_));
|
||||
}
|
||||
|
||||
static MaybeObject* FromSmi(Smi* smi) {
|
||||
DCHECK(HAS_SMI_TAG(smi));
|
||||
return reinterpret_cast<MaybeObject*>(smi);
|
||||
static MaybeObject FromSmi(Smi* smi) {
|
||||
DCHECK(HAS_SMI_TAG(smi->ptr()));
|
||||
return MaybeObject(smi->ptr());
|
||||
}
|
||||
|
||||
static MaybeObject* FromObject(Object* object) {
|
||||
static MaybeObject FromObject(Object* object) {
|
||||
DCHECK(!HasWeakHeapObjectTag(object));
|
||||
return reinterpret_cast<MaybeObject*>(object);
|
||||
return MaybeObject(object->ptr());
|
||||
}
|
||||
|
||||
static inline MaybeObject* MakeWeak(MaybeObject* object);
|
||||
static inline MaybeObject MakeWeak(MaybeObject object);
|
||||
|
||||
#ifdef VERIFY_HEAP
|
||||
static void VerifyMaybeObjectPointer(Isolate* isolate, MaybeObject* p);
|
||||
static void VerifyMaybeObjectPointer(Isolate* isolate, MaybeObject p);
|
||||
#endif
|
||||
|
||||
// Prints this object without details.
|
||||
@ -106,49 +116,33 @@ class MaybeObject {
|
||||
#endif
|
||||
|
||||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(MaybeObject);
|
||||
Address ptr_;
|
||||
};
|
||||
|
||||
// A HeapObjectReference is either a strong reference to a HeapObject, a weak
|
||||
// reference to a HeapObject, or a cleared weak reference.
|
||||
class HeapObjectReference : public MaybeObject {
|
||||
public:
|
||||
static HeapObjectReference* Strong(Object* object) {
|
||||
explicit HeapObjectReference(Address address) : MaybeObject(address) {}
|
||||
explicit HeapObjectReference(Object* object) : MaybeObject(object->ptr()) {}
|
||||
|
||||
static HeapObjectReference Strong(Object* object) {
|
||||
DCHECK(!object->IsSmi());
|
||||
DCHECK(!HasWeakHeapObjectTag(object));
|
||||
return reinterpret_cast<HeapObjectReference*>(object);
|
||||
return HeapObjectReference(object);
|
||||
}
|
||||
|
||||
static HeapObjectReference* Weak(Object* object) {
|
||||
static HeapObjectReference Weak(Object* object) {
|
||||
DCHECK(!object->IsSmi());
|
||||
DCHECK(!HasWeakHeapObjectTag(object));
|
||||
return AddWeakHeapObjectMask(object);
|
||||
return HeapObjectReference(object->ptr() | kWeakHeapObjectMask);
|
||||
}
|
||||
|
||||
static HeapObjectReference* ClearedValue() {
|
||||
return reinterpret_cast<HeapObjectReference*>(kClearedWeakHeapObject);
|
||||
static HeapObjectReference ClearedValue() {
|
||||
return HeapObjectReference(kClearedWeakHeapObject);
|
||||
}
|
||||
|
||||
static void Update(HeapObjectSlot slot, HeapObject* value) {
|
||||
DCHECK(!HAS_SMI_TAG(*slot));
|
||||
DCHECK(Internals::HasHeapObjectTag(reinterpret_cast<Address>(value)));
|
||||
|
||||
#ifdef DEBUG
|
||||
bool weak_before = HasWeakHeapObjectTag(*slot);
|
||||
#endif
|
||||
|
||||
slot.store(reinterpret_cast<HeapObjectReference*>(
|
||||
reinterpret_cast<intptr_t>(value) |
|
||||
(reinterpret_cast<intptr_t>(*slot) & kWeakHeapObjectMask)));
|
||||
|
||||
#ifdef DEBUG
|
||||
bool weak_after = HasWeakHeapObjectTag(*slot);
|
||||
DCHECK_EQ(weak_before, weak_after);
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(HeapObjectReference);
|
||||
static inline void Update(HeapObjectSlot slot, HeapObject* value);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
@ -9,6 +9,7 @@
|
||||
#undef DECL_BOOLEAN_ACCESSORS
|
||||
#undef DECL_INT_ACCESSORS
|
||||
#undef DECL_ACCESSORS
|
||||
#undef DECL_ACCESSORS2
|
||||
#undef DECL_CAST
|
||||
#undef DECL_CAST2
|
||||
#undef CAST_ACCESSOR
|
||||
|
@ -54,6 +54,14 @@
|
||||
inline void set_##name(type* value, \
|
||||
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
||||
|
||||
// Replacement for the above, temporarily separate to allow incremental
|
||||
// transition.
|
||||
// TODO(3770): Get rid of the duplication when the migration is complete.
|
||||
#define DECL_ACCESSORS2(name, type) \
|
||||
inline type name() const; \
|
||||
inline void set_##name(type value, \
|
||||
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
|
||||
|
||||
#define DECL_CAST(type) \
|
||||
V8_INLINE static type* cast(Object* object); \
|
||||
V8_INLINE static const type* cast(const Object* object);
|
||||
@ -146,17 +154,17 @@
|
||||
#define SYNCHRONIZED_ACCESSORS(holder, name, type, offset) \
|
||||
SYNCHRONIZED_ACCESSORS_CHECKED(holder, name, type, offset, true)
|
||||
|
||||
#define WEAK_ACCESSORS_CHECKED2(holder, name, offset, get_condition, \
|
||||
set_condition) \
|
||||
MaybeObject* holder::name() const { \
|
||||
MaybeObject* value = READ_WEAK_FIELD(this, offset); \
|
||||
DCHECK(get_condition); \
|
||||
return value; \
|
||||
} \
|
||||
void holder::set_##name(MaybeObject* value, WriteBarrierMode mode) { \
|
||||
DCHECK(set_condition); \
|
||||
WRITE_WEAK_FIELD(this, offset, value); \
|
||||
CONDITIONAL_WEAK_WRITE_BARRIER(this, offset, value, mode); \
|
||||
#define WEAK_ACCESSORS_CHECKED2(holder, name, offset, get_condition, \
|
||||
set_condition) \
|
||||
MaybeObject holder::name() const { \
|
||||
MaybeObject value = READ_WEAK_FIELD(this, offset); \
|
||||
DCHECK(get_condition); \
|
||||
return value; \
|
||||
} \
|
||||
void holder::set_##name(MaybeObject value, WriteBarrierMode mode) { \
|
||||
DCHECK(set_condition); \
|
||||
WRITE_WEAK_FIELD(this, offset, value); \
|
||||
CONDITIONAL_WEAK_WRITE_BARRIER(this, offset, value, mode); \
|
||||
}
|
||||
|
||||
#define WEAK_ACCESSORS_CHECKED(holder, name, offset, condition) \
|
||||
@ -231,7 +239,7 @@
|
||||
(*reinterpret_cast<Object* const*>(FIELD_ADDR(p, offset)))
|
||||
|
||||
#define READ_WEAK_FIELD(p, offset) \
|
||||
(*reinterpret_cast<MaybeObject* const*>(FIELD_ADDR(p, offset)))
|
||||
MaybeObject(*reinterpret_cast<Address*>(FIELD_ADDR(p, offset)))
|
||||
|
||||
#define ACQUIRE_READ_FIELD(p, offset) \
|
||||
reinterpret_cast<Object*>(base::Acquire_Load( \
|
||||
@ -241,24 +249,24 @@
|
||||
reinterpret_cast<Object*>(base::Relaxed_Load( \
|
||||
reinterpret_cast<const base::AtomicWord*>(FIELD_ADDR(p, offset))))
|
||||
|
||||
#define RELAXED_READ_WEAK_FIELD(p, offset) \
|
||||
reinterpret_cast<MaybeObject*>(base::Relaxed_Load( \
|
||||
#define RELAXED_READ_WEAK_FIELD(p, offset) \
|
||||
MaybeObject(base::Relaxed_Load( \
|
||||
reinterpret_cast<const base::AtomicWord*>(FIELD_ADDR(p, offset))))
|
||||
|
||||
#ifdef V8_CONCURRENT_MARKING
|
||||
#define WRITE_FIELD(p, offset, value) \
|
||||
base::Relaxed_Store( \
|
||||
reinterpret_cast<base::AtomicWord*>(FIELD_ADDR(p, offset)), \
|
||||
reinterpret_cast<base::AtomicWord>(value));
|
||||
static_cast<base::AtomicWord>((value)->ptr()));
|
||||
#define WRITE_WEAK_FIELD(p, offset, value) \
|
||||
base::Relaxed_Store( \
|
||||
reinterpret_cast<base::AtomicWord*>(FIELD_ADDR(p, offset)), \
|
||||
reinterpret_cast<base::AtomicWord>(value));
|
||||
static_cast<base::AtomicWord>(value.ptr()));
|
||||
#else
|
||||
#define WRITE_FIELD(p, offset, value) \
|
||||
(*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)) = value)
|
||||
#define WRITE_WEAK_FIELD(p, offset, value) \
|
||||
(*reinterpret_cast<MaybeObject**>(FIELD_ADDR(p, offset)) = value)
|
||||
(*reinterpret_cast<Address*>(FIELD_ADDR(p, offset)) = value.ptr())
|
||||
#endif
|
||||
|
||||
#define RELEASE_WRITE_FIELD(p, offset, value) \
|
||||
@ -269,7 +277,7 @@
|
||||
#define RELAXED_WRITE_FIELD(p, offset, value) \
|
||||
base::Relaxed_Store( \
|
||||
reinterpret_cast<base::AtomicWord*>(FIELD_ADDR(p, offset)), \
|
||||
reinterpret_cast<base::AtomicWord>(value));
|
||||
static_cast<base::AtomicWord>((value)->ptr()));
|
||||
|
||||
#define WRITE_BARRIER(object, offset, value) \
|
||||
do { \
|
||||
|
@ -30,7 +30,7 @@ void PrototypeInfo::SetObjectCreateMap(Handle<PrototypeInfo> info,
|
||||
}
|
||||
|
||||
bool PrototypeInfo::HasObjectCreateMap() {
|
||||
MaybeObject* cache = object_create_map();
|
||||
MaybeObject cache = object_create_map();
|
||||
return cache->IsWeak();
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ class PrototypeInfo : public Struct {
|
||||
class BodyDescriptor;
|
||||
|
||||
private:
|
||||
DECL_ACCESSORS(object_create_map, MaybeObject)
|
||||
DECL_ACCESSORS2(object_create_map, MaybeObject)
|
||||
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(PrototypeInfo);
|
||||
};
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "src/objects/slots.h"
|
||||
|
||||
#include "src/base/atomic-utils.h"
|
||||
#include "src/objects/maybe-object.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -29,17 +30,31 @@ void ObjectSlot::Relaxed_Store(int offset, Object* value) const {
|
||||
base::AsAtomicWord::Relaxed_Store(addr, reinterpret_cast<Address>(value));
|
||||
}
|
||||
|
||||
MaybeObject* MaybeObjectSlot::Relaxed_Load() const {
|
||||
Address object_ptr =
|
||||
base::AsAtomicWord::Relaxed_Load(reinterpret_cast<Address*>(address()));
|
||||
return reinterpret_cast<MaybeObject*>(object_ptr);
|
||||
MaybeObject MaybeObjectSlot::operator*() {
|
||||
return MaybeObject(*reinterpret_cast<Address*>(address()));
|
||||
}
|
||||
|
||||
void MaybeObjectSlot::Release_CompareAndSwap(MaybeObject* old,
|
||||
MaybeObject* target) const {
|
||||
void MaybeObjectSlot::store(MaybeObject value) {
|
||||
*reinterpret_cast<Address*>(address()) = value.ptr();
|
||||
}
|
||||
|
||||
MaybeObject MaybeObjectSlot::Relaxed_Load() const {
|
||||
Address object_ptr =
|
||||
base::AsAtomicWord::Relaxed_Load(reinterpret_cast<Address*>(address()));
|
||||
return MaybeObject(object_ptr);
|
||||
}
|
||||
|
||||
void MaybeObjectSlot::Release_CompareAndSwap(MaybeObject old,
|
||||
MaybeObject target) const {
|
||||
base::AsAtomicWord::Release_CompareAndSwap(
|
||||
reinterpret_cast<Address*>(address()), reinterpret_cast<Address>(old),
|
||||
reinterpret_cast<Address>(target));
|
||||
reinterpret_cast<Address*>(address()), old.ptr(), target.ptr());
|
||||
}
|
||||
|
||||
HeapObjectReference HeapObjectSlot::operator*() {
|
||||
return HeapObjectReference(*reinterpret_cast<Address*>(address()));
|
||||
}
|
||||
void HeapObjectSlot::store(HeapObjectReference value) {
|
||||
*reinterpret_cast<Address*>(address()) = value.ptr();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
@ -10,7 +10,7 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
template <typename Subclass, typename ValueType>
|
||||
template <typename Subclass>
|
||||
class SlotBase {
|
||||
public:
|
||||
Subclass& operator++() {
|
||||
@ -33,13 +33,6 @@ class SlotBase {
|
||||
return *static_cast<Subclass*>(this);
|
||||
}
|
||||
|
||||
ValueType operator*() const {
|
||||
return *reinterpret_cast<ValueType*>(address());
|
||||
}
|
||||
void store(ValueType value) {
|
||||
*reinterpret_cast<ValueType*>(address()) = value;
|
||||
}
|
||||
|
||||
void* ToVoidPtr() const { return reinterpret_cast<void*>(address()); }
|
||||
|
||||
Address address() const { return ptr_; }
|
||||
@ -60,14 +53,17 @@ class SlotBase {
|
||||
// a tagged pointer (smi or heap object).
|
||||
// Its address() is the address of the slot.
|
||||
// The slot's contents can be read and written using operator* and store().
|
||||
class ObjectSlot : public SlotBase<ObjectSlot, Object*> {
|
||||
class ObjectSlot : public SlotBase<ObjectSlot> {
|
||||
public:
|
||||
ObjectSlot() : SlotBase(kNullAddress) {}
|
||||
explicit ObjectSlot(Address ptr) : SlotBase(ptr) {}
|
||||
explicit ObjectSlot(Object** ptr)
|
||||
: SlotBase(reinterpret_cast<Address>(ptr)) {}
|
||||
template <typename T, typename U>
|
||||
explicit ObjectSlot(SlotBase<T, U> slot) : SlotBase(slot.address()) {}
|
||||
template <typename T>
|
||||
explicit ObjectSlot(SlotBase<T> slot) : SlotBase(slot.address()) {}
|
||||
|
||||
Object* operator*() const { return *reinterpret_cast<Object**>(address()); }
|
||||
void store(Object* value) { *reinterpret_cast<Object**>(address()) = value; }
|
||||
|
||||
inline Object* Relaxed_Load() const;
|
||||
inline Object* Relaxed_Load(int offset) const;
|
||||
@ -78,17 +74,19 @@ class ObjectSlot : public SlotBase<ObjectSlot, Object*> {
|
||||
// a possibly-weak tagged pointer (think: MaybeObject).
|
||||
// Its address() is the address of the slot.
|
||||
// The slot's contents can be read and written using operator* and store().
|
||||
class MaybeObjectSlot : public SlotBase<MaybeObjectSlot, MaybeObject*> {
|
||||
class MaybeObjectSlot : public SlotBase<MaybeObjectSlot> {
|
||||
public:
|
||||
explicit MaybeObjectSlot(Address ptr) : SlotBase(ptr) {}
|
||||
explicit MaybeObjectSlot(Object** ptr)
|
||||
: SlotBase(reinterpret_cast<Address>(ptr)) {}
|
||||
template <typename T, typename U>
|
||||
explicit MaybeObjectSlot(SlotBase<T, U> slot) : SlotBase(slot.address()) {}
|
||||
template <typename T>
|
||||
explicit MaybeObjectSlot(SlotBase<T> slot) : SlotBase(slot.address()) {}
|
||||
|
||||
inline MaybeObject* Relaxed_Load() const;
|
||||
inline void Release_CompareAndSwap(MaybeObject* old,
|
||||
MaybeObject* target) const;
|
||||
inline MaybeObject operator*();
|
||||
inline void store(MaybeObject value);
|
||||
|
||||
inline MaybeObject Relaxed_Load() const;
|
||||
inline void Release_CompareAndSwap(MaybeObject old, MaybeObject target) const;
|
||||
};
|
||||
|
||||
// A HeapObjectSlot instance describes a pointer-sized field ("slot") holding
|
||||
@ -97,12 +95,15 @@ class MaybeObjectSlot : public SlotBase<MaybeObjectSlot, MaybeObject*> {
|
||||
// The slot's contents can be read and written using operator* and store().
|
||||
// In case it is known that that slot contains a strong heap object pointer,
|
||||
// ToHeapObject() can be used to retrieve that heap object.
|
||||
class HeapObjectSlot : public SlotBase<HeapObjectSlot, HeapObjectReference*> {
|
||||
class HeapObjectSlot : public SlotBase<HeapObjectSlot> {
|
||||
public:
|
||||
HeapObjectSlot() : SlotBase(kNullAddress) {}
|
||||
explicit HeapObjectSlot(Address ptr) : SlotBase(ptr) {}
|
||||
template <typename T, typename U>
|
||||
explicit HeapObjectSlot(SlotBase<T, U> slot) : SlotBase(slot.address()) {}
|
||||
template <typename T>
|
||||
explicit HeapObjectSlot(SlotBase<T> slot) : SlotBase(slot.address()) {}
|
||||
|
||||
inline HeapObjectReference operator*();
|
||||
inline void store(HeapObjectReference value);
|
||||
|
||||
HeapObject* ToHeapObject() {
|
||||
DCHECK((*reinterpret_cast<Address*>(address()) & kHeapObjectTagMask) ==
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "src/objects/js-promise-inl.h"
|
||||
#include "src/objects/js-regexp-inl.h"
|
||||
#include "src/objects/literal-objects-inl.h"
|
||||
#include "src/objects/slots.h"
|
||||
#include "src/objects/slots-inl.h"
|
||||
#include "src/profiler/allocation-tracker.h"
|
||||
#include "src/profiler/heap-profiler.h"
|
||||
#include "src/profiler/heap-snapshot-generator-inl.h"
|
||||
@ -983,7 +983,7 @@ void V8HeapExplorer::ExtractContextReferences(HeapEntry* entry,
|
||||
}
|
||||
|
||||
void V8HeapExplorer::ExtractMapReferences(HeapEntry* entry, Map* map) {
|
||||
MaybeObject* maybe_raw_transitions_or_prototype_info = map->raw_transitions();
|
||||
MaybeObject maybe_raw_transitions_or_prototype_info = map->raw_transitions();
|
||||
HeapObject* raw_transitions_or_prototype_info;
|
||||
if (maybe_raw_transitions_or_prototype_info->GetHeapObjectIfWeak(
|
||||
&raw_transitions_or_prototype_info)) {
|
||||
@ -1232,7 +1232,7 @@ void V8HeapExplorer::ExtractFixedArrayReferences(HeapEntry* entry,
|
||||
|
||||
void V8HeapExplorer::ExtractFeedbackVectorReferences(
|
||||
HeapEntry* entry, FeedbackVector* feedback_vector) {
|
||||
MaybeObject* code = feedback_vector->optimized_code_weak_or_smi();
|
||||
MaybeObject code = feedback_vector->optimized_code_weak_or_smi();
|
||||
HeapObject* code_heap_object;
|
||||
if (code->GetHeapObjectIfWeak(&code_heap_object)) {
|
||||
SetWeakReference(entry, "optimized code", code_heap_object,
|
||||
@ -1244,7 +1244,7 @@ template <typename T>
|
||||
void V8HeapExplorer::ExtractWeakArrayReferences(int header_size,
|
||||
HeapEntry* entry, T* array) {
|
||||
for (int i = 0; i < array->length(); ++i) {
|
||||
MaybeObject* object = array->Get(i);
|
||||
MaybeObject object = array->Get(i);
|
||||
HeapObject* heap_object;
|
||||
if (object->GetHeapObjectIfWeak(&heap_object)) {
|
||||
SetWeakReference(entry, i, heap_object, header_size + i * kPointerSize);
|
||||
|
@ -255,18 +255,16 @@ bool TickSample::GetStackSample(Isolate* v8_isolate, RegisterState* regs,
|
||||
// bytecode_array might be garbage, so don't actually dereference it. We
|
||||
// avoid the frame->GetXXX functions since they call BytecodeArray::cast,
|
||||
// which has a heap access in its DCHECK.
|
||||
i::Object* bytecode_array = i::Memory<i::Object*>(
|
||||
i::Address bytecode_array = i::Memory<i::Address>(
|
||||
frame->fp() + i::InterpreterFrameConstants::kBytecodeArrayFromFp);
|
||||
i::Object* bytecode_offset = i::Memory<i::Object*>(
|
||||
i::Address bytecode_offset = i::Memory<i::Address>(
|
||||
frame->fp() + i::InterpreterFrameConstants::kBytecodeOffsetFromFp);
|
||||
|
||||
// If the bytecode array is a heap object and the bytecode offset is a
|
||||
// Smi, use those, otherwise fall back to using the frame's pc.
|
||||
if (HAS_HEAP_OBJECT_TAG(bytecode_array) && HAS_SMI_TAG(bytecode_offset)) {
|
||||
frames[i++] = reinterpret_cast<void*>(
|
||||
reinterpret_cast<i::Address>(bytecode_array) +
|
||||
i::Internals::SmiValue(
|
||||
reinterpret_cast<i::Address>(bytecode_offset)));
|
||||
bytecode_array + i::Internals::SmiValue(bytecode_offset));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -537,8 +537,8 @@ RUNTIME_FUNCTION(Runtime_DebugPrint) {
|
||||
DCHECK_EQ(1, args.length());
|
||||
|
||||
// Hack: The argument is passed as Object* but here it's really a
|
||||
// MaybeObject*.
|
||||
MaybeObject* maybe_object = reinterpret_cast<MaybeObject*>(args[0]);
|
||||
// MaybeObject.
|
||||
MaybeObject maybe_object(reinterpret_cast<Address>(args[0]));
|
||||
|
||||
StdoutStream os;
|
||||
if (maybe_object->IsCleared()) {
|
||||
|
@ -28,7 +28,7 @@ class UnalignedSlot {
|
||||
public:
|
||||
explicit UnalignedSlot(ObjectSlot slot) : ptr_(slot.address()) {}
|
||||
explicit UnalignedSlot(Address address) : ptr_(address) {}
|
||||
explicit UnalignedSlot(MaybeObject** slot)
|
||||
explicit UnalignedSlot(MaybeObject* slot)
|
||||
: ptr_(reinterpret_cast<Address>(slot)) {}
|
||||
explicit UnalignedSlot(Object** slot)
|
||||
: ptr_(reinterpret_cast<Address>(slot)) {}
|
||||
@ -42,16 +42,16 @@ class UnalignedSlot {
|
||||
|
||||
inline void Advance(int bytes = kPointerSize) { ptr_ += bytes; }
|
||||
|
||||
MaybeObject* Read() {
|
||||
MaybeObject* result;
|
||||
MaybeObject Read() {
|
||||
Address result;
|
||||
memcpy(&result, reinterpret_cast<void*>(ptr_), sizeof(result));
|
||||
return result;
|
||||
return MaybeObject(result);
|
||||
}
|
||||
MaybeObject* ReadPrevious() {
|
||||
MaybeObject* result;
|
||||
MaybeObject ReadPrevious() {
|
||||
Address result;
|
||||
memcpy(&result, reinterpret_cast<void*>(ptr_ - kPointerSize),
|
||||
sizeof(result));
|
||||
return result;
|
||||
return MaybeObject(result);
|
||||
}
|
||||
inline void Write(Address value) {
|
||||
memcpy(reinterpret_cast<void*>(ptr_), &value, sizeof(value));
|
||||
@ -66,9 +66,9 @@ class UnalignedSlot {
|
||||
|
||||
template <class AllocatorT>
|
||||
void Deserializer<AllocatorT>::UnalignedCopy(UnalignedSlot dest,
|
||||
MaybeObject* value) {
|
||||
MaybeObject value) {
|
||||
DCHECK(!allocator()->next_reference_is_weak());
|
||||
dest.Write(reinterpret_cast<Address>(value));
|
||||
dest.Write(value.ptr());
|
||||
}
|
||||
|
||||
template <class AllocatorT>
|
||||
@ -396,10 +396,9 @@ void Deserializer<AllocatorT>::ReadObject(
|
||||
obj = PostProcessNewObject(obj, space_number);
|
||||
}
|
||||
|
||||
MaybeObject* write_back_obj =
|
||||
reference_type == HeapObjectReferenceType::STRONG
|
||||
? HeapObjectReference::Strong(obj)
|
||||
: HeapObjectReference::Weak(obj);
|
||||
MaybeObject write_back_obj = reference_type == HeapObjectReferenceType::STRONG
|
||||
? HeapObjectReference::Strong(obj)
|
||||
: HeapObjectReference::Weak(obj);
|
||||
UnalignedCopy(write_back, write_back_obj);
|
||||
#ifdef DEBUG
|
||||
if (obj->IsCode()) {
|
||||
@ -412,7 +411,7 @@ void Deserializer<AllocatorT>::ReadObject(
|
||||
|
||||
template <class AllocatorT>
|
||||
Object* Deserializer<AllocatorT>::ReadDataSingle() {
|
||||
MaybeObject* o;
|
||||
MaybeObject o;
|
||||
UnalignedSlot start(&o);
|
||||
UnalignedSlot end(start.address() + kPointerSize);
|
||||
int source_space = NEW_SPACE;
|
||||
@ -663,7 +662,7 @@ bool Deserializer<AllocatorT>::ReadData(UnalignedSlot current,
|
||||
|
||||
case kVariableRepeat: {
|
||||
int repeats = source_.GetInt();
|
||||
MaybeObject* object = current.ReadPrevious();
|
||||
MaybeObject object = current.ReadPrevious();
|
||||
DCHECK(!Heap::InNewSpace(object));
|
||||
for (int i = 0; i < repeats; i++) {
|
||||
UnalignedCopy(current, object);
|
||||
@ -733,8 +732,7 @@ bool Deserializer<AllocatorT>::ReadData(UnalignedSlot current,
|
||||
SIXTEEN_CASES(kRootArrayConstants + 16) {
|
||||
int id = data & kRootArrayConstantsMask;
|
||||
RootIndex root_index = static_cast<RootIndex>(id);
|
||||
MaybeObject* object =
|
||||
MaybeObject::FromObject(isolate->root(root_index));
|
||||
MaybeObject object = MaybeObject::FromObject(isolate->root(root_index));
|
||||
DCHECK(!Heap::InNewSpace(object));
|
||||
UnalignedCopy(current, object);
|
||||
current.Advance();
|
||||
@ -753,7 +751,7 @@ bool Deserializer<AllocatorT>::ReadData(UnalignedSlot current,
|
||||
FOUR_CASES(kHotObject + 4) {
|
||||
int index = data & kHotObjectMask;
|
||||
Object* hot_object = hot_objects_.Get(index);
|
||||
MaybeObject* hot_maybe_object = MaybeObject::FromObject(hot_object);
|
||||
MaybeObject hot_maybe_object = MaybeObject::FromObject(hot_object);
|
||||
if (allocator()->GetAndClearNextReferenceIsWeak()) {
|
||||
hot_maybe_object = MaybeObject::MakeWeak(hot_maybe_object);
|
||||
}
|
||||
@ -781,7 +779,7 @@ bool Deserializer<AllocatorT>::ReadData(UnalignedSlot current,
|
||||
STATIC_ASSERT(kNumberOfFixedRepeat == 16);
|
||||
SIXTEEN_CASES(kFixedRepeat) {
|
||||
int repeats = data - kFixedRepeatStart;
|
||||
MaybeObject* object = current.ReadPrevious();
|
||||
MaybeObject object = current.ReadPrevious();
|
||||
DCHECK(!Heap::InNewSpace(object));
|
||||
for (int i = 0; i < repeats; i++) {
|
||||
UnalignedCopy(current, object);
|
||||
@ -911,7 +909,7 @@ UnalignedSlot Deserializer<AllocatorT>::ReadDataCase(
|
||||
current.Advance(skip);
|
||||
current_was_incremented = true;
|
||||
} else {
|
||||
MaybeObject* new_maybe_object = MaybeObject::FromObject(new_object);
|
||||
MaybeObject new_maybe_object = MaybeObject::FromObject(new_object);
|
||||
if (allocator()->GetAndClearNextReferenceIsWeak()) {
|
||||
new_maybe_object = MaybeObject::MakeWeak(new_maybe_object);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ class Deserializer : public SerializerDeserializer {
|
||||
|
||||
void Synchronize(VisitorSynchronization::SyncTag tag) override;
|
||||
|
||||
void UnalignedCopy(UnalignedSlot dest, MaybeObject* value);
|
||||
void UnalignedCopy(UnalignedSlot dest, MaybeObject value);
|
||||
void UnalignedCopy(UnalignedSlot dest, Address value);
|
||||
|
||||
// Fills in some heap data in an area from start to end (non-inclusive). The
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "src/objects/js-array-buffer-inl.h"
|
||||
#include "src/objects/js-array-inl.h"
|
||||
#include "src/objects/map.h"
|
||||
#include "src/objects/slots.h"
|
||||
#include "src/objects/slots-inl.h"
|
||||
#include "src/snapshot/builtin-serializer-allocator.h"
|
||||
#include "src/snapshot/natives.h"
|
||||
#include "src/snapshot/snapshot.h"
|
||||
|
@ -50,7 +50,7 @@ void TransitionArray::SetPrototypeTransitions(WeakFixedArray* transitions) {
|
||||
int TransitionArray::NumberOfPrototypeTransitions(
|
||||
WeakFixedArray* proto_transitions) {
|
||||
if (proto_transitions->length() == 0) return 0;
|
||||
MaybeObject* raw =
|
||||
MaybeObject raw =
|
||||
proto_transitions->Get(kProtoTransitionNumberOfEntriesOffset);
|
||||
return Smi::ToInt(raw->cast<Smi>());
|
||||
}
|
||||
@ -99,17 +99,17 @@ PropertyDetails TransitionsAccessor::GetTargetDetails(Name* name, Map* target) {
|
||||
}
|
||||
|
||||
// static
|
||||
Map* TransitionsAccessor::GetTargetFromRaw(MaybeObject* raw) {
|
||||
Map* TransitionsAccessor::GetTargetFromRaw(MaybeObject raw) {
|
||||
return Map::cast(raw->GetHeapObjectAssumeWeak());
|
||||
}
|
||||
|
||||
MaybeObject* TransitionArray::GetRawTarget(int transition_number) {
|
||||
MaybeObject TransitionArray::GetRawTarget(int transition_number) {
|
||||
DCHECK(transition_number < number_of_transitions());
|
||||
return Get(ToTargetIndex(transition_number));
|
||||
}
|
||||
|
||||
Map* TransitionArray::GetTarget(int transition_number) {
|
||||
MaybeObject* raw = GetRawTarget(transition_number);
|
||||
MaybeObject raw = GetRawTarget(transition_number);
|
||||
return TransitionsAccessor::GetTargetFromRaw(raw);
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ Map* TransitionsAccessor::GetTarget(int transition_number) {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
void TransitionArray::SetRawTarget(int transition_number, MaybeObject* value) {
|
||||
void TransitionArray::SetRawTarget(int transition_number, MaybeObject value) {
|
||||
DCHECK(transition_number < number_of_transitions());
|
||||
DCHECK(value->IsWeak());
|
||||
DCHECK(value->GetHeapObjectAssumeWeak()->IsMap());
|
||||
@ -136,7 +136,7 @@ void TransitionArray::SetRawTarget(int transition_number, MaybeObject* value) {
|
||||
|
||||
bool TransitionArray::GetTargetIfExists(int transition_number, Isolate* isolate,
|
||||
Map** target) {
|
||||
MaybeObject* raw = GetRawTarget(transition_number);
|
||||
MaybeObject raw = GetRawTarget(transition_number);
|
||||
HeapObject* heap_object;
|
||||
if (raw->GetHeapObjectIfStrong(&heap_object) &&
|
||||
heap_object->IsUndefined(isolate)) {
|
||||
@ -194,7 +194,7 @@ int TransitionArray::CompareDetails(PropertyKind kind1,
|
||||
}
|
||||
|
||||
void TransitionArray::Set(int transition_number, Name* key,
|
||||
MaybeObject* target) {
|
||||
MaybeObject target) {
|
||||
WeakFixedArray::Set(ToKeyIndex(transition_number),
|
||||
MaybeObject::FromObject(key));
|
||||
WeakFixedArray::Set(ToTargetIndex(transition_number), target);
|
||||
|
@ -316,7 +316,7 @@ bool TransitionArray::CompactPrototypeTransitionArray(Isolate* isolate,
|
||||
}
|
||||
int new_number_of_transitions = 0;
|
||||
for (int i = 0; i < number_of_transitions; i++) {
|
||||
MaybeObject* target = array->Get(header + i);
|
||||
MaybeObject target = array->Get(header + i);
|
||||
DCHECK(target->IsCleared() ||
|
||||
(target->IsWeak() && target->GetHeapObject()->IsMap()));
|
||||
if (!target->IsCleared()) {
|
||||
@ -327,7 +327,7 @@ bool TransitionArray::CompactPrototypeTransitionArray(Isolate* isolate,
|
||||
}
|
||||
}
|
||||
// Fill slots that became free with undefined value.
|
||||
MaybeObject* undefined =
|
||||
MaybeObject undefined =
|
||||
MaybeObject::FromObject(*isolate->factory()->undefined_value());
|
||||
for (int i = new_number_of_transitions; i < number_of_transitions; i++) {
|
||||
array->Set(header + i, undefined);
|
||||
@ -396,7 +396,7 @@ Handle<Map> TransitionsAccessor::GetPrototypeTransition(
|
||||
WeakFixedArray* cache = GetPrototypeTransitions();
|
||||
int length = TransitionArray::NumberOfPrototypeTransitions(cache);
|
||||
for (int i = 0; i < length; i++) {
|
||||
MaybeObject* target =
|
||||
MaybeObject target =
|
||||
cache->Get(TransitionArray::kProtoTransitionHeaderSize + i);
|
||||
DCHECK(target->IsWeakOrCleared());
|
||||
HeapObject* heap_object;
|
||||
@ -447,7 +447,7 @@ void TransitionArray::Zap(Isolate* isolate) {
|
||||
SetNumberOfTransitions(0);
|
||||
}
|
||||
|
||||
void TransitionsAccessor::ReplaceTransitions(MaybeObject* new_transitions) {
|
||||
void TransitionsAccessor::ReplaceTransitions(MaybeObject new_transitions) {
|
||||
if (encoding() == kFullTransitionArray) {
|
||||
TransitionArray* old_transitions = transitions();
|
||||
#if DEBUG
|
||||
@ -510,7 +510,7 @@ void TransitionsAccessor::TraverseTransitionTreeInternal(
|
||||
int length = TransitionArray::NumberOfPrototypeTransitions(proto_trans);
|
||||
for (int i = 0; i < length; ++i) {
|
||||
int index = TransitionArray::kProtoTransitionHeaderSize + i;
|
||||
MaybeObject* target = proto_trans->Get(index);
|
||||
MaybeObject target = proto_trans->Get(index);
|
||||
HeapObject* heap_object;
|
||||
if (target->GetHeapObjectIfWeak(&heap_object)) {
|
||||
TransitionsAccessor(isolate_, Map::cast(heap_object), no_gc)
|
||||
@ -596,7 +596,7 @@ void TransitionArray::Sort() {
|
||||
ReadOnlyRoots roots = GetReadOnlyRoots();
|
||||
for (int i = 1; i < length; i++) {
|
||||
Name* key = GetKey(i);
|
||||
MaybeObject* target = GetRawTarget(i);
|
||||
MaybeObject target = GetRawTarget(i);
|
||||
PropertyKind kind = kData;
|
||||
PropertyAttributes attributes = NONE;
|
||||
if (!TransitionsAccessor::IsSpecialTransition(roots, key)) {
|
||||
@ -609,7 +609,7 @@ void TransitionArray::Sort() {
|
||||
int j;
|
||||
for (j = i - 1; j >= 0; j--) {
|
||||
Name* temp_key = GetKey(j);
|
||||
MaybeObject* temp_target = GetRawTarget(j);
|
||||
MaybeObject temp_target = GetRawTarget(j);
|
||||
PropertyKind temp_kind = kData;
|
||||
PropertyAttributes temp_attributes = NONE;
|
||||
if (!TransitionsAccessor::IsSpecialTransition(roots, temp_key)) {
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "src/objects.h"
|
||||
#include "src/objects/descriptor-array.h"
|
||||
#include "src/objects/map.h"
|
||||
#include "src/objects/maybe-object.h"
|
||||
#include "src/objects/name.h"
|
||||
|
||||
// Has to be the last include (doesn't have include guards):
|
||||
@ -153,7 +154,7 @@ class TransitionsAccessor {
|
||||
return transition->instance_descriptors()->GetKey(descriptor);
|
||||
}
|
||||
|
||||
static inline Map* GetTargetFromRaw(MaybeObject* raw);
|
||||
static inline Map* GetTargetFromRaw(MaybeObject raw);
|
||||
|
||||
void MarkNeedsReload() {
|
||||
#if DEBUG
|
||||
@ -166,7 +167,7 @@ class TransitionsAccessor {
|
||||
inline Map* GetSimpleTransition();
|
||||
bool HasSimpleTransitionTo(Map* map);
|
||||
|
||||
void ReplaceTransitions(MaybeObject* new_transitions);
|
||||
void ReplaceTransitions(MaybeObject new_transitions);
|
||||
|
||||
inline Map* GetTargetMapFromWeakRef();
|
||||
|
||||
@ -182,7 +183,7 @@ class TransitionsAccessor {
|
||||
Isolate* isolate_;
|
||||
Handle<Map> map_handle_;
|
||||
Map* map_;
|
||||
MaybeObject* raw_transitions_;
|
||||
MaybeObject raw_transitions_;
|
||||
Encoding encoding_;
|
||||
#if DEBUG
|
||||
bool needs_reload_;
|
||||
@ -216,8 +217,8 @@ class TransitionArray : public WeakFixedArray {
|
||||
inline HeapObjectSlot GetKeySlot(int transition_number);
|
||||
|
||||
inline Map* GetTarget(int transition_number);
|
||||
inline void SetRawTarget(int transition_number, MaybeObject* target);
|
||||
inline MaybeObject* GetRawTarget(int transition_number);
|
||||
inline void SetRawTarget(int transition_number, MaybeObject target);
|
||||
inline MaybeObject GetRawTarget(int transition_number);
|
||||
inline HeapObjectSlot GetTargetSlot(int transition_number);
|
||||
inline bool GetTargetIfExists(int transition_number, Isolate* isolate,
|
||||
Map** target);
|
||||
@ -337,7 +338,7 @@ class TransitionArray : public WeakFixedArray {
|
||||
PropertyKind kind2,
|
||||
PropertyAttributes attributes2);
|
||||
|
||||
inline void Set(int transition_number, Name* key, MaybeObject* target);
|
||||
inline void Set(int transition_number, Name* key, MaybeObject target);
|
||||
|
||||
void Zap(Isolate* isolate);
|
||||
|
||||
|
@ -254,7 +254,7 @@ bool WasmModuleObject::SetBreakPoint(Handle<WasmModuleObject> module_object,
|
||||
Handle<WeakArrayList> weak_instance_list(module_object->weak_instance_list(),
|
||||
isolate);
|
||||
for (int i = 0; i < weak_instance_list->length(); ++i) {
|
||||
MaybeObject* maybe_instance = weak_instance_list->Get(i);
|
||||
MaybeObject maybe_instance = weak_instance_list->Get(i);
|
||||
if (maybe_instance->IsWeak()) {
|
||||
Handle<WasmInstanceObject> instance(
|
||||
WasmInstanceObject::cast(maybe_instance->GetHeapObjectAssumeWeak()),
|
||||
@ -1063,7 +1063,7 @@ int32_t WasmMemoryObject::Grow(Isolate* isolate,
|
||||
if (memory_object->has_instances()) {
|
||||
Handle<WeakArrayList> instances(memory_object->instances(), isolate);
|
||||
for (int i = 0; i < instances->length(); i++) {
|
||||
MaybeObject* elem = instances->Get(i);
|
||||
MaybeObject elem = instances->Get(i);
|
||||
HeapObject* heap_object;
|
||||
if (elem->GetHeapObjectIfWeak(&heap_object)) {
|
||||
Handle<WasmInstanceObject> instance(
|
||||
|
@ -2068,7 +2068,7 @@ void MacroAssembler::LoadWeakValue(Register in_out, Label* target_if_cleared) {
|
||||
cmpp(in_out, Immediate(kClearedWeakHeapObject));
|
||||
j(equal, target_if_cleared);
|
||||
|
||||
andp(in_out, Immediate(~kWeakHeapObjectMask));
|
||||
andp(in_out, Immediate(~static_cast<int32_t>(kWeakHeapObjectMask)));
|
||||
}
|
||||
|
||||
void MacroAssembler::IncrementCounter(StatsCounter* counter, int value) {
|
||||
|
@ -4140,13 +4140,13 @@ TEST(WeakFunctionInConstructor) {
|
||||
Handle<FeedbackVector> feedback_vector =
|
||||
Handle<FeedbackVector>(createObj->feedback_vector(), CcTest::i_isolate());
|
||||
for (int i = 0; i < 20; i++) {
|
||||
MaybeObject* slot_value = feedback_vector->Get(FeedbackSlot(0));
|
||||
MaybeObject slot_value = feedback_vector->Get(FeedbackSlot(0));
|
||||
CHECK(slot_value->IsWeakOrCleared());
|
||||
if (slot_value->IsCleared()) break;
|
||||
CcTest::CollectAllGarbage();
|
||||
}
|
||||
|
||||
MaybeObject* slot_value = feedback_vector->Get(FeedbackSlot(0));
|
||||
MaybeObject slot_value = feedback_vector->Get(FeedbackSlot(0));
|
||||
CHECK(slot_value->IsCleared());
|
||||
CompileRun(
|
||||
"function coat() { this.x = 6; }"
|
||||
|
@ -42,7 +42,7 @@ TEST(WeakReferencesBasic) {
|
||||
CreateFeedbackVectorForTest(CcTest::isolate(), factory);
|
||||
CHECK(Heap::InNewSpace(*fv));
|
||||
|
||||
MaybeObject* code_object = fv->optimized_code_weak_or_smi();
|
||||
MaybeObject code_object = fv->optimized_code_weak_or_smi();
|
||||
CHECK(code_object->IsSmi());
|
||||
CcTest::CollectAllGarbage();
|
||||
CHECK(Heap::InNewSpace(*fv));
|
||||
|
@ -421,7 +421,7 @@ TEST(InterpreterBinaryOpsBigInt) {
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK(return_value->IsBigInt());
|
||||
MaybeObject* feedback = callable.vector()->Get(slot);
|
||||
MaybeObject feedback = callable.vector()->Get(slot);
|
||||
CHECK(feedback->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kBigInt,
|
||||
feedback->cast<Smi>()->value());
|
||||
@ -542,7 +542,7 @@ TEST(InterpreterStringAdd) {
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK(return_value->SameValue(*test_cases[i].expected_value));
|
||||
|
||||
MaybeObject* feedback = callable.vector()->Get(slot);
|
||||
MaybeObject feedback = callable.vector()->Get(slot);
|
||||
CHECK(feedback->IsSmi());
|
||||
CHECK_EQ(test_cases[i].expected_feedback, feedback->cast<Smi>()->value());
|
||||
}
|
||||
@ -747,7 +747,7 @@ TEST(InterpreterBinaryOpTypeFeedback) {
|
||||
auto callable = tester.GetCallable<>();
|
||||
|
||||
Handle<Object> return_val = callable().ToHandleChecked();
|
||||
MaybeObject* feedback0 = callable.vector()->Get(slot0);
|
||||
MaybeObject feedback0 = callable.vector()->Get(slot0);
|
||||
CHECK(feedback0->IsSmi());
|
||||
CHECK_EQ(test_case.feedback, feedback0->cast<Smi>()->value());
|
||||
CHECK(Object::Equals(isolate, test_case.result, return_val).ToChecked());
|
||||
@ -853,7 +853,7 @@ TEST(InterpreterBinaryOpSmiTypeFeedback) {
|
||||
auto callable = tester.GetCallable<>();
|
||||
|
||||
Handle<Object> return_val = callable().ToHandleChecked();
|
||||
MaybeObject* feedback0 = callable.vector()->Get(slot0);
|
||||
MaybeObject feedback0 = callable.vector()->Get(slot0);
|
||||
CHECK(feedback0->IsSmi());
|
||||
CHECK_EQ(test_case.feedback, feedback0->cast<Smi>()->value());
|
||||
CHECK(Object::Equals(isolate, test_case.result, return_val).ToChecked());
|
||||
@ -924,24 +924,24 @@ TEST(InterpreterUnaryOpFeedback) {
|
||||
test_case.bigint_feedback_value, test_case.any_feedback_value)
|
||||
.ToHandleChecked();
|
||||
USE(return_val);
|
||||
MaybeObject* feedback0 = callable.vector()->Get(slot0);
|
||||
MaybeObject feedback0 = callable.vector()->Get(slot0);
|
||||
CHECK(feedback0->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kSignedSmall,
|
||||
feedback0->cast<Smi>()->value());
|
||||
|
||||
MaybeObject* feedback1 = callable.vector()->Get(slot1);
|
||||
MaybeObject feedback1 = callable.vector()->Get(slot1);
|
||||
CHECK(feedback1->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kNumber, feedback1->cast<Smi>()->value());
|
||||
|
||||
MaybeObject* feedback2 = callable.vector()->Get(slot2);
|
||||
MaybeObject feedback2 = callable.vector()->Get(slot2);
|
||||
CHECK(feedback2->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kNumber, feedback2->cast<Smi>()->value());
|
||||
|
||||
MaybeObject* feedback3 = callable.vector()->Get(slot3);
|
||||
MaybeObject feedback3 = callable.vector()->Get(slot3);
|
||||
CHECK(feedback3->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kBigInt, feedback3->cast<Smi>()->value());
|
||||
|
||||
MaybeObject* feedback4 = callable.vector()->Get(slot4);
|
||||
MaybeObject feedback4 = callable.vector()->Get(slot4);
|
||||
CHECK(feedback4->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kAny, feedback4->cast<Smi>()->value());
|
||||
}
|
||||
@ -986,16 +986,16 @@ TEST(InterpreterBitwiseTypeFeedback) {
|
||||
Handle<Object> return_val =
|
||||
callable(arg1, arg2, arg3, arg4).ToHandleChecked();
|
||||
USE(return_val);
|
||||
MaybeObject* feedback0 = callable.vector()->Get(slot0);
|
||||
MaybeObject feedback0 = callable.vector()->Get(slot0);
|
||||
CHECK(feedback0->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kSignedSmall,
|
||||
feedback0->cast<Smi>()->value());
|
||||
|
||||
MaybeObject* feedback1 = callable.vector()->Get(slot1);
|
||||
MaybeObject feedback1 = callable.vector()->Get(slot1);
|
||||
CHECK(feedback1->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kNumber, feedback1->cast<Smi>()->value());
|
||||
|
||||
MaybeObject* feedback2 = callable.vector()->Get(slot2);
|
||||
MaybeObject feedback2 = callable.vector()->Get(slot2);
|
||||
CHECK(feedback2->IsSmi());
|
||||
CHECK_EQ(BinaryOperationFeedback::kAny, feedback2->cast<Smi>()->value());
|
||||
}
|
||||
@ -1816,7 +1816,7 @@ TEST(InterpreterSmiComparisons) {
|
||||
CHECK(return_value->IsBoolean());
|
||||
CHECK_EQ(return_value->BooleanValue(isolate),
|
||||
CompareC(comparison, inputs[i], inputs[j]));
|
||||
MaybeObject* feedback = callable.vector()->Get(slot);
|
||||
MaybeObject feedback = callable.vector()->Get(slot);
|
||||
CHECK(feedback->IsSmi());
|
||||
CHECK_EQ(CompareOperationFeedback::kSignedSmall,
|
||||
feedback->cast<Smi>()->value());
|
||||
@ -1865,7 +1865,7 @@ TEST(InterpreterHeapNumberComparisons) {
|
||||
CHECK(return_value->IsBoolean());
|
||||
CHECK_EQ(return_value->BooleanValue(isolate),
|
||||
CompareC(comparison, inputs[i], inputs[j]));
|
||||
MaybeObject* feedback = callable.vector()->Get(slot);
|
||||
MaybeObject feedback = callable.vector()->Get(slot);
|
||||
CHECK(feedback->IsSmi());
|
||||
CHECK_EQ(CompareOperationFeedback::kNumber,
|
||||
feedback->cast<Smi>()->value());
|
||||
@ -1908,7 +1908,7 @@ TEST(InterpreterBigIntComparisons) {
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK(return_value->IsBoolean());
|
||||
MaybeObject* feedback = callable.vector()->Get(slot);
|
||||
MaybeObject feedback = callable.vector()->Get(slot);
|
||||
CHECK(feedback->IsSmi());
|
||||
CHECK_EQ(CompareOperationFeedback::kBigInt,
|
||||
feedback->cast<Smi>()->value());
|
||||
@ -1956,7 +1956,7 @@ TEST(InterpreterStringComparisons) {
|
||||
CHECK(return_value->IsBoolean());
|
||||
CHECK_EQ(return_value->BooleanValue(isolate),
|
||||
CompareC(comparison, inputs[i], inputs[j]));
|
||||
MaybeObject* feedback = callable.vector()->Get(slot);
|
||||
MaybeObject feedback = callable.vector()->Get(slot);
|
||||
CHECK(feedback->IsSmi());
|
||||
int const expected_feedback =
|
||||
Token::IsOrderedRelationalCompareOp(comparison)
|
||||
@ -2071,7 +2071,7 @@ TEST(InterpreterMixedComparisons) {
|
||||
CHECK(return_value->IsBoolean());
|
||||
CHECK_EQ(return_value->BooleanValue(isolate),
|
||||
CompareC(comparison, lhs, rhs, true));
|
||||
MaybeObject* feedback = callable.vector()->Get(slot);
|
||||
MaybeObject feedback = callable.vector()->Get(slot);
|
||||
CHECK(feedback->IsSmi());
|
||||
// Comparison with a number and string collects kAny feedback.
|
||||
CHECK_EQ(CompareOperationFeedback::kAny,
|
||||
|
@ -227,8 +227,8 @@ TEST(TryProbeStubCache) {
|
||||
int index = rand_gen.NextInt();
|
||||
Handle<Name> name = names[index % names.size()];
|
||||
Handle<JSObject> receiver = receivers[index % receivers.size()];
|
||||
MaybeObject* handler = stub_cache.Get(*name, receiver->map());
|
||||
if (handler == nullptr) {
|
||||
MaybeObject handler = stub_cache.Get(*name, receiver->map());
|
||||
if (handler.ptr() == kNullAddress) {
|
||||
queried_non_existing = true;
|
||||
} else {
|
||||
queried_existing = true;
|
||||
@ -243,8 +243,8 @@ TEST(TryProbeStubCache) {
|
||||
int index2 = rand_gen.NextInt();
|
||||
Handle<Name> name = names[index1 % names.size()];
|
||||
Handle<JSObject> receiver = receivers[index2 % receivers.size()];
|
||||
MaybeObject* handler = stub_cache.Get(*name, receiver->map());
|
||||
if (handler == nullptr) {
|
||||
MaybeObject handler = stub_cache.Get(*name, receiver->map());
|
||||
if (handler.ptr() == kNullAddress) {
|
||||
queried_non_existing = true;
|
||||
} else {
|
||||
queried_existing = true;
|
||||
|
@ -315,7 +315,7 @@ TEST(FeedbackVectorPreservedAcrossRecompiles) {
|
||||
Handle<FeedbackVector> feedback_vector(f->feedback_vector(), f->GetIsolate());
|
||||
CHECK(!feedback_vector->is_empty());
|
||||
FeedbackSlot slot_for_a(0);
|
||||
MaybeObject* object = feedback_vector->Get(slot_for_a);
|
||||
MaybeObject object = feedback_vector->Get(slot_for_a);
|
||||
{
|
||||
HeapObject* heap_object;
|
||||
CHECK(object->GetHeapObjectIfWeak(&heap_object));
|
||||
|
@ -3622,7 +3622,7 @@ void CheckSFIsAreWeak(WeakFixedArray* sfis, Isolate* isolate) {
|
||||
CHECK_GT(sfis->length(), 0);
|
||||
int no_of_weak = 0;
|
||||
for (int i = 0; i < sfis->length(); ++i) {
|
||||
MaybeObject* maybe_object = sfis->Get(i);
|
||||
MaybeObject maybe_object = sfis->Get(i);
|
||||
HeapObject* heap_object;
|
||||
CHECK(maybe_object->IsWeakOrCleared() ||
|
||||
(maybe_object->GetHeapObjectIfStrong(&heap_object) &&
|
||||
|
Loading…
Reference in New Issue
Block a user