Changeset 167020 in webkit


Ignore:
Timestamp:
Apr 9, 2014 10:28:40 AM (10 years ago)
Author:
oliver@apple.com
Message:

Rewrite Function.bind as a builtin
https://bugs.webkit.org/show_bug.cgi?id=131083

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

This change removes the existing function.bind implementation
entirely so JSBoundFunction is no more.

Instead we just return a regular JS closure with a few
private properties hanging off it that allow us to perform
the necessary bound function fakery. While most of this is
simple, a couple of key changes:

  • The parser and lexer now directly track whether they're parsing code for call or construct and convert the private name @IsConstructor into TRUETOK or FALSETOK as appropriate. This automatically gives us the ability to vary behaviour from within the builtin. It also leaves a lot of headroom for trivial future improvements.
  • The instanceof operator now uses the prototypeForHasInstance private name, and we have a helper function to ensure that all objects that need to can update their magical 'prototype' property pair correctly.
  • API/JSScriptRef.cpp:

(parseScript):

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • builtins/BuiltinExecutables.cpp:

(JSC::BuiltinExecutables::createBuiltinExecutable):

  • builtins/Function.prototype.js:

(bind.bindingFunction):
(bind.else.bindingFunction):
(bind):

  • 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/CodeCache.cpp:

(JSC::CodeCache::getGlobalCodeBlock):
(JSC::CodeCache::getFunctionExecutableFromGlobalCode):

  • runtime/CommonIdentifiers.h:
  • runtime/Completion.cpp:

(JSC::checkSyntax):

  • runtime/Executable.cpp:

(JSC::ProgramExecutable::checkSyntax):

  • runtime/FunctionPrototype.cpp:

(JSC::FunctionPrototype::addFunctionProperties):
(JSC::functionProtoFuncBind): Deleted.

  • runtime/JSBoundFunction.cpp: Removed.
  • runtime/JSBoundFunction.h: Removed.
  • runtime/JSFunction.cpp:

(JSC::RetrieveCallerFunctionFunctor::RetrieveCallerFunctionFunctor):
(JSC::RetrieveCallerFunctionFunctor::operator()):
(JSC::retrieveCallerFunction):
(JSC::JSFunction::getOwnPropertySlot):
(JSC::JSFunction::defineOwnProperty):

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::reset):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncSetTypeErrorAccessor):

  • runtime/JSGlobalObjectFunctions.h:
  • runtime/JSObject.h:

(JSC::JSObject::inlineGetOwnPropertySlot):

Source/WebCore:

Switch WebCore to use the helper functions when defining the
prototype properties on DOM constructors, and update bindings
tests accordingly.

  • 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:

Testing.

  • js/dom/function-bind-expected.txt:
  • js/regress/function-bind-expected.txt: Added.
  • js/regress/function-bind.html: Added.
  • js/regress/script-tests/function-bind.js: Added.

(foo):

