Remove RecordTypeFeedback() methods from some AST classes and move into typing.cc.
authortitzer <titzer@chromium.org>
Thu, 26 Feb 2015 18:34:41 +0000 (10:34 -0800)
committerCommit bot <commit-bot@chromium.org>
Thu, 26 Feb 2015 18:34:46 +0000 (18:34 +0000)
R=mvstanton@chromium.org
BUG=

Review URL: https://codereview.chromium.org/955243002

Cr-Commit-Position: refs/heads/master@{#26890}

src/ast.cc
src/ast.h
src/typing.cc

index 6bbbe641cf42259a623550b425248eca91298f3b..01c4131d3a9e895647acac9a4fac6b4255e1b7ca 100644 (file)
@@ -611,29 +611,6 @@ bool Call::ComputeGlobalTarget(Handle<GlobalObject> global,
 }
 
 
-void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
-  FeedbackVectorSlot allocation_site_feedback_slot =
-      FLAG_pretenuring_call_new ? AllocationSiteFeedbackSlot()
-                                : CallNewFeedbackSlot();
-  allocation_site_ =
-      oracle->GetCallNewAllocationSite(allocation_site_feedback_slot);
-  is_monomorphic_ = oracle->CallNewIsMonomorphic(CallNewFeedbackSlot());
-  if (is_monomorphic_) {
-    target_ = oracle->GetCallNewTarget(CallNewFeedbackSlot());
-  }
-}
-
-
-void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) {
-  DCHECK(!is_computed_name());
-  TypeFeedbackId id = key()->AsLiteral()->LiteralFeedbackId();
-  SmallMapList maps;
-  oracle->CollectReceiverTypes(id, &maps);
-  receiver_type_ = maps.length() == 1 ? maps.at(0)
-                                      : Handle<Map>::null();
-}
-
-
 // ----------------------------------------------------------------------------
 // Implementation of AstVisitor
 
index 3a273f38655fc4db74be4a23cce46620d1b242ac..735f2f92f9e680ab1c3eac43da348468fb688c6e 100644 (file)
--- a/src/ast.h
+++ b/src/ast.h
@@ -1414,7 +1414,6 @@ class ObjectLiteralProperty FINAL : public ZoneObject {
   Kind kind() { return kind_; }
 
   // Type feedback information.
-  void RecordTypeFeedback(TypeFeedbackOracle* oracle);
   bool IsMonomorphic() { return !receiver_type_.is_null(); }
   Handle<Map> GetReceiverType() { return receiver_type_; }
 
@@ -1426,6 +1425,8 @@ class ObjectLiteralProperty FINAL : public ZoneObject {
   bool is_static() const { return is_static_; }
   bool is_computed_name() const { return is_computed_name_; }
 
+  void set_receiver_type(Handle<Map> map) { receiver_type_ = map; }
+
  protected:
   friend class AstNodeFactory;
 
@@ -1918,7 +1919,6 @@ class CallNew FINAL : public Expression {
     return CallNewFeedbackSlot().next();
   }
 
-  void RecordTypeFeedback(TypeFeedbackOracle* oracle);
   bool IsMonomorphic() OVERRIDE { return is_monomorphic_; }
   Handle<JSFunction> target() const { return target_; }
   Handle<AllocationSite> allocation_site() const {
@@ -1929,6 +1929,12 @@ class CallNew FINAL : public Expression {
   static int feedback_slots() { return 1; }
   BailoutId ReturnId() const { return BailoutId(local_id(0)); }
 
+  void set_allocation_site(Handle<AllocationSite> site) {
+    allocation_site_ = site;
+  }
+  void set_is_monomorphic(bool monomorphic) { is_monomorphic_ = monomorphic; }
+  void set_target(Handle<JSFunction> target) { target_ = target; }
+
  protected:
   CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments,
           int pos)
index 48528705bf1e1abb605d2a243199eb7a7ab05e30..794accc48399d7095bea85aac88e0bb5954594cc 100644 (file)
@@ -410,7 +410,12 @@ void AstTyper::VisitObjectLiteral(ObjectLiteral* expr) {
       if (!prop->is_computed_name() &&
           prop->key()->AsLiteral()->value()->IsInternalizedString() &&
           prop->emit_store()) {
-        prop->RecordTypeFeedback(oracle());
+        // Record type feed back for the property.
+        TypeFeedbackId id = prop->key()->AsLiteral()->LiteralFeedbackId();
+        SmallMapList maps;
+        oracle()->CollectReceiverTypes(id, &maps);
+        prop->set_receiver_type(maps.length() == 1 ? maps.at(0)
+                                                   : Handle<Map>::null());
       }
     }
 
@@ -562,7 +567,17 @@ void AstTyper::VisitCall(Call* expr) {
 
 void AstTyper::VisitCallNew(CallNew* expr) {
   // Collect type feedback.
-  expr->RecordTypeFeedback(oracle());
+  FeedbackVectorSlot allocation_site_feedback_slot =
+      FLAG_pretenuring_call_new ? expr->AllocationSiteFeedbackSlot()
+                                : expr->CallNewFeedbackSlot();
+  expr->set_allocation_site(
+      oracle()->GetCallNewAllocationSite(allocation_site_feedback_slot));
+  bool monomorphic =
+      oracle()->CallNewIsMonomorphic(expr->CallNewFeedbackSlot());
+  expr->set_is_monomorphic(monomorphic);
+  if (monomorphic) {
+    expr->set_target(oracle()->GetCallNewTarget(expr->CallNewFeedbackSlot()));
+  }
 
   RECURSE(Visit(expr->expression()));
   ZoneList<Expression*>* args = expr->arguments();