Reviewers: Hannes Payer,

Message:
PTAL

Description:
Add soft-deopt for uninitialized assignment

Please review this at https://chromiumcodereview.appspot.com/17071002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/ast.h
  M src/ast.cc
  M src/hydrogen.cc
  M src/type-info.h
  M src/type-info.cc


Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index 0ebbd35be886cdef66de2bb459226000d41750a3..7f00ef30b148d9f9992ae03de0379e9e411a4450 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -135,6 +135,7 @@ Assignment::Assignment(Isolate* isolate,
       binary_operation_(NULL),
       assignment_id_(GetNextId(isolate)),
       is_monomorphic_(false),
+      is_uninitialized_(false),
       store_mode_(STANDARD_STORE) { }


@@ -465,6 +466,8 @@ void Assignment::RecordTypeFeedback(TypeFeedbackOracle* oracle,
   Property* prop = target()->AsProperty();
   ASSERT(prop != NULL);
   TypeFeedbackId id = AssignmentFeedbackId();
+  is_uninitialized_ = oracle->StoreIsUninitialized(id);
+  if (is_uninitialized_) return;
   is_monomorphic_ = oracle->StoreIsMonomorphicNormal(id);
   receiver_types_.Clear();
   if (prop->key()->IsPropertyName()) {
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index b7ada60665869ca575a5180d934fe689238d9750..1a231f28512cfd12d867d83d27ab01653dd28c99 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -2096,6 +2096,7 @@ class Assignment: public Expression {
   TypeFeedbackId AssignmentFeedbackId() { return reuse(id()); }
   void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* zone);
   virtual bool IsMonomorphic() { return is_monomorphic_; }
+  bool IsUninitialized() { return is_uninitialized_; }
   virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; }
   virtual KeyedAccessStoreMode GetStoreMode() {
     return store_mode_;
@@ -2126,6 +2127,7 @@ class Assignment: public Expression {
   const BailoutId assignment_id_;

   bool is_monomorphic_ : 1;
+  bool is_uninitialized_ : 1;
   KeyedAccessStoreMode store_mode_ : 5;  // Windows treats as signed,
                                          // must have extra bit.
   SmallMapList receiver_types_;
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 74bf48961177ee7baa2063d294005c10bb7f93bf..3fc4a62b496461a2225b524672a9fd733aa434ab 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -6484,6 +6484,9 @@ void HOptimizedGraphBuilder::HandlePropertyAssignment(Assignment* expr) { return HandlePolymorphicStoreNamedField(expr, object, value, types, name);
     } else {
       Drop(2);
+      if (expr->IsUninitialized()) {
+        AddSoftDeoptimize();
+      }
       instr = BuildStoreNamedGeneric(object, name, value);
     }

Index: src/type-info.cc
diff --git a/src/type-info.cc b/src/type-info.cc
index 32aef1cc5ef4472a8d2cb842240882f4a608cbdf..c0b6056d9a5a17ebbb07bae6fd4b72ad14fe2e6e 100644
--- a/src/type-info.cc
+++ b/src/type-info.cc
@@ -138,6 +138,15 @@ bool TypeFeedbackOracle::LoadIsPolymorphic(Property* expr) {
 }


+bool TypeFeedbackOracle::StoreIsUninitialized(TypeFeedbackId ast_id) {
+  Handle<Object> map_or_code = GetInfo(ast_id);
+  if (map_or_code->IsMap()) return false;
+  if (!map_or_code->IsCode()) return true;
+  Handle<Code> code = Handle<Code>::cast(map_or_code);
+  return code->ic_state() == UNINITIALIZED;
+}
+
+
 bool TypeFeedbackOracle::StoreIsMonomorphicNormal(TypeFeedbackId ast_id) {
   Handle<Object> map_or_code = GetInfo(ast_id);
   if (map_or_code->IsMap()) return true;
Index: src/type-info.h
diff --git a/src/type-info.h b/src/type-info.h
index 1262b3177c888b85f3d32b8fdf30bebc4f6d7023..8d63befa51804528def901485e1db61984954149 100644
--- a/src/type-info.h
+++ b/src/type-info.h
@@ -246,6 +246,7 @@ class TypeFeedbackOracle: public ZoneObject {
   bool LoadIsMonomorphicNormal(Property* expr);
   bool LoadIsUninitialized(Property* expr);
   bool LoadIsPolymorphic(Property* expr);
+  bool StoreIsUninitialized(TypeFeedbackId ast_id);
   bool StoreIsMonomorphicNormal(TypeFeedbackId ast_id);
   bool StoreIsPolymorphic(TypeFeedbackId ast_id);
   bool CallIsMonomorphic(Call* expr);


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to