Location:
trunk
Files:
3 added
2 deleted
69 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r167018 r167020  
     12014-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
    1162014-04-09  Radu Stavila  <stavila@adobe.com>
    217
  • trunk/LayoutTests/js/dom/function-bind-expected.txt

    r156066 r167020  
    44
    55
    6 PASS new (decodeURI.bind())() threw exception TypeError: function is not a constructor (evaluating 'new (decodeURI.bind())()').
     6PASS new (decodeURI.bind())() threw exception TypeError: function is not a constructor.
    77PASS (new (String.bind())('foo')).toString() is 'foo'
    88PASS result is "[object Window] -> x:1, y:2"
     
    2424PASS "prototype" in G is false
    2525PASS "prototype" in H is false
    26 PASS Function.bind.call(undefined) threw exception TypeError: Type error.
     26PASS Function.bind.call(undefined) threw exception TypeError: Cannot bind non-function object..
    2727PASS abcAt(1) is "b"
    28 PASS new abcAt(1) threw exception TypeError: function is not a constructor (evaluating 'new abcAt(1)').
     28PASS new abcAt(1) threw exception TypeError: function is not a constructor.
    2929PASS boundFunctionPrototypeAccessed is false
    3030PASS Function.bind.length is 1
  • trunk/Source/JavaScriptCore/API/JSObjectRef.cpp

    r166554 r167020  
    128128    JSCallbackConstructor* constructor = JSCallbackConstructor::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
    129129    constructor->putDirect(exec->vm(), exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
     130    constructor->putDirect(exec->vm(), exec->propertyNames().prototypeForHasInstancePrivateName, jsPrototype, DontEnum | DontDelete | ReadOnly);
    130131    return toRef(constructor);
    131132}
  • trunk/Source/JavaScriptCore/API/JSScriptRef.cpp

    r165074 r167020  
    6969static bool parseScript(VM* vm, const SourceCode& source, ParserError& error)
    7070{
    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);
    7272}
    7373
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r166837 r167020  
    395395    runtime/JSArrayBufferView.cpp
    396396    runtime/JSArrayIterator.cpp
    397     runtime/JSBoundFunction.cpp
    398397    runtime/JSCJSValue.cpp
    399398    runtime/JSCell.cpp
  • trunk/Source/JavaScriptCore/ChangeLog

    r166993 r167020  
     12014-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
    1792014-04-08  Jon Lee  <jonlee@apple.com>
    280
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj

    r166837 r167020  
    641641    <ClCompile Include="..\runtime\JSArrayBufferPrototype.cpp" />
    642642    <ClCompile Include="..\runtime\JSArrayBufferView.cpp" />
    643     <ClCompile Include="..\runtime\JSBoundFunction.cpp" />
    644643    <ClCompile Include="..\runtime\JSCJSValue.cpp" />
    645644    <ClCompile Include="..\runtime\JSCell.cpp" />
     
    13031302    <ClInclude Include="..\runtime\JSArrayBufferViewInlines.h" />
    13041303    <ClInclude Include="..\runtime\JSArrayIterator.h" />
    1305     <ClInclude Include="..\runtime\JSBoundFunction.h" />
    13061304    <ClInclude Include="..\runtime\JSCInlines.h" />
    13071305    <ClInclude Include="..\runtime\JSCJSValue.h" />
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters

    r166837 r167020  
    607607      <Filter>runtime</Filter>
    608608    </ClCompile>
    609     <ClCompile Include="..\runtime\JSBoundFunction.cpp">
    610       <Filter>runtime</Filter>
    611     </ClCompile>
    612609    <ClCompile Include="..\runtime\JSCell.cpp">
    613610      <Filter>runtime</Filter>
     
    22542251    </ClInclude>
    22552252    <ClInclude Include="..\runtime\JSArray.h">
    2256       <Filter>runtime</Filter>
    2257     </ClInclude>
    2258     <ClInclude Include="..\runtime\JSBoundFunction.h">
    22592253      <Filter>runtime</Filter>
    22602254    </ClInclude>
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r166837 r167020  
    939939                86F3EEBE168CDE930077B92A /* ObjCCallbackFunction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 86F3EEBA168CCF750077B92A /* ObjCCallbackFunction.mm */; };
    940940                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 */; };
    943941                90213E3D123A40C200D422F3 /* MemoryStatistics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 90213E3B123A40C200D422F3 /* MemoryStatistics.cpp */; };
    944942                90213E3E123A40C200D422F3 /* MemoryStatistics.h in Headers */ = {isa = PBXBuildFile; fileRef = 90213E3C123A40C200D422F3 /* MemoryStatistics.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    24772475                86F75EFC151C062F007C9BA3 /* RegExpCachedResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpCachedResult.h; sourceTree = "<group>"; };
    24782476                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>"; };
    24812477                90213E3B123A40C200D422F3 /* MemoryStatistics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryStatistics.cpp; sourceTree = "<group>"; };
    24822478                90213E3C123A40C200D422F3 /* MemoryStatistics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryStatistics.h; sourceTree = "<group>"; };
     
    40094005                                A7BDAEC417F4EA1400F6140C /* JSArrayIterator.cpp */,
    40104006                                A7BDAEC517F4EA1400F6140C /* JSArrayIterator.h */,
    4011                                 86FA9E8F142BBB2D001773B7 /* JSBoundFunction.cpp */,
    4012                                 86FA9E90142BBB2E001773B7 /* JSBoundFunction.h */,
    40134007                                BC7F8FBA0E19D1EF008632C0 /* JSCell.cpp */,
    40144008                                BC1167D80E19BCC9008066DD /* JSCell.h */,
     
    53905384                                BC18C4180E16F5CD00B34460 /* JSBase.h in Headers */,
    53915385                                140D17D70E8AD4A9000CD17D /* JSBasePrivate.h in Headers */,
    5392                                 86FA9E92142BBB2E001773B7 /* JSBoundFunction.h in Headers */,
    53935386                                BC18C4190E16F5CD00B34460 /* JSCallbackConstructor.h in Headers */,
    53945387                                BC18C41A0E16F5CD00B34460 /* JSCallbackFunction.h in Headers */,
     
    65216514                                A7BDAECA17F4EA1400F6140C /* JSArrayIterator.cpp in Sources */,
    65226515                                1421359B0A677F4F00A8195E /* JSBase.cpp in Sources */,
    6523                                 86FA9E91142BBB2E001773B7 /* JSBoundFunction.cpp in Sources */,
    65246516                                1440F8AF0A508D200005F061 /* JSCallbackConstructor.cpp in Sources */,
    65256517                                1440F8920A508B100005F061 /* JSCallbackFunction.cpp in Sources */,
  • trunk/Source/JavaScriptCore/builtins/BuiltinExecutables.cpp

    r164346 r167020  
    4747    JSTextPosition positionBeforeLastNewline;
    4848    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);
    5050
    5151    if (!program) {
     
    7272    for (const auto& closedVariable : program->closedVariables()) {
    7373        if (closedVariable == m_vm.propertyNames->arguments.impl())
    74         continue;
     74            continue;
    7575       
    7676        if (closedVariable == m_vm.propertyNames->undefinedKeyword.impl())
  • trunk/Source/JavaScriptCore/builtins/Function.prototype.js

    r164835 r167020  
    3333    return this.@apply(thisValue, argumentValues);
    3434}
     35
     36function 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  
    5252static UnlinkedFunctionCodeBlock* generateFunctionCodeBlock(VM& vm, UnlinkedFunctionExecutable* executable, const SourceCode& source, CodeSpecializationKind kind, DebuggerMode debuggerMode, ProfilerMode profilerMode, UnlinkedFunctionKind functionKind, ParserError& error)
    5353{
    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);
    5555
    5656    if (!body) {
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r166243 r167020  
    12861286
    12871287    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);
    12891289
    12901290    generator.emitExpressionInfo(divot(), divotStart(), divotEnd());
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r165676 r167020  
    4545#include "JSActivation.h"
    4646#include "JSArray.h"
    47 #include "JSBoundFunction.h"
    4847#include "JSNameScope.h"
    4948#include "JSNotAnObject.h"
  • trunk/Source/JavaScriptCore/parser/Lexer.cpp

    r165603 r167020  
    490490
    491491template <typename T>
    492 Lexer<T>::Lexer(VM* vm, JSParserStrictness strictness)
     492Lexer<T>::Lexer(VM* vm, JSParserStrictness strictness, JSFunctionKind functionKind)
    493493    : m_isReparsing(false)
    494494    , m_vm(vm)
    495495    , m_parsingBuiltinFunction(strictness == JSParseBuiltin)
     496    , m_functionKind(functionKind)
    496497{
    497498}
     
    820821            else if (*ident == m_vm->propertyNames->undefinedKeyword)
    821822                tokenData->ident = &m_vm->propertyNames->undefinedPrivateName;
     823           
    822824            if (!ident)
    823825                return INVALID_PRIVATE_NAME_ERRORTOK;
     826           
     827            if (*ident == m_vm->propertyNames->IsConstructorPrivateName)
     828                return m_functionKind == JSFunctionIsConstructorKind ? TRUETOKEN : FALSETOKEN;
     829           
    824830        }
    825831        tokenData->ident = ident;
     
    897903            else if (*ident == m_vm->propertyNames->undefinedKeyword)
    898904                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            }
    899910            if (!ident)
    900911                return INVALID_PRIVATE_NAME_ERRORTOK;
  • trunk/Source/JavaScriptCore/parser/Lexer.h

    r165603 r167020  
    7272
    7373public:
    74     Lexer(VM*, JSParserStrictness);
     74    Lexer(VM*, JSParserStrictness, JSFunctionKind);
    7575    ~Lexer();
    7676
     
    239239    VM* m_vm;
    240240    bool m_parsingBuiltinFunction;
     241    JSFunctionKind m_functionKind;
    241242};
    242243
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r166392 r167020  
    193193
    194194template <typename LexerType>
    195 Parser<LexerType>::Parser(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode)
     195Parser<LexerType>::Parser(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, JSFunctionKind functionKind)
    196196    : m_vm(vm)
    197197    , m_source(&source)
     
    208208    , m_parsingBuiltin(strictness == JSParseBuiltin)
    209209{
    210     m_lexer = adoptPtr(new LexerType(vm, strictness));
     210    m_lexer = adoptPtr(new LexerType(vm, strictness, functionKind));
    211211    m_arena = m_vm->parserArena.get();
    212212    m_lexer->setCode(source, m_arena);
     
    284284    Vector<RefPtr<StringImpl>> closedVariables;
    285285    if (m_parsingBuiltin) {
    286         RELEASE_ASSERT(!capturedVariables.size());
    287286        IdentifierSet usedVariables;
    288287        scope->getUsedVariables(usedVariables);
     
    294293                continue;
    295294            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            }
    296305        }
    297306    }
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r163960 r167020  
    412412
    413413public:
    414     Parser(VM*, const SourceCode&, FunctionParameters*, const Identifier&, JSParserStrictness, JSParserMode);
     414    Parser(VM*, const SourceCode&, FunctionParameters*, const Identifier&, JSParserStrictness, JSParserMode, JSFunctionKind);
    415415    ~Parser();
    416416
     
    955955
    956956template <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)
     957PassRefPtr<ParsedNode> parse(VM* vm, const SourceCode& source, FunctionParameters* parameters, const Identifier& name, JSParserStrictness strictness, JSParserMode parserMode, JSFunctionKind functionKind, ParserError& error, JSTextPosition* positionBeforeLastNewline = 0)
    958958{
    959959    SamplingRegion samplingRegion("Parsing");
     
    961961    ASSERT(!source.provider()->source().isNull());
    962962    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);
    964964        RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error);
    965965        if (positionBeforeLastNewline)
     
    973973        return result.release();
    974974    }
    975     Parser<Lexer<UChar>> parser(vm, source, parameters, name, strictness, parserMode);
     975    Parser<Lexer<UChar>> parser(vm, source, parameters, name, strictness, parserMode, functionKind);
    976976    RefPtr<ParsedNode> result = parser.parse<ParsedNode>(error);
    977977    if (positionBeforeLastNewline)
  • trunk/Source/JavaScriptCore/parser/ParserModes.h

    r163960 r167020  
    3434enum JSParserStrictness { JSParseNormal, JSParseBuiltin, JSParseStrict };
    3535enum JSParserMode { JSParseProgramCode, JSParseFunctionCode };
    36 
     36enum JSFunctionKind { JSNotFunctionKind, JSFunctionIsFunctionKind, JSFunctionIsConstructorKind };
     37   
    3738enum ProfilerMode { ProfilerOff, ProfilerOn };
    3839enum DebuggerMode { DebuggerOff, DebuggerOn };
  • trunk/Source/JavaScriptCore/runtime/ArgumentsIteratorConstructor.cpp

    r158793 r167020  
    4040{
    4141    Base::finishCreation(vm);
    42     putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
     42    putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
    4343}
    4444
  • trunk/Source/JavaScriptCore/runtime/ArrayConstructor.cpp

    r163844 r167020  
    6363{
    6464    Base::finishCreation(vm, arrayPrototype->classInfo()->className);
    65     putDirectWithoutTransition(vm, vm.propertyNames->prototype, arrayPrototype, DontEnum | DontDelete | ReadOnly);
     65    putDirectPrototypePropertyWithoutTransitions(vm, arrayPrototype, DontEnum | DontDelete | ReadOnly);
    6666    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
    6767}
  • trunk/Source/JavaScriptCore/runtime/BooleanConstructor.cpp

    r163844 r167020  
    4040{
    4141    Base::finishCreation(vm, booleanPrototype->classInfo()->className);
    42     putDirectWithoutTransition(vm, vm.propertyNames->prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly);
     42    putDirectPrototypePropertyWithoutTransitions(vm, booleanPrototype, DontEnum | DontDelete | ReadOnly);
    4343
    4444    // no. of arguments for constructor
  • trunk/Source/JavaScriptCore/runtime/CodeCache.cpp

    r163960 r167020  
    9393
    9494    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);
    9696    if (!rootNode) {
    9797        m_sourceCode.remove(addResult.iterator);
     
    143143
    144144    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);
    146146    if (!program) {
    147147        RELEASE_ASSERT(error.m_type != ParserError::ErrorNone);
  • trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h

    r164835 r167020  
    219219    macro(Object) \
    220220    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)
    222229
    223230namespace JSC {
  • trunk/Source/JavaScriptCore/runtime/Completion.cpp

    r165999 r167020  
    5656    JSLockHolder lock(vm);
    5757    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);
    5959    return programNode;
    6060}
  • trunk/Source/JavaScriptCore/runtime/DateConstructor.cpp

    r166876 r167020  
    109109{
    110110    Base::finishCreation(vm, datePrototype->classInfo()->className);
    111     putDirectWithoutTransition(vm, vm.propertyNames->prototype, datePrototype, DontEnum | DontDelete | ReadOnly);
     111    putDirectPrototypePropertyWithoutTransitions(vm, datePrototype, DontEnum | DontDelete | ReadOnly);
    112112    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(7), ReadOnly | DontEnum | DontDelete);
    113113}
  • trunk/Source/JavaScriptCore/runtime/ErrorConstructor.cpp

    r163844 r167020  
    4343    Base::finishCreation(vm, errorPrototype->classInfo()->className);
    4444    // ECMA 15.11.3.1 Error.prototype
    45     putDirectWithoutTransition(vm, vm.propertyNames->prototype, errorPrototype, DontEnum | DontDelete | ReadOnly);
     45    putDirectPrototypePropertyWithoutTransitions(vm, errorPrototype, DontEnum | DontDelete | ReadOnly);
    4646    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), DontDelete | ReadOnly | DontEnum);
    4747}
  • trunk/Source/JavaScriptCore/runtime/Executable.cpp

    r166678 r167020  
    448448    VM* vm = &exec->vm();
    449449    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);
    451451    if (programNode)
    452452        return 0;
  • trunk/Source/JavaScriptCore/runtime/FunctionConstructor.cpp

    r163844 r167020  
    4848{
    4949    Base::finishCreation(vm, functionPrototype->classInfo()->className);
    50     putDirectWithoutTransition(vm, vm.propertyNames->prototype, functionPrototype, DontEnum | DontDelete | ReadOnly);
     50    putDirectPrototypePropertyWithoutTransitions(vm, functionPrototype, DontEnum | DontDelete | ReadOnly);
    5151
    5252    // Number of arguments for constructor
  • trunk/Source/JavaScriptCore/runtime/FunctionPrototype.cpp

    r166493 r167020  
    2626#include "BuiltinNames.h"
    2727#include "JSArray.h"
    28 #include "JSBoundFunction.h"
    2928#include "JSFunction.h"
    3029#include "JSString.h"
     
    4140
    4241static EncodedJSValue JSC_HOST_CALL functionProtoFuncToString(ExecState*);
    43 static EncodedJSValue JSC_HOST_CALL functionProtoFuncBind(ExecState*);
    4442
    4543FunctionPrototype::FunctionPrototype(VM& vm, Structure* structure)
     
    6361    *applyFunction = putDirectBuiltinFunctionWithoutTransition(vm, globalObject, vm.propertyNames->builtinNames().applyPublicName(), functionPrototypeApplyCodeGenerator(vm), DontEnum);
    6462    *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);
    6865}
    6966
     
    122119}
    123120
    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 
    167121} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/JSArrayBufferConstructor.cpp

    r163844 r167020  
    5151{
    5252    Base::finishCreation(vm, "ArrayBuffer");
    53     putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
     53    putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
    5454    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), DontEnum | DontDelete | ReadOnly);
    5555
  • trunk/Source/JavaScriptCore/runtime/JSFunction.cpp

    r164764 r167020  
    3434#include "GetterSetter.h"
    3535#include "JSArray.h"
    36 #include "JSBoundFunction.h"
    3736#include "JSFunctionInlines.h"
    3837#include "JSGlobalObject.h"
     
    252251class RetrieveCallerFunctionFunctor {
    253252public:
    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))
    256256        , m_hasFoundFrame(false)
    257257        , m_hasSkippedToCallerFrame(false)
     
    266266        JSObject* callee = visitor->callee();
    267267
    268         if (callee && callee->inherits(JSBoundFunction::info()))
     268        if (callee && callee->hasOwnProperty(m_exec, m_exec->propertyNames().boundFunctionNamePrivateName))
    269269            return StackVisitor::Continue;
    270270
     
    284284
    285285private:
     286    ExecState* m_exec;
    286287    JSObject* m_targetCallee;
    287288    bool m_hasFoundFrame;
     
    292293static JSValue retrieveCallerFunction(ExecState* exec, JSFunction* functionObj)
    293294{
    294     RetrieveCallerFunctionFunctor functor(functionObj);
     295    RetrieveCallerFunctionFunctor functor(exec, functionObj);
    295296    exec->iterate(functor);
    296297    return functor.result();
     
    329330{
    330331    JSFunction* thisObject = jsCast<JSFunction*>(object);
    331     if (thisObject->isHostOrBuiltinFunction())
     332    if (thisObject->isHostFunction())
    332333        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) {
    335378        VM& vm = exec->vm();
    336379        unsigned attributes;
     
    339382            JSObject* prototype = constructEmptyObject(exec);
    340383            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);
    342385            offset = thisObject->getDirectOffset(vm, exec->propertyNames().prototype, attributes);
    343386            ASSERT(isValidOffset(offset));
     
    391434{
    392435    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        }
    403453    }
    404454    Base::getOwnNonIndexPropertyNames(thisObject, exec, propertyNames, mode);
     
    420470        thisObject->m_allocationProfileWatchpoint.fireAll();
    421471        // 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);
    424476        return;
    425477    }
     
    466518        thisObject->m_allocationProfile.clear();
    467519        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;
    469524    }
    470525
  • trunk/Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructorInlines.h

    r163225 r167020  
    4444{
    4545    Base::finishCreation(vm, name);
    46     putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
     46    putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
    4747    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(3), DontEnum | DontDelete | ReadOnly);
    4848    putDirectWithoutTransition(vm, vm.propertyNames->BYTES_PER_ELEMENT, jsNumber(ViewClass::elementSize), DontEnum | ReadOnly | DontDelete);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r166852 r167020  
    6161#include "JSArrayBufferPrototype.h"
    6262#include "JSArrayIterator.h"
    63 #include "JSBoundFunction.h"
    6463#include "JSCInlines.h"
    6564#include "JSCallbackConstructor.h"
     
    279278    m_functionPrototype.set(vm, this, FunctionPrototype::create(vm, FunctionPrototype::createStructure(vm, this, jsNull()))); // The real prototype will be set once ObjectPrototype is created.
    280279    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()));
    282280    m_namedFunctionStructure.set(vm, this, Structure::addPropertyTransition(vm, m_functionStructure.get(), vm.propertyNames->name, DontDelete | ReadOnly | DontEnum, 0, m_functionNameOffset));
    283281    m_internalFunctionStructure.set(vm, this, InternalFunction::createStructure(vm, this, m_functionPrototype.get()));
     
    452450        putDirectWithoutTransition(vm, Identifier(exec, typedArrayConstructors[typedArrayIndex]->name(exec)), typedArrayConstructors[typedArrayIndex], DontEnum);
    453451    }
    454 
     452   
     453    JSFunction* setTypeErrorAccessor = JSFunction::create(vm, this, 2, vm.propertyNames->emptyIdentifier.string(), globalFuncSetTypeErrorAccessor);
    455454    GlobalPropertyInfo staticGlobals[] = {
    456455        GlobalPropertyInfo(vm.propertyNames->NaN, jsNaN(), DontEnum | DontDelete | ReadOnly),
     
    459458        GlobalPropertyInfo(vm.propertyNames->undefinedPrivateName, jsUndefined(), DontEnum | DontDelete | ReadOnly),
    460459        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)
    462462    };
    463463    addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r165703 r167020  
    2727
    2828#include "CallFrame.h"
     29#include "GetterSetter.h"
    2930#include "Interpreter.h"
    3031#include "JSFunction.h"
     
    806807    return JSValue::encode(jsUndefined());
    807808}
    808 
     809   
     810EncodedJSValue 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   
    809824} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.h

    r165703 r167020  
    5252EncodedJSValue JSC_HOST_CALL globalFuncProtoGetter(ExecState*);
    5353EncodedJSValue JSC_HOST_CALL globalFuncProtoSetter(ExecState*);
    54 
     54EncodedJSValue JSC_HOST_CALL globalFuncSetTypeErrorAccessor(ExecState*);
     55   
    5556static const double mantissaOverflowLowerBound = 9007199254740992.0;
    5657double parseIntOverflow(const LChar*, unsigned length, int radix);
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r166945 r167020  
    26692669    return exec->vm().throwException(exec, createTypeError(exec, message));
    26702670}
    2671 
     2671   
     2672void 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   
     2678void 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   
    26722684} // namespace JSC
  • trunk/Source/JavaScriptCore/runtime/JSObject.h

    r166760 r167020  
    933933    }
    934934
     935    JS_EXPORT_PRIVATE void putDirectPrototypeProperty(VM&, JSValue, int);
     936    void putDirectPrototypePropertyWithoutTransitions(VM&, JSValue, int);
     937   
    935938private:
    936939    friend class LLIntOffsetsExtractor;
  • trunk/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp

    r163225 r167020  
    8787{
    8888    Base::finishCreation(vm, "Promise");
    89     putDirectWithoutTransition(vm, vm.propertyNames->prototype, promisePrototype, DontEnum | DontDelete | ReadOnly);
     89    putDirectPrototypePropertyWithoutTransitions(vm, promisePrototype, DontEnum | DontDelete | ReadOnly);
    9090    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
    9191}
  • trunk/Source/JavaScriptCore/runtime/MapConstructor.cpp

    r156498 r167020  
    4141{
    4242    Base::finishCreation(vm, mapPrototype->classInfo()->className);
    43     putDirectWithoutTransition(vm, vm.propertyNames->prototype, mapPrototype, DontEnum | DontDelete | ReadOnly);
     43    putDirectPrototypePropertyWithoutTransitions(vm, mapPrototype, DontEnum | DontDelete | ReadOnly);
    4444    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum | DontDelete);
    4545}
  • trunk/Source/JavaScriptCore/runtime/MapIteratorConstructor.cpp

    r159008 r167020  
    4040{
    4141    Base::finishCreation(vm);
    42     putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
     42    putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
    4343}
    4444
  • trunk/Source/JavaScriptCore/runtime/NameConstructor.cpp

    r163844 r167020  
    4545{
    4646    Base::finishCreation(vm, prototype->classInfo()->className);
    47     putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
     47    putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
    4848    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), DontDelete | ReadOnly | DontEnum);
    4949}
  • trunk/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp

    r163960 r167020  
    4747   
    4848    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);
    5050    m_errorStructure.set(vm, this, ErrorInstance::createStructure(vm, globalObject, prototype));
    5151    ASSERT(m_errorStructure);
  • trunk/Source/JavaScriptCore/runtime/NumberConstructor.cpp

    r163844 r167020  
    6767
    6868    // Number.Prototype
    69     putDirectWithoutTransition(vm, vm.propertyNames->prototype, numberPrototype, DontEnum | DontDelete | ReadOnly);
     69    putDirectPrototypePropertyWithoutTransitions(vm, numberPrototype, DontEnum | DontDelete | ReadOnly);
    7070
    7171    // no. of arguments for constructor
  • trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

    r164764 r167020  
    8989    Base::finishCreation(vm, Identifier(&vm, "Object").string());
    9090    // ECMA 15.2.3.1
    91     putDirectWithoutTransition(vm, vm.propertyNames->prototype, objectPrototype, DontEnum | DontDelete | ReadOnly);
     91    putDirectPrototypePropertyWithoutTransitions(vm, objectPrototype, DontEnum | DontDelete | ReadOnly);
    9292    // no. of arguments for constructor
    9393    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
  • trunk/Source/JavaScriptCore/runtime/RegExpConstructor.cpp

    r163844 r167020  
    9696
    9797    // ECMA 15.10.5.1 RegExp.prototype
    98     putDirectWithoutTransition(vm, vm.propertyNames->prototype, regExpPrototype, DontEnum | DontDelete | ReadOnly);
     98    putDirectPrototypePropertyWithoutTransitions(vm, regExpPrototype, DontEnum | DontDelete | ReadOnly);
    9999
    100100    // no. of arguments for constructor
  • trunk/Source/JavaScriptCore/runtime/SetConstructor.cpp

    r163225 r167020  
    4242{
    4343    Base::finishCreation(vm, setPrototype->classInfo()->className);
    44     putDirectWithoutTransition(vm, vm.propertyNames->prototype, setPrototype, DontEnum | DontDelete | ReadOnly);
     44    putDirectPrototypePropertyWithoutTransitions(vm, setPrototype, DontEnum | DontDelete | ReadOnly);
    4545    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum | DontDelete);
    4646}
  • trunk/Source/JavaScriptCore/runtime/SetIteratorConstructor.cpp

    r159031 r167020  
    4040{
    4141    Base::finishCreation(vm);
    42     putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
     42    putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
    4343}
    4444
  • trunk/Source/JavaScriptCore/runtime/StringConstructor.cpp

    r163844 r167020  
    5757{
    5858    Base::finishCreation(vm, stringPrototype->classInfo()->className);
    59     putDirectWithoutTransition(vm, vm.propertyNames->prototype, stringPrototype, ReadOnly | DontEnum | DontDelete);
     59    putDirectPrototypePropertyWithoutTransitions(vm, stringPrototype, ReadOnly | DontEnum | DontDelete);
    6060    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
    6161}
  • trunk/Source/JavaScriptCore/runtime/WeakMapConstructor.cpp

    r156498 r167020  
    4040{
    4141    Base::finishCreation(vm, prototype->classInfo()->className);
    42     putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
     42    putDirectPrototypePropertyWithoutTransitions(vm, prototype, DontEnum | DontDelete | ReadOnly);
    4343    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum | DontDelete);
    4444}
  • trunk/Source/WebCore/ChangeLog

    r167019 r167020  
     12014-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
    1502014-04-09  Enrica Casucci  <enrica@apple.com>
    251
  • trunk/Source/WebCore/bindings/js/JSImageConstructor.cpp

    r156485 r167020  
    11/*
    22 *  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.
    44 *
    55 *  This library is free software; you can redistribute it and/or
     
    4444    Base::finishCreation(globalObject);
    4545    ASSERT(inherits(info()));
    46     putDirect(vm, vm.propertyNames->prototype, JSHTMLImageElementPrototype::self(vm, globalObject), None);
     46    putDirectPrototypeProperty(vm, JSHTMLImageElementPrototype::self(vm, globalObject), None);
    4747}
    4848
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r166864 r167020  
    45574557        push(@$outputArray, "    Base::finishCreation(vm);\n");
    45584558        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");
    45604560    } elsif ($generatingNamedConstructor) {
    45614561        push(@$outputArray, "    Base::finishCreation(globalObject);\n");
    45624562        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");
    45644564    } else {
    45654565        push(@$outputArray, "    Base::finishCreation(vm);\n");
    45664566        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");
    45684568    }
    45694569    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  
    7575    Base::finishCreation(vm);
    7676    ASSERT(inherits(info()));
    77     putDirect(vm, vm.propertyNames->prototype, JSTestActiveDOMObjectPrototype::self(vm, globalObject), DontDelete | ReadOnly);
     77    putDirectPrototypeProperty(vm, JSTestActiveDOMObjectPrototype::self(vm, globalObject), DontDelete | ReadOnly);
    7878    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
    7979}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp

    r166864 r167020  
    7171    Base::finishCreation(vm);
    7272    ASSERT(inherits(info()));
    73     putDirect(vm, vm.propertyNames->prototype, JSTestCustomNamedGetterPrototype::self(vm, globalObject), DontDelete | ReadOnly);
     73    putDirectPrototypeProperty(vm, JSTestCustomNamedGetterPrototype::self(vm, globalObject), DontDelete | ReadOnly);
    7474    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
    7575}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp

    r166864 r167020  
    9696    Base::finishCreation(vm);
    9797    ASSERT(inherits(info()));
    98     putDirect(vm, vm.propertyNames->prototype, JSTestEventConstructorPrototype::self(vm, globalObject), DontDelete | ReadOnly);
     98    putDirectPrototypeProperty(vm, JSTestEventConstructorPrototype::self(vm, globalObject), DontDelete | ReadOnly);
    9999    putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
    100100}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventTarget.cpp

    r166864 r167020  
    7777    Base::finishCreation(vm);
    7878    ASSERT(inherits(info()));
    79     putDirect(vm, vm.propertyNames->prototype, JSTestEventTargetPrototype::self(vm, globalObject), DontDelete | ReadOnly);
     79    putDirectPrototypeProperty(vm, JSTestEventTargetPrototype::self(vm, globalObject), DontDelete | ReadOnly);
    8080    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
    8181}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestException.cpp

    r166864 r167020  
    7070    Base::finishCreation(vm);
    7171    ASSERT(inherits(info()));
    72     putDirect(vm, vm.propertyNames->prototype, JSTestExceptionPrototype::self(vm, globalObject), DontDelete | ReadOnly);
     72    putDirectPrototypeProperty(vm, JSTestExceptionPrototype::self(vm, globalObject), DontDelete | ReadOnly);
    7373    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
    7474}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp

    r166864 r167020  
    5353    Base::finishCreation(vm);
    5454    ASSERT(inherits(info()));
    55     putDirect(vm, vm.propertyNames->prototype, JSTestGenerateIsReachablePrototype::self(vm, globalObject), DontDelete | ReadOnly);
     55    putDirectPrototypeProperty(vm, JSTestGenerateIsReachablePrototype::self(vm, globalObject), DontDelete | ReadOnly);
    5656    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
    5757}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp

    r166864 r167020  
    194194    Base::finishCreation(vm);
    195195    ASSERT(inherits(info()));
    196     putDirect(vm, vm.propertyNames->prototype, JSTestInterfacePrototype::self(vm, globalObject), DontDelete | ReadOnly);
     196    putDirectPrototypeProperty(vm, JSTestInterfacePrototype::self(vm, globalObject), DontDelete | ReadOnly);
    197197    putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
    198198}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp

    r166864 r167020  
    5757    Base::finishCreation(vm);
    5858    ASSERT(inherits(info()));
    59     putDirect(vm, vm.propertyNames->prototype, JSTestMediaQueryListListenerPrototype::self(vm, globalObject), DontDelete | ReadOnly);
     59    putDirectPrototypeProperty(vm, JSTestMediaQueryListListenerPrototype::self(vm, globalObject), DontDelete | ReadOnly);
    6060    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
    6161}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNamedConstructor.cpp

    r166864 r167020  
    5656    Base::finishCreation(vm);
    5757    ASSERT(inherits(info()));
    58     putDirect(vm, vm.propertyNames->prototype, JSTestNamedConstructorPrototype::self(vm, globalObject), DontDelete | ReadOnly);
     58    putDirectPrototypeProperty(vm, JSTestNamedConstructorPrototype::self(vm, globalObject), DontDelete | ReadOnly);
    5959    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
    6060}
     
    9999    Base::finishCreation(globalObject);
    100100    ASSERT(inherits(info()));
    101     putDirect(vm, vm.propertyNames->prototype, JSTestNamedConstructorPrototype::self(vm, globalObject), None);
     101    putDirectPrototypeProperty(vm, JSTestNamedConstructorPrototype::self(vm, globalObject), None);
    102102    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
    103103}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp

    r166864 r167020  
    6363    Base::finishCreation(vm);
    6464    ASSERT(inherits(info()));
    65     putDirect(vm, vm.propertyNames->prototype, JSTestNodePrototype::self(vm, globalObject), DontDelete | ReadOnly);
     65    putDirectPrototypeProperty(vm, JSTestNodePrototype::self(vm, globalObject), DontDelete | ReadOnly);
    6666    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
    6767}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r166864 r167020  
    243243    Base::finishCreation(vm);
    244244    ASSERT(inherits(info()));
    245     putDirect(vm, vm.propertyNames->prototype, JSTestObjPrototype::self(vm, globalObject), DontDelete | ReadOnly);
     245    putDirectPrototypeProperty(vm, JSTestObjPrototype::self(vm, globalObject), DontDelete | ReadOnly);
    246246    putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
    247247}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp

    r166864 r167020  
    122122    Base::finishCreation(vm);
    123123    ASSERT(inherits(info()));
    124     putDirect(vm, vm.propertyNames->prototype, JSTestOverloadedConstructorsPrototype::self(vm, globalObject), DontDelete | ReadOnly);
     124    putDirectPrototypeProperty(vm, JSTestOverloadedConstructorsPrototype::self(vm, globalObject), DontDelete | ReadOnly);
    125125    putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
    126126}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp

    r166864 r167020  
    6161    Base::finishCreation(vm);
    6262    ASSERT(inherits(info()));
    63     putDirect(vm, vm.propertyNames->prototype, JSTestSerializedScriptValueInterfacePrototype::self(vm, globalObject), DontDelete | ReadOnly);
     63    putDirectPrototypeProperty(vm, JSTestSerializedScriptValueInterfacePrototype::self(vm, globalObject), DontDelete | ReadOnly);
    6464    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
    6565}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestTypedefs.cpp

    r166864 r167020  
    9898    Base::finishCreation(vm);
    9999    ASSERT(inherits(info()));
    100     putDirect(vm, vm.propertyNames->prototype, JSTestTypedefsPrototype::self(vm, globalObject), DontDelete | ReadOnly);
     100    putDirectPrototypeProperty(vm, JSTestTypedefsPrototype::self(vm, globalObject), DontDelete | ReadOnly);
    101101    putDirect(vm, vm.propertyNames->length, jsNumber(2), ReadOnly | DontDelete | DontEnum);
    102102}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSattribute.cpp

    r166864 r167020  
    5656    Base::finishCreation(vm);
    5757    ASSERT(inherits(info()));
    58     putDirect(vm, vm.propertyNames->prototype, JSattributePrototype::self(vm, globalObject), DontDelete | ReadOnly);
     58    putDirectPrototypeProperty(vm, JSattributePrototype::self(vm, globalObject), DontDelete | ReadOnly);
    5959    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
    6060}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSreadonly.cpp

    r166864 r167020  
    5353    Base::finishCreation(vm);
    5454    ASSERT(inherits(info()));
    55     putDirect(vm, vm.propertyNames->prototype, JSreadonlyPrototype::self(vm, globalObject), DontDelete | ReadOnly);
     55    putDirectPrototypeProperty(vm, JSreadonlyPrototype::self(vm, globalObject), DontDelete | ReadOnly);
    5656    putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
    5757}
Note: See TracChangeset for help on using the changeset viewer.