Commit 22215665 authored by barraclough@apple.com's avatar barraclough@apple.com

Implement Function.prototype.bind

https://bugs.webkit.org/show_bug.cgi?id=26382

Reviewed by Sam Weinig.

Source/JavaScriptCore: 

This patch provides a basic functional implementation
for Function.bind. It should (hopefully!) be fully
functionally correct, and the bound functions can be
called to quickly (since they are a subclass of
JSFunction, not InternalFunction), but we'll probably
want to follow up with some optimization work to keep
bound calls in JIT code.

* JavaScriptCore.JSVALUE32_64only.exp:
* JavaScriptCore.JSVALUE64only.exp:
* JavaScriptCore.exp:
* JavaScriptCore.xcodeproj/project.pbxproj:
* jit/JITStubs.cpp:
(JSC::JITThunks::hostFunctionStub):
* jit/JITStubs.h:
* jsc.cpp:
(GlobalObject::addFunction):
* runtime/CommonIdentifiers.h:
* runtime/ConstructData.h:
* runtime/Executable.h:
(JSC::NativeExecutable::NativeExecutable):
* runtime/FunctionPrototype.cpp:
(JSC::FunctionPrototype::addFunctionProperties):
(JSC::functionProtoFuncBind):
* runtime/FunctionPrototype.h:
* runtime/JSBoundFunction.cpp: Added.
(JSC::boundFunctionCall):
(JSC::boundFunctionConstruct):
(JSC::JSBoundFunction::create):
(JSC::JSBoundFunction::hasInstance):
(JSC::JSBoundFunction::getOwnPropertySlot):
(JSC::JSBoundFunction::getOwnPropertyDescriptor):
(JSC::JSBoundFunction::JSBoundFunction):
(JSC::JSBoundFunction::finishCreation):
* runtime/JSBoundFunction.h: Added.
(JSC::JSBoundFunction::targetFunction):
(JSC::JSBoundFunction::boundThis):
(JSC::JSBoundFunction::boundArgs):
(JSC::JSBoundFunction::createStructure):
* runtime/JSFunction.cpp:
(JSC::JSFunction::create):
(JSC::JSFunction::finishCreation):
(JSC::createDescriptorForThrowingProperty):
(JSC::JSFunction::getOwnPropertySlot):
* runtime/JSFunction.h:
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::getHostFunction):
* runtime/JSGlobalData.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::boundFunctionStructure):
* runtime/Lookup.cpp:
(JSC::setUpStaticFunctionSlot):

Source/WebCore: 

Test: fast/js/function-bind.html

* bindings/js/JSDOMBinding.cpp:
(WebCore::objectToStringFunctionGetter):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::nonCachingStaticFunctionGetter):
* bindings/js/JSHistoryCustom.cpp:
(WebCore::nonCachingStaticBackFunctionGetter):
(WebCore::nonCachingStaticForwardFunctionGetter):
(WebCore::nonCachingStaticGoFunctionGetter):
* bindings/js/JSLocationCustom.cpp:
(WebCore::nonCachingStaticReplaceFunctionGetter):
(WebCore::nonCachingStaticReloadFunctionGetter):
(WebCore::nonCachingStaticAssignFunctionGetter):
    - Function::create no longer requires functionStructure() to be passed.

LayoutTests: 

We now pass Function.bind tests.

