https://bugs.webkit.org/show_bug.cgi?id=131083
Unreviewed.
Rolling out r167020 while investigating a performance regression.
Source/JavaScriptCore:
* API/JSObjectRef.cpp:
(JSObjectMakeConstructor):
* API/JSScriptRef.cpp:
(parseScript):
* CMakeLists.txt:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createBuiltinExecutable):
* builtins/Function.prototype.js:
(apply):
(bind.bindingFunction): Deleted.
(bind.else.bindingFunction): Deleted.
(bind): Deleted.
* bytecode/UnlinkedCodeBlock.cpp:
(JSC::generateFunctionCodeBlock):
* bytecompiler/NodesCodegen.cpp:
(JSC::InstanceOfNode::emitBytecode):
* interpreter/Interpreter.cpp:
* parser/Lexer.cpp:
(JSC::Lexer<T>::Lexer):
(JSC::Lexer<LChar>::parseIdentifier):
(JSC::Lexer<UChar>::parseIdentifier):
* parser/Lexer.h:
* parser/Parser.cpp:
(JSC::Parser<LexerType>::Parser):
(JSC::Parser<LexerType>::parseInner):
* parser/Parser.h:
(JSC::parse):
* parser/ParserModes.h:
* runtime/ArgumentsIteratorConstructor.cpp:
(JSC::ArgumentsIteratorConstructor::finishCreation):
* runtime/ArrayConstructor.cpp:
(JSC::ArrayConstructor::finishCreation):
* runtime/BooleanConstructor.cpp:
(JSC::BooleanConstructor::finishCreation):
* runtime/CodeCache.cpp:
(JSC::CodeCache::getGlobalCodeBlock):
(JSC::CodeCache::getFunctionExecutableFromGlobalCode):
* runtime/CommonIdentifiers.h:
* runtime/Completion.cpp:
(JSC::checkSyntax):
* runtime/DateConstructor.cpp:
(JSC::DateConstructor::finishCreation):
* runtime/ErrorConstructor.cpp:
(JSC::ErrorConstructor::finishCreation):
* runtime/Executable.cpp:
(JSC::ProgramExecutable::checkSyntax):
* runtime/FunctionConstructor.cpp:
(JSC::FunctionConstructor::finishCreation):
* runtime/FunctionPrototype.cpp:
(JSC::FunctionPrototype::addFunctionProperties):
(JSC::functionProtoFuncBind):
* runtime/JSArrayBufferConstructor.cpp:
(JSC::JSArrayBufferConstructor::finishCreation):
* runtime/JSBoundFunction.cpp: Added.
(JSC::boundFunctionCall):
(JSC::boundFunctionConstruct):
(JSC::JSBoundFunction::create):
(JSC::JSBoundFunction::destroy):
(JSC::JSBoundFunction::customHasInstance):
(JSC::JSBoundFunction::JSBoundFunction):
(JSC::JSBoundFunction::finishCreation):
(JSC::JSBoundFunction::visitChildren):
* runtime/JSBoundFunction.h: Added.
(JSC::JSBoundFunction::targetFunction):
(JSC::JSBoundFunction::boundThis):
(JSC::JSBoundFunction::boundArgs):
(JSC::JSBoundFunction::createStructure):
* runtime/JSFunction.cpp:
(JSC::RetrieveCallerFunctionFunctor::RetrieveCallerFunctionFunctor):
(JSC::RetrieveCallerFunctionFunctor::operator()):
(JSC::retrieveCallerFunction):
(JSC::JSFunction::getOwnPropertySlot):
(JSC::JSFunction::getOwnNonIndexPropertyNames):
(JSC::JSFunction::put):
(JSC::JSFunction::defineOwnProperty):
* runtime/JSGenericTypedArrayViewConstructorInlines.h:
(JSC::JSGenericTypedArrayViewConstructor<ViewClass>::finishCreation):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::globalFuncSetTypeErrorAccessor): Deleted.
* runtime/JSGlobalObjectFunctions.h:
* runtime/JSObject.cpp:
(JSC::JSObject::putDirectPrototypeProperty): Deleted.
(JSC::JSObject::putDirectPrototypePropertyWithoutTransitions): Deleted.
* runtime/JSObject.h:
* runtime/JSPromiseConstructor.cpp:
(JSC::JSPromiseConstructor::finishCreation):
* runtime/MapConstructor.cpp:
(JSC::MapConstructor::finishCreation):
* runtime/MapIteratorConstructor.cpp:
(JSC::MapIteratorConstructor::finishCreation):
* runtime/NameConstructor.cpp:
(JSC::NameConstructor::finishCreation):
* runtime/NativeErrorConstructor.cpp:
(JSC::NativeErrorConstructor::finishCreation):
* runtime/NumberConstructor.cpp:
(JSC::NumberConstructor::finishCreation):
* runtime/ObjectConstructor.cpp:
(JSC::ObjectConstructor::finishCreation):
* runtime/RegExpConstructor.cpp:
(JSC::RegExpConstructor::finishCreation):
* runtime/SetConstructor.cpp:
(JSC::SetConstructor::finishCreation):
* runtime/SetIteratorConstructor.cpp:
(JSC::SetIteratorConstructor::finishCreation):
* runtime/StringConstructor.cpp:
(JSC::StringConstructor::finishCreation):
* runtime/WeakMapConstructor.cpp:
(JSC::WeakMapConstructor::finishCreation):
Source/WebCore:
* bindings/js/JSImageConstructor.cpp:
(WebCore::JSImageConstructor::finishCreation):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateConstructorHelperMethods):
* bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
(WebCore::JSTestActiveDOMObjectConstructor::finishCreation):
* bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
(WebCore::JSTestCustomNamedGetterConstructor::finishCreation):
* bindings/scripts/test/JS/JSTestEventConstructor.cpp:
(WebCore::JSTestEventConstructorConstructor::finishCreation):
* bindings/scripts/test/JS/JSTestEventTarget.cpp:
(WebCore::JSTestEventTargetConstructor::finishCreation):
* bindings/scripts/test/JS/JSTestException.cpp:
(WebCore::JSTestExceptionConstructor::finishCreation):
* bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:
(WebCore::JSTestGenerateIsReachableConstructor::finishCreation):
* bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore::JSTestInterfaceConstructor::finishCreation):
* bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
(WebCore::JSTestMediaQueryListListenerConstructor::finishCreation):
* bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
(WebCore::JSTestNamedConstructorConstructor::finishCreation):
(WebCore::JSTestNamedConstructorNamedConstructor::finishCreation):
* bindings/scripts/test/JS/JSTestNode.cpp:
(WebCore::JSTestNodeConstructor::finishCreation):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::JSTestObjConstructor::finishCreation):
* bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
(WebCore::JSTestOverloadedConstructorsConstructor::finishCreation):
* bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
(WebCore::JSTestSerializedScriptValueInterfaceConstructor::finishCreation):
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
(WebCore::JSTestTypedefsConstructor::finishCreation):
* bindings/scripts/test/JS/JSattribute.cpp:
(WebCore::JSattributeConstructor::finishCreation):
* bindings/scripts/test/JS/JSreadonly.cpp:
(WebCore::JSreadonlyConstructor::finishCreation):
LayoutTests:
* js/dom/function-bind-expected.txt:
* js/regress/function-bind-expected.txt: Removed.
* js/regress/function-bind.html: Removed.
* js/regress/script-tests/function-bind.js: Removed.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@167165
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-04-11 Gavin Barraclough <baraclough@apple.com>
+
+ Rollout - Rewrite Function.bind as a builtin
+ https://bugs.webkit.org/show_bug.cgi?id=131083
+
+ Unreviewed.
+
+ Rolling out r167020 while investigating a performance regression.
+
+ * js/dom/function-bind-expected.txt:
+ * js/regress/function-bind-expected.txt: Removed.
+ * js/regress/function-bind.html: Removed.
+ * js/regress/script-tests/function-bind.js: Removed.
+
2014-04-11 Hans Muller <hmuller@adobe.com>
[CSS Shapes] shape-outside from image doesn't load properly
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS new (decodeURI.bind())() threw exception TypeError: function is not a constructor.
+PASS new (decodeURI.bind())() threw exception TypeError: function is not a constructor (evaluating 'new (decodeURI.bind())()').
PASS (new (String.bind())('foo')).toString() is 'foo'
PASS result is "[object Window] -> x:1, y:2"
PASS result is "'a' -> x:'b', y:1"
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: Cannot bind non-function object..
+PASS Function.bind.call(undefined) threw exception TypeError: Type error.
PASS abcAt(1) is "b"
-PASS new abcAt(1) threw exception TypeError: function is not a constructor.
+PASS new abcAt(1) threw exception TypeError: function is not a constructor (evaluating 'new abcAt(1)').
PASS boundFunctionPrototypeAccessed is false
PASS Function.bind.length is 1
PASS successfullyParsed is true
+++ /dev/null
-JSRegress/function-bind
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS no exception thrown
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-<head>
-<script src="../../resources/js-test-pre.js"></script>
-</head>
-<body>
-<script src="../../resources/regress-pre.js"></script>
-<script src="script-tests/function-bind.js"></script>
-<script src="../../resources/regress-post.js"></script>
-<script src="../../resources/js-test-post.js"></script>
-</body>
-</html>
+++ /dev/null
-function foo(a,b) {
- return a ^ b;
-}
-
-var g = foo.bind({});
-
-var result = 0;
-for (var i = 0; i < 100000; ++i) {
- result *= 3;
- result += g(i, result);
- result |= 0;
-}
-
-if (result != -2055604513)
- throw "Bad result: " + result;
JSCallbackConstructor* constructor = JSCallbackConstructor::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
constructor->putDirect(exec->vm(), exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
- constructor->putDirect(exec->vm(), exec->propertyNames().prototypeForHasInstancePrivateName, jsPrototype, DontEnum | DontDelete | ReadOnly);
return toRef(constructor);
}
static bool parseScript(VM* vm, const SourceCode& source, ParserError& error)
{
- return JSC::parse<JSC::ProgramNode>(vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, JSNotFunctionKind, error);
+ return JSC::parse<JSC::ProgramNode>(vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error);
}
extern "C" {
runtime/JSArrayBufferPrototype.cpp
runtime/JSArrayBufferView.cpp
runtime/JSArrayIterator.cpp
+ runtime/JSBoundFunction.cpp
runtime/JSCJSValue.cpp
runtime/JSCell.cpp
runtime/JSConsole.cpp
+2014-04-11 Gavin Barraclough <baraclough@apple.com>
+
+ Rollout - Rewrite Function.bind as a builtin
+ https://bugs.webkit.org/show_bug.cgi?id=131083
+
+ Unreviewed.
+
+ Rolling out r167020 while investigating a performance regression.
+
+ * API/JSObjectRef.cpp:
+ (JSObjectMakeConstructor):
+ * API/JSScriptRef.cpp:
+ (parseScript):
+ * CMakeLists.txt:
+ * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
+ * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * builtins/BuiltinExecutables.cpp:
+ (JSC::BuiltinExecutables::createBuiltinExecutable):
+ * builtins/Function.prototype.js:
+ (apply):
+ (bind.bindingFunction): Deleted.
+ (bind.else.bindingFunction): Deleted.
+ (bind): Deleted.
+ * bytecode/UnlinkedCodeBlock.cpp:
+ (JSC::generateFunctionCodeBlock):
+ * bytecompiler/NodesCodegen.cpp:
+ (JSC::InstanceOfNode::emitBytecode):
+ * interpreter/Interpreter.cpp:
+ * parser/Lexer.cpp:
+ (JSC::Lexer<T>::Lexer):
+ (JSC::Lexer<LChar>::parseIdentifier):
+ (JSC::Lexer<UChar>::parseIdentifier):
+ * parser/Lexer.h:
+ * parser/Parser.cpp:
+ (JSC::Parser<LexerType>::Parser):
+ (JSC::Parser<LexerType>::parseInner):
+ * parser/Parser.h:
+ (JSC::parse):
+ * parser/ParserModes.h:
+ * runtime/ArgumentsIteratorConstructor.cpp:
+ (JSC::ArgumentsIteratorConstructor::finishCreation):
+ * runtime/ArrayConstructor.cpp:
+ (JSC::ArrayConstructor::finishCreation):
+ * runtime/BooleanConstructor.cpp:
+ (JSC::BooleanConstructor::finishCreation):
+ * runtime/CodeCache.cpp:
+ (JSC::CodeCache::getGlobalCodeBlock):
+ (JSC::CodeCache::getFunctionExecutableFromGlobalCode):
+ * runtime/CommonIdentifiers.h:
+ * runtime/Completion.cpp:
+ (JSC::checkSyntax):
+ * runtime/DateConstructor.cpp:
+ (JSC::DateConstructor::finishCreation):
+ * runtime/ErrorConstructor.cpp:
+ (JSC::ErrorConstructor::finishCreation):
+ * runtime/Executable.cpp:
+ (JSC::ProgramExecutable::checkSyntax):
+ * runtime/FunctionConstructor.cpp:
+ (JSC::FunctionConstructor::finishCreation):
+ * runtime/FunctionPrototype.cpp:
+ (JSC::FunctionPrototype::addFunctionProperties):
+ (JSC::functionProtoFuncBind):
+ * runtime/JSArrayBufferConstructor.cpp:
+ (JSC::JSArrayBufferConstructor::finishCreation):
+ * runtime/JSBoundFunction.cpp: Added.
+ (JSC::boundFunctionCall):
+ (JSC::boundFunctionConstruct):
+ (JSC::JSBoundFunction::create):
+ (JSC::JSBoundFunction::destroy):
+ (JSC::JSBoundFunction::customHasInstance):
+ (JSC::JSBoundFunction::JSBoundFunction):
+ (JSC::JSBoundFunction::finishCreation):
+ (JSC::JSBoundFunction::visitChildren):
+ * runtime/JSBoundFunction.h: Added.
+ (JSC::JSBoundFunction::targetFunction):
+ (JSC::JSBoundFunction::boundThis):
+ (JSC::JSBoundFunction::boundArgs):
+ (JSC::JSBoundFunction::createStructure):
+ * runtime/JSFunction.cpp:
+ (JSC::RetrieveCallerFunctionFunctor::RetrieveCallerFunctionFunctor):
+ (JSC::RetrieveCallerFunctionFunctor::operator()):
+ (JSC::retrieveCallerFunction):
+ (JSC::JSFunction::getOwnPropertySlot):
+ (JSC::JSFunction::getOwnNonIndexPropertyNames):
+ (JSC::JSFunction::put):
+ (JSC::JSFunction::defineOwnProperty):
+ * runtime/JSGenericTypedArrayViewConstructorInlines.h:
+ (JSC::JSGenericTypedArrayViewConstructor<ViewClass>::finishCreation):
+ * runtime/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::reset):
+ * runtime/JSGlobalObjectFunctions.cpp:
+ (JSC::globalFuncSetTypeErrorAccessor): Deleted.
+ * runtime/JSGlobalObjectFunctions.h:
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::putDirectPrototypeProperty): Deleted.
+ (JSC::JSObject::putDirectPrototypePropertyWithoutTransitions): Deleted.
+ * runtime/JSObject.h:
+ * runtime/JSPromiseConstructor.cpp:
+ (JSC::JSPromiseConstructor::finishCreation):
+ * runtime/MapConstructor.cpp:
+ (JSC::MapConstructor::finishCreation):
+ * runtime/MapIteratorConstructor.cpp:
+ (JSC::MapIteratorConstructor::finishCreation):
+ * runtime/NameConstructor.cpp:
+ (JSC::NameConstructor::finishCreation):
+ * runtime/NativeErrorConstructor.cpp:
+ (JSC::NativeErrorConstructor::finishCreation):
+ * runtime/NumberConstructor.cpp:
+ (JSC::NumberConstructor::finishCreation):
+ * runtime/ObjectConstructor.cpp:
+ (JSC::ObjectConstructor::finishCreation):
+ * runtime/RegExpConstructor.cpp:
+ (JSC::RegExpConstructor::finishCreation):
+ * runtime/SetConstructor.cpp:
+ (JSC::SetConstructor::finishCreation):
+ * runtime/SetIteratorConstructor.cpp:
+ (JSC::SetIteratorConstructor::finishCreation):
+ * runtime/StringConstructor.cpp:
+ (JSC::StringConstructor::finishCreation):
+ * runtime/WeakMapConstructor.cpp:
+ (JSC::WeakMapConstructor::finishCreation):
+
2014-04-11 David Kilzer <ddkilzer@apple.com>
[ASan] Build broke because libCompileRuntimeToLLVMIR.a links to libclang_rt.asan_osx_dynamic.dylib
<ClCompile Include="..\runtime\JSArrayBufferConstructor.cpp" />
<ClCompile Include="..\runtime\JSArrayBufferPrototype.cpp" />
<ClCompile Include="..\runtime\JSArrayBufferView.cpp" />
+ <ClCompile Include="..\runtime\JSBoundFunction.cpp" />
<ClCompile Include="..\runtime\JSCJSValue.cpp" />
<ClCompile Include="..\runtime\JSCell.cpp" />
<ClCompile Include="..\runtime\JSConsole.cpp" />
<ClInclude Include="..\runtime\JSArrayBufferView.h" />
<ClInclude Include="..\runtime\JSArrayBufferViewInlines.h" />
<ClInclude Include="..\runtime\JSArrayIterator.h" />
+ <ClInclude Include="..\runtime\JSBoundFunction.h" />
<ClInclude Include="..\runtime\JSCInlines.h" />
<ClInclude Include="..\runtime\JSCJSValue.h" />
<ClInclude Include="..\runtime\JSCJSValueInlines.h" />
<ClCompile Include="..\runtime\JSArray.cpp">
<Filter>runtime</Filter>
</ClCompile>
+ <ClCompile Include="..\runtime\JSBoundFunction.cpp">
+ <Filter>runtime</Filter>
+ </ClCompile>
<ClCompile Include="..\runtime\JSCell.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClInclude Include="..\runtime\JSArray.h">
<Filter>runtime</Filter>
</ClInclude>
+ <ClInclude Include="..\runtime\JSBoundFunction.h">
+ <Filter>runtime</Filter>
+ </ClInclude>
<ClInclude Include="..\runtime\JSCell.h">
<Filter>runtime</Filter>
</ClInclude>
86F3EEBD168CDE930077B92A /* ObjCCallbackFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 86F3EEB9168CCF750077B92A /* ObjCCallbackFunction.h */; };
86F3EEBE168CDE930077B92A /* ObjCCallbackFunction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 86F3EEBA168CCF750077B92A /* ObjCCallbackFunction.mm */; };
86F3EEBF168CDE930077B92A /* ObjcRuntimeExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 86F3EEB616855A5B0077B92A /* ObjcRuntimeExtras.h */; };
+ 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, ); }; };
93052C340FB792190048FDC3 /* ParserArena.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93052C320FB792190048FDC3 /* ParserArena.cpp */; };
86F75EFB151C062F007C9BA3 /* RegExpCachedResult.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegExpCachedResult.cpp; sourceTree = "<group>"; };
86F75EFC151C062F007C9BA3 /* RegExpCachedResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpCachedResult.h; sourceTree = "<group>"; };
86F75EFD151C062F007C9BA3 /* RegExpMatchesArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegExpMatchesArray.cpp; 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>"; };
93052C320FB792190048FDC3 /* ParserArena.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParserArena.cpp; sourceTree = "<group>"; };
0F2B66BC17B6B5AB00A7AE3F /* JSArrayBufferViewInlines.h */,
A7BDAEC417F4EA1400F6140C /* JSArrayIterator.cpp */,
A7BDAEC517F4EA1400F6140C /* JSArrayIterator.h */,
+ 86FA9E8F142BBB2D001773B7 /* JSBoundFunction.cpp */,
+ 86FA9E90142BBB2E001773B7 /* JSBoundFunction.h */,
BC7F8FBA0E19D1EF008632C0 /* JSCell.cpp */,
BC1167D80E19BCC9008066DD /* JSCell.h */,
0F97496F1687ADE200A4FF6A /* JSCellInlines.h */,
A7BDAECB17F4EA1400F6140C /* JSArrayIterator.h in Headers */,
BC18C4180E16F5CD00B34460 /* JSBase.h in Headers */,
140D17D70E8AD4A9000CD17D /* JSBasePrivate.h in Headers */,
+ 86FA9E92142BBB2E001773B7 /* JSBoundFunction.h in Headers */,
BC18C4190E16F5CD00B34460 /* JSCallbackConstructor.h in Headers */,
BC18C41A0E16F5CD00B34460 /* JSCallbackFunction.h in Headers */,
BC18C41B0E16F5CD00B34460 /* JSCallbackObject.h in Headers */,
0F2B66E817B6B5AB00A7AE3F /* JSArrayBufferView.cpp in Sources */,
A7BDAECA17F4EA1400F6140C /* JSArrayIterator.cpp in Sources */,
1421359B0A677F4F00A8195E /* JSBase.cpp in Sources */,
+ 86FA9E91142BBB2E001773B7 /* JSBoundFunction.cpp in Sources */,
1440F8AF0A508D200005F061 /* JSCallbackConstructor.cpp in Sources */,
1440F8920A508B100005F061 /* JSCallbackFunction.cpp in Sources */,
14ABDF600A437FEF00ECCA01 /* JSCallbackObject.cpp in Sources */,
{
JSTextPosition positionBeforeLastNewline;
ParserError error;
- RefPtr<ProgramNode> program = parse<ProgramNode>(&m_vm, source, 0, Identifier(), JSParseBuiltin, JSParseProgramCode, JSNotFunctionKind, error, &positionBeforeLastNewline);
+ RefPtr<ProgramNode> program = parse<ProgramNode>(&m_vm, source, 0, Identifier(), JSParseBuiltin, JSParseProgramCode, error, &positionBeforeLastNewline);
if (!program) {
dataLog("Fatal error compiling builtin function '", name.string(), "': ", error.m_message);
RELEASE_ASSERT(body);
for (const auto& closedVariable : program->closedVariables()) {
if (closedVariable == m_vm.propertyNames->arguments.impl())
- continue;
+ continue;
if (closedVariable == m_vm.propertyNames->undefinedKeyword.impl())
continue;
"use strict";
return this.@apply(thisValue, argumentValues);
}
-
-function bind(thisValue /*, optional arguments */)
-{
- "use strict";
- var boundFunction = this;
- if (typeof boundFunction !== "function")
- throw new @TypeError("Cannot bind non-function object.");
- var bindingFunction;
- if (arguments.length <= 1) {
- bindingFunction = function () {
- if (@IsConstructor) {
- return new boundFunction(...arguments);
- } else {
- return boundFunction.@apply(thisValue, arguments);
- }
- }
- } else {
- var boundParameters = [];
- var length = arguments.length;
- for (var i = 1; i < length; i++)
- boundParameters[i - 1] = arguments[i];
-
- bindingFunction = function () {
- if (arguments.length) {
- var completeArguments = [...boundParameters, ...arguments];
- if (@IsConstructor)
- return new boundFunction(...completeArguments);
- else
- return boundFunction.@apply(thisValue, completeArguments);
- }
- if (@IsConstructor)
- return new boundFunction(...boundParameters);
- else
- return boundFunction.@apply(thisValue, boundParameters);
-
- }
- }
- bindingFunction.@boundFunctionName = this.name;
- bindingFunction.@boundFunction = boundFunction.@boundFunction || boundFunction;
- var boundLength = boundFunction.length - (arguments.length - 1);
- if (boundLength < 0)
- boundLength = 0;
- bindingFunction.@boundFunctionLength = boundLength;
- @SetTypeErrorAccessor(bindingFunction, "arguments");
- @SetTypeErrorAccessor(bindingFunction, "caller");
- return bindingFunction;
-}
static UnlinkedFunctionCodeBlock* generateFunctionCodeBlock(VM& vm, UnlinkedFunctionExecutable* executable, const SourceCode& source, CodeSpecializationKind kind, DebuggerMode debuggerMode, ProfilerMode profilerMode, UnlinkedFunctionKind functionKind, ParserError& error)
{
- RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(&vm, source, executable->parameters(), executable->name(), executable->toStrictness(), JSParseFunctionCode, kind == CodeForConstruct ? JSFunctionIsConstructorKind : JSFunctionIsFunctionKind, error);
+ RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(&vm, source, executable->parameters(), executable->name(), executable->toStrictness(), JSParseFunctionCode, error);
if (!body) {
ASSERT(error.m_type != ParserError::ErrorNone);
generator.emitCheckHasInstance(dstReg.get(), src1.get(), src2.get(), target.get());
generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
- generator.emitGetById(prototype.get(), src2.get(), generator.vm()->propertyNames->prototypeForHasInstancePrivateName);
+ generator.emitGetById(prototype.get(), src2.get(), generator.vm()->propertyNames->prototype);
generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
RegisterID* result = generator.emitInstanceOf(dstReg.get(), src1.get(), prototype.get());
#include "GetterSetter.h"
#include "JSActivation.h"
#include "JSArray.h"
+#include "JSBoundFunction.h"
#include "JSNameScope.h"
#include "JSNotAnObject.h"
#include "JSPropertyNameIterator.h"
};
template <typename T>
-Lexer<T>::Lexer(VM* vm, JSParserStrictness strictness, JSFunctionKind functionKind)
+Lexer<T>::Lexer(VM* vm, JSParserStrictness strictness)
: m_isReparsing(false)
, m_vm(vm)
, m_parsingBuiltinFunction(strictness == JSParseBuiltin)
- , m_functionKind(functionKind)
{
}
ident = m_vm->propertyNames->getPrivateName(*ident);
else if (*ident == m_vm->propertyNames->undefinedKeyword)
tokenData->ident = &m_vm->propertyNames->undefinedPrivateName;
-
if (!ident)
return INVALID_PRIVATE_NAME_ERRORTOK;
-
- if (*ident == m_vm->propertyNames->IsConstructorPrivateName)
- return m_functionKind == JSFunctionIsConstructorKind ? TRUETOKEN : FALSETOKEN;
-
}
tokenData->ident = ident;
} else
ident = m_vm->propertyNames->getPrivateName(*ident);
else if (*ident == m_vm->propertyNames->undefinedKeyword)
tokenData->ident = &m_vm->propertyNames->undefinedPrivateName;
- if (m_functionKind == JSFunctionIsConstructorKind) {
- if (*ident == m_vm->propertyNames->IsConstructorPrivateName)
- return TRUETOKEN;
- return FALSETOKEN;
- }
if (!ident)
return INVALID_PRIVATE_NAME_ERRORTOK;
}
WTF_MAKE_FAST_ALLOCATED;
public:
- Lexer(VM*, JSParserStrictness, JSFunctionKind);
+ Lexer(VM*, JSParserStrictness);
~Lexer();
// Character manipulation functions.
VM* m_vm;
bool m_parsingBuiltinFunction;
- JSFunctionKind m_functionKind;
};
template <>
}
template <typename LexerType>
-Parser<LexerType>::Parser(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, JSFunctionKind functionKind)
+Parser<LexerType>::Parser(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode)
: m_vm(vm)
, m_source(&source)
, m_hasStackOverflow(false)
, m_sourceElements(0)
, m_parsingBuiltin(strictness == JSParseBuiltin)
{
- m_lexer = adoptPtr(new LexerType(vm, strictness, functionKind));
+ m_lexer = adoptPtr(new LexerType(vm, strictness));
m_arena = m_vm->parserArena.get();
m_lexer->setCode(source, m_arena);
m_token.m_location.line = source.firstLine();
Vector<RefPtr<StringImpl>> closedVariables;
if (m_parsingBuiltin) {
+ RELEASE_ASSERT(!capturedVariables.size());
IdentifierSet usedVariables;
scope->getUsedVariables(usedVariables);
for (const auto& variable : usedVariables) {
continue;
closedVariables.append(variable);
}
- if (!capturedVariables.isEmpty()) {
- for (const auto& capturedVariable : capturedVariables) {
- if (scope->hasDeclaredVariable(Identifier(m_vm, capturedVariable.get())))
- continue;
-
- if (scope->hasDeclaredParameter(Identifier(m_vm, capturedVariable.get())))
- continue;
- RELEASE_ASSERT_NOT_REACHED();
- }
- }
}
didFinishParsing(sourceElements, context.varDeclarations(), context.funcDeclarations(), features,
context.numConstants(), capturedVariables, std::move(closedVariables));
WTF_MAKE_FAST_ALLOCATED;
public:
- Parser(VM*, const SourceCode&, FunctionParameters*, const Identifier&, JSParserStrictness, JSParserMode, JSFunctionKind);
+ Parser(VM*, const SourceCode&, FunctionParameters*, const Identifier&, JSParserStrictness, JSParserMode);
~Parser();
template <class ParsedNode>
}
template <class ParsedNode>
-PassRefPtr<ParsedNode> parse(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, JSFunctionKind functionKind, ParserError& error, JSTextPosition* positionBeforeLastNewline = 0)
+PassRefPtr<ParsedNode> parse(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, ParserError& error, JSTextPosition* positionBeforeLastNewline = 0)
{
SamplingRegion samplingRegion("Parsing");
ASSERT(!source.provider()->source().isNull());
if (source.provider()->source().is8Bit()) {
- Parser<Lexer<LChar>> parser(vm, source, parameters, name, strictness, parserMode, functionKind);
+ Parser<Lexer<LChar>> parser(vm, source, parameters, name, strictness, parserMode);
RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error);
if (positionBeforeLastNewline)
*positionBeforeLastNewline = parser.positionBeforeLastNewline();
}
return result.release();
}
- Parser<Lexer<UChar>> parser(vm, source, parameters, name, strictness, parserMode, functionKind);
+ Parser<Lexer<UChar>> parser(vm, source, parameters, name, strictness, parserMode);
RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error);
if (positionBeforeLastNewline)
*positionBeforeLastNewline = parser.positionBeforeLastNewline();
enum JSParserStrictness { JSParseNormal, JSParseBuiltin, JSParseStrict };
enum JSParserMode { JSParseProgramCode, JSParseFunctionCode };
-enum JSFunctionKind { JSNotFunctionKind, JSFunctionIsFunctionKind, JSFunctionIsConstructorKind };
-
+
enum ProfilerMode { ProfilerOff, ProfilerOn };
enum DebuggerMode { DebuggerOff, DebuggerOn };
void ArgumentsIteratorConstructor::finishCreation(VM& vm, ArgumentsIteratorPrototype* prototype)
{
Base::finishCreation(vm);
- putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
}
}
void ArrayConstructor::finishCreation(VM& vm, ArrayPrototype* arrayPrototype)
{
Base::finishCreation(vm, arrayPrototype->classInfo()->className);
- putDirectPrototypePropertyWithoutTransitions(vm, arrayPrototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, arrayPrototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
}
void BooleanConstructor::finishCreation(VM& vm, BooleanPrototype* booleanPrototype)
{
Base::finishCreation(vm, booleanPrototype->classInfo()->className);
- putDirectPrototypePropertyWithoutTransitions(vm, booleanPrototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly);
// no. of arguments for constructor
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
}
typedef typename CacheTypes<UnlinkedCodeBlockType>::RootNode RootNode;
- RefPtr<RootNode> rootNode = parse<RootNode>(&vm, source, 0, Identifier(), strictness, JSParseProgramCode, JSNotFunctionKind, error);
+ RefPtr<RootNode> rootNode = parse<RootNode>(&vm, source, 0, Identifier(), strictness, JSParseProgramCode, error);
if (!rootNode) {
m_sourceCode.remove(addResult.iterator);
return 0;
return jsCast<UnlinkedFunctionExecutable*>(addResult.iterator->value.cell.get());
JSTextPosition positionBeforeLastNewline;
- RefPtr<ProgramNode> program = parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, JSNotFunctionKind, error, &positionBeforeLastNewline);
+ RefPtr<ProgramNode> program = parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error, &positionBeforeLastNewline);
if (!program) {
RELEASE_ASSERT(error.m_type != ParserError::ErrorNone);
m_sourceCode.remove(addResult.iterator);
macro(Object) \
macro(TypeError) \
macro(undefined) \
- macro(IsConstructor) \
- macro(boundFunctionName) \
- macro(boundFunctionParameters) \
- macro(boundFunction) \
- macro(boundFunctionLength) \
- macro(prototypeForHasInstance) \
- macro(SetTypeErrorAccessor) \
macro(BuiltinLog)
namespace JSC {
{
JSLockHolder lock(vm);
RELEASE_ASSERT(vm.atomicStringTable() == wtfThreadData().atomicStringTable());
- RefPtr<ProgramNode> programNode = parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, JSNotFunctionKind, error);
+ RefPtr<ProgramNode> programNode = parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error);
return programNode;
}
void DateConstructor::finishCreation(VM& vm, DatePrototype* datePrototype)
{
Base::finishCreation(vm, datePrototype->classInfo()->className);
- putDirectPrototypePropertyWithoutTransitions(vm, datePrototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, datePrototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(7), ReadOnly | DontEnum | DontDelete);
}
{
Base::finishCreation(vm, errorPrototype->classInfo()->className);
// ECMA 15.11.3.1 Error.prototype
- putDirectPrototypePropertyWithoutTransitions(vm, errorPrototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, errorPrototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), DontDelete | ReadOnly | DontEnum);
}
ParserError error;
VM* vm = &exec->vm();
JSGlobalObject* lexicalGlobalObject = exec->lexicalGlobalObject();
- RefPtr<ProgramNode> programNode = parse<ProgramNode>(vm, m_source, 0, Identifier(), JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, JSNotFunctionKind, error);
+ RefPtr<ProgramNode> programNode = parse<ProgramNode>(vm, m_source, 0, Identifier(), JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, error);
if (programNode)
return 0;
ASSERT(error.m_type != ParserError::ErrorNone);
void FunctionConstructor::finishCreation(VM& vm, FunctionPrototype* functionPrototype)
{
Base::finishCreation(vm, functionPrototype->classInfo()->className);
- putDirectPrototypePropertyWithoutTransitions(vm, functionPrototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, functionPrototype, DontEnum | DontDelete | ReadOnly);
// Number of arguments for constructor
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
#include "BuiltinExecutables.h"
#include "BuiltinNames.h"
#include "JSArray.h"
+#include "JSBoundFunction.h"
#include "JSFunction.h"
#include "JSString.h"
#include "JSStringBuilder.h"
const ClassInfo FunctionPrototype::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(FunctionPrototype) };
static EncodedJSValue JSC_HOST_CALL functionProtoFuncToString(ExecState*);
+static EncodedJSValue JSC_HOST_CALL functionProtoFuncBind(ExecState*);
FunctionPrototype::FunctionPrototype(VM& vm, Structure* structure)
: InternalFunction(vm, structure)
*applyFunction = putDirectBuiltinFunctionWithoutTransition(vm, globalObject, vm.propertyNames->builtinNames().applyPublicName(), functionPrototypeApplyCodeGenerator(vm), DontEnum);
*callFunction = putDirectBuiltinFunctionWithoutTransition(vm, globalObject, vm.propertyNames->builtinNames().callPublicName(), functionPrototypeCallCodeGenerator(vm), DontEnum);
-
- putDirectBuiltinFunctionWithoutTransition(vm, globalObject, vm.propertyNames->builtinNames().bindPublicName(), functionPrototypeBindCodeGenerator(vm), DontEnum);
+
+ JSFunction* bindFunction = JSFunction::create(vm, globalObject, 1, vm.propertyNames->bind.string(), functionProtoFuncBind);
+ putDirectWithoutTransition(vm, vm.propertyNames->bind, bindFunction, DontEnum);
}
static EncodedJSValue JSC_HOST_CALL callFunctionPrototype(ExecState*)
return throwVMTypeError(exec);
}
+// 15.3.4.5 Function.prototype.bind (thisArg [, arg1 [, arg2, ...]])
+EncodedJSValue JSC_HOST_CALL functionProtoFuncBind(ExecState* exec)
+{
+ JSGlobalObject* globalObject = exec->callee()->globalObject();
+
+ // Let Target be the this value.
+ JSValue target = exec->thisValue();
+
+ // If IsCallable(Target) is false, throw a TypeError exception.
+ CallData callData;
+ CallType callType = getCallData(target, callData);
+ if (callType == CallTypeNone)
+ return throwVMTypeError(exec);
+ // Primitive values are not callable.
+ ASSERT(target.isObject());
+ JSObject* targetObject = asObject(target);
+ VM& vm = exec->vm();
+
+ // Let A be a new (possibly empty) internal list of all of the argument values provided after thisArg (arg1, arg2 etc), in order.
+ size_t numBoundArgs = exec->argumentCount() > 1 ? exec->argumentCount() - 1 : 0;
+ JSArray* boundArgs = JSArray::tryCreateUninitialized(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithUndecided), numBoundArgs);
+ if (!boundArgs)
+ return JSValue::encode(throwOutOfMemoryError(exec));
+
+ for (size_t i = 0; i < numBoundArgs; ++i)
+ boundArgs->initializeIndex(vm, i, exec->argument(i + 1));
+
+ // If the [[Class]] internal property of Target is "Function", then ...
+ // Else set the length own property of F to 0.
+ unsigned length = 0;
+ if (targetObject->inherits(JSFunction::info())) {
+ ASSERT(target.get(exec, exec->propertyNames().length).isNumber());
+ // a. Let L be the length property of Target minus the length of A.
+ // b. Set the length own property of F to either 0 or L, whichever is larger.
+ unsigned targetLength = (unsigned)target.get(exec, exec->propertyNames().length).asNumber();
+ if (targetLength > numBoundArgs)
+ length = targetLength - numBoundArgs;
+ }
+
+ JSString* name = target.get(exec, exec->propertyNames().name).toString(exec);
+ return JSValue::encode(JSBoundFunction::create(vm, globalObject, targetObject, exec->argument(0), boundArgs, length, name->value(exec)));
+}
+
} // namespace JSC
void JSArrayBufferConstructor::finishCreation(VM& vm, JSArrayBufferPrototype* prototype)
{
Base::finishCreation(vm, "ArrayBuffer");
- putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), DontEnum | DontDelete | ReadOnly);
JSGlobalObject* globalObject = this->globalObject();
--- /dev/null
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSBoundFunction.h"
+
+#include "GetterSetter.h"
+#include "JSGlobalObject.h"
+#include "JSCInlines.h"
+
+namespace JSC {
+
+const ClassInfo JSBoundFunction::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSBoundFunction) };
+
+EncodedJSValue JSC_HOST_CALL boundFunctionCall(ExecState* exec)
+{
+ JSBoundFunction* boundFunction = jsCast<JSBoundFunction*>(exec->callee());
+
+ ASSERT(isJSArray(boundFunction->boundArgs())); // Currently this is true!
+ JSArray* boundArgs = asArray(boundFunction->boundArgs());
+
+ MarkedArgumentBuffer args;
+ for (unsigned i = 0; i < boundArgs->length(); ++i)
+ args.append(boundArgs->getIndexQuickly(i));
+ for (unsigned i = 0; i < exec->argumentCount(); ++i)
+ args.append(exec->uncheckedArgument(i));
+
+ JSObject* targetFunction = boundFunction->targetFunction();
+ CallData callData;
+ CallType callType = getCallData(targetFunction, callData);
+ ASSERT(callType != CallTypeNone);
+ return JSValue::encode(call(exec, targetFunction, callType, callData, boundFunction->boundThis(), args));
+}
+
+EncodedJSValue JSC_HOST_CALL boundFunctionConstruct(ExecState* exec)
+{
+ JSBoundFunction* boundFunction = jsCast<JSBoundFunction*>(exec->callee());
+
+ ASSERT(isJSArray(boundFunction->boundArgs())); // Currently this is true!
+ JSArray* boundArgs = asArray(boundFunction->boundArgs());
+
+ MarkedArgumentBuffer args;
+ for (unsigned i = 0; i < boundArgs->length(); ++i)
+ args.append(boundArgs->getIndexQuickly(i));
+ for (unsigned i = 0; i < exec->argumentCount(); ++i)
+ args.append(exec->uncheckedArgument(i));
+
+ JSObject* targetFunction = boundFunction->targetFunction();
+ ConstructData constructData;
+ ConstructType constructType = getConstructData(targetFunction, constructData);
+ ASSERT(constructType != ConstructTypeNone);
+ return JSValue::encode(construct(exec, targetFunction, constructType, constructData, args));
+}
+
+JSBoundFunction* JSBoundFunction::create(VM& vm, JSGlobalObject* globalObject, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs, int length, const String& name)
+{
+ ConstructData constructData;
+ ConstructType constructType = JSC::getConstructData(targetFunction, constructData);
+ bool canConstruct = constructType != ConstructTypeNone;
+ NativeExecutable* executable = vm.getHostFunction(boundFunctionCall, canConstruct ? boundFunctionConstruct : callHostFunctionAsConstructor);
+ JSBoundFunction* function = new (NotNull, allocateCell<JSBoundFunction>(vm.heap)) JSBoundFunction(vm, globalObject, globalObject->boundFunctionStructure(), targetFunction, boundThis, boundArgs);
+
+ function->finishCreation(vm, executable, length, name);
+ return function;
+}
+
+void JSBoundFunction::destroy(JSCell* cell)
+{
+ static_cast<JSBoundFunction*>(cell)->JSBoundFunction::~JSBoundFunction();
+}
+
+bool JSBoundFunction::customHasInstance(JSObject* object, ExecState* exec, JSValue value)
+{
+ return jsCast<JSBoundFunction*>(object)->m_targetFunction->hasInstance(exec, value);
+}
+
+JSBoundFunction::JSBoundFunction(VM& vm, JSGlobalObject* globalObject, Structure* structure, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs)
+ : Base(vm, globalObject, structure)
+ , m_targetFunction(vm, this, targetFunction)
+ , m_boundThis(vm, this, boundThis)
+ , m_boundArgs(vm, this, boundArgs)
+{
+}
+
+void JSBoundFunction::finishCreation(VM& vm, NativeExecutable* executable, int length, const String& name)
+{
+ Base::finishCreation(vm, executable, length, name);
+ ASSERT(inherits(info()));
+
+ putDirectNonIndexAccessor(vm, vm.propertyNames->arguments, globalObject()->throwTypeErrorGetterSetter(vm), DontDelete | DontEnum | Accessor);
+ putDirectNonIndexAccessor(vm, vm.propertyNames->caller, globalObject()->throwTypeErrorGetterSetter(vm), DontDelete | DontEnum | Accessor);
+}
+
+void JSBoundFunction::visitChildren(JSCell* cell, SlotVisitor& visitor)
+{
+ JSBoundFunction* thisObject = jsCast<JSBoundFunction*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
+ ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
+ Base::visitChildren(thisObject, visitor);
+
+ visitor.append(&thisObject->m_targetFunction);
+ visitor.append(&thisObject->m_boundThis);
+ visitor.append(&thisObject->m_boundArgs);
+}
+
+} // namespace JSC
--- /dev/null
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef JSBoundFunction_h
+#define JSBoundFunction_h
+
+#include "JSFunction.h"
+
+namespace JSC {
+
+EncodedJSValue JSC_HOST_CALL boundFunctionCall(ExecState*);
+EncodedJSValue JSC_HOST_CALL boundFunctionConstruct(ExecState*);
+
+class JSBoundFunction : public JSFunction {
+public:
+ typedef JSFunction Base;
+
+ static JSBoundFunction* create(VM&, JSGlobalObject*, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs, int, const String&);
+
+ static void destroy(JSCell*);
+
+ static bool customHasInstance(JSObject*, ExecState*, JSValue);
+
+ JSObject* targetFunction() { return m_targetFunction.get(); }
+ JSValue boundThis() { return m_boundThis.get(); }
+ JSValue boundArgs() { return m_boundArgs.get(); }
+
+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+ {
+ ASSERT(globalObject);
+ return Structure::create(vm, globalObject, prototype, TypeInfo(JSFunctionType, StructureFlags), info());
+ }
+
+ DECLARE_INFO;
+
+protected:
+ const static unsigned StructureFlags = OverridesHasInstance | OverridesVisitChildren | Base::StructureFlags;
+
+ static void visitChildren(JSCell*, SlotVisitor&);
+
+private:
+ JSBoundFunction(VM&, JSGlobalObject*, Structure*, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs);
+
+ void finishCreation(VM&, NativeExecutable*, int, const String&);
+
+ WriteBarrier<JSObject> m_targetFunction;
+ WriteBarrier<Unknown> m_boundThis;
+ WriteBarrier<Unknown> m_boundArgs;
+};
+
+} // namespace JSC
+
+#endif // JSFunction_h
#include "FunctionPrototype.h"
#include "GetterSetter.h"
#include "JSArray.h"
+#include "JSBoundFunction.h"
#include "JSFunctionInlines.h"
#include "JSGlobalObject.h"
#include "JSNameScope.h"
class RetrieveCallerFunctionFunctor {
public:
- RetrieveCallerFunctionFunctor(ExecState* exec, JSFunction* functionObj)
- : m_exec(exec)
- , m_targetCallee(jsDynamicCast<JSObject*>(functionObj))
+ RetrieveCallerFunctionFunctor(JSFunction* functionObj)
+ : m_targetCallee(jsDynamicCast<JSObject*>(functionObj))
, m_hasFoundFrame(false)
, m_hasSkippedToCallerFrame(false)
, m_result(jsNull())
{
JSObject* callee = visitor->callee();
- if (callee && callee->hasOwnProperty(m_exec, m_exec->propertyNames().boundFunctionNamePrivateName))
+ if (callee && callee->inherits(JSBoundFunction::info()))
return StackVisitor::Continue;
if (!m_hasFoundFrame && (callee != m_targetCallee))
}
private:
- ExecState* m_exec;
JSObject* m_targetCallee;
bool m_hasFoundFrame;
bool m_hasSkippedToCallerFrame;
static JSValue retrieveCallerFunction(ExecState* exec, JSFunction* functionObj)
{
- RetrieveCallerFunctionFunctor functor(exec, functionObj);
+ RetrieveCallerFunctionFunctor functor(functionObj);
exec->iterate(functor);
return functor.result();
}
bool JSFunction::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
{
JSFunction* thisObject = jsCast<JSFunction*>(object);
- if (thisObject->isHostFunction())
- return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
- if (thisObject->isBuiltinFunction()) {
- if (propertyName == exec->propertyNames().caller) {
- if (thisObject->jsExecutable()->isStrictMode()) {
- bool result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
- if (!result) {
- thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec->vm()), DontDelete | DontEnum | Accessor);
- result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
- ASSERT(result);
- }
- return result;
- }
- slot.setCacheableCustom(thisObject, ReadOnly | DontEnum | DontDelete, callerGetter);
- return true;
- }
- if (propertyName == exec->propertyNames().prototypeForHasInstancePrivateName) {
- PropertySlot boundFunctionSlot(thisObject);
- if (Base::getOwnPropertySlot(thisObject, exec, exec->propertyNames().boundFunctionPrivateName, boundFunctionSlot)) {
- JSValue boundFunction = boundFunctionSlot.getValue(exec, exec->propertyNames().boundFunctionPrivateName);
- PropertySlot boundPrototypeSlot(asObject(boundFunction));
- if (asObject(boundFunction)->getPropertySlot(exec, propertyName, boundPrototypeSlot)) {
- slot.setValue(boundPrototypeSlot.slotBase(), boundPrototypeSlot.attributes(), boundPrototypeSlot.getValue(exec, propertyName));
- return true;
- }
- }
- }
- if (propertyName == exec->propertyNames().name) {
- PropertySlot nameSlot(thisObject);
- if (Base::getOwnPropertySlot(thisObject, exec, exec->vm().propertyNames->boundFunctionNamePrivateName, nameSlot)) {
- slot.setValue(thisObject, DontEnum | DontDelete | ReadOnly, nameSlot.getValue(exec, exec->vm().propertyNames->boundFunctionNamePrivateName));
- return true;
- }
- }
- if (propertyName == exec->propertyNames().length) {
- PropertySlot lengthSlot(thisObject);
- if (Base::getOwnPropertySlot(thisObject, exec, exec->vm().propertyNames->boundFunctionLengthPrivateName, lengthSlot)) {
- slot.setValue(thisObject, DontEnum | DontDelete | ReadOnly, lengthSlot.getValue(exec, exec->vm().propertyNames->boundFunctionLengthPrivateName));
- return true;
- }
- }
-
+ if (thisObject->isHostOrBuiltinFunction())
return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
- }
-
- if (propertyName == exec->propertyNames().prototype || propertyName == exec->propertyNames().prototypeForHasInstancePrivateName) {
+
+ if (propertyName == exec->propertyNames().prototype) {
VM& vm = exec->vm();
unsigned attributes;
PropertyOffset offset = thisObject->getDirectOffset(vm, propertyName, attributes);
if (!isValidOffset(offset)) {
JSObject* prototype = constructEmptyObject(exec);
prototype->putDirect(vm, exec->propertyNames().constructor, thisObject, DontEnum);
- thisObject->putDirectPrototypeProperty(vm, prototype, DontDelete | DontEnum);
+ thisObject->putDirect(vm, exec->propertyNames().prototype, prototype, DontDelete | DontEnum);
offset = thisObject->getDirectOffset(vm, exec->propertyNames().prototype, attributes);
ASSERT(isValidOffset(offset));
}
void JSFunction::getOwnNonIndexPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
JSFunction* thisObject = jsCast<JSFunction*>(object);
- if (mode == IncludeDontEnumProperties) {
- bool shouldIncludeJSFunctionProperties = !thisObject->isHostOrBuiltinFunction();
- if (!shouldIncludeJSFunctionProperties && thisObject->isBuiltinFunction()) {
- PropertySlot boundFunctionSlot(thisObject);
- shouldIncludeJSFunctionProperties = Base::getOwnPropertySlot(thisObject, exec, exec->propertyNames().boundFunctionPrivateName, boundFunctionSlot);
- }
- if (shouldIncludeJSFunctionProperties) {
- VM& vm = exec->vm();
- // Make sure prototype has been reified.
- PropertySlot slot(thisObject);
- thisObject->methodTable(vm)->getOwnPropertySlot(thisObject, exec, vm.propertyNames->prototype, slot);
+ if (!thisObject->isHostOrBuiltinFunction() && (mode == IncludeDontEnumProperties)) {
+ VM& vm = exec->vm();
+ // Make sure prototype has been reified.
+ PropertySlot slot(thisObject);
+ thisObject->methodTable(vm)->getOwnPropertySlot(thisObject, exec, vm.propertyNames->prototype, slot);
- propertyNames.add(vm.propertyNames->arguments);
- propertyNames.add(vm.propertyNames->caller);
- propertyNames.add(vm.propertyNames->length);
- propertyNames.add(vm.propertyNames->name);
- }
+ propertyNames.add(vm.propertyNames->arguments);
+ propertyNames.add(vm.propertyNames->caller);
+ propertyNames.add(vm.propertyNames->length);
+ propertyNames.add(vm.propertyNames->name);
}
Base::getOwnNonIndexPropertyNames(thisObject, exec, propertyNames, mode);
}
thisObject->m_allocationProfile.clear();
thisObject->m_allocationProfileWatchpoint.fireAll();
// Don't allow this to be cached, since a [[Put]] must clear m_allocationProfile.
- PutPropertySlot dontCachePrototype(thisObject);
- Base::put(thisObject, exec, propertyName, value, dontCachePrototype);
- PutPropertySlot dontCachePrototypeForHasInstance(thisObject);
- Base::put(thisObject, exec, exec->propertyNames().prototypeForHasInstancePrivateName, value, dontCachePrototypeForHasInstance);
+ PutPropertySlot dontCache(thisObject);
+ Base::put(thisObject, exec, propertyName, value, dontCache);
return;
}
if (thisObject->jsExecutable()->isStrictMode() && (propertyName == exec->propertyNames().arguments || propertyName == exec->propertyNames().caller)) {
thisObject->methodTable(exec->vm())->getOwnPropertySlot(thisObject, exec, propertyName, slot);
thisObject->m_allocationProfile.clear();
thisObject->m_allocationProfileWatchpoint.fireAll();
- if (!Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException))
- return false;
- Base::defineOwnProperty(object, exec, exec->propertyNames().prototypeForHasInstancePrivateName, descriptor, throwException);
- return true;
+ return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
}
bool valueCheck;
void JSGenericTypedArrayViewConstructor<ViewClass>::finishCreation(VM& vm, JSObject* prototype, const String& name)
{
Base::finishCreation(vm, name);
- putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(3), DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->BYTES_PER_ELEMENT, jsNumber(ViewClass::elementSize), DontEnum | ReadOnly | DontDelete);
}
#include "JSArrayBufferConstructor.h"
#include "JSArrayBufferPrototype.h"
#include "JSArrayIterator.h"
+#include "JSBoundFunction.h"
#include "JSCInlines.h"
#include "JSCallbackConstructor.h"
#include "JSCallbackFunction.h"
m_functionPrototype.set(vm, this, FunctionPrototype::create(vm, FunctionPrototype::createStructure(vm, this, jsNull()))); // The real prototype will be set once ObjectPrototype is created.
m_functionStructure.set(vm, this, JSFunction::createStructure(vm, this, m_functionPrototype.get()));
+ m_boundFunctionStructure.set(vm, this, JSBoundFunction::createStructure(vm, this, m_functionPrototype.get()));
m_namedFunctionStructure.set(vm, this, Structure::addPropertyTransition(vm, m_functionStructure.get(), vm.propertyNames->name, DontDelete | ReadOnly | DontEnum, 0, m_functionNameOffset));
m_internalFunctionStructure.set(vm, this, InternalFunction::createStructure(vm, this, m_functionPrototype.get()));
JSFunction* callFunction = 0;
putDirectWithoutTransition(vm, Identifier(exec, typedArrayConstructors[typedArrayIndex]->name(exec)), typedArrayConstructors[typedArrayIndex], DontEnum);
}
- JSFunction* setTypeErrorAccessor = JSFunction::create(vm, this, 2, vm.propertyNames->emptyIdentifier.string(), globalFuncSetTypeErrorAccessor);
JSFunction* builtinLog = JSFunction::create(vm, this, 1, vm.propertyNames->emptyIdentifier.string(), globalFuncBuiltinLog);
GlobalPropertyInfo staticGlobals[] = {
GlobalPropertyInfo(vm.propertyNames->NaN, jsNaN(), DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(vm.propertyNames->undefinedPrivateName, jsUndefined(), DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(vm.propertyNames->ObjectPrivateName, objectConstructor, DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(vm.propertyNames->TypeErrorPrivateName, m_typeErrorConstructor.get(), DontEnum | DontDelete | ReadOnly),
- GlobalPropertyInfo(vm.propertyNames->SetTypeErrorAccessorPrivateName, setTypeErrorAccessor, DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(vm.propertyNames->BuiltinLogPrivateName, builtinLog, DontEnum | DontDelete | ReadOnly)
};
addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
#include "JSGlobalObjectFunctions.h"
#include "CallFrame.h"
-#include "GetterSetter.h"
#include "Interpreter.h"
#include "JSFunction.h"
#include "JSGlobalObject.h"
return JSValue::encode(jsUndefined());
}
-EncodedJSValue JSC_HOST_CALL globalFuncSetTypeErrorAccessor(ExecState* exec)
-{
- JSObject* target = jsDynamicCast<JSObject*>(exec->argument(0));
- JSValue propertyName = exec->argument(1);
-
- // Setting __proto__ of a primitive should have no effect.
- if (!target || !propertyName.isString())
- return JSValue::encode(jsUndefined());
- VM& vm = exec->vm();
- Identifier property(exec, asString(propertyName)->getString(exec));
- target->putDirectNonIndexAccessor(vm, vm.propertyNames->arguments, target->globalObject()->throwTypeErrorGetterSetter(vm), DontDelete | DontEnum | Accessor);
- return JSValue::encode(jsUndefined());
-}
-
EncodedJSValue JSC_HOST_CALL globalFuncBuiltinLog(ExecState* exec)
{
dataLog(exec->argument(0).toWTFString(exec), "\n");
EncodedJSValue JSC_HOST_CALL globalFuncThrowTypeError(ExecState*);
EncodedJSValue JSC_HOST_CALL globalFuncProtoGetter(ExecState*);
EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState*);
-EncodedJSValue JSC_HOST_CALL globalFuncSetTypeErrorAccessor(ExecState*);
EncodedJSValue JSC_HOST_CALL globalFuncBuiltinLog(ExecState*);
static const double mantissaOverflowLowerBound = 9007199254740992.0;
{
return exec->vm().throwException(exec, createTypeError(exec, message));
}
-
-void JSObject::putDirectPrototypeProperty(VM& vm, JSValue value, int attributes)
-{
- putDirect(vm, vm.propertyNames->prototype, value, attributes);
- putDirect(vm, vm.propertyNames->prototypeForHasInstancePrivateName, value, attributes);
-}
-
-void JSObject::putDirectPrototypePropertyWithoutTransitions(VM& vm, JSValue value, int attributes)
-{
- putDirectWithoutTransition(vm, vm.propertyNames->prototype, value, attributes);
- putDirectWithoutTransition(vm, vm.propertyNames->prototypeForHasInstancePrivateName, value, attributes);
-}
-
+
} // namespace JSC
}
}
- JS_EXPORT_PRIVATE void putDirectPrototypeProperty(VM&, JSValue, int);
- void putDirectPrototypePropertyWithoutTransitions(VM&, JSValue, int);
-
private:
friend class LLIntOffsetsExtractor;
void JSPromiseConstructor::finishCreation(VM& vm, JSPromisePrototype* promisePrototype)
{
Base::finishCreation(vm, "Promise");
- putDirectPrototypePropertyWithoutTransitions(vm, promisePrototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, promisePrototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
}
void MapConstructor::finishCreation(VM& vm, MapPrototype* mapPrototype)
{
Base::finishCreation(vm, mapPrototype->classInfo()->className);
- putDirectPrototypePropertyWithoutTransitions(vm, mapPrototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, mapPrototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum | DontDelete);
}
void MapIteratorConstructor::finishCreation(VM& vm, MapIteratorPrototype* prototype)
{
Base::finishCreation(vm);
- putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
}
}
void NameConstructor::finishCreation(VM& vm, NamePrototype* prototype)
{
Base::finishCreation(vm, prototype->classInfo()->className);
- putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), DontDelete | ReadOnly | DontEnum);
}
NativeErrorPrototype* prototype = NativeErrorPrototype::create(vm, globalObject, prototypeStructure, name, this);
putDirect(vm, vm.propertyNames->length, jsNumber(1), DontDelete | ReadOnly | DontEnum); // ECMA 15.11.7.5
- putDirectPrototypeProperty(vm, prototype, DontDelete | ReadOnly | DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, prototype, DontDelete | ReadOnly | DontEnum);
m_errorStructure.set(vm, this, ErrorInstance::createStructure(vm, globalObject, prototype));
ASSERT(m_errorStructure);
ASSERT(m_errorStructure->isObject());
ASSERT(inherits(info()));
// Number.Prototype
- putDirectPrototypePropertyWithoutTransitions(vm, numberPrototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, numberPrototype, DontEnum | DontDelete | ReadOnly);
// no. of arguments for constructor
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
{
Base::finishCreation(vm, Identifier(&vm, "Object").string());
// ECMA 15.2.3.1
- putDirectPrototypePropertyWithoutTransitions(vm, objectPrototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, objectPrototype, DontEnum | DontDelete | ReadOnly);
// no. of arguments for constructor
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
}
ASSERT(inherits(info()));
// ECMA 15.10.5.1 RegExp.prototype
- putDirectPrototypePropertyWithoutTransitions(vm, regExpPrototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, regExpPrototype, DontEnum | DontDelete | ReadOnly);
// no. of arguments for constructor
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(2), ReadOnly | DontDelete | DontEnum);
void SetConstructor::finishCreation(VM& vm, SetPrototype* setPrototype)
{
Base::finishCreation(vm, setPrototype->classInfo()->className);
- putDirectPrototypePropertyWithoutTransitions(vm, setPrototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, setPrototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum | DontDelete);
}
void SetIteratorConstructor::finishCreation(VM& vm, SetIteratorPrototype* prototype)
{
Base::finishCreation(vm);
- putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
}
}
void StringConstructor::finishCreation(VM& vm, StringPrototype* stringPrototype)
{
Base::finishCreation(vm, stringPrototype->classInfo()->className);
- putDirectPrototypePropertyWithoutTransitions(vm, stringPrototype, ReadOnly | DontEnum | DontDelete);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, stringPrototype, ReadOnly | DontEnum | DontDelete);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
}
void WeakMapConstructor::finishCreation(VM& vm, WeakMapPrototype* prototype)
{
Base::finishCreation(vm, prototype->classInfo()->className);
- putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum | DontDelete);
}
+2014-04-11 Gavin Barraclough <baraclough@apple.com>
+
+ Rollout - Rewrite Function.bind as a builtin
+ https://bugs.webkit.org/show_bug.cgi?id=131083
+
+ Unreviewed.
+
+ Rolling out r167020 while investigating a performance regression.
+
+ * bindings/js/JSImageConstructor.cpp:
+ (WebCore::JSImageConstructor::finishCreation):
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateConstructorHelperMethods):
+ * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
+ (WebCore::JSTestActiveDOMObjectConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
+ (WebCore::JSTestCustomNamedGetterConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSTestEventConstructor.cpp:
+ (WebCore::JSTestEventConstructorConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSTestEventTarget.cpp:
+ (WebCore::JSTestEventTargetConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSTestException.cpp:
+ (WebCore::JSTestExceptionConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp:
+ (WebCore::JSTestGenerateIsReachableConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSTestInterface.cpp:
+ (WebCore::JSTestInterfaceConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
+ (WebCore::JSTestMediaQueryListListenerConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
+ (WebCore::JSTestNamedConstructorConstructor::finishCreation):
+ (WebCore::JSTestNamedConstructorNamedConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSTestNode.cpp:
+ (WebCore::JSTestNodeConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSTestObj.cpp:
+ (WebCore::JSTestObjConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
+ (WebCore::JSTestOverloadedConstructorsConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
+ (WebCore::JSTestSerializedScriptValueInterfaceConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSTestTypedefs.cpp:
+ (WebCore::JSTestTypedefsConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSattribute.cpp:
+ (WebCore::JSattributeConstructor::finishCreation):
+ * bindings/scripts/test/JS/JSreadonly.cpp:
+ (WebCore::JSreadonlyConstructor::finishCreation):
+
2014-04-11 Myles C. Maxfield <mmaxfield@apple.com>
Build Fix after r167151.
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
{
Base::finishCreation(globalObject);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSHTMLImageElementPrototype::self(vm, globalObject), None);
+ putDirect(vm, vm.propertyNames->prototype, JSHTMLImageElementPrototype::self(vm, globalObject), None);
}
static EncodedJSValue JSC_HOST_CALL constructImage(ExecState* exec)
if (IsDOMGlobalObject($interface)) {
push(@$outputArray, " Base::finishCreation(vm);\n");
push(@$outputArray, " ASSERT(inherits(info()));\n");
- push(@$outputArray, " putDirectPrototypeProperty(vm, globalObject->prototype(), DontDelete | ReadOnly);\n");
+ push(@$outputArray, " putDirect(vm, vm.propertyNames->prototype, globalObject->prototype(), DontDelete | ReadOnly);\n");
} elsif ($generatingNamedConstructor) {
push(@$outputArray, " Base::finishCreation(globalObject);\n");
push(@$outputArray, " ASSERT(inherits(info()));\n");
- push(@$outputArray, " putDirectPrototypeProperty(vm, ${className}Prototype::self(vm, globalObject), None);\n");
+ push(@$outputArray, " putDirect(vm, vm.propertyNames->prototype, ${className}Prototype::self(vm, globalObject), None);\n");
} else {
push(@$outputArray, " Base::finishCreation(vm);\n");
push(@$outputArray, " ASSERT(inherits(info()));\n");
- push(@$outputArray, " putDirectPrototypeProperty(vm, ${protoClassName}::self(vm, globalObject), DontDelete | ReadOnly);\n");
+ push(@$outputArray, " putDirect(vm, vm.propertyNames->prototype, ${protoClassName}::self(vm, globalObject), DontDelete | ReadOnly);\n");
}
push(@$outputArray, " putDirect(vm, vm.propertyNames->length, jsNumber(${leastConstructorLength}), ReadOnly | DontDelete | DontEnum);\n") if defined $leastConstructorLength;
push(@$outputArray, "}\n\n");
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestActiveDOMObjectPrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestActiveDOMObjectPrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestCustomNamedGetterPrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestCustomNamedGetterPrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestEventConstructorPrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestEventConstructorPrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestEventTargetPrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestEventTargetPrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestExceptionPrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestExceptionPrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestGenerateIsReachablePrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestGenerateIsReachablePrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestInterfacePrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestInterfacePrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestMediaQueryListListenerPrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestMediaQueryListListenerPrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestNamedConstructorPrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestNamedConstructorPrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(globalObject);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestNamedConstructorPrototype::self(vm, globalObject), None);
+ putDirect(vm, vm.propertyNames->prototype, JSTestNamedConstructorPrototype::self(vm, globalObject), None);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestNodePrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestNodePrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestObjPrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestObjPrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestOverloadedConstructorsPrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestOverloadedConstructorsPrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestSerializedScriptValueInterfacePrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestSerializedScriptValueInterfacePrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSTestTypedefsPrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSTestTypedefsPrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(2), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSattributePrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSattributePrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}
{
Base::finishCreation(vm);
ASSERT(inherits(info()));
- putDirectPrototypeProperty(vm, JSreadonlyPrototype::self(vm, globalObject), DontDelete | ReadOnly);
+ putDirect(vm, vm.propertyNames->prototype, JSreadonlyPrototype::self(vm, globalObject), DontDelete | ReadOnly);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
}