Reviewers: jarin,

Description:
[turbofan] Simplify graph construction for for-in.

This is an initial step towards a faster and less incorrect
implementation of for-in in TurboFan.

[email protected]

Please review this at https://codereview.chromium.org/1153403002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+11, -29 lines):
  M src/compiler/ast-graph-builder.cc
  M src/runtime/runtime-array.cc


Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index aaef0569e7b7e172d1a16e0fbcc45c3e322cd5bc..c2e0dd4b3c22741c65ef913ab4d9be516e22c192 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -1328,27 +1328,14 @@ void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) { NewNode(javascript()->CallRuntime(Runtime::kForInCacheArrayLength, 2),
                 cache_type, cache_array);
     {
-      // TODO(dcarney): this check is actually supposed to be for the
-      //                empty enum case only.
-      IfBuilder have_no_properties(this);
-      Node* empty_array_cond = NewNode(javascript()->StrictEqual(),
- cache_length, jsgraph()->ZeroConstant());
-      have_no_properties.If(empty_array_cond);
-      have_no_properties.Then();
-      // Pop obj and skip loop.
-      environment()->Pop();
-      have_no_properties.Else();
-      {
-        // Construct the rest of the environment.
-        environment()->Push(cache_type);
-        environment()->Push(cache_array);
-        environment()->Push(cache_length);
-        environment()->Push(jsgraph()->ZeroConstant());
-
-        // Build the actual loop body.
-        VisitForInBody(stmt);
-      }
-      have_no_properties.End();
+      // Construct the rest of the environment.
+      environment()->Push(cache_type);
+      environment()->Push(cache_array);
+      environment()->Push(cache_length);
+      environment()->Push(jsgraph()->ZeroConstant());
+
+      // Build the actual loop body.
+      VisitForInBody(stmt);
     }
     is_null.End();
   }
Index: src/runtime/runtime-array.cc
diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc
index b6e8494edccc539c5808c4abf32875a41bfb6ab9..06cfa05fe40ba473e88c4261420a08065574a704 100644
--- a/src/runtime/runtime-array.cc
+++ b/src/runtime/runtime-array.cc
@@ -1318,14 +1318,9 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_ForInInit) {
   Handle<Object> cache_type = args.at<Object>(1);
   if (cache_type->IsMap()) {
     // Enum cache case.
- if (Map::EnumLengthBits::decode(Map::cast(*cache_type)->bit_field3()) ==
-        0) {
-      // 0 length enum.
-      // Can't handle this case in the graph builder,
-      // so transform it into the empty fixed array case.
- return MakePair(isolate->heap()->empty_fixed_array(), Smi::FromInt(1));
-    }
-    return MakePair(object->map()->instance_descriptors()->GetEnumCache(),
+    return MakePair(Map::cast(*cache_type)->EnumLength() != 0
+ ? object->map()->instance_descriptors()->GetEnumCache()
+                        : isolate->heap()->empty_fixed_array(),
                     *cache_type);
   } else {
     // FixedArray case.


--
--
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/d/optout.

Reply via email to