Changeset 167020 in webkit
- Timestamp:
- Apr 9, 2014 10:28:40 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 2 deleted
- 69 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r167018 r167020 1 2014-04-08 Oliver Hunt <oliver@apple.com> 2 3 Rewrite Function.bind as a builtin 4 https://bugs.webkit.org/show_bug.cgi?id=131083 5 6 Reviewed by Geoffrey Garen. 7 8 Testing. 9 10 * js/dom/function-bind-expected.txt: 11 * js/regress/function-bind-expected.txt: Added. 12 * js/regress/function-bind.html: Added. 13 * js/regress/script-tests/function-bind.js: Added. 14 (foo): 15 1 16 2014-04-09 Radu Stavila <stavila@adobe.com> 2 17 -
trunk/LayoutTests/js/dom/function-bind-expected.txt
r156066 r167020 4 4 5 5 6 PASS new (decodeURI.bind())() threw exception TypeError: function is not a constructor (evaluating 'new (decodeURI.bind())()').6 PASS new (decodeURI.bind())() threw exception TypeError: function is not a constructor. 7 7 PASS (new (String.bind())('foo')).toString() is 'foo' 8 8 PASS result is "[object Window] -> x:1, y:2" … … 24 24 PASS "prototype" in G is false 25 25 PASS "prototype" in H is false 26 PASS Function.bind.call(undefined) threw exception TypeError: Type error.26 PASS Function.bind.call(undefined) threw exception TypeError: Cannot bind non-function object.. 27 27 PASS abcAt(1) is "b" 28 PASS new abcAt(1) threw exception TypeError: function is not a constructor (evaluating 'new abcAt(1)').28 PASS new abcAt(1) threw exception TypeError: function is not a constructor. 29 29 PASS boundFunctionPrototypeAccessed is false 30 30 PASS Function.bind.length is 1 -
trunk/Source/JavaScriptCore/API/JSObjectRef.cpp
r166554 r167020 128 128 JSCallbackConstructor* constructor = JSCallbackConstructor::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor); 129 129 constructor->putDirect(exec->vm(), exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly); 130 constructor->putDirect(exec->vm(), exec->propertyNames().prototypeForHasInstancePrivateName, jsPrototype, DontEnum | DontDelete | ReadOnly); 130 131 return toRef(constructor); 131 132 } -
trunk/Source/JavaScriptCore/API/JSScriptRef.cpp
r165074 r167020 69 69 static bool parseScript(VM* vm, const SourceCode& source, ParserError& error) 70 70 { 71 return JSC::parse<JSC::ProgramNode>(vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error);71 return JSC::parse<JSC::ProgramNode>(vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, JSNotFunctionKind, error); 72 72 } 73 73 -
trunk/Source/JavaScriptCore/CMakeLists.txt
r166837 r167020 395 395 runtime/JSArrayBufferView.cpp 396 396 runtime/JSArrayIterator.cpp 397 runtime/JSBoundFunction.cpp398 397 runtime/JSCJSValue.cpp 399 398 runtime/JSCell.cpp -
trunk/Source/JavaScriptCore/ChangeLog
r166993 r167020 1 2014-04-08 Oliver Hunt <oliver@apple.com> 2 3 Rewrite Function.bind as a builtin 4 https://bugs.webkit.org/show_bug.cgi?id=131083 5 6 Reviewed by Geoffrey Garen. 7 8 This change removes the existing function.bind implementation 9 entirely so JSBoundFunction is no more. 10 11 Instead we just return a regular JS closure with a few 12 private properties hanging off it that allow us to perform 13 the necessary bound function fakery. While most of this is 14 simple, a couple of key changes: 15 16 - The parser and lexer now directly track whether they're 17 parsing code for call or construct and convert the private 18 name @IsConstructor into TRUETOK or FALSETOK as appropriate. 19 This automatically gives us the ability to vary behaviour 20 from within the builtin. It also leaves a lot of headroom 21 for trivial future improvements. 22 - The instanceof operator now uses the prototypeForHasInstance 23 private name, and we have a helper function to ensure that 24 all objects that need to can update their magical 'prototype' 25 property pair correctly. 26 27 * API/JSScriptRef.cpp: 28 (parseScript): 29 * JavaScriptCore.xcodeproj/project.pbxproj: 30 * builtins/BuiltinExecutables.cpp: 31 (JSC::BuiltinExecutables::createBuiltinExecutable): 32 * builtins/Function.prototype.js: 33 (bind.bindingFunction): 34 (bind.else.bindingFunction): 35 (bind): 36 * bytecode/UnlinkedCodeBlock.cpp: 37 (JSC::generateFunctionCodeBlock): 38 * bytecompiler/NodesCodegen.cpp: 39 (JSC::InstanceOfNode::emitBytecode): 40 * interpreter/Interpreter.cpp: 41 * parser/Lexer.cpp: 42 (JSC::Lexer<T>::Lexer): 43 (JSC::Lexer<LChar>::parseIdentifier): 44 (JSC::Lexer<UChar>::parseIdentifier): 45 * parser/Lexer.h: 46 * parser/Parser.cpp: 47 (JSC::Parser<LexerType>::Parser): 48 (JSC::Parser<LexerType>::parseInner): 49 * parser/Parser.h: 50 (JSC::parse): 51 * parser/ParserModes.h: 52 * runtime/CodeCache.cpp: 53 (JSC::CodeCache::getGlobalCodeBlock): 54 (JSC::CodeCache::getFunctionExecutableFromGlobalCode): 55 * runtime/CommonIdentifiers.h: 56 * runtime/Completion.cpp: 57 (JSC::checkSyntax): 58 * runtime/Executable.cpp: 59 (JSC::ProgramExecutable::checkSyntax): 60 * runtime/FunctionPrototype.cpp: 61 (JSC::FunctionPrototype::addFunctionProperties): 62 (JSC::functionProtoFuncBind): Deleted. 63 * runtime/JSBoundFunction.cpp: Removed. 64 * runtime/JSBoundFunction.h: Removed. 65 * runtime/JSFunction.cpp: 66 (JSC::RetrieveCallerFunctionFunctor::RetrieveCallerFunctionFunctor): 67 (JSC::RetrieveCallerFunctionFunctor::operator()): 68 (JSC::retrieveCallerFunction): 69 (JSC::JSFunction::getOwnPropertySlot): 70 (JSC::JSFunction::defineOwnProperty): 71 * runtime/JSGlobalObject.cpp: 72 (JSC::JSGlobalObject::reset): 73 * runtime/JSGlobalObjectFunctions.cpp: 74 (JSC::globalFuncSetTypeErrorAccessor): 75 * runtime/JSGlobalObjectFunctions.h: 76 * runtime/JSObject.h: 77 (JSC::JSObject::inlineGetOwnPropertySlot): 78 1 79 2014-04-08 Jon Lee <jonlee@apple.com> 2 80 -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
r166837 r167020 641 641 <ClCompile Include="..\runtime\JSArrayBufferPrototype.cpp" /> 642 642 <ClCompile Include="..\runtime\JSArrayBufferView.cpp" /> 643 <ClCompile Include="..\runtime\JSBoundFunction.cpp" />644 643 <ClCompile Include="..\runtime\JSCJSValue.cpp" /> 645 644 <ClCompile Include="..\runtime\JSCell.cpp" /> … … 1303 1302 <ClInclude Include="..\runtime\JSArrayBufferViewInlines.h" /> 1304 1303 <ClInclude Include="..\runtime\JSArrayIterator.h" /> 1305 <ClInclude Include="..\runtime\JSBoundFunction.h" />1306 1304 <ClInclude Include="..\runtime\JSCInlines.h" /> 1307 1305 <ClInclude Include="..\runtime\JSCJSValue.h" /> -
trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
r166837 r167020 607 607 <Filter>runtime</Filter> 608 608 </ClCompile> 609 <ClCompile Include="..\runtime\JSBoundFunction.cpp">610 <Filter>runtime</Filter>611 </ClCompile>612 609 <ClCompile Include="..\runtime\JSCell.cpp"> 613 610 <Filter>runtime</Filter> … … 2254 2251 </ClInclude> 2255 2252 <ClInclude Include="..\runtime\JSArray.h"> 2256 <Filter>runtime</Filter>2257 </ClInclude>2258 <ClInclude Include="..\runtime\JSBoundFunction.h">2259 2253 <Filter>runtime</Filter> 2260 2254 </ClInclude> -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r166837 r167020 939 939 86F3EEBE168CDE930077B92A /* ObjCCallbackFunction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 86F3EEBA168CCF750077B92A /* ObjCCallbackFunction.mm */; }; 940 940 86F3EEBF168CDE930077B92A /* ObjcRuntimeExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 86F3EEB616855A5B0077B92A /* ObjcRuntimeExtras.h */; }; 941 86FA9E91142BBB2E001773B7 /* JSBoundFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86FA9E8F142BBB2D001773B7 /* JSBoundFunction.cpp */; };942 86FA9E92142BBB2E001773B7 /* JSBoundFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 86FA9E90142BBB2E001773B7 /* JSBoundFunction.h */; };943 941 90213E3D123A40C200D422F3 /* MemoryStatistics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90213E3B123A40C200D422F3 /* MemoryStatistics.cpp */; }; 944 942 90213E3E123A40C200D422F3 /* MemoryStatistics.h in Headers */ = {isa = PBXBuildFile; fileRef = 90213E3C123A40C200D422F3 /* MemoryStatistics.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 2477 2475 86F75EFC151C062F007C9BA3 /* RegExpCachedResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpCachedResult.h; sourceTree = "<group>"; }; 2478 2476 86F75EFD151C062F007C9BA3 /* RegExpMatchesArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegExpMatchesArray.cpp; sourceTree = "<group>"; }; 2479 86FA9E8F142BBB2D001773B7 /* JSBoundFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBoundFunction.cpp; sourceTree = "<group>"; };2480 86FA9E90142BBB2E001773B7 /* JSBoundFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBoundFunction.h; sourceTree = "<group>"; };2481 2477 90213E3B123A40C200D422F3 /* MemoryStatistics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryStatistics.cpp; sourceTree = "<group>"; }; 2482 2478 90213E3C123A40C200D422F3 /* MemoryStatistics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryStatistics.h; sourceTree = "<group>"; }; … … 4009 4005 A7BDAEC417F4EA1400F6140C /* JSArrayIterator.cpp */, 4010 4006 A7BDAEC517F4EA1400F6140C /* JSArrayIterator.h */, 4011 86FA9E8F142BBB2D001773B7 /* JSBoundFunction.cpp */,4012 86FA9E90142BBB2E001773B7 /* JSBoundFunction.h */,4013 4007 BC7F8FBA0E19D1EF008632C0 /* JSCell.cpp */, 4014 4008 BC1167D80E19BCC9008066DD /* JSCell.h */, … … 5390 5384 BC18C4180E16F5CD00B34460 /* JSBase.h in Headers */, 5391 5385 140D17D70E8AD4A9000CD17D /* JSBasePrivate.h in Headers */, 5392 86FA9E92142BBB2E001773B7 /* JSBoundFunction.h in Headers */,5393 5386 BC18C4190E16F5CD00B34460 /* JSCallbackConstructor.h in Headers */, 5394 5387 BC18C41A0E16F5CD00B34460 /* JSCallbackFunction.h in Headers */, … … 6521 6514 A7BDAECA17F4EA1400F6140C /* JSArrayIterator.cpp in Sources */, 6522 6515 1421359B0A677F4F00A8195E /* JSBase.cpp in Sources */, 6523 86FA9E91142BBB2E001773B7 /* JSBoundFunction.cpp in Sources */,6524 6516 1440F8AF0A508D200005F061 /* JSCallbackConstructor.cpp in Sources */, 6525 6517 1440F8920A508B100005F061 /* JSCallbackFunction.cpp in Sources */, -
trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp
r164346 r167020 47 47 JSTextPosition positionBeforeLastNewline; 48 48 ParserError error; 49 RefPtr<ProgramNode> program = parse<ProgramNode>(&m_vm, source, 0, Identifier(), JSParseBuiltin, JSParseProgramCode, error, &positionBeforeLastNewline);49 RefPtr<ProgramNode> program = parse<ProgramNode>(&m_vm, source, 0, Identifier(), JSParseBuiltin, JSParseProgramCode, JSNotFunctionKind, error, &positionBeforeLastNewline); 50 50 51 51 if (!program) { … … 72 72 for (const auto& closedVariable : program->closedVariables()) { 73 73 if (closedVariable == m_vm.propertyNames->arguments.impl()) 74 continue;74 continue; 75 75 76 76 if (closedVariable == m_vm.propertyNames->undefinedKeyword.impl()) -
trunk/Source/JavaScriptCore/builtins/Function.prototype.js
r164835 r167020 33 33 return this.@apply(thisValue, argumentValues); 34 34 } 35 36 function bind(thisValue /*, optional arguments */) 37 { 38 "use strict"; 39 var boundFunction = this; 40 if (typeof boundFunction !== "function") 41 throw new @TypeError("Cannot bind non-function object."); 42 var bindingFunction; 43 if (arguments.length <= 1) { 44 bindingFunction = function () { 45 if (@IsConstructor) { 46 return new boundFunction(...arguments); 47 } else { 48 return boundFunction.@apply(thisValue, arguments); 49 } 50 } 51 } else { 52 var boundParameters = []; 53 var length = arguments.length; 54 for (var i = 1; i < length; i++) 55 boundParameters[i - 1] = arguments[i]; 56 57 bindingFunction = function () { 58 if (arguments.length) { 59 var completeArguments = [...boundParameters, ...arguments]; 60 if (@IsConstructor) 61 return new boundFunction(...completeArguments); 62 else 63 return boundFunction.@apply(thisValue, completeArguments); 64 } 65 if (@IsConstructor) 66 return new boundFunction(...boundParameters); 67 else 68 return boundFunction.@apply(thisValue, boundParameters); 69 70 } 71 } 72 bindingFunction.@boundFunctionName = this.name; 73 bindingFunction.@boundFunction = boundFunction.@boundFunction || boundFunction; 74 var boundLength = boundFunction.length - (arguments.length - 1); 75 if (boundLength < 0) 76 boundLength = 0; 77 bindingFunction.@boundFunctionLength = boundLength; 78 @SetTypeErrorAccessor(bindingFunction, "arguments"); 79 @SetTypeErrorAccessor(bindingFunction, "caller"); 80 return bindingFunction; 81 } -
trunk/Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp
r163960 r167020 52 52 static UnlinkedFunctionCodeBlock* generateFunctionCodeBlock(VM& vm, UnlinkedFunctionExecutable* executable, const SourceCode& source, CodeSpecializationKind kind, DebuggerMode debuggerMode, ProfilerMode profilerMode, UnlinkedFunctionKind functionKind, ParserError& error) 53 53 { 54 RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(&vm, source, executable->parameters(), executable->name(), executable->toStrictness(), JSParseFunctionCode, error);54 RefPtr<FunctionBodyNode> body = parse<FunctionBodyNode>(&vm, source, executable->parameters(), executable->name(), executable->toStrictness(), JSParseFunctionCode, kind == CodeForConstruct ? JSFunctionIsConstructorKind : JSFunctionIsFunctionKind, error); 55 55 56 56 if (!body) { -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r166243 r167020 1286 1286 1287 1287 generator.emitExpressionInfo(divot(), divotStart(), divotEnd()); 1288 generator.emitGetById(prototype.get(), src2.get(), generator.vm()->propertyNames->prototype );1288 generator.emitGetById(prototype.get(), src2.get(), generator.vm()->propertyNames->prototypeForHasInstancePrivateName); 1289 1289 1290 1290 generator.emitExpressionInfo(divot(), divotStart(), divotEnd()); -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r165676 r167020 45 45 #include "JSActivation.h" 46 46 #include "JSArray.h" 47 #include "JSBoundFunction.h"48 47 #include "JSNameScope.h" 49 48 #include "JSNotAnObject.h" -
trunk/Source/JavaScriptCore/parser/Lexer.cpp
r165603 r167020 490 490 491 491 template <typename T> 492 Lexer<T>::Lexer(VM* vm, JSParserStrictness strictness )492 Lexer<T>::Lexer(VM* vm, JSParserStrictness strictness, JSFunctionKind functionKind) 493 493 : m_isReparsing(false) 494 494 , m_vm(vm) 495 495 , m_parsingBuiltinFunction(strictness == JSParseBuiltin) 496 , m_functionKind(functionKind) 496 497 { 497 498 } … … 820 821 else if (*ident == m_vm->propertyNames->undefinedKeyword) 821 822 tokenData->ident = &m_vm->propertyNames->undefinedPrivateName; 823 822 824 if (!ident) 823 825 return INVALID_PRIVATE_NAME_ERRORTOK; 826 827 if (*ident == m_vm->propertyNames->IsConstructorPrivateName) 828 return m_functionKind == JSFunctionIsConstructorKind ? TRUETOKEN : FALSETOKEN; 829 824 830 } 825 831 tokenData->ident = ident; … … 897 903 else if (*ident == m_vm->propertyNames->undefinedKeyword) 898 904 tokenData->ident = &m_vm->propertyNames->undefinedPrivateName; 905 if (m_functionKind == JSFunctionIsConstructorKind) { 906 if (*ident == m_vm->propertyNames->IsConstructorPrivateName) 907 return TRUETOKEN; 908 return FALSETOKEN; 909 } 899 910 if (!ident) 900 911 return INVALID_PRIVATE_NAME_ERRORTOK; -
trunk/Source/JavaScriptCore/parser/Lexer.h
r165603 r167020 72 72 73 73 public: 74 Lexer(VM*, JSParserStrictness );74 Lexer(VM*, JSParserStrictness, JSFunctionKind); 75 75 ~Lexer(); 76 76 … … 239 239 VM* m_vm; 240 240 bool m_parsingBuiltinFunction; 241 JSFunctionKind m_functionKind; 241 242 }; 242 243 -
trunk/Source/JavaScriptCore/parser/Parser.cpp
r166392 r167020 193 193 194 194 template <typename LexerType> 195 Parser<LexerType>::Parser(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode )195 Parser<LexerType>::Parser(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, JSFunctionKind functionKind) 196 196 : m_vm(vm) 197 197 , m_source(&source) … … 208 208 , m_parsingBuiltin(strictness == JSParseBuiltin) 209 209 { 210 m_lexer = adoptPtr(new LexerType(vm, strictness ));210 m_lexer = adoptPtr(new LexerType(vm, strictness, functionKind)); 211 211 m_arena = m_vm->parserArena.get(); 212 212 m_lexer->setCode(source, m_arena); … … 284 284 Vector<RefPtr<StringImpl>> closedVariables; 285 285 if (m_parsingBuiltin) { 286 RELEASE_ASSERT(!capturedVariables.size());287 286 IdentifierSet usedVariables; 288 287 scope->getUsedVariables(usedVariables); … … 294 293 continue; 295 294 closedVariables.append(variable); 295 } 296 if (!capturedVariables.isEmpty()) { 297 for (const auto& capturedVariable : capturedVariables) { 298 if (scope->hasDeclaredVariable(Identifier(m_vm, capturedVariable.get()))) 299 continue; 300 301 if (scope->hasDeclaredParameter(Identifier(m_vm, capturedVariable.get()))) 302 continue; 303 RELEASE_ASSERT_NOT_REACHED(); 304 } 296 305 } 297 306 } -
trunk/Source/JavaScriptCore/parser/Parser.h
r163960 r167020 412 412 413 413 public: 414 Parser(VM*, const SourceCode&, FunctionParameters*, const Identifier&, JSParserStrictness, JSParserMode );414 Parser(VM*, const SourceCode&, FunctionParameters*, const Identifier&, JSParserStrictness, JSParserMode, JSFunctionKind); 415 415 ~Parser(); 416 416 … … 955 955 956 956 template <class ParsedNode> 957 PassRefPtr<ParsedNode> parse(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, ParserError& error, JSTextPosition* positionBeforeLastNewline = 0)957 PassRefPtr<ParsedNode> parse(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, JSFunctionKind functionKind, ParserError& error, JSTextPosition* positionBeforeLastNewline = 0) 958 958 { 959 959 SamplingRegion samplingRegion("Parsing"); … … 961 961 ASSERT(!source.provider()->source().isNull()); 962 962 if (source.provider()->source().is8Bit()) { 963 Parser<Lexer<LChar>> parser(vm, source, parameters, name, strictness, parserMode );963 Parser<Lexer<LChar>> parser(vm, source, parameters, name, strictness, parserMode, functionKind); 964 964 RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error); 965 965 if (positionBeforeLastNewline) … … 973 973 return result.release(); 974 974 } 975 Parser<Lexer<UChar>> parser(vm, source, parameters, name, strictness, parserMode );975 Parser<Lexer<UChar>> parser(vm, source, parameters, name, strictness, parserMode, functionKind); 976 976 RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error); 977 977 if (positionBeforeLastNewline) -
trunk/Source/JavaScriptCore/parser/ParserModes.h
r163960 r167020 34 34 enum JSParserStrictness { JSParseNormal, JSParseBuiltin, JSParseStrict }; 35 35 enum JSParserMode { JSParseProgramCode, JSParseFunctionCode }; 36 36 enum JSFunctionKind { JSNotFunctionKind, JSFunctionIsFunctionKind, JSFunctionIsConstructorKind }; 37 37 38 enum ProfilerMode { ProfilerOff, ProfilerOn }; 38 39 enum DebuggerMode { DebuggerOff, DebuggerOn }; -
trunk/Source/JavaScriptCore/runtime/ArgumentsIteratorConstructor.cpp
r158793 r167020 40 40 { 41 41 Base::finishCreation(vm); 42 putDirect WithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);42 putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly); 43 43 } 44 44 -
trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp
r163844 r167020 63 63 { 64 64 Base::finishCreation(vm, arrayPrototype->classInfo()->className); 65 putDirect WithoutTransition(vm, vm.propertyNames->prototype, arrayPrototype, DontEnum | DontDelete | ReadOnly);65 putDirectPrototypePropertyWithoutTransitions(vm, arrayPrototype, DontEnum | DontDelete | ReadOnly); 66 66 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete); 67 67 } -
trunk/Source/JavaScriptCore/runtime/BooleanConstructor.cpp
r163844 r167020 40 40 { 41 41 Base::finishCreation(vm, booleanPrototype->classInfo()->className); 42 putDirect WithoutTransition(vm, vm.propertyNames->prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly);42 putDirectPrototypePropertyWithoutTransitions(vm, booleanPrototype, DontEnum | DontDelete | ReadOnly); 43 43 44 44 // no. of arguments for constructor -
trunk/Source/JavaScriptCore/runtime/CodeCache.cpp
r163960 r167020 93 93 94 94 typedef typename CacheTypes<UnlinkedCodeBlockType>::RootNode RootNode; 95 RefPtr<RootNode> rootNode = parse<RootNode>(&vm, source, 0, Identifier(), strictness, JSParseProgramCode, error);95 RefPtr<RootNode> rootNode = parse<RootNode>(&vm, source, 0, Identifier(), strictness, JSParseProgramCode, JSNotFunctionKind, error); 96 96 if (!rootNode) { 97 97 m_sourceCode.remove(addResult.iterator); … … 143 143 144 144 JSTextPosition positionBeforeLastNewline; 145 RefPtr<ProgramNode> program = parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error, &positionBeforeLastNewline);145 RefPtr<ProgramNode> program = parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, JSNotFunctionKind, error, &positionBeforeLastNewline); 146 146 if (!program) { 147 147 RELEASE_ASSERT(error.m_type != ParserError::ErrorNone); -
trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h
r164835 r167020 219 219 macro(Object) \ 220 220 macro(TypeError) \ 221 macro(undefined) 221 macro(undefined) \ 222 macro(IsConstructor) \ 223 macro(boundFunctionName) \ 224 macro(boundFunctionParameters) \ 225 macro(boundFunction) \ 226 macro(boundFunctionLength) \ 227 macro(prototypeForHasInstance) \ 228 macro(SetTypeErrorAccessor) 222 229 223 230 namespace JSC { -
trunk/Source/JavaScriptCore/runtime/Completion.cpp
r165999 r167020 56 56 JSLockHolder lock(vm); 57 57 RELEASE_ASSERT(vm.atomicStringTable() == wtfThreadData().atomicStringTable()); 58 RefPtr<ProgramNode> programNode = parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, error);58 RefPtr<ProgramNode> programNode = parse<ProgramNode>(&vm, source, 0, Identifier(), JSParseNormal, JSParseProgramCode, JSNotFunctionKind, error); 59 59 return programNode; 60 60 } -
trunk/Source/JavaScriptCore/runtime/DateConstructor.cpp
r166876 r167020 109 109 { 110 110 Base::finishCreation(vm, datePrototype->classInfo()->className); 111 putDirect WithoutTransition(vm, vm.propertyNames->prototype, datePrototype, DontEnum | DontDelete | ReadOnly);111 putDirectPrototypePropertyWithoutTransitions(vm, datePrototype, DontEnum | DontDelete | ReadOnly); 112 112 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(7), ReadOnly | DontEnum | DontDelete); 113 113 } -
trunk/Source/JavaScriptCore/runtime/ErrorConstructor.cpp
r163844 r167020 43 43 Base::finishCreation(vm, errorPrototype->classInfo()->className); 44 44 // ECMA 15.11.3.1 Error.prototype 45 putDirect WithoutTransition(vm, vm.propertyNames->prototype, errorPrototype, DontEnum | DontDelete | ReadOnly);45 putDirectPrototypePropertyWithoutTransitions(vm, errorPrototype, DontEnum | DontDelete | ReadOnly); 46 46 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), DontDelete | ReadOnly | DontEnum); 47 47 } -
trunk/Source/JavaScriptCore/runtime/Executable.cpp
r166678 r167020 448 448 VM* vm = &exec->vm(); 449 449 JSGlobalObject* lexicalGlobalObject = exec->lexicalGlobalObject(); 450 RefPtr<ProgramNode> programNode = parse<ProgramNode>(vm, m_source, 0, Identifier(), JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, error);450 RefPtr<ProgramNode> programNode = parse<ProgramNode>(vm, m_source, 0, Identifier(), JSParseNormal, ProgramNode::isFunctionNode ? JSParseFunctionCode : JSParseProgramCode, JSNotFunctionKind, error); 451 451 if (programNode) 452 452 return 0; -
trunk/Source/JavaScriptCore/runtime/FunctionConstructor.cpp
r163844 r167020 48 48 { 49 49 Base::finishCreation(vm, functionPrototype->classInfo()->className); 50 putDirect WithoutTransition(vm, vm.propertyNames->prototype, functionPrototype, DontEnum | DontDelete | ReadOnly);50 putDirectPrototypePropertyWithoutTransitions(vm, functionPrototype, DontEnum | DontDelete | ReadOnly); 51 51 52 52 // Number of arguments for constructor -
trunk/Source/JavaScriptCore/runtime/FunctionPrototype.cpp
r166493 r167020 26 26 #include "BuiltinNames.h" 27 27 #include "JSArray.h" 28 #include "JSBoundFunction.h"29 28 #include "JSFunction.h" 30 29 #include "JSString.h" … … 41 40 42 41 static EncodedJSValue JSC_HOST_CALL functionProtoFuncToString(ExecState*); 43 static EncodedJSValue JSC_HOST_CALL functionProtoFuncBind(ExecState*);44 42 45 43 FunctionPrototype::FunctionPrototype(VM& vm, Structure* structure) … … 63 61 *applyFunction = putDirectBuiltinFunctionWithoutTransition(vm, globalObject, vm.propertyNames->builtinNames().applyPublicName(), functionPrototypeApplyCodeGenerator(vm), DontEnum); 64 62 *callFunction = putDirectBuiltinFunctionWithoutTransition(vm, globalObject, vm.propertyNames->builtinNames().callPublicName(), functionPrototypeCallCodeGenerator(vm), DontEnum); 65 66 JSFunction* bindFunction = JSFunction::create(vm, globalObject, 1, vm.propertyNames->bind.string(), functionProtoFuncBind); 67 putDirectWithoutTransition(vm, vm.propertyNames->bind, bindFunction, DontEnum); 63 64 putDirectBuiltinFunctionWithoutTransition(vm, globalObject, vm.propertyNames->builtinNames().bindPublicName(), functionPrototypeBindCodeGenerator(vm), DontEnum); 68 65 } 69 66 … … 122 119 } 123 120 124 // 15.3.4.5 Function.prototype.bind (thisArg [, arg1 [, arg2, ...]])125 EncodedJSValue JSC_HOST_CALL functionProtoFuncBind(ExecState* exec)126 {127 JSGlobalObject* globalObject = exec->callee()->globalObject();128 129 // Let Target be the this value.130 JSValue target = exec->thisValue();131 132 // If IsCallable(Target) is false, throw a TypeError exception.133 CallData callData;134 CallType callType = getCallData(target, callData);135 if (callType == CallTypeNone)136 return throwVMTypeError(exec);137 // Primitive values are not callable.138 ASSERT(target.isObject());139 JSObject* targetObject = asObject(target);140 VM& vm = exec->vm();141 142 // Let A be a new (possibly empty) internal list of all of the argument values provided after thisArg (arg1, arg2 etc), in order.143 size_t numBoundArgs = exec->argumentCount() > 1 ? exec->argumentCount() - 1 : 0;144 JSArray* boundArgs = JSArray::tryCreateUninitialized(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithUndecided), numBoundArgs);145 if (!boundArgs)146 return JSValue::encode(throwOutOfMemoryError(exec));147 148 for (size_t i = 0; i < numBoundArgs; ++i)149 boundArgs->initializeIndex(vm, i, exec->argument(i + 1));150 151 // If the [[Class]] internal property of Target is "Function", then ...152 // Else set the length own property of F to 0.153 unsigned length = 0;154 if (targetObject->inherits(JSFunction::info())) {155 ASSERT(target.get(exec, exec->propertyNames().length).isNumber());156 // a. Let L be the length property of Target minus the length of A.157 // b. Set the length own property of F to either 0 or L, whichever is larger.158 unsigned targetLength = (unsigned)target.get(exec, exec->propertyNames().length).asNumber();159 if (targetLength > numBoundArgs)160 length = targetLength - numBoundArgs;161 }162 163 JSString* name = target.get(exec, exec->propertyNames().name).toString(exec);164 return JSValue::encode(JSBoundFunction::create(vm, globalObject, targetObject, exec->argument(0), boundArgs, length, name->value(exec)));165 }166 167 121 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp
r163844 r167020 51 51 { 52 52 Base::finishCreation(vm, "ArrayBuffer"); 53 putDirect WithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);53 putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly); 54 54 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), DontEnum | DontDelete | ReadOnly); 55 55 -
trunk/Source/JavaScriptCore/runtime/JSFunction.cpp
r164764 r167020 34 34 #include "GetterSetter.h" 35 35 #include "JSArray.h" 36 #include "JSBoundFunction.h"37 36 #include "JSFunctionInlines.h" 38 37 #include "JSGlobalObject.h" … … 252 251 class RetrieveCallerFunctionFunctor { 253 252 public: 254 RetrieveCallerFunctionFunctor(JSFunction* functionObj) 255 : m_targetCallee(jsDynamicCast<JSObject*>(functionObj)) 253 RetrieveCallerFunctionFunctor(ExecState* exec, JSFunction* functionObj) 254 : m_exec(exec) 255 , m_targetCallee(jsDynamicCast<JSObject*>(functionObj)) 256 256 , m_hasFoundFrame(false) 257 257 , m_hasSkippedToCallerFrame(false) … … 266 266 JSObject* callee = visitor->callee(); 267 267 268 if (callee && callee-> inherits(JSBoundFunction::info()))268 if (callee && callee->hasOwnProperty(m_exec, m_exec->propertyNames().boundFunctionNamePrivateName)) 269 269 return StackVisitor::Continue; 270 270 … … 284 284 285 285 private: 286 ExecState* m_exec; 286 287 JSObject* m_targetCallee; 287 288 bool m_hasFoundFrame; … … 292 293 static JSValue retrieveCallerFunction(ExecState* exec, JSFunction* functionObj) 293 294 { 294 RetrieveCallerFunctionFunctor functor( functionObj);295 RetrieveCallerFunctionFunctor functor(exec, functionObj); 295 296 exec->iterate(functor); 296 297 return functor.result(); … … 329 330 { 330 331 JSFunction* thisObject = jsCast<JSFunction*>(object); 331 if (thisObject->isHost OrBuiltinFunction())332 if (thisObject->isHostFunction()) 332 333 return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 333 334 if (propertyName == exec->propertyNames().prototype) { 334 if (thisObject->isBuiltinFunction()) { 335 if (propertyName == exec->propertyNames().caller) { 336 if (thisObject->jsExecutable()->isStrictMode()) { 337 bool result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 338 if (!result) { 339 thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec->vm()), DontDelete | DontEnum | Accessor); 340 result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 341 ASSERT(result); 342 } 343 return result; 344 } 345 slot.setCacheableCustom(thisObject, ReadOnly | DontEnum | DontDelete, callerGetter); 346 return true; 347 } 348 if (propertyName == exec->propertyNames().prototypeForHasInstancePrivateName) { 349 PropertySlot boundFunctionSlot(thisObject); 350 if (Base::getOwnPropertySlot(thisObject, exec, exec->propertyNames().boundFunctionPrivateName, boundFunctionSlot)) { 351 JSValue boundFunction = boundFunctionSlot.getValue(exec, exec->propertyNames().boundFunctionPrivateName); 352 PropertySlot boundPrototypeSlot(asObject(boundFunction)); 353 if (asObject(boundFunction)->getPropertySlot(exec, propertyName, boundPrototypeSlot)) { 354 slot.setValue(boundPrototypeSlot.slotBase(), boundPrototypeSlot.attributes(), boundPrototypeSlot.getValue(exec, propertyName)); 355 return true; 356 } 357 } 358 } 359 if (propertyName == exec->propertyNames().name) { 360 PropertySlot nameSlot(thisObject); 361 if (Base::getOwnPropertySlot(thisObject, exec, exec->vm().propertyNames->boundFunctionNamePrivateName, nameSlot)) { 362 slot.setValue(thisObject, DontEnum | DontDelete | ReadOnly, nameSlot.getValue(exec, exec->vm().propertyNames->boundFunctionNamePrivateName)); 363 return true; 364 } 365 } 366 if (propertyName == exec->propertyNames().length) { 367 PropertySlot lengthSlot(thisObject); 368 if (Base::getOwnPropertySlot(thisObject, exec, exec->vm().propertyNames->boundFunctionLengthPrivateName, lengthSlot)) { 369 slot.setValue(thisObject, DontEnum | DontDelete | ReadOnly, lengthSlot.getValue(exec, exec->vm().propertyNames->boundFunctionLengthPrivateName)); 370 return true; 371 } 372 } 373 374 return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot); 375 } 376 377 if (propertyName == exec->propertyNames().prototype || propertyName == exec->propertyNames().prototypeForHasInstancePrivateName) { 335 378 VM& vm = exec->vm(); 336 379 unsigned attributes; … … 339 382 JSObject* prototype = constructEmptyObject(exec); 340 383 prototype->putDirect(vm, exec->propertyNames().constructor, thisObject, DontEnum); 341 thisObject->putDirect (vm, exec->propertyNames().prototype, prototype, DontDelete | DontEnum);384 thisObject->putDirectPrototypeProperty(vm, prototype, DontDelete | DontEnum); 342 385 offset = thisObject->getDirectOffset(vm, exec->propertyNames().prototype, attributes); 343 386 ASSERT(isValidOffset(offset)); … … 391 434 { 392 435 JSFunction* thisObject = jsCast<JSFunction*>(object); 393 if (!thisObject->isHostOrBuiltinFunction() && (mode == IncludeDontEnumProperties)) { 394 VM& vm = exec->vm(); 395 // Make sure prototype has been reified. 396 PropertySlot slot(thisObject); 397 thisObject->methodTable(vm)->getOwnPropertySlot(thisObject, exec, vm.propertyNames->prototype, slot); 398 399 propertyNames.add(vm.propertyNames->arguments); 400 propertyNames.add(vm.propertyNames->caller); 401 propertyNames.add(vm.propertyNames->length); 402 propertyNames.add(vm.propertyNames->name); 436 if (mode == IncludeDontEnumProperties) { 437 bool shouldIncludeJSFunctionProperties = !thisObject->isHostOrBuiltinFunction(); 438 if (!shouldIncludeJSFunctionProperties && thisObject->isBuiltinFunction()) { 439 PropertySlot boundFunctionSlot(thisObject); 440 shouldIncludeJSFunctionProperties = Base::getOwnPropertySlot(thisObject, exec, exec->propertyNames().boundFunctionPrivateName, boundFunctionSlot); 441 } 442 if (shouldIncludeJSFunctionProperties) { 443 VM& vm = exec->vm(); 444 // Make sure prototype has been reified. 445 PropertySlot slot(thisObject); 446 thisObject->methodTable(vm)->getOwnPropertySlot(thisObject, exec, vm.propertyNames->prototype, slot); 447 448 propertyNames.add(vm.propertyNames->arguments); 449 propertyNames.add(vm.propertyNames->caller); 450 propertyNames.add(vm.propertyNames->length); 451 propertyNames.add(vm.propertyNames->name); 452 } 403 453 } 404 454 Base::getOwnNonIndexPropertyNames(thisObject, exec, propertyNames, mode); … … 420 470 thisObject->m_allocationProfileWatchpoint.fireAll(); 421 471 // Don't allow this to be cached, since a [[Put]] must clear m_allocationProfile. 422 PutPropertySlot dontCache(thisObject); 423 Base::put(thisObject, exec, propertyName, value, dontCache); 472 PutPropertySlot dontCachePrototype(thisObject); 473 Base::put(thisObject, exec, propertyName, value, dontCachePrototype); 474 PutPropertySlot dontCachePrototypeForHasInstance(thisObject); 475 Base::put(thisObject, exec, exec->propertyNames().prototypeForHasInstancePrivateName, value, dontCachePrototypeForHasInstance); 424 476 return; 425 477 } … … 466 518 thisObject->m_allocationProfile.clear(); 467 519 thisObject->m_allocationProfileWatchpoint.fireAll(); 468 return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException); 520 if (!Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException)) 521 return false; 522 Base::defineOwnProperty(object, exec, exec->propertyNames().prototypeForHasInstancePrivateName, descriptor, throwException); 523 return true; 469 524 } 470 525 -
trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h
r163225 r167020 44 44 { 45 45 Base::finishCreation(vm, name); 46 putDirect WithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);46 putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly); 47 47 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(3), DontEnum | DontDelete | ReadOnly); 48 48 putDirectWithoutTransition(vm, vm.propertyNames->BYTES_PER_ELEMENT, jsNumber(ViewClass::elementSize), DontEnum | ReadOnly | DontDelete); -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r166852 r167020 61 61 #include "JSArrayBufferPrototype.h" 62 62 #include "JSArrayIterator.h" 63 #include "JSBoundFunction.h"64 63 #include "JSCInlines.h" 65 64 #include "JSCallbackConstructor.h" … … 279 278 m_functionPrototype.set(vm, this, FunctionPrototype::create(vm, FunctionPrototype::createStructure(vm, this, jsNull()))); // The real prototype will be set once ObjectPrototype is created. 280 279 m_functionStructure.set(vm, this, JSFunction::createStructure(vm, this, m_functionPrototype.get())); 281 m_boundFunctionStructure.set(vm, this, JSBoundFunction::createStructure(vm, this, m_functionPrototype.get()));282 280 m_namedFunctionStructure.set(vm, this, Structure::addPropertyTransition(vm, m_functionStructure.get(), vm.propertyNames->name, DontDelete | ReadOnly | DontEnum, 0, m_functionNameOffset)); 283 281 m_internalFunctionStructure.set(vm, this, InternalFunction::createStructure(vm, this, m_functionPrototype.get())); … … 452 450 putDirectWithoutTransition(vm, Identifier(exec, typedArrayConstructors[typedArrayIndex]->name(exec)), typedArrayConstructors[typedArrayIndex], DontEnum); 453 451 } 454 452 453 JSFunction* setTypeErrorAccessor = JSFunction::create(vm, this, 2, vm.propertyNames->emptyIdentifier.string(), globalFuncSetTypeErrorAccessor); 455 454 GlobalPropertyInfo staticGlobals[] = { 456 455 GlobalPropertyInfo(vm.propertyNames->NaN, jsNaN(), DontEnum | DontDelete | ReadOnly), … … 459 458 GlobalPropertyInfo(vm.propertyNames->undefinedPrivateName, jsUndefined(), DontEnum | DontDelete | ReadOnly), 460 459 GlobalPropertyInfo(vm.propertyNames->ObjectPrivateName, objectConstructor, DontEnum | DontDelete | ReadOnly), 461 GlobalPropertyInfo(vm.propertyNames->TypeErrorPrivateName, m_typeErrorConstructor.get(), DontEnum | DontDelete | ReadOnly) 460 GlobalPropertyInfo(vm.propertyNames->TypeErrorPrivateName, m_typeErrorConstructor.get(), DontEnum | DontDelete | ReadOnly), 461 GlobalPropertyInfo(vm.propertyNames->SetTypeErrorAccessorPrivateName, setTypeErrorAccessor, DontEnum | DontDelete | ReadOnly) 462 462 }; 463 463 addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals)); -
trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r165703 r167020 27 27 28 28 #include "CallFrame.h" 29 #include "GetterSetter.h" 29 30 #include "Interpreter.h" 30 31 #include "JSFunction.h" … … 806 807 return JSValue::encode(jsUndefined()); 807 808 } 808 809 810 EncodedJSValue JSC_HOST_CALL globalFuncSetTypeErrorAccessor(ExecState* exec) 811 { 812 JSObject* target = jsDynamicCast<JSObject*>(exec->argument(0)); 813 JSValue propertyName = exec->argument(1); 814 815 // Setting __proto__ of a primitive should have no effect. 816 if (!target || !propertyName.isString()) 817 return JSValue::encode(jsUndefined()); 818 VM& vm = exec->vm(); 819 Identifier property(exec, asString(propertyName)->getString(exec)); 820 target->putDirectNonIndexAccessor(vm, vm.propertyNames->arguments, target->globalObject()->throwTypeErrorGetterSetter(vm), DontDelete | DontEnum | Accessor); 821 return JSValue::encode(jsUndefined()); 822 } 823 809 824 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h
r165703 r167020 52 52 EncodedJSValue JSC_HOST_CALL globalFuncProtoGetter(ExecState*); 53 53 EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState*); 54 54 EncodedJSValue JSC_HOST_CALL globalFuncSetTypeErrorAccessor(ExecState*); 55 55 56 static const double mantissaOverflowLowerBound = 9007199254740992.0; 56 57 double parseIntOverflow(const LChar*, unsigned length, int radix); -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r166945 r167020 2669 2669 return exec->vm().throwException(exec, createTypeError(exec, message)); 2670 2670 } 2671 2671 2672 void JSObject::putDirectPrototypeProperty(VM& vm, JSValue value, int attributes) 2673 { 2674 putDirect(vm, vm.propertyNames->prototype, value, attributes); 2675 putDirect(vm, vm.propertyNames->prototypeForHasInstancePrivateName, value, attributes); 2676 } 2677 2678 void JSObject::putDirectPrototypePropertyWithoutTransitions(VM& vm, JSValue value, int attributes) 2679 { 2680 putDirectWithoutTransition(vm, vm.propertyNames->prototype, value, attributes); 2681 putDirectWithoutTransition(vm, vm.propertyNames->prototypeForHasInstancePrivateName, value, attributes); 2682 } 2683 2672 2684 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r166760 r167020 933 933 } 934 934 935 JS_EXPORT_PRIVATE void putDirectPrototypeProperty(VM&, JSValue, int); 936 void putDirectPrototypePropertyWithoutTransitions(VM&, JSValue, int); 937 935 938 private: 936 939 friend class LLIntOffsetsExtractor; -
trunk/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp
r163225 r167020 87 87 { 88 88 Base::finishCreation(vm, "Promise"); 89 putDirect WithoutTransition(vm, vm.propertyNames->prototype, promisePrototype, DontEnum | DontDelete | ReadOnly);89 putDirectPrototypePropertyWithoutTransitions(vm, promisePrototype, DontEnum | DontDelete | ReadOnly); 90 90 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete); 91 91 } -
trunk/Source/JavaScriptCore/runtime/MapConstructor.cpp
r156498 r167020 41 41 { 42 42 Base::finishCreation(vm, mapPrototype->classInfo()->className); 43 putDirect WithoutTransition(vm, vm.propertyNames->prototype, mapPrototype, DontEnum | DontDelete | ReadOnly);43 putDirectPrototypePropertyWithoutTransitions(vm, mapPrototype, DontEnum | DontDelete | ReadOnly); 44 44 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum | DontDelete); 45 45 } -
trunk/Source/JavaScriptCore/runtime/MapIteratorConstructor.cpp
r159008 r167020 40 40 { 41 41 Base::finishCreation(vm); 42 putDirect WithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);42 putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly); 43 43 } 44 44 -
trunk/Source/JavaScriptCore/runtime/NameConstructor.cpp
r163844 r167020 45 45 { 46 46 Base::finishCreation(vm, prototype->classInfo()->className); 47 putDirect WithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);47 putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly); 48 48 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), DontDelete | ReadOnly | DontEnum); 49 49 } -
trunk/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp
r163960 r167020 47 47 48 48 putDirect(vm, vm.propertyNames->length, jsNumber(1), DontDelete | ReadOnly | DontEnum); // ECMA 15.11.7.5 49 putDirect (vm, vm.propertyNames->prototype, prototype, DontDelete | ReadOnly | DontEnum);49 putDirectPrototypeProperty(vm, prototype, DontDelete | ReadOnly | DontEnum); 50 50 m_errorStructure.set(vm, this, ErrorInstance::createStructure(vm, globalObject, prototype)); 51 51 ASSERT(m_errorStructure); -
trunk/Source/JavaScriptCore/runtime/NumberConstructor.cpp
r163844 r167020 67 67 68 68 // Number.Prototype 69 putDirect WithoutTransition(vm, vm.propertyNames->prototype, numberPrototype, DontEnum | DontDelete | ReadOnly);69 putDirectPrototypePropertyWithoutTransitions(vm, numberPrototype, DontEnum | DontDelete | ReadOnly); 70 70 71 71 // no. of arguments for constructor -
trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp
r164764 r167020 89 89 Base::finishCreation(vm, Identifier(&vm, "Object").string()); 90 90 // ECMA 15.2.3.1 91 putDirect WithoutTransition(vm, vm.propertyNames->prototype, objectPrototype, DontEnum | DontDelete | ReadOnly);91 putDirectPrototypePropertyWithoutTransitions(vm, objectPrototype, DontEnum | DontDelete | ReadOnly); 92 92 // no. of arguments for constructor 93 93 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete); -
trunk/Source/JavaScriptCore/runtime/RegExpConstructor.cpp
r163844 r167020 96 96 97 97 // ECMA 15.10.5.1 RegExp.prototype 98 putDirect WithoutTransition(vm, vm.propertyNames->prototype, regExpPrototype, DontEnum | DontDelete | ReadOnly);98 putDirectPrototypePropertyWithoutTransitions(vm, regExpPrototype, DontEnum | DontDelete | ReadOnly); 99 99 100 100 // no. of arguments for constructor -
trunk/Source/JavaScriptCore/runtime/SetConstructor.cpp
r163225 r167020 42 42 { 43 43 Base::finishCreation(vm, setPrototype->classInfo()->className); 44 putDirect WithoutTransition(vm, vm.propertyNames->prototype, setPrototype, DontEnum | DontDelete | ReadOnly);44 putDirectPrototypePropertyWithoutTransitions(vm, setPrototype, DontEnum | DontDelete | ReadOnly); 45 45 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum | DontDelete); 46 46 } -
trunk/Source/JavaScriptCore/runtime/SetIteratorConstructor.cpp
r159031 r167020 40 40 { 41 41 Base::finishCreation(vm); 42 putDirect WithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);42 putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly); 43 43 } 44 44 -
trunk/Source/JavaScriptCore/runtime/StringConstructor.cpp
r163844 r167020 57 57 { 58 58 Base::finishCreation(vm, stringPrototype->classInfo()->className); 59 putDirect WithoutTransition(vm, vm.propertyNames->prototype, stringPrototype, ReadOnly | DontEnum | DontDelete);59 putDirectPrototypePropertyWithoutTransitions(vm, stringPrototype, ReadOnly | DontEnum | DontDelete); 60 60 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete); 61 61 } -
trunk/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp
r156498 r167020 40 40 { 41 41 Base::finishCreation(vm, prototype->classInfo()->className); 42 putDirect WithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);42 putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly); 43 43 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum | DontDelete); 44 44 } -
trunk/Source/WebCore/ChangeLog
r167019 r167020 1 2014-04-08 Oliver Hunt <oliver@apple.com> 2 3 Rewrite Function.bind as a builtin 4 https://bugs.webkit.org/show_bug.cgi?id=131083 5 6 Reviewed by Geoffrey Garen. 7 8 Switch WebCore to use the helper functions when defining the 9 prototype properties on DOM constructors, and update bindings 10 tests accordingly. 11 12 * bindings/js/JSImageConstructor.cpp: 13 (WebCore::JSImageConstructor::finishCreation): 14 * bindings/scripts/CodeGeneratorJS.pm: 15 (GenerateConstructorHelperMethods): 16 * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp: 17 (WebCore::JSTestActiveDOMObjectConstructor::finishCreation): 18 * bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp: 19 (WebCore::JSTestCustomNamedGetterConstructor::finishCreation): 20 * bindings/scripts/test/JS/JSTestEventConstructor.cpp: 21 (WebCore::JSTestEventConstructorConstructor::finishCreation): 22 * bindings/scripts/test/JS/JSTestEventTarget.cpp: 23 (WebCore::JSTestEventTargetConstructor::finishCreation): 24 * bindings/scripts/test/JS/JSTestException.cpp: 25 (WebCore::JSTestExceptionConstructor::finishCreation): 26 * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp: 27 (WebCore::JSTestGenerateIsReachableConstructor::finishCreation): 28 * bindings/scripts/test/JS/JSTestInterface.cpp: 29 (WebCore::JSTestInterfaceConstructor::finishCreation): 30 * bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp: 31 (WebCore::JSTestMediaQueryListListenerConstructor::finishCreation): 32 * bindings/scripts/test/JS/JSTestNamedConstructor.cpp: 33 (WebCore::JSTestNamedConstructorConstructor::finishCreation): 34 (WebCore::JSTestNamedConstructorNamedConstructor::finishCreation): 35 * bindings/scripts/test/JS/JSTestNode.cpp: 36 (WebCore::JSTestNodeConstructor::finishCreation): 37 * bindings/scripts/test/JS/JSTestObj.cpp: 38 (WebCore::JSTestObjConstructor::finishCreation): 39 * bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp: 40 (WebCore::JSTestOverloadedConstructorsConstructor::finishCreation): 41 * bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp: 42 (WebCore::JSTestSerializedScriptValueInterfaceConstructor::finishCreation): 43 * bindings/scripts/test/JS/JSTestTypedefs.cpp: 44 (WebCore::JSTestTypedefsConstructor::finishCreation): 45 * bindings/scripts/test/JS/JSattribute.cpp: 46 (WebCore::JSattributeConstructor::finishCreation): 47 * bindings/scripts/test/JS/JSreadonly.cpp: 48 (WebCore::JSreadonlyConstructor::finishCreation): 49 1 50 2014-04-09 Enrica Casucci <enrica@apple.com> 2 51 -
trunk/Source/WebCore/bindings/js/JSImageConstructor.cpp
r156485 r167020 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2014 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 44 44 Base::finishCreation(globalObject); 45 45 ASSERT(inherits(info())); 46 putDirect (vm, vm.propertyNames->prototype, JSHTMLImageElementPrototype::self(vm, globalObject), None);46 putDirectPrototypeProperty(vm, JSHTMLImageElementPrototype::self(vm, globalObject), None); 47 47 } 48 48 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r166864 r167020 4557 4557 push(@$outputArray, " Base::finishCreation(vm);\n"); 4558 4558 push(@$outputArray, " ASSERT(inherits(info()));\n"); 4559 push(@$outputArray, " putDirect (vm, vm.propertyNames->prototype, globalObject->prototype(), DontDelete | ReadOnly);\n");4559 push(@$outputArray, " putDirectPrototypeProperty(vm, globalObject->prototype(), DontDelete | ReadOnly);\n"); 4560 4560 } elsif ($generatingNamedConstructor) { 4561 4561 push(@$outputArray, " Base::finishCreation(globalObject);\n"); 4562 4562 push(@$outputArray, " ASSERT(inherits(info()));\n"); 4563 push(@$outputArray, " putDirect (vm, vm.propertyNames->prototype, ${className}Prototype::self(vm, globalObject), None);\n");4563 push(@$outputArray, " putDirectPrototypeProperty(vm, ${className}Prototype::self(vm, globalObject), None);\n"); 4564 4564 } else { 4565 4565 push(@$outputArray, " Base::finishCreation(vm);\n"); 4566 4566 push(@$outputArray, " ASSERT(inherits(info()));\n"); 4567 push(@$outputArray, " putDirect (vm, vm.propertyNames->prototype, ${protoClassName}::self(vm, globalObject), DontDelete | ReadOnly);\n");4567 push(@$outputArray, " putDirectPrototypeProperty(vm, ${protoClassName}::self(vm, globalObject), DontDelete | ReadOnly);\n"); 4568 4568 } 4569 4569 push(@$outputArray, " putDirect(vm, vm.propertyNames->length, jsNumber(${leastConstructorLength}), ReadOnly | DontDelete | DontEnum);\n") if defined $leastConstructorLength; -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp
r166864 r167020 75 75 Base::finishCreation(vm); 76 76 ASSERT(inherits(info())); 77 putDirect (vm, vm.propertyNames->prototype, JSTestActiveDOMObjectPrototype::self(vm, globalObject), DontDelete | ReadOnly);77 putDirectPrototypeProperty(vm, JSTestActiveDOMObjectPrototype::self(vm, globalObject), DontDelete | ReadOnly); 78 78 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum); 79 79 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp
r166864 r167020 71 71 Base::finishCreation(vm); 72 72 ASSERT(inherits(info())); 73 putDirect (vm, vm.propertyNames->prototype, JSTestCustomNamedGetterPrototype::self(vm, globalObject), DontDelete | ReadOnly);73 putDirectPrototypeProperty(vm, JSTestCustomNamedGetterPrototype::self(vm, globalObject), DontDelete | ReadOnly); 74 74 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum); 75 75 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp
r166864 r167020 96 96 Base::finishCreation(vm); 97 97 ASSERT(inherits(info())); 98 putDirect (vm, vm.propertyNames->prototype, JSTestEventConstructorPrototype::self(vm, globalObject), DontDelete | ReadOnly);98 putDirectPrototypeProperty(vm, JSTestEventConstructorPrototype::self(vm, globalObject), DontDelete | ReadOnly); 99 99 putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum); 100 100 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp
r166864 r167020 77 77 Base::finishCreation(vm); 78 78 ASSERT(inherits(info())); 79 putDirect (vm, vm.propertyNames->prototype, JSTestEventTargetPrototype::self(vm, globalObject), DontDelete | ReadOnly);79 putDirectPrototypeProperty(vm, JSTestEventTargetPrototype::self(vm, globalObject), DontDelete | ReadOnly); 80 80 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum); 81 81 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp
r166864 r167020 70 70 Base::finishCreation(vm); 71 71 ASSERT(inherits(info())); 72 putDirect (vm, vm.propertyNames->prototype, JSTestExceptionPrototype::self(vm, globalObject), DontDelete | ReadOnly);72 putDirectPrototypeProperty(vm, JSTestExceptionPrototype::self(vm, globalObject), DontDelete | ReadOnly); 73 73 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum); 74 74 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp
r166864 r167020 53 53 Base::finishCreation(vm); 54 54 ASSERT(inherits(info())); 55 putDirect (vm, vm.propertyNames->prototype, JSTestGenerateIsReachablePrototype::self(vm, globalObject), DontDelete | ReadOnly);55 putDirectPrototypeProperty(vm, JSTestGenerateIsReachablePrototype::self(vm, globalObject), DontDelete | ReadOnly); 56 56 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum); 57 57 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
r166864 r167020 194 194 Base::finishCreation(vm); 195 195 ASSERT(inherits(info())); 196 putDirect (vm, vm.propertyNames->prototype, JSTestInterfacePrototype::self(vm, globalObject), DontDelete | ReadOnly);196 putDirectPrototypeProperty(vm, JSTestInterfacePrototype::self(vm, globalObject), DontDelete | ReadOnly); 197 197 putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum); 198 198 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp
r166864 r167020 57 57 Base::finishCreation(vm); 58 58 ASSERT(inherits(info())); 59 putDirect (vm, vm.propertyNames->prototype, JSTestMediaQueryListListenerPrototype::self(vm, globalObject), DontDelete | ReadOnly);59 putDirectPrototypeProperty(vm, JSTestMediaQueryListListenerPrototype::self(vm, globalObject), DontDelete | ReadOnly); 60 60 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum); 61 61 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp
r166864 r167020 56 56 Base::finishCreation(vm); 57 57 ASSERT(inherits(info())); 58 putDirect (vm, vm.propertyNames->prototype, JSTestNamedConstructorPrototype::self(vm, globalObject), DontDelete | ReadOnly);58 putDirectPrototypeProperty(vm, JSTestNamedConstructorPrototype::self(vm, globalObject), DontDelete | ReadOnly); 59 59 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum); 60 60 } … … 99 99 Base::finishCreation(globalObject); 100 100 ASSERT(inherits(info())); 101 putDirect (vm, vm.propertyNames->prototype, JSTestNamedConstructorPrototype::self(vm, globalObject), None);101 putDirectPrototypeProperty(vm, JSTestNamedConstructorPrototype::self(vm, globalObject), None); 102 102 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum); 103 103 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
r166864 r167020 63 63 Base::finishCreation(vm); 64 64 ASSERT(inherits(info())); 65 putDirect (vm, vm.propertyNames->prototype, JSTestNodePrototype::self(vm, globalObject), DontDelete | ReadOnly);65 putDirectPrototypeProperty(vm, JSTestNodePrototype::self(vm, globalObject), DontDelete | ReadOnly); 66 66 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum); 67 67 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r166864 r167020 243 243 Base::finishCreation(vm); 244 244 ASSERT(inherits(info())); 245 putDirect (vm, vm.propertyNames->prototype, JSTestObjPrototype::self(vm, globalObject), DontDelete | ReadOnly);245 putDirectPrototypeProperty(vm, JSTestObjPrototype::self(vm, globalObject), DontDelete | ReadOnly); 246 246 putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum); 247 247 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp
r166864 r167020 122 122 Base::finishCreation(vm); 123 123 ASSERT(inherits(info())); 124 putDirect (vm, vm.propertyNames->prototype, JSTestOverloadedConstructorsPrototype::self(vm, globalObject), DontDelete | ReadOnly);124 putDirectPrototypeProperty(vm, JSTestOverloadedConstructorsPrototype::self(vm, globalObject), DontDelete | ReadOnly); 125 125 putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum); 126 126 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp
r166864 r167020 61 61 Base::finishCreation(vm); 62 62 ASSERT(inherits(info())); 63 putDirect (vm, vm.propertyNames->prototype, JSTestSerializedScriptValueInterfacePrototype::self(vm, globalObject), DontDelete | ReadOnly);63 putDirectPrototypeProperty(vm, JSTestSerializedScriptValueInterfacePrototype::self(vm, globalObject), DontDelete | ReadOnly); 64 64 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum); 65 65 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp
r166864 r167020 98 98 Base::finishCreation(vm); 99 99 ASSERT(inherits(info())); 100 putDirect (vm, vm.propertyNames->prototype, JSTestTypedefsPrototype::self(vm, globalObject), DontDelete | ReadOnly);100 putDirectPrototypeProperty(vm, JSTestTypedefsPrototype::self(vm, globalObject), DontDelete | ReadOnly); 101 101 putDirect(vm, vm.propertyNames->length, jsNumber(2), ReadOnly | DontDelete | DontEnum); 102 102 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.cpp
r166864 r167020 56 56 Base::finishCreation(vm); 57 57 ASSERT(inherits(info())); 58 putDirect (vm, vm.propertyNames->prototype, JSattributePrototype::self(vm, globalObject), DontDelete | ReadOnly);58 putDirectPrototypeProperty(vm, JSattributePrototype::self(vm, globalObject), DontDelete | ReadOnly); 59 59 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum); 60 60 } -
trunk/Source/WebCore/bindings/scripts/test/JS/JSreadonly.cpp
r166864 r167020 53 53 Base::finishCreation(vm); 54 54 ASSERT(inherits(info())); 55 putDirect (vm, vm.propertyNames->prototype, JSreadonlyPrototype::self(vm, globalObject), DontDelete | ReadOnly);55 putDirectPrototypeProperty(vm, JSreadonlyPrototype::self(vm, globalObject), DontDelete | ReadOnly); 56 56 putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum); 57 57 }
Note: See TracChangeset
for help on using the changeset viewer.