From: arv@chromium.org Date: Fri, 12 Sep 2014 15:07:43 +0000 (+0000) Subject: Arrow functions: Cleanup handling of the prototype property X-Git-Tag: upstream/4.7.83~6940 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=477b75f1cb2c21a55a8c96ccefbfb19ee1715336;p=platform%2Fupstream%2Fv8.git Arrow functions: Cleanup handling of the prototype property 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 --- diff --git a/src/contexts.h b/src/contexts.h index ae80021..ac25e48 100644 --- a/src/contexts.h +++ b/src/contexts.h @@ -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; diff --git a/src/factory.cc b/src/factory.cc index f931b7f..5303dd0 100644 --- a/src/factory.cc +++ b/src/factory.cc @@ -1237,10 +1237,6 @@ void Factory::InitializeFunction(Handle 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(); } diff --git a/test/mjsunit/harmony/arrow-functions.js b/test/mjsunit/harmony/arrow-functions.js index 22b1c94..0ffa936 100644 --- a/test/mjsunit/harmony/arrow-functions.js +++ b/test/mjsunit/harmony/arrow-functions.js @@ -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)());