bool is_computed_name)
: key_(key),
value_(value),
- ic_slot_or_count_(FeedbackVectorICSlot::Invalid().ToInt()),
+ slot_(FeedbackVectorICSlot::Invalid()),
kind_(kind),
emit_store_(true),
is_static_(is_static),
bool is_computed_name)
: key_(key),
value_(value),
- ic_slot_or_count_(FeedbackVectorICSlot::Invalid().ToInt()),
+ slot_(FeedbackVectorICSlot::Invalid()),
emit_store_(true),
is_static_(is_static),
is_computed_name_(is_computed_name) {
// This logic that computes the number of slots needed for vector store
// ICs must mirror FullCodeGenerator::VisitClassLiteral.
- int ic_slots = 0;
if (NeedsProxySlot()) {
- ic_slots++;
+ slot_ = spec->AddStoreICSlot();
}
for (int i = 0; i < properties()->length(); i++) {
ObjectLiteral::Property* property = properties()->at(i);
- // In case we don't end up using any slots.
- property->set_ic_slot_count(0);
-
Expression* value = property->value();
if (FunctionLiteral::NeedsHomeObject(value)) {
- property->set_ic_slot_count(1);
- ic_slots++;
+ property->set_slot(spec->AddStoreICSlot());
}
}
-
- if (ic_slots > 0) {
- slot_ = spec->AddStoreICSlots(ic_slots);
- }
-}
-
-
-void ClassLiteral::LayoutFeedbackSlots() {
- int base_slot = slot_.ToInt();
- if (NeedsProxySlot()) base_slot++;
-
- for (int i = 0; i < properties()->length(); i++) {
- ObjectLiteral::Property* property = properties()->at(i);
- base_slot += property->set_base_slot(base_slot);
- }
}
}
-void ObjectLiteral::LayoutFeedbackSlots() {
- int base_slot = slot_.ToInt();
- for (int i = 0; i < properties()->length(); i++) {
- ObjectLiteral::Property* property = properties()->at(i);
- base_slot += property->set_base_slot(base_slot);
- }
-}
-
-
void ObjectLiteral::AssignFeedbackVectorSlots(Isolate* isolate,
FeedbackVectorSpec* spec,
ICSlotCache* cache) {
int property_index = 0;
for (; property_index < properties()->length(); property_index++) {
ObjectLiteral::Property* property = properties()->at(property_index);
- // In case we don't end up using any slots.
- property->set_ic_slot_count(0);
-
if (property->is_computed_name()) break;
if (property->IsCompileTimeValue()) continue;
// contains computed properties with an uninitialized value.
if (key->value()->IsInternalizedString()) {
if (property->emit_store()) {
- int slot_count = 1;
+ property->set_slot(spec->AddStoreICSlot());
if (FunctionLiteral::NeedsHomeObject(value)) {
- slot_count++;
+ spec->AddStoreICSlot();
}
- property->set_ic_slot_count(slot_count);
}
break;
}
if (property->emit_store() && FunctionLiteral::NeedsHomeObject(value)) {
- property->set_ic_slot_count(1);
+ property->set_slot(spec->AddStoreICSlot());
}
break;
case ObjectLiteral::Property::PROTOTYPE:
break;
case ObjectLiteral::Property::GETTER:
if (property->emit_store() && FunctionLiteral::NeedsHomeObject(value)) {
- property->set_ic_slot_count(1);
+ property->set_slot(spec->AddStoreICSlot());
}
break;
case ObjectLiteral::Property::SETTER:
if (property->emit_store() && FunctionLiteral::NeedsHomeObject(value)) {
- property->set_ic_slot_count(1);
+ property->set_slot(spec->AddStoreICSlot());
}
break;
}
Expression* value = property->value();
if (property->kind() != ObjectLiteral::Property::PROTOTYPE) {
if (FunctionLiteral::NeedsHomeObject(value)) {
- property->set_ic_slot_count(1);
+ property->set_slot(spec->AddStoreICSlot());
}
}
}
-
- // How many slots did we allocate?
- int ic_slots = 0;
- for (int i = 0; i < properties()->length(); i++) {
- ObjectLiteral::Property* property = properties()->at(i);
- ic_slots += property->ic_slot_count();
- }
-
- if (ic_slots > 0) {
- slot_ = spec->AddStoreICSlots(ic_slots);
- }
}
bool is_computed_name() const { return is_computed_name_; }
FeedbackVectorICSlot GetSlot(int offset = 0) const {
- if (ic_slot_or_count_ == FeedbackVectorICSlot::Invalid().ToInt()) {
- return FeedbackVectorICSlot::Invalid();
- }
- return FeedbackVectorICSlot(ic_slot_or_count_ + offset);
- }
-
- int ic_slot_count() const {
- if (ic_slot_or_count_ == FeedbackVectorICSlot::Invalid().ToInt()) {
- return 0;
- }
- return ic_slot_or_count_;
+ if (slot_.IsInvalid()) return slot_;
+ int slot = slot_.ToInt();
+ return FeedbackVectorICSlot(slot + offset);
}
+ FeedbackVectorICSlot slot() const { return slot_; }
+ void set_slot(FeedbackVectorICSlot slot) { slot_ = slot; }
void set_receiver_type(Handle<Map> map) { receiver_type_ = map; }
- void set_ic_slot_count(int count) {
- // Should only be called once.
- if (count == 0) {
- ic_slot_or_count_ = FeedbackVectorICSlot::Invalid().ToInt();
- } else {
- ic_slot_or_count_ = count;
- }
- }
-
- int set_base_slot(int slot) {
- if (ic_slot_count() > 0) {
- int count = ic_slot_count();
- ic_slot_or_count_ = slot;
- return count;
- }
- return 0;
- }
protected:
friend class AstNodeFactory;
private:
Expression* key_;
Expression* value_;
- int ic_slot_or_count_;
+ FeedbackVectorICSlot slot_;
Kind kind_;
bool emit_store_;
bool is_static_;
void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
ICSlotCache* cache) override;
- // After feedback slots were assigned, propagate information to the properties
- // which need it.
- void LayoutFeedbackSlots();
-
protected:
ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index,
int boilerplate_properties, bool has_function, bool is_strong,
FeedbackVectorICSlot ProxySlot() const { return slot_; }
- // After feedback slots were assigned, propagate information to the properties
- // which need it.
- void LayoutFeedbackSlots();
-
protected:
ClassLiteral(Zone* zone, const AstRawString* name, Scope* scope,
VariableProxy* class_variable_proxy, Expression* extends,