Index: src/ast.h |
diff --git a/src/ast.h b/src/ast.h |
index 9784797d843feab16868485a8dc998ea060c0003..d87565f538df59fb614512f27490c84aa5330709 100644 |
--- a/src/ast.h |
+++ b/src/ast.h |
@@ -138,14 +138,14 @@ typedef ZoneList<Handle<Object>> ZoneObjectList; |
friend class AstNodeFactory; |
-class ICSlotCache { |
+class FeedbackVectorSlotCache { |
public: |
- explicit ICSlotCache(Zone* zone) |
+ explicit FeedbackVectorSlotCache(Zone* zone) |
: zone_(zone), |
hash_map_(HashMap::PointersMatch, ZoneHashMap::kDefaultHashMapCapacity, |
ZoneAllocationPolicy(zone)) {} |
- void Put(Variable* variable, FeedbackVectorICSlot slot) { |
+ void Put(Variable* variable, FeedbackVectorSlot slot) { |
ZoneHashMap::Entry* entry = hash_map_.LookupOrInsert( |
variable, ComputePointerHash(variable), ZoneAllocationPolicy(zone_)); |
entry->value = reinterpret_cast<void*>(slot.ToInt()); |
@@ -230,7 +230,7 @@ class AstNode: public ZoneObject { |
// vtable entry per node, something we don't want for space reasons. |
virtual void AssignFeedbackVectorSlots(Isolate* isolate, |
FeedbackVectorSpec* spec, |
- ICSlotCache* cache) {} |
+ FeedbackVectorSlotCache* cache) {} |
private: |
// Hidden to prevent accidental usage. It would have to load the |
@@ -777,20 +777,17 @@ class ForEachStatement : public IterationStatement { |
Expression* subject() const { return subject_; } |
void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
- ICSlotCache* cache) override; |
- FeedbackVectorICSlot EachFeedbackSlot() const { return each_slot_; } |
+ FeedbackVectorSlotCache* cache) override; |
+ FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; } |
protected: |
ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
- : IterationStatement(zone, labels, pos), |
- each_(NULL), |
- subject_(NULL), |
- each_slot_(FeedbackVectorICSlot::Invalid()) {} |
+ : IterationStatement(zone, labels, pos), each_(NULL), subject_(NULL) {} |
private: |
Expression* each_; |
Expression* subject_; |
- FeedbackVectorICSlot each_slot_; |
+ FeedbackVectorSlot each_slot_; |
}; |
@@ -804,9 +801,9 @@ class ForInStatement final : public ForEachStatement { |
// Type feedback information. |
void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
- ICSlotCache* cache) override { |
+ FeedbackVectorSlotCache* cache) override { |
ForEachStatement::AssignFeedbackVectorSlots(isolate, spec, cache); |
- for_in_feedback_slot_ = spec->AddStubSlot(); |
+ for_in_feedback_slot_ = spec->AddGeneralSlot(); |
} |
FeedbackVectorSlot ForInFeedbackSlot() { |
@@ -830,9 +827,7 @@ class ForInStatement final : public ForEachStatement { |
protected: |
ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
- : ForEachStatement(zone, labels, pos), |
- for_in_type_(SLOW_FOR_IN), |
- for_in_feedback_slot_(FeedbackVectorSlot::Invalid()) {} |
+ : ForEachStatement(zone, labels, pos), for_in_type_(SLOW_FOR_IN) {} |
static int parent_num_ids() { return ForEachStatement::num_ids(); } |
private: |
@@ -1383,13 +1378,14 @@ class ObjectLiteralProperty final : public ZoneObject { |
bool is_static() const { return is_static_; } |
bool is_computed_name() const { return is_computed_name_; } |
- FeedbackVectorICSlot GetSlot(int offset = 0) const { |
- if (slot_.IsInvalid()) return slot_; |
- int slot = slot_.ToInt(); |
- return FeedbackVectorICSlot(slot + offset); |
+ FeedbackVectorSlot GetSlot(int offset = 0) const { |
+ DCHECK_LT(offset, static_cast<int>(arraysize(slots_))); |
+ return slots_[offset]; |
+ } |
+ void SetSlot(FeedbackVectorSlot slot, int offset = 0) { |
+ DCHECK_LT(offset, static_cast<int>(arraysize(slots_))); |
+ slots_[offset] = slot; |
} |
- FeedbackVectorICSlot slot() const { return slot_; } |
- void set_slot(FeedbackVectorICSlot slot) { slot_ = slot; } |
void set_receiver_type(Handle<Map> map) { receiver_type_ = map; } |
@@ -1405,7 +1401,7 @@ class ObjectLiteralProperty final : public ZoneObject { |
private: |
Expression* key_; |
Expression* value_; |
- FeedbackVectorICSlot slot_; |
+ FeedbackVectorSlot slots_[2]; |
Kind kind_; |
bool emit_store_; |
bool is_static_; |
@@ -1486,7 +1482,7 @@ class ObjectLiteral final : public MaterializedLiteral { |
// Object literals need one feedback slot for each non-trivial value, as well |
// as some slots for home objects. |
void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
- ICSlotCache* cache) override; |
+ FeedbackVectorSlotCache* cache) override; |
protected: |
ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, |
@@ -1498,9 +1494,7 @@ class ObjectLiteral final : public MaterializedLiteral { |
fast_elements_(false), |
has_elements_(false), |
may_store_doubles_(false), |
- has_function_(has_function), |
- slot_(FeedbackVectorICSlot::Invalid()) { |
- } |
+ has_function_(has_function) {} |
static int parent_num_ids() { return MaterializedLiteral::num_ids(); } |
private: |
@@ -1512,7 +1506,7 @@ class ObjectLiteral final : public MaterializedLiteral { |
bool has_elements_; |
bool may_store_doubles_; |
bool has_function_; |
- FeedbackVectorICSlot slot_; |
+ FeedbackVectorSlot slot_; |
}; |
@@ -1656,11 +1650,9 @@ class VariableProxy final : public Expression { |
} |
void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
- ICSlotCache* cache) override; |
+ FeedbackVectorSlotCache* cache) override; |
- FeedbackVectorICSlot VariableFeedbackSlot() { |
- return variable_feedback_slot_; |
- } |
+ FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; } |
static int num_ids() { return parent_num_ids() + 1; } |
BailoutId BeforeId() const { return BailoutId(local_id(0)); } |
@@ -1683,7 +1675,7 @@ class VariableProxy final : public Expression { |
// Start with 16-bit (or smaller) field, which should get packed together |
// with Expression's trailing 16-bit field. |
uint8_t bit_field_; |
- FeedbackVectorICSlot variable_feedback_slot_; |
+ FeedbackVectorSlot variable_feedback_slot_; |
union { |
const AstRawString* raw_name_; // if !is_resolved_ |
Variable* var_; // if is_resolved_ |
@@ -1755,14 +1747,14 @@ class Property final : public Expression { |
bool IsSuperAccess() { return obj()->IsSuperPropertyReference(); } |
void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
- ICSlotCache* cache) override { |
+ FeedbackVectorSlotCache* cache) override { |
FeedbackVectorSlotKind kind = key()->IsPropertyName() |
? FeedbackVectorSlotKind::LOAD_IC |
: FeedbackVectorSlotKind::KEYED_LOAD_IC; |
property_feedback_slot_ = spec->AddSlot(kind); |
} |
- FeedbackVectorICSlot PropertyFeedbackSlot() const { |
+ FeedbackVectorSlot PropertyFeedbackSlot() const { |
return property_feedback_slot_; |
} |
@@ -1780,7 +1772,6 @@ class Property final : public Expression { |
bit_field_(IsForCallField::encode(false) | |
IsStringAccessField::encode(false) | |
InlineCacheStateField::encode(UNINITIALIZED)), |
- property_feedback_slot_(FeedbackVectorICSlot::Invalid()), |
obj_(obj), |
key_(key) {} |
static int parent_num_ids() { return Expression::num_ids(); } |
@@ -1793,7 +1784,7 @@ class Property final : public Expression { |
class KeyTypeField : public BitField8<IcCheckType, 2, 1> {}; |
class InlineCacheStateField : public BitField8<InlineCacheState, 3, 4> {}; |
uint8_t bit_field_; |
- FeedbackVectorICSlot property_feedback_slot_; |
+ FeedbackVectorSlot property_feedback_slot_; |
Expression* obj_; |
Expression* key_; |
SmallMapList receiver_types_; |
@@ -1809,11 +1800,11 @@ class Call final : public Expression { |
// Type feedback information. |
void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
- ICSlotCache* cache) override; |
+ FeedbackVectorSlotCache* cache) override; |
- FeedbackVectorSlot CallFeedbackSlot() const { return slot_; } |
+ FeedbackVectorSlot CallFeedbackSlot() const { return stub_slot_; } |
- FeedbackVectorICSlot CallFeedbackICSlot() const { return ic_slot_; } |
+ FeedbackVectorSlot CallFeedbackICSlot() const { return ic_slot_; } |
SmallMapList* GetReceiverTypes() override { |
if (expression()->IsProperty()) { |
@@ -1886,8 +1877,6 @@ class Call final : public Expression { |
Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
int pos) |
: Expression(zone, pos), |
- ic_slot_(FeedbackVectorICSlot::Invalid()), |
- slot_(FeedbackVectorSlot::Invalid()), |
expression_(expression), |
arguments_(arguments), |
bit_field_(IsUninitializedField::encode(false)) { |
@@ -1900,8 +1889,8 @@ class Call final : public Expression { |
private: |
int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
- FeedbackVectorICSlot ic_slot_; |
- FeedbackVectorSlot slot_; |
+ FeedbackVectorSlot ic_slot_; |
+ FeedbackVectorSlot stub_slot_; |
Expression* expression_; |
ZoneList<Expression*>* arguments_; |
Handle<JSFunction> target_; |
@@ -1920,8 +1909,8 @@ class CallNew final : public Expression { |
// Type feedback information. |
void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
- ICSlotCache* cache) override { |
- callnew_feedback_slot_ = spec->AddStubSlot(); |
+ FeedbackVectorSlotCache* cache) override { |
+ callnew_feedback_slot_ = spec->AddGeneralSlot(); |
} |
FeedbackVectorSlot CallNewFeedbackSlot() { |
@@ -1955,8 +1944,7 @@ class CallNew final : public Expression { |
: Expression(zone, pos), |
expression_(expression), |
arguments_(arguments), |
- is_monomorphic_(false), |
- callnew_feedback_slot_(FeedbackVectorSlot::Invalid()) {} |
+ is_monomorphic_(false) {} |
static int parent_num_ids() { return Expression::num_ids(); } |
@@ -2151,8 +2139,8 @@ class CountOperation final : public Expression { |
} |
void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
- ICSlotCache* cache) override; |
- FeedbackVectorICSlot CountSlot() const { return slot_; } |
+ FeedbackVectorSlotCache* cache) override; |
+ FeedbackVectorSlot CountSlot() const { return slot_; } |
protected: |
CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, |
@@ -2162,8 +2150,7 @@ class CountOperation final : public Expression { |
IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | |
StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)), |
type_(NULL), |
- expression_(expr), |
- slot_(FeedbackVectorICSlot::Invalid()) {} |
+ expression_(expr) {} |
static int parent_num_ids() { return Expression::num_ids(); } |
private: |
@@ -2180,7 +2167,7 @@ class CountOperation final : public Expression { |
Type* type_; |
Expression* expression_; |
SmallMapList receiver_types_; |
- FeedbackVectorICSlot slot_; |
+ FeedbackVectorSlot slot_; |
}; |
@@ -2324,8 +2311,8 @@ class Assignment final : public Expression { |
} |
void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
- ICSlotCache* cache) override; |
- FeedbackVectorICSlot AssignmentSlot() const { return slot_; } |
+ FeedbackVectorSlotCache* cache) override; |
+ FeedbackVectorSlot AssignmentSlot() const { return slot_; } |
protected: |
Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, |
@@ -2347,7 +2334,7 @@ class Assignment final : public Expression { |
Expression* value_; |
BinaryOperation* binary_operation_; |
SmallMapList receiver_types_; |
- FeedbackVectorICSlot slot_; |
+ FeedbackVectorSlot slot_; |
}; |
@@ -2369,23 +2356,22 @@ class Yield final : public Expression { |
// Type feedback information. |
bool HasFeedbackSlots() const { return yield_kind() == kDelegating; } |
void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
- ICSlotCache* cache) override { |
+ FeedbackVectorSlotCache* cache) override { |
if (HasFeedbackSlots()) { |
yield_first_feedback_slot_ = spec->AddKeyedLoadICSlot(); |
- spec->AddLoadICSlots(2); |
+ keyed_load_feedback_slot_ = spec->AddLoadICSlot(); |
+ done_feedback_slot_ = spec->AddLoadICSlot(); |
} |
} |
- FeedbackVectorICSlot KeyedLoadFeedbackSlot() { |
+ FeedbackVectorSlot KeyedLoadFeedbackSlot() { |
DCHECK(!HasFeedbackSlots() || !yield_first_feedback_slot_.IsInvalid()); |
return yield_first_feedback_slot_; |
} |
- FeedbackVectorICSlot DoneFeedbackSlot() { |
- return KeyedLoadFeedbackSlot().next(); |
- } |
+ FeedbackVectorSlot DoneFeedbackSlot() { return keyed_load_feedback_slot_; } |
- FeedbackVectorICSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); } |
+ FeedbackVectorSlot ValueFeedbackSlot() { return done_feedback_slot_; } |
protected: |
Yield(Zone* zone, Expression* generator_object, Expression* expression, |
@@ -2393,14 +2379,15 @@ class Yield final : public Expression { |
: Expression(zone, pos), |
generator_object_(generator_object), |
expression_(expression), |
- yield_kind_(yield_kind), |
- yield_first_feedback_slot_(FeedbackVectorICSlot::Invalid()) {} |
+ yield_kind_(yield_kind) {} |
private: |
Expression* generator_object_; |
Expression* expression_; |
Kind yield_kind_; |
- FeedbackVectorICSlot yield_first_feedback_slot_; |
+ FeedbackVectorSlot yield_first_feedback_slot_; |
+ FeedbackVectorSlot keyed_load_feedback_slot_; |
+ FeedbackVectorSlot done_feedback_slot_; |
}; |
@@ -2642,14 +2629,14 @@ class ClassLiteral final : public Expression { |
// Object literals need one feedback slot for each non-trivial value, as well |
// as some slots for home objects. |
void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
- ICSlotCache* cache) override; |
+ FeedbackVectorSlotCache* cache) override; |
bool NeedsProxySlot() const { |
return FLAG_vector_stores && scope() != NULL && |
class_variable_proxy()->var()->IsUnallocated(); |
} |
- FeedbackVectorICSlot ProxySlot() const { return slot_; } |
+ FeedbackVectorSlot ProxySlot() const { return slot_; } |
protected: |
ClassLiteral(Zone* zone, const AstRawString* name, Scope* scope, |
@@ -2663,9 +2650,7 @@ class ClassLiteral final : public Expression { |
extends_(extends), |
constructor_(constructor), |
properties_(properties), |
- end_position_(end_position), |
- slot_(FeedbackVectorICSlot::Invalid()) { |
- } |
+ end_position_(end_position) {} |
static int parent_num_ids() { return Expression::num_ids(); } |
@@ -2679,7 +2664,7 @@ class ClassLiteral final : public Expression { |
FunctionLiteral* constructor_; |
ZoneList<Property*>* properties_; |
int end_position_; |
- FeedbackVectorICSlot slot_; |
+ FeedbackVectorSlot slot_; |
}; |