[cleanpup][ic] Tnodify accessor-assembler

Bug: v8:9810
Change-Id: I30c6265904c43ec86abc91a28d789fe5bfb22694
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1910106
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64934}
This commit is contained in:
Mythri A 2019-11-12 12:34:50 +00:00 committed by Commit Bot
parent 53201194d2
commit 1f1e4cdb04
4 changed files with 318 additions and 303 deletions

File diff suppressed because it is too large Load Diff

View File

@ -55,26 +55,30 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
void GenerateStoreInArrayLiteralIC(); void GenerateStoreInArrayLiteralIC();
void TryProbeStubCache(StubCache* stub_cache, Node* receiver, void TryProbeStubCache(StubCache* stub_cache, TNode<Object> receiver,
TNode<Object> name, Label* if_handler, TNode<Name> name, Label* if_handler,
TVariable<MaybeObject>* var_handler, Label* if_miss); TVariable<MaybeObject>* var_handler, Label* if_miss);
Node* StubCachePrimaryOffsetForTesting(Node* name, Node* map) { TNode<IntPtrT> StubCachePrimaryOffsetForTesting(TNode<Name> name,
TNode<Map> map) {
return StubCachePrimaryOffset(name, map); return StubCachePrimaryOffset(name, map);
} }
Node* StubCacheSecondaryOffsetForTesting(Node* name, Node* map) { TNode<IntPtrT> StubCacheSecondaryOffsetForTesting(TNode<Name> name,
return StubCacheSecondaryOffset(name, map); TNode<IntPtrT> seed) {
return StubCacheSecondaryOffset(name, seed);
} }
struct LoadICParameters { struct LoadICParameters {
LoadICParameters(TNode<Context> context, Node* receiver, TNode<Object> name, LoadICParameters(TNode<Context> context,
TNode<Smi> slot, Node* vector, Node* holder = nullptr) base::Optional<TNode<Object>> receiver, TNode<Object> name,
TNode<Smi> slot, TNode<HeapObject> vector,
base::Optional<TNode<Object>> holder = base::nullopt)
: context_(context), : context_(context),
receiver_(receiver), receiver_(receiver),
name_(name), name_(name),
slot_(slot), slot_(slot),
vector_(vector), vector_(vector),
holder_(holder ? holder : receiver) {} holder_(holder ? holder.value() : receiver) {}
LoadICParameters(const LoadICParameters* p, TNode<Object> unique_name) LoadICParameters(const LoadICParameters* p, TNode<Object> unique_name)
: context_(p->context_), : context_(p->context_),
@ -85,31 +89,33 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
holder_(p->holder_) {} holder_(p->holder_) {}
TNode<Context> context() const { return context_; } TNode<Context> context() const { return context_; }
Node* receiver() const { return receiver_; } TNode<Object> receiver() const { return receiver_.value(); }
TNode<Object> name() const { return name_; } TNode<Object> name() const { return name_; }
TNode<Smi> slot() const { return slot_; } TNode<Smi> slot() const { return slot_; }
Node* vector() const { return vector_; } TNode<HeapObject> vector() const { return vector_; }
Node* holder() const { return holder_; } TNode<Object> holder() const { return holder_.value(); }
bool receiver_is_null() const { return !receiver_.has_value(); }
private: private:
TNode<Context> context_; TNode<Context> context_;
Node* receiver_; base::Optional<TNode<Object>> receiver_;
TNode<Object> name_; TNode<Object> name_;
TNode<Smi> slot_; TNode<Smi> slot_;
Node* vector_; TNode<HeapObject> vector_;
Node* holder_; base::Optional<TNode<Object>> holder_;
}; };
struct LazyLoadICParameters { struct LazyLoadICParameters {
LazyLoadICParameters(LazyNode<Context> context, Node* receiver, LazyLoadICParameters(LazyNode<Context> context, TNode<Object> receiver,
LazyNode<Object> name, LazyNode<Smi> slot, LazyNode<Object> name, LazyNode<Smi> slot,
Node* vector, Node* holder = nullptr) TNode<HeapObject> vector,
base::Optional<TNode<Object>> holder = base::nullopt)
: context_(context), : context_(context),
receiver_(receiver), receiver_(receiver),
name_(name), name_(name),
slot_(slot), slot_(slot),
vector_(vector), vector_(vector),
holder_(holder ? holder : receiver) {} holder_(holder ? holder.value() : receiver) {}
explicit LazyLoadICParameters(const LoadICParameters* p) explicit LazyLoadICParameters(const LoadICParameters* p)
: receiver_(p->receiver()), : receiver_(p->receiver()),
@ -121,19 +127,19 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
} }
TNode<Context> context() const { return context_(); } TNode<Context> context() const { return context_(); }
Node* receiver() const { return receiver_; } TNode<Object> receiver() const { return receiver_; }
TNode<Object> name() const { return name_(); } TNode<Object> name() const { return name_(); }
TNode<Smi> slot() const { return slot_(); } TNode<Smi> slot() const { return slot_(); }
Node* vector() const { return vector_; } TNode<HeapObject> vector() const { return vector_; }
Node* holder() const { return holder_; } TNode<Object> holder() const { return holder_; }
private: private:
LazyNode<Context> context_; LazyNode<Context> context_;
Node* receiver_; TNode<Object> receiver_;
LazyNode<Object> name_; LazyNode<Object> name_;
LazyNode<Smi> slot_; LazyNode<Smi> slot_;
Node* vector_; TNode<HeapObject> vector_;
Node* holder_; TNode<Object> holder_;
}; };
void LoadGlobalIC(TNode<HeapObject> maybe_feedback_vector, void LoadGlobalIC(TNode<HeapObject> maybe_feedback_vector,
@ -149,21 +155,22 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
ExitPoint* exit_point); ExitPoint* exit_point);
// Loads dataX field from the DataHandler object. // Loads dataX field from the DataHandler object.
TNode<MaybeObject> LoadHandlerDataField(SloppyTNode<DataHandler> handler, TNode<MaybeObject> LoadHandlerDataField(TNode<DataHandler> handler,
int data_index); int data_index);
protected: protected:
struct StoreICParameters : public LoadICParameters { struct StoreICParameters : public LoadICParameters {
StoreICParameters(TNode<Context> context, Node* receiver, StoreICParameters(TNode<Context> context,
TNode<Object> name, SloppyTNode<Object> value, base::Optional<TNode<Object>> receiver,
TNode<Smi> slot, Node* vector) TNode<Object> name, TNode<Object> value, TNode<Smi> slot,
TNode<HeapObject> vector)
: LoadICParameters(context, receiver, name, slot, vector), : LoadICParameters(context, receiver, name, slot, vector),
value_(value) {} value_(value) {}
SloppyTNode<Object> value() const { return value_; } TNode<Object> value() const { return value_; }
private: private:
SloppyTNode<Object> value_; TNode<Object> value_;
}; };
enum class LoadAccessMode { kLoad, kHas }; enum class LoadAccessMode { kLoad, kHas };
@ -186,9 +193,10 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
void JumpIfDataProperty(TNode<Uint32T> details, Label* writable, void JumpIfDataProperty(TNode<Uint32T> details, Label* writable,
Label* readonly); Label* readonly);
void InvalidateValidityCellIfPrototype(Node* map, Node* bitfield3 = nullptr); void InvalidateValidityCellIfPrototype(
TNode<Map> map, base::Optional<TNode<Uint32T>> bitfield3 = base::nullopt);
void OverwriteExistingFastDataProperty(SloppyTNode<HeapObject> object, void OverwriteExistingFastDataProperty(TNode<HeapObject> object,
TNode<Map> object_map, TNode<Map> object_map,
TNode<DescriptorArray> descriptors, TNode<DescriptorArray> descriptors,
TNode<IntPtrT> descriptor_name_index, TNode<IntPtrT> descriptor_name_index,
@ -198,7 +206,7 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
void CheckFieldType(TNode<DescriptorArray> descriptors, void CheckFieldType(TNode<DescriptorArray> descriptors,
TNode<IntPtrT> name_index, TNode<Word32T> representation, TNode<IntPtrT> name_index, TNode<Word32T> representation,
Node* value, Label* bailout); TNode<Object> value, Label* bailout);
private: private:
// Stub generation entry points. // Stub generation entry points.
@ -226,7 +234,8 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
LoadAccessMode access_mode); LoadAccessMode access_mode);
void StoreIC(const StoreICParameters* p); void StoreIC(const StoreICParameters* p);
void StoreGlobalIC(const StoreICParameters* p); void StoreGlobalIC(const StoreICParameters* p);
void StoreGlobalIC_PropertyCellCase(Node* property_cell, TNode<Object> value, void StoreGlobalIC_PropertyCellCase(TNode<PropertyCell> property_cell,
TNode<Object> value,
ExitPoint* exit_point, Label* miss); ExitPoint* exit_point, Label* miss);
void KeyedStoreIC(const StoreICParameters* p); void KeyedStoreIC(const StoreICParameters* p);
void StoreInArrayLiteralIC(const StoreICParameters* p); void StoreInArrayLiteralIC(const StoreICParameters* p);
@ -250,15 +259,18 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
ElementSupport support_elements = kOnlyProperties, ElementSupport support_elements = kOnlyProperties,
LoadAccessMode access_mode = LoadAccessMode::kLoad); LoadAccessMode access_mode = LoadAccessMode::kLoad);
void HandleLoadICSmiHandlerCase( void HandleLoadICSmiHandlerCase(const LazyLoadICParameters* p,
const LazyLoadICParameters* p, SloppyTNode<HeapObject> holder, TNode<Object> holder, TNode<Smi> smi_handler,
SloppyTNode<Smi> smi_handler, SloppyTNode<Object> handler, Label* miss, TNode<Object> handler, Label* miss,
ExitPoint* exit_point, ICMode ic_mode, OnNonExistent on_nonexistent, ExitPoint* exit_point, ICMode ic_mode,
ElementSupport support_elements, LoadAccessMode access_mode); OnNonExistent on_nonexistent,
ElementSupport support_elements,
LoadAccessMode access_mode);
void HandleLoadICProtoHandler(const LazyLoadICParameters* p, void HandleLoadICProtoHandler(const LazyLoadICParameters* p,
TNode<DataHandler> handler, TNode<DataHandler> handler,
Variable* var_holder, Variable* var_smi_handler, TVariable<Object>* var_holder,
TVariable<Object>* var_smi_handler,
Label* if_smi_handler, Label* miss, Label* if_smi_handler, Label* miss,
ExitPoint* exit_point, ICMode ic_mode, ExitPoint* exit_point, ICMode ic_mode,
LoadAccessMode access_mode); LoadAccessMode access_mode);
@ -273,7 +285,7 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
TNode<WordT> handler_word, TNode<DataHandler> handler, TNode<WordT> handler_word, TNode<DataHandler> handler,
TNode<IntPtrT> handler_kind, ExitPoint* exit_point); TNode<IntPtrT> handler_kind, ExitPoint* exit_point);
void HandleLoadField(SloppyTNode<JSObject> holder, TNode<WordT> handler_word, void HandleLoadField(TNode<JSObject> holder, TNode<WordT> handler_word,
Variable* var_double_value, Label* rebox_double, Variable* var_double_value, Label* rebox_double,
Label* miss, ExitPoint* exit_point); Label* miss, ExitPoint* exit_point);
@ -282,15 +294,14 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
Label* can_access, Label* miss); Label* can_access, Label* miss);
void HandleLoadICSmiHandlerLoadNamedCase( void HandleLoadICSmiHandlerLoadNamedCase(
const LazyLoadICParameters* p, TNode<HeapObject> holder, const LazyLoadICParameters* p, TNode<Object> holder,
TNode<IntPtrT> handler_kind, TNode<WordT> handler_word, TNode<IntPtrT> handler_kind, TNode<WordT> handler_word,
Label* rebox_double, Variable* var_double_value, Label* rebox_double, Variable* var_double_value, TNode<Object> handler,
SloppyTNode<Object> handler, Label* miss, ExitPoint* exit_point, Label* miss, ExitPoint* exit_point, ICMode ic_mode,
ICMode ic_mode, OnNonExistent on_nonexistent, OnNonExistent on_nonexistent, ElementSupport support_elements);
ElementSupport support_elements);
void HandleLoadICSmiHandlerHasNamedCase(const LazyLoadICParameters* p, void HandleLoadICSmiHandlerHasNamedCase(const LazyLoadICParameters* p,
TNode<HeapObject> holder, TNode<Object> holder,
TNode<IntPtrT> handler_kind, TNode<IntPtrT> handler_kind,
Label* miss, ExitPoint* exit_point, Label* miss, ExitPoint* exit_point,
ICMode ic_mode); ICMode ic_mode);
@ -322,9 +333,9 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
TNode<StoreHandler> handler, Label* miss, TNode<StoreHandler> handler, Label* miss,
ICMode ic_mode, ICMode ic_mode,
ElementSupport support_elements); ElementSupport support_elements);
void HandleStoreICSmiHandlerCase(SloppyTNode<Word32T> handler_word, void HandleStoreICSmiHandlerCase(TNode<Word32T> handler_word,
SloppyTNode<JSObject> holder, TNode<JSObject> holder, TNode<Object> value,
SloppyTNode<Object> value, Label* miss); Label* miss);
void HandleStoreFieldAndReturn(TNode<Word32T> handler_word, void HandleStoreFieldAndReturn(TNode<Word32T> handler_word,
TNode<JSObject> holder, TNode<Object> value, TNode<JSObject> holder, TNode<Object> value,
base::Optional<TNode<Float64T>> double_value, base::Optional<TNode<Float64T>> double_value,
@ -333,25 +344,24 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
void CheckPrototypeValidityCell(TNode<Object> maybe_validity_cell, void CheckPrototypeValidityCell(TNode<Object> maybe_validity_cell,
Label* miss); Label* miss);
void HandleStoreICNativeDataProperty(const StoreICParameters* p, void HandleStoreICNativeDataProperty(const StoreICParameters* p,
SloppyTNode<HeapObject> holder, TNode<HeapObject> holder,
TNode<Word32T> handler_word); TNode<Word32T> handler_word);
void HandleStoreToProxy(const StoreICParameters* p, Node* proxy, Label* miss, void HandleStoreToProxy(const StoreICParameters* p, TNode<JSProxy> proxy,
ElementSupport support_elements); Label* miss, ElementSupport support_elements);
void HandleStoreAccessor(const StoreICParameters* p, void HandleStoreAccessor(const StoreICParameters* p, TNode<HeapObject> holder,
SloppyTNode<HeapObject> holder,
TNode<Word32T> handler_word); TNode<Word32T> handler_word);
// KeyedLoadIC_Generic implementation. // KeyedLoadIC_Generic implementation.
void GenericElementLoad(Node* receiver, TNode<Map> receiver_map, void GenericElementLoad(TNode<HeapObject> receiver, TNode<Map> receiver_map,
SloppyTNode<Int32T> instance_type, Node* index, TNode<Int32T> instance_type, TNode<IntPtrT> index,
Label* slow); Label* slow);
enum UseStubCache { kUseStubCache, kDontUseStubCache }; enum UseStubCache { kUseStubCache, kDontUseStubCache };
void GenericPropertyLoad(Node* receiver, TNode<Map> receiver_map, void GenericPropertyLoad(TNode<HeapObject> receiver, TNode<Map> receiver_map,
SloppyTNode<Int32T> instance_type, TNode<Int32T> instance_type,
const LoadICParameters* p, Label* slow, const LoadICParameters* p, Label* slow,
UseStubCache use_stub_cache = kUseStubCache); UseStubCache use_stub_cache = kUseStubCache);
@ -380,20 +390,21 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
// Extends properties backing store by JSObject::kFieldsAdded elements, // Extends properties backing store by JSObject::kFieldsAdded elements,
// returns updated properties backing store. // returns updated properties backing store.
Node* ExtendPropertiesBackingStore(Node* object, Node* index); TNode<PropertyArray> ExtendPropertiesBackingStore(TNode<HeapObject> object,
TNode<IntPtrT> index);
void EmitFastElementsBoundsCheck(Node* object, Node* elements, void EmitFastElementsBoundsCheck(TNode<JSObject> object,
Node* intptr_index, TNode<FixedArrayBase> elements,
Node* is_jsarray_condition, Label* miss); TNode<IntPtrT> intptr_index,
void EmitElementLoad(Node* object, TNode<Word32T> elements_kind, TNode<BoolT> is_jsarray_condition,
SloppyTNode<IntPtrT> key, Node* is_jsarray_condition, Label* miss);
void EmitElementLoad(TNode<HeapObject> object, TNode<Word32T> elements_kind,
TNode<IntPtrT> key, TNode<BoolT> is_jsarray_condition,
Label* if_hole, Label* rebox_double, Label* if_hole, Label* rebox_double,
Variable* var_double_value, TVariable<Float64T>* var_double_value,
Label* unimplemented_elements_kind, Label* out_of_bounds, Label* unimplemented_elements_kind, Label* out_of_bounds,
Label* miss, ExitPoint* exit_point, Label* miss, ExitPoint* exit_point,
LoadAccessMode access_mode = LoadAccessMode::kLoad); LoadAccessMode access_mode = LoadAccessMode::kLoad);
void NameDictionaryNegativeLookup(Node* object, SloppyTNode<Name> name,
Label* miss);
TNode<BoolT> IsPropertyDetailsConst(TNode<Uint32T> details); TNode<BoolT> IsPropertyDetailsConst(TNode<Uint32T> details);
// Stub cache access helpers. // Stub cache access helpers.
@ -402,11 +413,12 @@ class V8_EXPORT_PRIVATE AccessorAssembler : public CodeStubAssembler {
// including stub cache header. // including stub cache header.
enum StubCacheTable : int; enum StubCacheTable : int;
Node* StubCachePrimaryOffset(Node* name, Node* map); TNode<IntPtrT> StubCachePrimaryOffset(TNode<Name> name, TNode<Map> map);
Node* StubCacheSecondaryOffset(Node* name, Node* seed); TNode<IntPtrT> StubCacheSecondaryOffset(TNode<Name> name,
TNode<IntPtrT> seed);
void TryProbeStubCacheTable(StubCache* stub_cache, StubCacheTable table_id, void TryProbeStubCacheTable(StubCache* stub_cache, StubCacheTable table_id,
Node* entry_offset, TNode<Object> name, TNode<IntPtrT> entry_offset, TNode<Object> name,
TNode<Map> map, Label* if_handler, TNode<Map> map, Label* if_handler,
TVariable<MaybeObject>* var_handler, TVariable<MaybeObject>* var_handler,
Label* if_miss); Label* if_miss);
@ -445,7 +457,7 @@ class ExitPoint {
} }
template <class... TArgs> template <class... TArgs>
void ReturnCallRuntime(Runtime::FunctionId function, Node* context, void ReturnCallRuntime(Runtime::FunctionId function, TNode<Context> context,
TArgs... args) { TArgs... args) {
if (IsDirect()) { if (IsDirect()) {
asm_->TailCallRuntime(function, context, args...); asm_->TailCallRuntime(function, context, args...);
@ -455,7 +467,8 @@ class ExitPoint {
} }
template <class... TArgs> template <class... TArgs>
void ReturnCallStub(Callable const& callable, Node* context, TArgs... args) { void ReturnCallStub(Callable const& callable, TNode<Context> context,
TArgs... args) {
if (IsDirect()) { if (IsDirect()) {
asm_->TailCallStub(callable, context, args...); asm_->TailCallStub(callable, context, args...);
} else { } else {
@ -464,8 +477,9 @@ class ExitPoint {
} }
template <class... TArgs> template <class... TArgs>
void ReturnCallStub(const CallInterfaceDescriptor& descriptor, Node* target, void ReturnCallStub(const CallInterfaceDescriptor& descriptor,
Node* context, TArgs... args) { TNode<Code> target, TNode<Context> context,
TArgs... args) {
if (IsDirect()) { if (IsDirect()) {
asm_->TailCallStub(descriptor, target, context, args...); asm_->TailCallStub(descriptor, target, context, args...);
} else { } else {

View File

@ -1023,7 +1023,7 @@ void KeyedStoreGenericAssembler::KeyedStoreGeneric(
{ {
Comment("key is unique name"); Comment("key is unique name");
StoreICParameters p(context, receiver, var_unique.value(), value, {}, StoreICParameters p(context, receiver, var_unique.value(), value, {},
nullptr); UndefinedConstant());
ExitPoint direct_exit(this); ExitPoint direct_exit(this);
EmitGenericPropertyStore(CAST(receiver), receiver_map, &p, &direct_exit, EmitGenericPropertyStore(CAST(receiver), receiver_map, &p, &direct_exit,
&slow, language_mode); &slow, language_mode);
@ -1112,7 +1112,8 @@ void KeyedStoreGenericAssembler::SetProperty(TNode<Context> context,
TNode<Name> unique_name, TNode<Name> unique_name,
TNode<Object> value, TNode<Object> value,
LanguageMode language_mode) { LanguageMode language_mode) {
StoreICParameters p(context, receiver, unique_name, value, {}, nullptr); StoreICParameters p(context, receiver, unique_name, value, {},
UndefinedConstant());
Label done(this), slow(this, Label::kDeferred); Label done(this), slow(this, Label::kDeferred);
ExitPoint exit_point(this, [&](TNode<Object> result) { Goto(&done); }); ExitPoint exit_point(this, [&](TNode<Object> result) { Goto(&done); });

View File

@ -28,9 +28,10 @@ void TestStubCacheOffsetCalculation(StubCache::Table table) {
AccessorAssembler m(data.state()); AccessorAssembler m(data.state());
{ {
Node* name = m.Parameter(0); TNode<Name> name = m.CAST(m.Parameter(0));
Node* map = m.Parameter(1); TNode<Map> map = m.CAST(m.Parameter(1));
Node* primary_offset = m.StubCachePrimaryOffsetForTesting(name, map); TNode<IntPtrT> primary_offset =
m.StubCachePrimaryOffsetForTesting(name, map);
Node* result; Node* result;
if (table == StubCache::kPrimary) { if (table == StubCache::kPrimary) {
result = primary_offset; result = primary_offset;
@ -59,7 +60,6 @@ void TestStubCacheOffsetCalculation(StubCache::Table table) {
}; };
Handle<Map> maps[] = { Handle<Map> maps[] = {
Handle<Map>(Map(), isolate),
factory->cell_map(), factory->cell_map(),
Map::Create(isolate, 0), Map::Create(isolate, 0),
factory->meta_map(), factory->meta_map(),
@ -128,8 +128,8 @@ TEST(TryProbeStubCache) {
stub_cache.Clear(); stub_cache.Clear();
{ {
Node* receiver = m.Parameter(0); TNode<Object> receiver = m.CAST(m.Parameter(0));
TNode<Object> name = m.CAST(m.Parameter(1)); TNode<Name> name = m.CAST(m.Parameter(1));
TNode<MaybeObject> expected_handler = TNode<MaybeObject> expected_handler =
m.UncheckedCast<MaybeObject>(m.Parameter(2)); m.UncheckedCast<MaybeObject>(m.Parameter(2));