* fast/js/Object-getOwnPropertyNames-expected.txt:
* fast/js/basic-strict-mode-expected.txt:
* fast/js/function-bind-expected.txt: Added.
* fast/js/function-bind.html: Added.
* fast/js/mozilla/strict/15.3.4.5-expected.txt:
* fast/js/script-tests/function-bind.js: Added.
* ietestcenter/Javascript/15.2.3.3-4-38-expected.txt:
* ietestcenter/Javascript/15.3.4.5-0-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-0-2-expected.txt:
* ietestcenter/Javascript/15.3.4.5-13.b-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-13.b-2-expected.txt:
* ietestcenter/Javascript/15.3.4.5-13.b-3-expected.txt:
* ietestcenter/Javascript/15.3.4.5-13.b-4-expected.txt:
* ietestcenter/Javascript/15.3.4.5-13.b-5-expected.txt:
* ietestcenter/Javascript/15.3.4.5-15-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-15-2-expected.txt:
* ietestcenter/Javascript/15.3.4.5-16-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-2-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-3-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-4-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-5-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-6-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-7-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-8-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-9-expected.txt:
* ietestcenter/Javascript/15.3.4.5-8-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-8-2-expected.txt:
* ietestcenter/Javascript/15.3.4.5-9-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-9-2-expected.txt:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95751 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0c6cd7ae
2011-09-22 Gavin Barraclough <barraclough@apple.com>
Implement Function.prototype.bind
https://bugs.webkit.org/show_bug.cgi?id=26382
Reviewed by Sam Weinig.
We now pass Function.bind tests.
* fast/js/Object-getOwnPropertyNames-expected.txt:
* fast/js/basic-strict-mode-expected.txt:
* fast/js/function-bind-expected.txt: Added.
* fast/js/function-bind.html: Added.
* fast/js/mozilla/strict/15.3.4.5-expected.txt:
* fast/js/script-tests/function-bind.js: Added.
* ietestcenter/Javascript/15.2.3.3-4-38-expected.txt:
* ietestcenter/Javascript/15.3.4.5-0-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-0-2-expected.txt:
* ietestcenter/Javascript/15.3.4.5-13.b-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-13.b-2-expected.txt:
* ietestcenter/Javascript/15.3.4.5-13.b-3-expected.txt:
* ietestcenter/Javascript/15.3.4.5-13.b-4-expected.txt:
* ietestcenter/Javascript/15.3.4.5-13.b-5-expected.txt:
* ietestcenter/Javascript/15.3.4.5-15-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-15-2-expected.txt:
* ietestcenter/Javascript/15.3.4.5-16-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-2-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-3-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-4-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-5-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-6-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-7-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-8-expected.txt:
* ietestcenter/Javascript/15.3.4.5-2-9-expected.txt:
* ietestcenter/Javascript/15.3.4.5-8-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-8-2-expected.txt:
* ietestcenter/Javascript/15.3.4.5-9-1-expected.txt:
* ietestcenter/Javascript/15.3.4.5-9-2-expected.txt:
2011-09-22 David Hyatt <hyatt@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=68650
......@@ -43,7 +43,7 @@ PASS getSortedOwnPropertyNames(encodeURIComponent) is ['length', 'name']
PASS getSortedOwnPropertyNames(Object) is ['create', 'defineProperties', 'defineProperty', 'freeze', 'getOwnPropertyDescriptor', 'getOwnPropertyNames', 'getPrototypeOf', 'isExtensible', 'isFrozen', 'isSealed', 'keys', 'length', 'name', 'preventExtensions', 'prototype', 'seal']
PASS getSortedOwnPropertyNames(Object.prototype) is ['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']
PASS getSortedOwnPropertyNames(Function) is ['length', 'name', 'prototype']
PASS getSortedOwnPropertyNames(Function.prototype) is ['apply', 'call', 'constructor', 'length', 'name', 'toString']
FAIL getSortedOwnPropertyNames(Function.prototype) should be apply,call,constructor,length,name,toString. Was apply,bind,call,constructor,length,name,toString.
PASS getSortedOwnPropertyNames(Array) is ['isArray', 'length', 'name', 'prototype']
PASS getSortedOwnPropertyNames(Array.prototype) is ['concat', 'constructor', 'every', 'filter', 'forEach', 'indexOf', 'join', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift']
PASS getSortedOwnPropertyNames(String) is ['fromCharCode', 'length', 'name', 'prototype']
......
......@@ -56,13 +56,13 @@ PASS (function (){'use strict'; with(1){};}) threw exception SyntaxError: 'with'
PASS (function(){(function (){'use strict'; with(1){};})}) threw exception SyntaxError: 'with' statements are not valid in strict mode.
PASS (function (){'use strict'; arguments.callee; })() threw exception TypeError: Unable to access callee of strict mode function.
PASS (function (){'use strict'; arguments.caller; })() threw exception TypeError: Unable to access caller of strict mode function.
PASS (function f(){'use strict'; f.arguments; })() threw exception TypeError: Can't access arguments object of a strict mode function.
PASS (function f(){'use strict'; f.arguments; })() threw exception TypeError: Cannot access arguments property of a strict mode function.
PASS (function f(){'use strict'; f.caller; })() threw exception TypeError: Cannot access caller property of a strict mode function.
PASS (function f(){'use strict'; f.arguments=5; })() threw exception TypeError: Cannot access arguments property of a strict mode function.
PASS (function f(){'use strict'; f.caller=5; })() threw exception TypeError: Cannot access caller property of a strict mode function.
PASS (function (arg){'use strict'; arguments.callee; })() threw exception TypeError: Unable to access callee of strict mode function.
PASS (function (arg){'use strict'; arguments.caller; })() threw exception TypeError: Unable to access caller of strict mode function.
PASS (function f(arg){'use strict'; f.arguments; })() threw exception TypeError: Can't access arguments object of a strict mode function.
PASS (function f(arg){'use strict'; f.arguments; })() threw exception TypeError: Cannot access arguments property of a strict mode function.
PASS (function f(arg){'use strict'; f.caller; })() threw exception TypeError: Cannot access caller property of a strict mode function.
PASS (function f(arg){'use strict'; f.arguments=5; })() threw exception TypeError: Cannot access arguments property of a strict mode function.
PASS (function f(arg){'use strict'; f.caller=5; })() threw exception TypeError: Cannot access caller property of a strict mode function.
......
Tests Function.bind.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS result is "[object DOMWindow] -> x:1, y:2"
PASS result is "'a' -> x:'b', y:1"
PASS result is "'a' -> x:'b', y:'c'"
PASS result is "[object Object] -> x:1, y:2"
PASS result is "[object Object] -> x:'b', y:1"
PASS result is "[object Object] -> x:'b', y:'c'"
PASS f instanceof F is true
PASS f instanceof G is true
PASS f instanceof H is true
PASS g instanceof F is true
PASS g instanceof G is true
PASS g instanceof H is true
PASS h instanceof F is true
PASS h instanceof G is true
PASS h instanceof H is true
PASS "prototype" in F is true
PASS "prototype" in G is false
PASS "prototype" in H is false
PASS Function.bind.call(undefined) threw exception TypeError: Type error.
PASS abcAt(1) is "b"
PASS new abcAt(1) threw exception TypeError: 'function charAt() {
[native code]
}' is not a constructor (evaluating 'new abcAt(1)').
FAIL boundFunctionPrototypeAccessed should be false. Was true.
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="resources/js-test-style.css">
<script src="resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/function-bind.js"></script>
<script src="resources/js-test-post.js"></script>
</body>
</html>
CONSOLE MESSAGE: line 12: TypeError: 'undefined' is not a function (evaluating 'strict.bind(true)')
FAIL successfullyParsed should be true (of type boolean). Was undefined (of type undefined).
PASS true === true
PASS 42 === 42
PASS ===
PASS null === null
PASS undefined === undefined
PASS [object Object] === [object Object]
PASS true === true
PASS true === true
PASS true === true
PASS [object DOMWindow] === [object DOMWindow]
PASS [object DOMWindow] === [object DOMWindow]
PASS [object Object] === [object Object]
PASSED!
PASS successfullyParsed is true
TEST COMPLETE
description("Tests Function.bind.");
var result;
function F(x, y)
{
result = this + " -> x:" + x + ", y:" + y;
}
G = F.bind("'a'", "'b'");
H = G.bind("'Cannot rebind this!'", "'c'");
F(1,2);
shouldBe("result", '"[object DOMWindow] -> x:1, y:2"');
G(1,2);
shouldBe("result", '"\'a\' -> x:\'b\', y:1"');
H(1,2);
shouldBe("result", '"\'a\' -> x:\'b\', y:\'c\'"');
var f = new F(1,2);
shouldBe("result", '"[object Object] -> x:1, y:2"');
var g = new G(1,2);
shouldBe("result", '"[object Object] -> x:\'b\', y:1"');
var h = new H(1,2);
shouldBe("result", '"[object Object] -> x:\'b\', y:\'c\'"');
// Objects f & g & h are all actually instances of F, G's HasInstance method
// actually is checking whether the argument is an instance of F, and H's
// HasInstance calls G's which calls F's!
shouldBeTrue('f instanceof F');
shouldBeTrue('f instanceof G');
shouldBeTrue('f instanceof H');
shouldBeTrue('g instanceof F');
shouldBeTrue('g instanceof G');
shouldBeTrue('g instanceof H');
shouldBeTrue('h instanceof F');
shouldBeTrue('h instanceof G');
shouldBeTrue('h instanceof H');
// Bound functions don't have a 'prototype' property.
shouldBeTrue('"prototype" in F');
shouldBeFalse('"prototype" in G');
shouldBeFalse('"prototype" in H');
// The object passed to bind as 'this' must be callable.
shouldThrow('Function.bind.call(undefined)');
// Objects that allow call but not construct can be bound, but should throw if used with new.
var abcAt = String.prototype.charAt.bind("abc");
shouldBe('abcAt(1)', '"b"');
shouldThrow('new abcAt(1)');
// This exposes a bug in our implementation of instanceof. The prototype property should not
// be accessed until after we have established the default HasInstance is being executed.
// https://bugs.webkit.org/show_bug.cgi?id=68656
var boundFunctionPrototypeAccessed = false;
P = F.bind(1,2);
Object.defineProperty(P, 'prototype', { get:function(){ boundFunctionPrototypeAccessed = true; } });
f instanceof P;
shouldBeFalse('boundFunctionPrototypeAccessed');
var successfullyParsed = true;
......@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS ES5Harness.preconditionPassed is true
FAIL ES5Harness.testPassed should be true. Was false.
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS ES5Harness.preconditionPassed is true
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,7 +3,7 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS successfullyParsed is true
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -3,8 +3,8 @@
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
FAIL ES5Harness.preconditionPassed should be true (of type boolean). Was undefined (of type undefined).
FAIL ES5Harness.testPassed should be true (of type boolean). Was undefined (of type undefined).
PASS ES5Harness.preconditionPassed is true
PASS ES5Harness.testPassed is true
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -123,6 +123,7 @@ SET(JavaScriptCore_SOURCES
runtime/JSByteArray.cpp
runtime/JSCell.cpp
runtime/JSFunction.cpp
runtime/JSBoundFunction.cpp
runtime/JSGlobalData.cpp
runtime/JSGlobalObject.cpp
runtime/JSGlobalObjectFunctions.cpp
......
2011-09-22 Gavin Barraclough <barraclough@apple.com>
Implement Function.prototype.bind
https://bugs.webkit.org/show_bug.cgi?id=26382
Reviewed by Sam Weinig.
This patch provides a basic functional implementation
for Function.bind. It should (hopefully!) be fully
functionally correct, and the bound functions can be
called to quickly (since they are a subclass of
JSFunction, not InternalFunction), but we'll probably
want to follow up with some optimization work to keep
bound calls in JIT code.
* JavaScriptCore.JSVALUE32_64only.exp:
* JavaScriptCore.JSVALUE64only.exp:
* JavaScriptCore.exp:
* JavaScriptCore.xcodeproj/project.pbxproj:
* jit/JITStubs.cpp:
(JSC::JITThunks::hostFunctionStub):
* jit/JITStubs.h:
* jsc.cpp:
(GlobalObject::addFunction):
* runtime/CommonIdentifiers.h:
* runtime/ConstructData.h:
* runtime/Executable.h:
(JSC::NativeExecutable::NativeExecutable):
* runtime/FunctionPrototype.cpp:
(JSC::FunctionPrototype::addFunctionProperties):
(JSC::functionProtoFuncBind):
* runtime/FunctionPrototype.h:
* runtime/JSBoundFunction.cpp: Added.
(JSC::boundFunctionCall):
(JSC::boundFunctionConstruct):
(JSC::JSBoundFunction::create):
(JSC::JSBoundFunction::hasInstance):
(JSC::JSBoundFunction::getOwnPropertySlot):
(JSC::JSBoundFunction::getOwnPropertyDescriptor):
(JSC::JSBoundFunction::JSBoundFunction):
(JSC::JSBoundFunction::finishCreation):
* runtime/JSBoundFunction.h: Added.
(JSC::JSBoundFunction::targetFunction):
(JSC::JSBoundFunction::boundThis):
(JSC::JSBoundFunction::boundArgs):
(JSC::JSBoundFunction::createStructure):
* runtime/JSFunction.cpp:
(JSC::JSFunction::create):
(JSC::JSFunction::finishCreation):
(JSC::createDescriptorForThrowingProperty):
(JSC::JSFunction::getOwnPropertySlot):
* runtime/JSFunction.h:
* runtime/JSGlobalData.cpp:
(JSC::JSGlobalData::getHostFunction):
* runtime/JSGlobalData.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::boundFunctionStructure):
* runtime/Lookup.cpp:
(JSC::setUpStaticFunctionSlot):
2011-09-22 Oliver Hunt <oliver@apple.com>
Implement get_scoped_var in the DFG
......@@ -347,6 +347,8 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/JSCell.h \
Source/JavaScriptCore/runtime/JSFunction.cpp \
Source/JavaScriptCore/runtime/JSFunction.h \
Source/JavaScriptCore/runtime/JSBoundFunction.cpp \
Source/JavaScriptCore/runtime/JSBoundFunction.h \
Source/JavaScriptCore/runtime/JSGlobalData.cpp \
Source/JavaScriptCore/runtime/JSGlobalData.h \
Source/JavaScriptCore/runtime/JSGlobalObject.cpp \
......
__ZN3JSC12JSGlobalData15getHostFunctionEPFxPNS_9ExecStateEE
__ZN3JSC10JSFunction6createEPNS_9ExecStateEPNS_14JSGlobalObjectEiRKNS_10IdentifierEPFxS2_ES9_
__ZN3JSC12JSGlobalData15getHostFunctionEPFPvPNS_9ExecStateEE
__ZN3JSC10JSFunction6createEPNS_9ExecStateEPNS_14JSGlobalObjectEiRKNS_10IdentifierEPFPvS2_ESA_
......@@ -109,7 +109,6 @@ __ZN3JSC10Identifier3addEPNS_9ExecStateEPKc
__ZN3JSC10Identifier4fromEPNS_9ExecStateEi
__ZN3JSC10Identifier4fromEPNS_9ExecStateEj
__ZN3JSC10Identifier8toUInt32ERKNS_7UStringERb
__ZN3JSC10JSFunction14finishCreationEPNS_9ExecStateEiRKNS_10IdentifierEPNS_14ExecutableBaseE
__ZN3JSC10JSFunction4nameEPNS_9ExecStateE
__ZN3JSC10JSFunction6s_infoE
__ZN3JSC10JSFunctionC1EPNS_9ExecStateEPNS_14JSGlobalObjectEPNS_9StructureE
......@@ -229,6 +228,7 @@ __ZN3JSC24DynamicGlobalObjectScopeC1ERNS_12JSGlobalDataEPNS_14JSGlobalObjectE
__ZN3JSC24TerminatedExecutionError6s_infoE
__ZN3JSC24createStackOverflowErrorEPNS_9ExecStateE
__ZN3JSC25evaluateInGlobalCallFrameERKNS_7UStringERNS_7JSValueEPNS_14JSGlobalObjectE
__ZN3JSC29callHostFunctionAsConstructorEPNS_9ExecStateE
__ZN3JSC30isTerminatedExecutionExceptionENS_7JSValueE
__ZN3JSC35createInterruptedExecutionExceptionEPNS_12JSGlobalDataE
__ZN3JSC41constructFunctionSkippingEvalEnabledCheckEPNS_9ExecStateEPNS_14JSGlobalObjectERKNS_7ArgListERKNS_10IdentifierERKNS_7UStringEi
......
......@@ -83,6 +83,7 @@
'runtime/JSByteArray.h',
'runtime/JSCell.h',
'runtime/JSFunction.h',
'runtime/JSBoundFunction.h',
'runtime/JSGlobalData.h',
'runtime/JSGlobalObject.h',
'runtime/JSLock.h',
......@@ -516,6 +517,7 @@
'runtime/JSByteArray.cpp',
'runtime/JSCell.cpp',
'runtime/JSFunction.cpp',
'runtime/JSBoundFunction.cpp',
'runtime/JSGlobalData.cpp',
'runtime/JSGlobalObject.cpp',
'runtime/JSGlobalObjectFunctions.cpp',
......
......@@ -153,6 +153,7 @@ SOURCES += \
runtime/JSByteArray.cpp \
runtime/JSCell.cpp \
runtime/JSFunction.cpp \
runtime/JSBoundFunction.cpp \
runtime/JSGlobalData.cpp \
runtime/JSGlobalObject.cpp \
runtime/JSGlobalObjectFunctions.cpp \
......
......@@ -797,6 +797,14 @@
RelativePath="..\..\runtime\JSFunction.h"
>
</File>
<File
RelativePath="..\..\runtime\JSBoundFunction.cpp"
>
</File>
<File
RelativePath="..\..\runtime\JSBoundFunction.h"
>
</File>
<File
RelativePath="..\..\runtime\JSGlobalData.cpp"
>
......
......@@ -361,6 +361,8 @@
86ECA3EA132DEF1C002B2AD7 /* DFGNode.h in Headers */ = {isa = PBXBuildFile; fileRef = 86ECA3E9132DEF1C002B2AD7 /* DFGNode.h */; };
86ECA3FA132DF25A002B2AD7 /* DFGScoreBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = 86ECA3F9132DF25A002B2AD7 /* DFGScoreBoard.h */; };
86F38859121130CA007A7CE3 /* AtomicStringHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 86F38858121130CA007A7CE3 /* AtomicStringHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
86FA9E91142BBB2E001773B7 /* JSBoundFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86FA9E8F142BBB2D001773B7 /* JSBoundFunction.cpp */; };
86FA9E92142BBB2E001773B7 /* JSBoundFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 86FA9E90142BBB2E001773B7 /* JSBoundFunction.h */; };
90213E3D123A40C200D422F3 /* MemoryStatistics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90213E3B123A40C200D422F3 /* MemoryStatistics.cpp */; };
90213E3E123A40C200D422F3 /* MemoryStatistics.h in Headers */ = {isa = PBXBuildFile; fileRef = 90213E3C123A40C200D422F3 /* MemoryStatistics.h */; settings = {ATTRIBUTES = (Private, ); }; };
905B02AE0E28640F006DF882 /* RefCountedLeakCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 905B02AD0E28640F006DF882 /* RefCountedLeakCounter.cpp */; };
......@@ -1115,6 +1117,8 @@
86ECA3E9132DEF1C002B2AD7 /* DFGNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGNode.h; path = dfg/DFGNode.h; sourceTree = "<group>"; };
86ECA3F9132DF25A002B2AD7 /* DFGScoreBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGScoreBoard.h; path = dfg/DFGScoreBoard.h; sourceTree = "<group>"; };
86F38858121130CA007A7CE3 /* AtomicStringHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AtomicStringHash.h; path = text/AtomicStringHash.h; sourceTree = "<group>"; };
86FA9E8F142BBB2D001773B7 /* JSBoundFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBoundFunction.cpp; sourceTree = "<group>"; };
86FA9E90142BBB2E001773B7 /* JSBoundFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBoundFunction.h; sourceTree = "<group>"; };
90213E3B123A40C200D422F3 /* MemoryStatistics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryStatistics.cpp; sourceTree = "<group>"; };
90213E3C123A40C200D422F3 /* MemoryStatistics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryStatistics.h; sourceTree = "<group>"; };
905B02AD0E28640F006DF882 /* RefCountedLeakCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RefCountedLeakCounter.cpp; sourceTree = "<group>"; };
......@@ -2066,6 +2070,8 @@
14DA818E0D99FD2000B0A4FB /* JSActivation.h */,
93ADFCE60CCBD7AC00D30B08 /* JSArray.cpp */,
938772E5038BFE19008635CE /* JSArray.h */,