From: rossberg@chromium.org Date: Thu, 28 Nov 2013 13:16:51 +0000 (+0000) Subject: Move more type collection logic from AST to oracle. X-Git-Tag: upstream/4.7.83~11522 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5532af443776a9bf7213ba137ff967027f337194;p=platform%2Fupstream%2Fv8.git Move more type collection logic from AST to oracle. (More to come in follow-up CL.) R=jkummerow@chromium.org BUG= Review URL: https://codereview.chromium.org/91863003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18119 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/ast.cc b/src/ast.cc index 3ca144940..20881bd5a 100644 --- a/src/ast.cc +++ b/src/ast.cc @@ -575,11 +575,6 @@ bool FunctionDeclaration::IsInlineable() const { // once we use the common type field in the AST consistently. -void ForInStatement::RecordTypeFeedback(TypeFeedbackOracle* oracle) { - for_in_type_ = static_cast(oracle->ForInType(this)); -} - - void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { to_boolean_types_ = oracle->ToBooleanTypes(test_id()); } @@ -645,31 +640,6 @@ void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle, } -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 type, Handle name) { // If there is an interceptor, we can't compute the target for a direct call. if (type->has_named_interceptor()) return false; diff --git a/src/ast.h b/src/ast.h index 4158907d9..33ede1658 100644 --- a/src/ast.h +++ b/src/ast.h @@ -924,9 +924,9 @@ class ForInStatement V8_FINAL : public ForEachStatement { } 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_; } @@ -1122,8 +1122,8 @@ class CaseClause V8_FINAL : public AstNode { // Type feedback information. TypeFeedbackId CompareId() { return compare_id_; } - void RecordTypeFeedback(TypeFeedbackOracle* oracle); Handle compare_type() { return compare_type_; } + void set_compare_type(Handle type) { compare_type_ = type; } private: CaseClause(Isolate* isolate, @@ -1996,7 +1996,6 @@ class CountOperation V8_FINAL : public Expression { 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_; @@ -2005,6 +2004,9 @@ class CountOperation V8_FINAL : public Expression { return store_mode_; } Handle 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; } BailoutId AssignmentId() const { return assignment_id_; } diff --git a/src/type-info.cc b/src/type-info.cc index 36a2dd124..59850c7fc 100644 --- a/src/type-info.cc +++ b/src/type-info.cc @@ -225,8 +225,8 @@ bool TypeFeedbackOracle::ObjectLiteralStoreIsMonomorphic( } -byte TypeFeedbackOracle::ForInType(ForInStatement* stmt) { - Handle value = GetInfo(stmt->ForInFeedbackId()); +byte TypeFeedbackOracle::ForInType(TypeFeedbackId id) { + Handle value = GetInfo(id); return value->IsSmi() && Smi::cast(*value)->value() == TypeFeedbackCells::kForInFastCaseMarker ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN; @@ -444,8 +444,8 @@ Handle TypeFeedbackOracle::ClauseType(TypeFeedbackId id) { } -Handle TypeFeedbackOracle::IncrementType(CountOperation* expr) { - Handle object = GetInfo(expr->CountBinOpFeedbackId()); +Handle TypeFeedbackOracle::CountType(TypeFeedbackId id) { + Handle object = GetInfo(id); Handle unknown(Type::None(), isolate_); if (!object->IsCode()) return unknown; Handle code = Handle::cast(object); @@ -456,6 +456,21 @@ Handle TypeFeedbackOracle::IncrementType(CountOperation* expr) { } +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, SmallMapList* types) { MapHandleList maps; diff --git a/src/type-info.h b/src/type-info.h index a11697105..d6b920750 100644 --- a/src/type-info.h +++ b/src/type-info.h @@ -256,7 +256,9 @@ class TypeFeedbackOracle: public ZoneObject { // 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 LoadMonomorphicReceiverType(Property* expr); Handle StoreMonomorphicReceiverType(TypeFeedbackId id); @@ -312,9 +314,10 @@ class TypeFeedbackOracle: public ZoneObject { Handle* right, Handle* combined); - Handle ClauseType(TypeFeedbackId id); + Handle CountType(TypeFeedbackId id); + void CountReceiverTypes(TypeFeedbackId id, SmallMapList* receiver_types); - Handle IncrementType(CountOperation* expr); + Handle ClauseType(TypeFeedbackId id); Zone* zone() const { return zone_; } Isolate* isolate() const { return isolate_; } diff --git a/src/typing.cc b/src/typing.cc index 84f596859..e5f4ce584 100644 --- a/src/typing.cc +++ b/src/typing.cc @@ -200,7 +200,7 @@ void AstTyper::VisitSwitchStatement(SwitchStatement* stmt) { 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())); } } } @@ -262,7 +262,8 @@ void AstTyper::VisitForStatement(ForStatement* stmt) { void AstTyper::VisitForInStatement(ForInStatement* stmt) { // Collect type feedback. - stmt->RecordTypeFeedback(oracle()); + stmt->set_for_in_type(static_cast( + oracle()->ForInType(stmt->ForInFeedbackId()))); RECURSE(Visit(stmt->enumerable())); store_.Forget(); // Control may transfer here via looping or 'continue'. @@ -525,11 +526,12 @@ void AstTyper::VisitUnaryOperation(UnaryOperation* expr) { 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()));