Revision: 10459
Author: [email protected]
Date: Fri Jan 20 05:59:37 2012
Log: Fix handling of function proxies in higher-order array and string
methods,
which use yet another way to determine strict vs non-strict function
receivers.
[email protected]
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/9270004
http://code.google.com/p/v8/source/detail?r=10459
Modified:
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/mjsunit/harmony/proxies-function.js
=======================================
--- /branches/bleeding_edge/src/runtime.cc Wed Jan 18 01:21:07 2012
+++ /branches/bleeding_edge/src/runtime.cc Fri Jan 20 05:59:37 2012
@@ -1869,9 +1869,19 @@
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) {
- NoHandleAllocation handle_free;
ASSERT(args.length() == 1);
- CONVERT_CHECKED(JSFunction, function, args[0]);
+ CONVERT_CHECKED(JSReceiver, callable, args[0]);
+
+ if (!callable->IsJSFunction()) {
+ HandleScope scope(isolate);
+ bool threw = false;
+ Handle<Object> delegate =
+ Execution::TryGetFunctionDelegate(Handle<JSReceiver>(callable),
&threw);
+ if (threw) return Failure::Exception();
+ callable = JSFunction::cast(*delegate);
+ }
+ JSFunction* function = JSFunction::cast(callable);
+
SharedFunctionInfo* shared = function->shared();
if (shared->native() || !shared->is_classic_mode()) {
return isolate->heap()->undefined_value();
=======================================
--- /branches/bleeding_edge/test/mjsunit/harmony/proxies-function.js Thu
Nov 10 07:48:07 2011
+++ /branches/bleeding_edge/test/mjsunit/harmony/proxies-function.js Fri
Jan 20 05:59:37 2012
@@ -611,6 +611,22 @@
+// Passing a proxy function to higher-order library functions.
+
+function TestHigherOrder(f) {
+ assertEquals(6, [6, 2].map(f)[0])
+ assertEquals(4, [5, 2].reduce(f, 4))
+ assertTrue([1, 2].some(f))
+ assertEquals("a.b.c", "a.b.c".replace(".", f))
+}
+
+TestHigherOrder(function(x) { return x })
+TestHigherOrder(function(x) { "use strict"; return x })
+TestHigherOrder(Proxy.createFunction({}, function(x) { return x }))
+TestHigherOrder(CreateFrozen({}, function(x) { return x }))
+
+
+
// TODO(rossberg): Ultimately, I want to have the following test function
// run through, but it currently fails on so many cases (some not even
// involving proxies), that I leave that for later...
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev