Arrow functions: Cleanup handling of the prototype property
authorarv@chromium.org <arv@chromium.org>
Fri, 12 Sep 2014 15:07:43 +0000 (15:07 +0000)
committerarv@chromium.org <arv@chromium.org>
Fri, 12 Sep 2014 15:07:43 +0000 (15:07 +0000)
The old code did not work correctly in case of optimizations. I
found this out when implementing concise methods and we now plumb
through the function kind so we know what kind of Map to create for
the function.

BUG=v8:2700
LOG=y
R=rossberg@chromium.org

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

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

src/contexts.h
src/factory.cc
test/mjsunit/harmony/arrow-functions.js

index ae80021..ac25e48 100644 (file)
@@ -559,7 +559,7 @@ class Context: public FixedArray {
                                    : STRICT_GENERATOR_FUNCTION_MAP_INDEX;
     }
 
-    if (IsConciseMethod(kind)) {
+    if (IsArrowFunction(kind) || IsConciseMethod(kind)) {
       return strict_mode == SLOPPY
                  ? SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX
                  : STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX;
index f931b7f..5303dd0 100644 (file)
@@ -1237,10 +1237,6 @@ void Factory::InitializeFunction(Handle<JSFunction> function,
   function->set_prototype_or_initial_map(*the_hole_value());
   function->set_literals_or_bindings(*empty_fixed_array());
   function->set_next_function_link(*undefined_value());
-
-  // TODO(arv): This does not look correct. We need to make sure we use
-  // a Map that has no prototype property.
-  if (info->is_arrow()) function->RemovePrototype();
 }
 
 
index 22b1c94..0ffa936 100644 (file)
@@ -8,7 +8,8 @@
 // "new" operator on them.
 assertEquals("function", typeof (() => {}));
 assertEquals(Function.prototype, Object.getPrototypeOf(() => {}));
-assertThrows("new (() => {})", TypeError);
+assertThrows(function() { new (() => {}); }, TypeError);
+assertFalse("prototype" in (() => {}));
 
 // Check the different syntax variations
 assertEquals(1, (() => 1)());