// once we use the common type field in the AST consistently.
-void ForInStatement::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
- for_in_type_ = static_cast<ForInType>(oracle->ForInType(this));
-}
-
-
void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) {
to_boolean_types_ = oracle->ToBooleanTypes(test_id());
}
}
-void CountOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle,
- Zone* zone) {
- TypeFeedbackId id = CountStoreFeedbackId();
- is_monomorphic_ = oracle->StoreIsMonomorphicNormal(id);
- receiver_types_.Clear();
- if (is_monomorphic_) {
- // Record receiver type for monomorphic keyed stores.
- receiver_types_.Add(
- oracle->StoreMonomorphicReceiverType(id), zone);
- } else if (oracle->StoreIsKeyedPolymorphic(id)) {
- receiver_types_.Reserve(kMaxKeyedPolymorphism, zone);
- oracle->CollectKeyedReceiverTypes(id, &receiver_types_);
- } else {
- oracle->CollectPolymorphicStoreReceiverTypes(id, &receiver_types_);
- }
- store_mode_ = oracle->GetStoreMode(id);
- type_ = oracle->IncrementType(this);
-}
-
-
-void CaseClause::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
- compare_type_ = oracle->ClauseType(CompareId());
-}
-
-
bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) {
// If there is an interceptor, we can't compute the target for a direct call.
if (type->has_named_interceptor()) return false;
}
TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); }
- void RecordTypeFeedback(TypeFeedbackOracle* oracle);
enum ForInType { FAST_FOR_IN, SLOW_FOR_IN };
ForInType for_in_type() const { return for_in_type_; }
+ void set_for_in_type(ForInType type) { for_in_type_ = type; }
BailoutId BodyId() const { return body_id_; }
BailoutId PrepareId() const { return prepare_id_; }
// Type feedback information.
TypeFeedbackId CompareId() { return compare_id_; }
- void RecordTypeFeedback(TypeFeedbackOracle* oracle);
Handle<Type> compare_type() { return compare_type_; }
+ void set_compare_type(Handle<Type> type) { compare_type_ = type; }
private:
CaseClause(Isolate* isolate,
Expression* expression() const { return expression_; }
- void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone);
virtual bool IsMonomorphic() V8_OVERRIDE { return is_monomorphic_; }
virtual SmallMapList* GetReceiverTypes() V8_OVERRIDE {
return &receiver_types_;
return store_mode_;
}
Handle<Type> type() const { return type_; }
+ void set_is_monomorphic(bool b) { is_monomorphic_ = b; }
+ void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; }
+ void set_type(Handle<Type> type) { type_ = type; }
BailoutId AssignmentId() const { return assignment_id_; }
}
-byte TypeFeedbackOracle::ForInType(ForInStatement* stmt) {
- Handle<Object> value = GetInfo(stmt->ForInFeedbackId());
+byte TypeFeedbackOracle::ForInType(TypeFeedbackId id) {
+ Handle<Object> value = GetInfo(id);
return value->IsSmi() &&
Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker
? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN;
}
-Handle<Type> TypeFeedbackOracle::IncrementType(CountOperation* expr) {
- Handle<Object> object = GetInfo(expr->CountBinOpFeedbackId());
+Handle<Type> TypeFeedbackOracle::CountType(TypeFeedbackId id) {
+ Handle<Object> object = GetInfo(id);
Handle<Type> unknown(Type::None(), isolate_);
if (!object->IsCode()) return unknown;
Handle<Code> code = Handle<Code>::cast(object);
}
+void TypeFeedbackOracle::CountReceiverTypes(
+ TypeFeedbackId id, SmallMapList* receiver_types) {
+ receiver_types->Clear();
+ if (StoreIsMonomorphicNormal(id)) {
+ // Record receiver type for monomorphic keyed stores.
+ receiver_types->Add(StoreMonomorphicReceiverType(id), zone());
+ } else if (StoreIsKeyedPolymorphic(id)) {
+ receiver_types->Reserve(kMaxKeyedPolymorphism, zone());
+ CollectKeyedReceiverTypes(id, receiver_types);
+ } else {
+ CollectPolymorphicStoreReceiverTypes(id, receiver_types);
+ }
+}
+
+
void TypeFeedbackOracle::CollectPolymorphicMaps(Handle<Code> code,
SmallMapList* types) {
MapHandleList maps;
// TODO(1571) We can't use ForInStatement::ForInType as the return value due
// to various cycles in our headers.
- byte ForInType(ForInStatement* expr);
+ // TODO(rossberg): once all oracle access is removed from ast.cc, it should
+ // be possible.
+ byte ForInType(TypeFeedbackId id);
Handle<Map> LoadMonomorphicReceiverType(Property* expr);
Handle<Map> StoreMonomorphicReceiverType(TypeFeedbackId id);
Handle<Type>* right,
Handle<Type>* combined);
- Handle<Type> ClauseType(TypeFeedbackId id);
+ Handle<Type> CountType(TypeFeedbackId id);
+ void CountReceiverTypes(TypeFeedbackId id, SmallMapList* receiver_types);
- Handle<Type> IncrementType(CountOperation* expr);
+ Handle<Type> ClauseType(TypeFeedbackId id);
Zone* zone() const { return zone_; }
Isolate* isolate() const { return isolate_; }
for (int i = 0; i < clauses->length(); ++i) {
CaseClause* clause = clauses->at(i);
if (!clause->is_default())
- clause->RecordTypeFeedback(oracle());
+ clause->set_compare_type(oracle()->ClauseType(clause->CompareId()));
}
}
}
void AstTyper::VisitForInStatement(ForInStatement* stmt) {
// Collect type feedback.
- stmt->RecordTypeFeedback(oracle());
+ stmt->set_for_in_type(static_cast<ForInStatement::ForInType>(
+ oracle()->ForInType(stmt->ForInFeedbackId())));
RECURSE(Visit(stmt->enumerable()));
store_.Forget(); // Control may transfer here via looping or 'continue'.
void AstTyper::VisitCountOperation(CountOperation* expr) {
// Collect type feedback.
- expr->RecordTypeFeedback(oracle(), zone());
- Property* prop = expr->expression()->AsProperty();
- if (prop != NULL) {
- prop->RecordTypeFeedback(oracle(), zone());
- }
+ TypeFeedbackId store_id = expr->CountStoreFeedbackId();
+ expr->set_is_monomorphic(oracle()->StoreIsMonomorphicNormal(store_id));
+ expr->set_store_mode(oracle()->GetStoreMode(store_id));
+ oracle()->CountReceiverTypes(store_id, expr->GetReceiverTypes());
+ expr->set_type(oracle()->CountType(expr->CountBinOpFeedbackId()));
+ // TODO(rossberg): merge the count type with the generic expression type.
RECURSE(Visit(expr->expression()));