[turbofan] Simplify graph construction for for-in.
authorbmeurer <bmeurer@chromium.org>
Thu, 28 May 2015 14:01:17 +0000 (07:01 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 28 May 2015 14:01:31 +0000 (14:01 +0000)
This is an initial step towards a faster and less incorrect
implementation of for-in in TurboFan.

R=jarin@chromium.org

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

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

src/compiler/ast-graph-builder.cc
src/runtime/runtime-array.cc

index 2a4bdd9..bc3840f 100644 (file)
@@ -1331,27 +1331,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 b6e8494..06cfa05 100644 (file)
@@ -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.