Add soft-deopt for uninitialized assignment
authorverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 20 Jun 2013 13:09:43 +0000 (13:09 +0000)
committerverwaest@chromium.org <verwaest@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 20 Jun 2013 13:09:43 +0000 (13:09 +0000)
R=hpayer@google.com

Review URL: https://chromiumcodereview.appspot.com/17071002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15241 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/ast.cc
src/ast.h
src/hydrogen.cc
src/type-info.cc
src/type-info.h

index bf607d255c15dbeda52c16146d2c97fa30a1fe8b..5567fb338d59327de007803f0a486f2f1e42d529 100644 (file)
@@ -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 b07456b8f789ed9f03d6aa8b82a2409bf0fe004b..1c779b38f7932b23d6d95627c583f5430d86ddeb 100644 (file)
--- 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 9d4fe2e50529e779b45cde69b4c3140274d8a3a5..1a1292b62565b62ee7443e982e4060d36a65cc46 100644 (file)
@@ -6516,6 +6516,7 @@ void HOptimizedGraphBuilder::HandlePropertyAssignment(Assignment* expr) {
     HValue* value = environment()->ExpressionStackAt(0);
     HValue* object = environment()->ExpressionStackAt(1);
 
+    if (expr->IsUninitialized()) AddSoftDeoptimize();
     return BuildStoreNamed(expr, expr->id(), expr->position(),
                            expr->AssignmentId(), prop, object, value);
   } else {
@@ -6988,8 +6989,6 @@ HInstruction* HOptimizedGraphBuilder::BuildLoadNamedGeneric(
     Property* expr) {
   if (expr->IsUninitialized()) {
     AddSoftDeoptimize();
-  } else {
-    // OS::DebugBreak();
   }
   HValue* context = environment()->LookupContext();
   return new(zone()) HLoadNamedGeneric(context, object, name);
index 22ffb6216f12f27420727cce89308913a7ddf5d6..1e298452c1bf479e0bd2814f0120940e81704d3b 100644 (file)
@@ -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 3c2b83114ce4898898257ec9939ddb7ad5026418..c163b2bac04338161c99b6e87f5852e820ad5ecf 100644 (file)
@@ -244,6 +244,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);