[in-place weak refs] Cleanup: rename CSA functions

See https://chromium-review.googlesource.com/1219025 for the corresponding
MaybeObject renaming.

BUG=v8:7308

Change-Id: Ib454fd53d12f110da289e1d3e1e12411b016e557
Reviewed-on: https://chromium-review.googlesource.com/c/1267937
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56443}
This commit is contained in:
Marja Hölttä 2018-10-08 11:00:25 +02:00 committed by Commit Bot
parent 3e43ded932
commit 3d32fbc1c6
7 changed files with 73 additions and 73 deletions

View File

@ -86,7 +86,7 @@ void LazyBuiltinsAssembler::MaybeTailCallOptimizedCodeSlot(
{
// Optimized code slot is a weak reference.
TNode<Code> optimized_code =
CAST(ToWeakHeapObject(maybe_optimized_code_entry, &fallthrough));
CAST(GetHeapObjectAssumeWeak(maybe_optimized_code_entry, &fallthrough));
// Check if the optimized code is marked for deopt. If it is, call the
// runtime to clear it.

View File

@ -1140,7 +1140,7 @@ TF_BUILTIN(CreateObjectWithoutProperties, ObjectBuiltinsAssembler) {
TNode<MaybeObject> maybe_map = LoadMaybeWeakObjectField(
prototype_info, PrototypeInfo::kObjectCreateMapOffset);
GotoIf(IsStrongReferenceTo(maybe_map, UndefinedConstant()), &call_runtime);
map.Bind(ToWeakHeapObject(maybe_map, &call_runtime));
map.Bind(GetHeapObjectAssumeWeak(maybe_map, &call_runtime));
Goto(&instantiate_map);
}
@ -1236,7 +1236,7 @@ TF_BUILTIN(ObjectCreate, ObjectBuiltinsAssembler) {
prototype_info, PrototypeInfo::kObjectCreateMapOffset);
GotoIf(IsStrongReferenceTo(maybe_map, UndefinedConstant()),
&call_runtime);
map.Bind(ToWeakHeapObject(maybe_map, &call_runtime));
map.Bind(GetHeapObjectAssumeWeak(maybe_map, &call_runtime));
Goto(&instantiate_map);
}

View File

@ -1394,14 +1394,14 @@ Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset,
Node* CodeStubAssembler::LoadObjectField(SloppyTNode<HeapObject> object,
int offset, MachineType rep) {
CSA_ASSERT(this, IsStrongHeapObject(object));
CSA_ASSERT(this, IsStrong(object));
return Load(rep, object, IntPtrConstant(offset - kHeapObjectTag));
}
Node* CodeStubAssembler::LoadObjectField(SloppyTNode<HeapObject> object,
SloppyTNode<IntPtrT> offset,
MachineType rep) {
CSA_ASSERT(this, IsStrongHeapObject(object));
CSA_ASSERT(this, IsStrong(object));
return Load(rep, object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)));
}
@ -1858,49 +1858,46 @@ void CodeStubAssembler::DispatchMaybeObject(TNode<MaybeObject> maybe_object,
Goto(if_strong);
}
TNode<BoolT> CodeStubAssembler::IsStrongHeapObject(TNode<MaybeObject> value) {
TNode<BoolT> CodeStubAssembler::IsStrong(TNode<MaybeObject> value) {
return WordEqual(WordAnd(BitcastMaybeObjectToWord(value),
IntPtrConstant(kHeapObjectTagMask)),
IntPtrConstant(kHeapObjectTag));
}
TNode<HeapObject> CodeStubAssembler::ToStrongHeapObject(
TNode<HeapObject> CodeStubAssembler::GetHeapObjectIfStrong(
TNode<MaybeObject> value, Label* if_not_strong) {
GotoIfNot(IsStrongHeapObject(value), if_not_strong);
GotoIfNot(IsStrong(value), if_not_strong);
return CAST(value);
}
TNode<BoolT> CodeStubAssembler::IsWeakOrClearedHeapObject(
TNode<MaybeObject> value) {
TNode<BoolT> CodeStubAssembler::IsWeakOrCleared(TNode<MaybeObject> value) {
return WordEqual(WordAnd(BitcastMaybeObjectToWord(value),
IntPtrConstant(kHeapObjectTagMask)),
IntPtrConstant(kWeakHeapObjectTag));
}
TNode<BoolT> CodeStubAssembler::IsClearedWeakHeapObject(
TNode<MaybeObject> value) {
TNode<BoolT> CodeStubAssembler::IsCleared(TNode<MaybeObject> value) {
return WordEqual(BitcastMaybeObjectToWord(value),
IntPtrConstant(kClearedWeakHeapObject));
}
TNode<BoolT> CodeStubAssembler::IsNotClearedWeakHeapObject(
TNode<MaybeObject> value) {
TNode<BoolT> CodeStubAssembler::IsNotCleared(TNode<MaybeObject> value) {
return WordNotEqual(BitcastMaybeObjectToWord(value),
IntPtrConstant(kClearedWeakHeapObject));
}
TNode<HeapObject> CodeStubAssembler::ToWeakHeapObject(
TNode<HeapObject> CodeStubAssembler::GetHeapObjectAssumeWeak(
TNode<MaybeObject> value) {
CSA_ASSERT(this, IsWeakOrClearedHeapObject(value));
CSA_ASSERT(this, IsNotClearedWeakHeapObject(value));
CSA_ASSERT(this, IsWeakOrCleared(value));
CSA_ASSERT(this, IsNotCleared(value));
return UncheckedCast<HeapObject>(BitcastWordToTagged(WordAnd(
BitcastMaybeObjectToWord(value), IntPtrConstant(~kWeakHeapObjectMask))));
}
TNode<HeapObject> CodeStubAssembler::ToWeakHeapObject(TNode<MaybeObject> value,
Label* if_cleared) {
GotoIf(IsClearedWeakHeapObject(value), if_cleared);
return ToWeakHeapObject(value);
TNode<HeapObject> CodeStubAssembler::GetHeapObjectAssumeWeak(
TNode<MaybeObject> value, Label* if_cleared) {
GotoIf(IsCleared(value), if_cleared);
return GetHeapObjectAssumeWeak(value);
}
TNode<BoolT> CodeStubAssembler::IsWeakReferenceTo(TNode<MaybeObject> object,

View File

@ -960,23 +960,23 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
Label* if_cleared, Label* if_weak, Label* if_strong,
TVariable<Object>* extracted);
// See MaybeObject for semantics of these functions.
TNode<BoolT> IsStrongHeapObject(TNode<MaybeObject> value);
TNode<BoolT> IsStrong(TNode<MaybeObject> value);
// This variant is for overzealous checking.
TNode<BoolT> IsStrongHeapObject(TNode<Object> value) {
return IsStrongHeapObject(ReinterpretCast<MaybeObject>(value));
TNode<BoolT> IsStrong(TNode<Object> value) {
return IsStrong(ReinterpretCast<MaybeObject>(value));
}
TNode<HeapObject> ToStrongHeapObject(TNode<MaybeObject> value,
Label* if_not_strong);
TNode<HeapObject> GetHeapObjectIfStrong(TNode<MaybeObject> value,
Label* if_not_strong);
TNode<BoolT> IsWeakOrClearedHeapObject(TNode<MaybeObject> value);
TNode<BoolT> IsClearedWeakHeapObject(TNode<MaybeObject> value);
TNode<BoolT> IsNotClearedWeakHeapObject(TNode<MaybeObject> value);
TNode<BoolT> IsWeakOrCleared(TNode<MaybeObject> value);
TNode<BoolT> IsCleared(TNode<MaybeObject> value);
TNode<BoolT> IsNotCleared(TNode<MaybeObject> value);
// Removes the weak bit + asserts it was set.
TNode<HeapObject> ToWeakHeapObject(TNode<MaybeObject> value);
TNode<HeapObject> GetHeapObjectAssumeWeak(TNode<MaybeObject> value);
TNode<HeapObject> ToWeakHeapObject(TNode<MaybeObject> value,
Label* if_cleared);
TNode<HeapObject> GetHeapObjectAssumeWeak(TNode<MaybeObject> value,
Label* if_cleared);
TNode<BoolT> IsWeakReferenceTo(TNode<MaybeObject> object,
TNode<Object> value);

View File

@ -129,7 +129,7 @@ void AccessorAssembler::HandlePolymorphicCase(
Label next_entry(this);
TNode<MaybeObject> maybe_cached_map =
LoadWeakFixedArrayElement(feedback, map_index);
CSA_ASSERT(this, IsWeakOrClearedHeapObject(maybe_cached_map));
CSA_ASSERT(this, IsWeakOrCleared(maybe_cached_map));
GotoIf(IsNotWeakReferenceTo(maybe_cached_map, CAST(receiver_map)),
&next_entry);
@ -153,7 +153,7 @@ void AccessorAssembler::HandlePolymorphicCase(
Label next_entry(this);
TNode<MaybeObject> maybe_cached_map =
LoadWeakFixedArrayElement(feedback, index);
CSA_ASSERT(this, IsWeakOrClearedHeapObject(maybe_cached_map));
CSA_ASSERT(this, IsWeakOrCleared(maybe_cached_map));
GotoIf(IsNotWeakReferenceTo(maybe_cached_map, CAST(receiver_map)),
&next_entry);
@ -243,9 +243,9 @@ void AccessorAssembler::HandleLoadAccessor(
[=] { return LoadHandlerDataField(handler, 3); },
[=] { return LoadHandlerDataField(handler, 2); });
CSA_ASSERT(this, IsWeakOrClearedHeapObject(maybe_context));
CSA_CHECK(this, IsNotClearedWeakHeapObject(maybe_context));
TNode<Object> context = ToWeakHeapObject(maybe_context);
CSA_ASSERT(this, IsWeakOrCleared(maybe_context));
CSA_CHECK(this, IsNotCleared(maybe_context));
TNode<Object> context = GetHeapObjectAssumeWeak(maybe_context);
GotoIf(IsRuntimeCallStatsEnabled(), &runtime);
{
@ -702,8 +702,9 @@ Node* AccessorAssembler::HandleProtoHandler(
BIND(&if_do_access_check);
{
TNode<MaybeObject> data2 = LoadHandlerDataField(handler, 2);
CSA_ASSERT(this, IsWeakOrClearedHeapObject(data2));
TNode<Object> expected_native_context = ToWeakHeapObject(data2, miss);
CSA_ASSERT(this, IsWeakOrCleared(data2));
TNode<Object> expected_native_context =
GetHeapObjectAssumeWeak(data2, miss);
EmitAccessCheck(expected_native_context, p->context, p->receiver, &done,
miss);
}
@ -775,8 +776,8 @@ void AccessorAssembler::HandleLoadICProtoHandler(
// For regular holders, having passed the receiver map check and the
// validity cell check implies that |holder| is alive. However, for global
// object receivers, |maybe_holder| may be cleared.
CSA_ASSERT(this, IsWeakOrClearedHeapObject(maybe_holder));
Node* holder = ToWeakHeapObject(maybe_holder, miss);
CSA_ASSERT(this, IsWeakOrCleared(maybe_holder));
Node* holder = GetHeapObjectAssumeWeak(maybe_holder, miss);
var_holder->Bind(holder);
Goto(&done);
@ -914,7 +915,7 @@ void AccessorAssembler::HandleStoreICHandlerCase(
BIND(&if_nonsmi_handler);
{
GotoIf(IsWeakOrClearedHeapObject(handler), &store_transition_or_global);
GotoIf(IsWeakOrCleared(handler), &store_transition_or_global);
TNode<HeapObject> strong_handler = CAST(handler);
TNode<Map> handler_map = LoadMap(strong_handler);
Branch(IsCodeMap(handler_map), &call_handler, &if_proto_handler);
@ -937,8 +938,9 @@ void AccessorAssembler::HandleStoreICHandlerCase(
BIND(&store_transition_or_global);
{
// Load value or miss if the {handler} weak cell is cleared.
CSA_ASSERT(this, IsWeakOrClearedHeapObject(handler));
TNode<HeapObject> map_or_property_cell = ToWeakHeapObject(handler, miss);
CSA_ASSERT(this, IsWeakOrCleared(handler));
TNode<HeapObject> map_or_property_cell =
GetHeapObjectAssumeWeak(handler, miss);
Label store_global(this), store_transition(this);
Branch(IsMap(map_or_property_cell), &store_transition, &store_global);
@ -1070,7 +1072,8 @@ void AccessorAssembler::CheckFieldType(TNode<DescriptorArray> descriptors,
&all_fine);
// Cleared weak references count as FieldType::None, which can't hold any
// value.
TNode<Map> field_type_map = CAST(ToWeakHeapObject(field_type, bailout));
TNode<Map> field_type_map =
CAST(GetHeapObjectAssumeWeak(field_type, bailout));
// FieldType::Class(...) performs a map check.
Branch(WordEqual(LoadMap(value), field_type_map), &all_fine, bailout);
}
@ -1280,7 +1283,7 @@ void AccessorAssembler::HandleStoreICProtoHandler(
TNode<MaybeObject> maybe_transition_map =
LoadHandlerDataField(handler, 1);
TNode<Map> transition_map =
CAST(ToWeakHeapObject(maybe_transition_map, miss));
CAST(GetHeapObjectAssumeWeak(maybe_transition_map, miss));
GotoIf(IsDeprecatedMap(transition_map), miss);
@ -1322,8 +1325,8 @@ void AccessorAssembler::HandleStoreICProtoHandler(
&if_add_normal);
TNode<MaybeObject> maybe_holder = LoadHandlerDataField(handler, 1);
CSA_ASSERT(this, IsWeakOrClearedHeapObject(maybe_holder));
TNode<Object> holder = ToWeakHeapObject(maybe_holder, miss);
CSA_ASSERT(this, IsWeakOrCleared(maybe_holder));
TNode<Object> holder = GetHeapObjectAssumeWeak(maybe_holder, miss);
GotoIf(WordEqual(handler_kind, IntPtrConstant(StoreHandler::kGlobalProxy)),
&if_store_global_proxy);
@ -1384,11 +1387,10 @@ void AccessorAssembler::HandleStoreICProtoHandler(
[=] { return LoadHandlerDataField(handler, 3); },
[=] { return LoadHandlerDataField(handler, 2); });
CSA_ASSERT(this, IsWeakOrClearedHeapObject(maybe_context));
TNode<Object> context =
Select<Object>(IsClearedWeakHeapObject(maybe_context),
[=] { return SmiConstant(0); },
[=] { return ToWeakHeapObject(maybe_context); });
CSA_ASSERT(this, IsWeakOrCleared(maybe_context));
TNode<Object> context = Select<Object>(
IsCleared(maybe_context), [=] { return SmiConstant(0); },
[=] { return GetHeapObjectAssumeWeak(maybe_context); });
Node* foreign = LoadObjectField(call_handler_info,
CallHandlerInfo::kJsCallbackOffset);
@ -1585,7 +1587,7 @@ Node* AccessorAssembler::PrepareValueForStore(Node* handler_word, Node* holder,
GotoIf(TaggedIsSmi(maybe_field_type), &done);
// Check that value type matches the field type.
{
Node* field_type = ToWeakHeapObject(maybe_field_type, bailout);
Node* field_type = GetHeapObjectAssumeWeak(maybe_field_type, bailout);
Branch(WordEqual(LoadMap(value), field_type), &done, bailout);
}
BIND(&done);
@ -2405,7 +2407,8 @@ void AccessorAssembler::LoadIC_BytecodeHandler(const LoadICParameters* p,
BIND(&try_polymorphic);
{
TNode<HeapObject> strong_feedback = ToStrongHeapObject(feedback, &miss);
TNode<HeapObject> strong_feedback =
GetHeapObjectIfStrong(feedback, &miss);
GotoIfNot(IsWeakFixedArrayMap(LoadMap(strong_feedback)), &stub_call);
HandlePolymorphicCase(recv_map, CAST(strong_feedback), &if_handler,
&var_handler, &miss, 2);
@ -2453,7 +2456,7 @@ void AccessorAssembler::LoadIC(const LoadICParameters* p) {
HandleLoadICHandlerCase(p, CAST(var_handler.value()), &miss, &direct_exit);
BIND(&try_polymorphic);
TNode<HeapObject> strong_feedback = ToStrongHeapObject(feedback, &miss);
TNode<HeapObject> strong_feedback = GetHeapObjectIfStrong(feedback, &miss);
{
// Check polymorphic case.
Comment("LoadIC_try_polymorphic");
@ -2589,9 +2592,9 @@ void AccessorAssembler::LoadGlobalIC_TryPropertyCellCase(
BIND(&if_property_cell);
{
// Load value or try handler case if the weak reference is cleared.
CSA_ASSERT(this, IsWeakOrClearedHeapObject(maybe_weak_ref));
CSA_ASSERT(this, IsWeakOrCleared(maybe_weak_ref));
TNode<PropertyCell> property_cell =
CAST(ToWeakHeapObject(maybe_weak_ref, try_handler));
CAST(GetHeapObjectAssumeWeak(maybe_weak_ref, try_handler));
TNode<Object> value =
LoadObjectField(property_cell, PropertyCell::kValueOffset);
GotoIf(WordEqual(value, TheHoleConstant()), miss);
@ -2668,7 +2671,7 @@ void AccessorAssembler::KeyedLoadIC(const LoadICParameters* p) {
}
BIND(&try_polymorphic);
TNode<HeapObject> strong_feedback = ToStrongHeapObject(feedback, &miss);
TNode<HeapObject> strong_feedback = GetHeapObjectIfStrong(feedback, &miss);
{
// Check polymorphic case.
Comment("KeyedLoadIC_try_polymorphic");
@ -2890,7 +2893,7 @@ void AccessorAssembler::StoreIC(const StoreICParameters* p) {
}
BIND(&try_polymorphic);
TNode<HeapObject> strong_feedback = ToStrongHeapObject(feedback, &miss);
TNode<HeapObject> strong_feedback = GetHeapObjectIfStrong(feedback, &miss);
{
// Check polymorphic case.
Comment("StoreIC_try_polymorphic");
@ -2934,9 +2937,9 @@ void AccessorAssembler::StoreGlobalIC(const StoreICParameters* pp) {
BIND(&if_property_cell);
{
Label try_handler(this), miss(this, Label::kDeferred);
CSA_ASSERT(this, IsWeakOrClearedHeapObject(maybe_weak_ref));
CSA_ASSERT(this, IsWeakOrCleared(maybe_weak_ref));
TNode<PropertyCell> property_cell =
CAST(ToWeakHeapObject(maybe_weak_ref, &try_handler));
CAST(GetHeapObjectAssumeWeak(maybe_weak_ref, &try_handler));
ExitPoint direct_exit(this);
StoreGlobalIC_PropertyCellCase(property_cell, pp->value, &direct_exit,
@ -3071,7 +3074,7 @@ void AccessorAssembler::KeyedStoreIC(const StoreICParameters* p) {
}
BIND(&try_polymorphic);
TNode<HeapObject> strong_feedback = ToStrongHeapObject(feedback, &miss);
TNode<HeapObject> strong_feedback = GetHeapObjectIfStrong(feedback, &miss);
{
// CheckPolymorphic case.
Comment("KeyedStoreIC_try_polymorphic");
@ -3145,7 +3148,7 @@ void AccessorAssembler::StoreInArrayLiteralIC(const StoreICParameters* p) {
TNode<MaybeObject> maybe_transition_map =
LoadHandlerDataField(CAST(handler), 1);
TNode<Map> transition_map =
CAST(ToWeakHeapObject(maybe_transition_map, &miss));
CAST(GetHeapObjectAssumeWeak(maybe_transition_map, &miss));
GotoIf(IsDeprecatedMap(transition_map), &miss);
Node* code = LoadObjectField(handler, StoreHandler::kSmiHandlerOffset);
CSA_ASSERT(this, IsCode(code));
@ -3155,7 +3158,7 @@ void AccessorAssembler::StoreInArrayLiteralIC(const StoreICParameters* p) {
}
BIND(&try_polymorphic);
TNode<HeapObject> strong_feedback = ToStrongHeapObject(feedback, &miss);
TNode<HeapObject> strong_feedback = GetHeapObjectIfStrong(feedback, &miss);
{
Comment("StoreInArrayLiteralIC_try_polymorphic");
GotoIfNot(IsWeakFixedArrayMap(LoadMap(strong_feedback)),
@ -3644,7 +3647,7 @@ void AccessorAssembler::GenerateCloneObjectIC() {
}
BIND(&try_polymorphic);
TNode<HeapObject> strong_feedback = ToStrongHeapObject(feedback, &miss);
TNode<HeapObject> strong_feedback = GetHeapObjectIfStrong(feedback, &miss);
{
Comment("CloneObjectIC_try_polymorphic");
GotoIfNot(IsWeakFixedArrayMap(LoadMap(strong_feedback)), &try_megamorphic);

View File

@ -740,7 +740,7 @@ TNode<Map> KeyedStoreGenericAssembler::FindCandidateStoreICTransitionMapHandler(
const int kKeyToTargetOffset = (TransitionArray::kEntryTargetIndex -
TransitionArray::kEntryKeyIndex) *
kPointerSize;
var_transition_map = CAST(ToWeakHeapObject(
var_transition_map = CAST(GetHeapObjectAssumeWeak(
LoadArrayElement(transitions, WeakFixedArray::kHeaderSize,
var_name_index.value(), kKeyToTargetOffset)));
Goto(&found_handler_candidate);

View File

@ -744,12 +744,12 @@ void InterpreterAssembler::CollectCallableFeedback(Node* target, Node* context,
feedback,
HeapConstant(FeedbackVector::UninitializedSentinel(isolate())));
GotoIf(is_uninitialized, &initialize);
CSA_ASSERT(this, IsWeakOrClearedHeapObject(feedback));
CSA_ASSERT(this, IsWeakOrCleared(feedback));
// If the weak reference is cleared, we have a new chance to become
// monomorphic.
Comment("check if weak reference is cleared");
Branch(IsClearedWeakHeapObject(feedback), &initialize, &mark_megamorphic);
Branch(IsCleared(feedback), &initialize, &mark_megamorphic);
BIND(&initialize);
{
@ -948,12 +948,12 @@ Node* InterpreterAssembler::Construct(Node* target, Node* context,
GotoIf(is_megamorphic, &construct);
Comment("check if weak reference");
GotoIfNot(IsWeakOrClearedHeapObject(feedback), &check_allocation_site);
GotoIfNot(IsWeakOrCleared(feedback), &check_allocation_site);
// If the weak reference is cleared, we have a new chance to become
// monomorphic.
Comment("check if weak reference is cleared");
Branch(IsClearedWeakHeapObject(feedback), &initialize, &mark_megamorphic);
Branch(IsCleared(feedback), &initialize, &mark_megamorphic);
BIND(&check_allocation_site);
{
@ -1127,12 +1127,12 @@ Node* InterpreterAssembler::ConstructWithSpread(Node* target, Node* context,
GotoIf(is_megamorphic, &construct);
Comment("check if weak reference");
GotoIfNot(IsWeakOrClearedHeapObject(feedback), &check_initialized);
GotoIfNot(IsWeakOrCleared(feedback), &check_initialized);
// If the weak reference is cleared, we have a new chance to become
// monomorphic.
Comment("check if weak reference is cleared");
Branch(IsClearedWeakHeapObject(feedback), &initialize, &mark_megamorphic);
Branch(IsCleared(feedback), &initialize, &mark_megamorphic);
BIND(&check_initialized);
{