Changeset 117859 in webkit


Ignore:
Timestamp:
May 21, 2012 5:37:09 PM (12 years ago)
Author:
barraclough@apple.com
Message:

Add support for private names
https://bugs.webkit.org/show_bug.cgi?id=86509

Reviewed by Oliver Hunt.

The spec isn't final, but we can start adding support to allow property maps
to contain keys that aren't identifiers.

Source/JavaScriptCore:

  • API/JSCallbackObjectFunctions.h:

(JSC::::getOwnPropertySlot):
(JSC::::put):
(JSC::::deleteProperty):
(JSC::::getStaticValue):
(JSC::::staticFunctionGetter):
(JSC::::callbackGetter):

  • Only expose public named properties over the JSC API.
  • CMakeLists.txt:
  • DerivedSources.make:
  • DerivedSources.pri:
  • GNUmakefile.list.am:
  • JavaScriptCore.gypi:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri:
    • Added new files to build system.
  • dfg/DFGOperations.cpp:

(JSC::DFG::operationPutByValInternal):

  • Added support for property access with name objects.
  • interpreter/CallFrame.h:

(JSC::ExecState::privateNamePrototypeTable):

  • Added hash table for NamePrototype
  • interpreter/Interpreter.cpp:

(JSC::Interpreter::privateExecute):

  • Added support for property access with name objects.
  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • Added support for property access with name objects.
  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::getByVal):
(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • runtime/CommonSlowPaths.h:

(JSC::CommonSlowPaths::opIn):

  • runtime/JSActivation.cpp:

(JSC::JSActivation::symbolTableGet):
(JSC::JSActivation::symbolTablePut):
(JSC::JSActivation::symbolTablePutWithAttributes):

  • Added support for property access with name objects.
  • runtime/JSGlobalData.cpp:

(JSC):
(JSC::JSGlobalData::JSGlobalData):
(JSC::JSGlobalData::~JSGlobalData):

  • runtime/JSGlobalData.h:

(JSGlobalData):

  • Added hash table for NamePrototype
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::reset):

  • runtime/JSGlobalObject.h:

(JSGlobalObject):
(JSC::JSGlobalObject::privateNameStructure):
(JSC::JSGlobalObject::symbolTableHasProperty):

  • Added new global properties.
  • runtime/JSType.h:
  • runtime/JSTypeInfo.h:

(JSC::TypeInfo::isName):

  • Added type for NameInstances, for fast isName check.
  • runtime/JSVariableObject.cpp:

(JSC::JSVariableObject::deleteProperty):
(JSC::JSVariableObject::symbolTableGet):

  • runtime/JSVariableObject.h:

(JSC::JSVariableObject::symbolTableGet):
(JSC::JSVariableObject::symbolTablePut):
(JSC::JSVariableObject::symbolTablePutWithAttributes):

  • symbol table lookup should take a PropertyName.
  • runtime/Lookup.cpp:

(JSC::setUpStaticFunctionSlot):

  • runtime/Lookup.h:

(JSC::HashTable::entry):

  • entry lookup should take a PropertyName.
  • runtime/NameConstructor.cpp: Added.

(JSC):
(JSC::NameConstructor::NameConstructor):
(JSC::NameConstructor::finishCreation):
(JSC::constructPrivateName):
(JSC::NameConstructor::getConstructData):
(JSC::NameConstructor::getCallData):

  • runtime/NameConstructor.h: Added.

(JSC):
(NameConstructor):
(JSC::NameConstructor::create):
(JSC::NameConstructor::createStructure):

  • Added constructor.
  • runtime/NameInstance.cpp: Added.

(JSC):
(JSC::NameInstance::NameInstance):
(JSC::NameInstance::destroy):

  • runtime/NameInstance.h: Added.

(JSC):
(NameInstance):
(JSC::NameInstance::createStructure):
(JSC::NameInstance::create):
(JSC::NameInstance::privateName):
(JSC::NameInstance::nameString):
(JSC::NameInstance::finishCreation):
(JSC::isName):

  • Added instance.
  • runtime/NamePrototype.cpp: Added.

(JSC):
(JSC::NamePrototype::NamePrototype):
(JSC::NamePrototype::finishCreation):
(JSC::NamePrototype::getOwnPropertySlot):
(JSC::NamePrototype::getOwnPropertyDescriptor):
(JSC::privateNameProtoFuncToString):

  • runtime/NamePrototype.h: Added.

(JSC):
(NamePrototype):
(JSC::NamePrototype::create):
(JSC::NamePrototype::createStructure):

  • Added prototype.
  • runtime/PrivateName.h: Added.

(JSC):
(PrivateName):
(JSC::PrivateName::PrivateName):
(JSC::PrivateName::uid):

  • A private name object holds a StringImpl that can be used as a unique key in a property map.
  • runtime/PropertyMapHashTable.h:

(JSC::PropertyTable::find):
(JSC::PropertyTable::findWithString):

  • Strings should only match keys in the table that are identifiers.
  • runtime/PropertyName.h:

(JSC::PropertyName::PropertyName):
(PropertyName):
(JSC::PropertyName::uid):
(JSC::PropertyName::publicName):
(JSC::PropertyName::asIndex):
(JSC::operator==):
(JSC::operator!=):

  • replaced impl() & ustring() with uid() [to get the raw impl] and publicName() [impl or null, if not an identifier].
  • runtime/Structure.cpp:

(JSC::Structure::despecifyDictionaryFunction):
(JSC::Structure::addPropertyTransitionToExistingStructure):
(JSC::Structure::addPropertyTransition):
(JSC::Structure::attributeChangeTransition):
(JSC::Structure::get):
(JSC::Structure::despecifyFunction):
(JSC::Structure::putSpecificValue):
(JSC::Structure::remove):
(JSC::Structure::getPropertyNamesFromStructure):

  • runtime/Structure.h:

(JSC::Structure::get):

  • call uid() to get a PropertyName raw impl, for use as a key.

Source/WebCore:

Test: fast/js/names.html

  • bindings/js/JSCSSStyleDeclarationCustom.cpp:

(WebCore::cssPropertyIDForJSCSSPropertyName):

  • bindings/js/JSDOMBinding.cpp:

(WebCore::findAtomicString):
(WebCore::objectToStringFunctionGetter):

  • bindings/js/JSDOMBinding.h:

(WebCore::propertyNameToString):
(WebCore::propertyNameToAtomicString):

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::nonCachingStaticFunctionGetter):

  • bindings/js/JSHistoryCustom.cpp:

(WebCore::nonCachingStaticBackFunctionGetter):
(WebCore::nonCachingStaticForwardFunctionGetter):
(WebCore::nonCachingStaticGoFunctionGetter):

  • bindings/js/JSLocationCustom.cpp:

(WebCore::nonCachingStaticReplaceFunctionGetter):
(WebCore::nonCachingStaticReloadFunctionGetter):
(WebCore::nonCachingStaticAssignFunctionGetter):

  • bridge/c/c_class.cpp:

(JSC::Bindings::CClass::methodsNamed):
(JSC::Bindings::CClass::fieldNamed):

  • bridge/c/c_instance.cpp:

(JSC::Bindings::CInstance::getMethod):

  • bridge/jni/jsc/JavaClassJSC.cpp:

(JavaClass::methodsNamed):
(JavaClass::fieldNamed):

  • bridge/jni/jsc/JavaInstanceJSC.cpp:
  • bridge/objc/objc_class.mm:

(JSC::Bindings::ObjcClass::methodsNamed):
(JSC::Bindings::ObjcClass::fieldNamed):
(JSC::Bindings::ObjcClass::fallbackObject):

  • bridge/objc/objc_instance.mm:

(ObjcInstance::setValueOfUndefinedField):
(ObjcInstance::getValueOfUndefinedField):

  • Removed PropertyName::impl(), call publicName() to get the string associated with a name.

Source/WebKit/mac:

  • Plugins/Hosted/ProxyInstance.mm:

(WebKit::ProxyClass::methodsNamed):
(WebKit::ProxyClass::fieldNamed):
(WebKit::ProxyInstance::getMethod):
(WebKit::ProxyInstance::methodsNamed):
(WebKit::ProxyInstance::fieldNamed):

  • Removed PropertyName::impl(), call publicName() to get the string associated with a name.

Source/WebKit2:

  • WebProcess/Plugins/Netscape/JSNPObject.cpp:

(WebKit::npIdentifierFromIdentifier):
(WebKit::JSNPObject::methodGetter):

  • Removed PropertyName::impl(), call publicName() to get the string associated with a name.

Source/WTF:

  • wtf/text/StringImpl.h:

(WTF::StringImpl::StringImpl):
(StringImpl):
(WTF::StringImpl::createEmptyUnique):
(WTF::StringImpl::isEmptyUnique):

  • Allow empty string impls to be allocated, which can be used as unique keys.

LayoutTests:

  • fast/js/names-expected.txt: Added.
  • fast/js/names.html: Added.
  • fast/js/script-tests/names.js: Added.
    • Added test cases.
Location:
trunk
Files:
10 added
57 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r117855 r117859  
     12012-05-15  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Add support for private names
     4        https://bugs.webkit.org/show_bug.cgi?id=86509
     5
     6        Reviewed by Oliver Hunt.
     7
     8        The spec isn't final, but we can start adding support to allow property maps
     9        to contain keys that aren't identifiers.
     10
     11        * fast/js/names-expected.txt: Added.
     12        * fast/js/names.html: Added.
     13        * fast/js/script-tests/names.js: Added.
     14            - Added test cases.
     15
    1162012-05-21  Emil A Eklund  <eae@chromium.org>
    217
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r117846 r117859  
    14371437BUGWK78657 : fast/js/constructor-length.html = FAIL
    14381438
     1439// This is JSC-only, preliminary implementation of a ES6 feature - doesn't exist in V8 (yet)
     1440BUGWK86509 SKIP WONTFIX : fast/js/names.html = FAIL
     1441
    14391442// Linux pixeltest failure: The text suggests that the radios should not
    14401443// overlap, but it's very close and quite different from the Windows version
  • trunk/Source/JavaScriptCore/API/JSCallbackObjectFunctions.h

    r116828 r117859  
    130130    RefPtr<OpaqueJSString> propertyNameRef;
    131131   
    132     for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
    133         // optional optimization to bypass getProperty in cases when we only need to know if the property exists
    134         if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) {
    135             if (!propertyNameRef)
    136                 propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    137             APICallbackShim callbackShim(exec);
    138             if (hasProperty(ctx, thisRef, propertyNameRef.get())) {
    139                 slot.setCustom(thisObject, callbackGetter);
    140                 return true;
    141             }
    142         } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
    143             if (!propertyNameRef)
    144                 propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    145             JSValueRef exception = 0;
    146             JSValueRef value;
    147             {
     132    if (StringImpl* name = propertyName.publicName()) {
     133        for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
     134            // optional optimization to bypass getProperty in cases when we only need to know if the property exists
     135            if (JSObjectHasPropertyCallback hasProperty = jsClass->hasProperty) {
     136                if (!propertyNameRef)
     137                    propertyNameRef = OpaqueJSString::create(name);
    148138                APICallbackShim callbackShim(exec);
    149                 value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception);
    150             }
    151             if (exception) {
    152                 throwError(exec, toJS(exec, exception));
    153                 slot.setValue(jsUndefined());
    154                 return true;
    155             }
    156             if (value) {
    157                 slot.setValue(toJS(exec, value));
    158                 return true;
    159             }
    160         }
    161        
    162         if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
    163             if (staticValues->contains(propertyName.impl())) {
    164                 JSValue value = thisObject->getStaticValue(exec, propertyName);
     139                if (hasProperty(ctx, thisRef, propertyNameRef.get())) {
     140                    slot.setCustom(thisObject, callbackGetter);
     141                    return true;
     142                }
     143            } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
     144                if (!propertyNameRef)
     145                    propertyNameRef = OpaqueJSString::create(name);
     146                JSValueRef exception = 0;
     147                JSValueRef value;
     148                {
     149                    APICallbackShim callbackShim(exec);
     150                    value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception);
     151                }
     152                if (exception) {
     153                    throwError(exec, toJS(exec, exception));
     154                    slot.setValue(jsUndefined());
     155                    return true;
     156                }
    165157                if (value) {
    166                     slot.setValue(value);
     158                    slot.setValue(toJS(exec, value));
    167159                    return true;
    168160                }
    169161            }
    170         }
    171        
    172         if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
    173             if (staticFunctions->contains(propertyName.impl())) {
    174                 slot.setCustom(thisObject, staticFunctionGetter);
    175                 return true;
    176             }
    177         }
    178     }
    179    
     162           
     163            if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
     164                if (staticValues->contains(name)) {
     165                    JSValue value = thisObject->getStaticValue(exec, propertyName);
     166                    if (value) {
     167                        slot.setValue(value);
     168                        return true;
     169                    }
     170                }
     171            }
     172           
     173            if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
     174                if (staticFunctions->contains(name)) {
     175                    slot.setCustom(thisObject, staticFunctionGetter);
     176                    return true;
     177                }
     178            }
     179        }
     180    }
     181
    180182    return Parent::getOwnPropertySlot(thisObject, exec, propertyName, slot);
    181183}
     
    234236    JSValueRef valueRef = toRef(exec, value);
    235237   
    236     for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
    237         if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) {
    238             if (!propertyNameRef)
    239                 propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    240             JSValueRef exception = 0;
    241             bool result;
    242             {
    243                 APICallbackShim callbackShim(exec);
    244                 result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
    245             }
    246             if (exception)
    247                 throwError(exec, toJS(exec, exception));
    248             if (result || exception)
    249                 return;
    250         }
    251        
    252         if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
    253             if (StaticValueEntry* entry = staticValues->get(propertyName.impl())) {
    254                 if (entry->attributes & kJSPropertyAttributeReadOnly)
     238    if (StringImpl* name = propertyName.publicName()) {
     239        for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
     240            if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) {
     241                if (!propertyNameRef)
     242                    propertyNameRef = OpaqueJSString::create(name);
     243                JSValueRef exception = 0;
     244                bool result;
     245                {
     246                    APICallbackShim callbackShim(exec);
     247                    result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
     248                }
     249                if (exception)
     250                    throwError(exec, toJS(exec, exception));
     251                if (result || exception)
    255252                    return;
    256                 if (JSObjectSetPropertyCallback setProperty = entry->setProperty) {
    257                     if (!propertyNameRef)
    258                         propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    259                     JSValueRef exception = 0;
    260                     bool result;
    261                     {
    262                         APICallbackShim callbackShim(exec);
    263                         result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
     253            }
     254           
     255            if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
     256                if (StaticValueEntry* entry = staticValues->get(name)) {
     257                    if (entry->attributes & kJSPropertyAttributeReadOnly)
     258                        return;
     259                    if (JSObjectSetPropertyCallback setProperty = entry->setProperty) {
     260                        if (!propertyNameRef)
     261                            propertyNameRef = OpaqueJSString::create(name);
     262                        JSValueRef exception = 0;
     263                        bool result;
     264                        {
     265                            APICallbackShim callbackShim(exec);
     266                            result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception);
     267                        }
     268                        if (exception)
     269                            throwError(exec, toJS(exec, exception));
     270                        if (result || exception)
     271                            return;
    264272                    }
    265                     if (exception)
    266                         throwError(exec, toJS(exec, exception));
    267                     if (result || exception)
     273                }
     274            }
     275           
     276            if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
     277                if (StaticFunctionEntry* entry = staticFunctions->get(name)) {
     278                    if (entry->attributes & kJSPropertyAttributeReadOnly)
    268279                        return;
    269                 }
    270             }
    271         }
    272        
    273         if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
    274             if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) {
    275                 if (entry->attributes & kJSPropertyAttributeReadOnly)
     280                    thisObject->JSCallbackObject<Parent>::putDirect(exec->globalData(), propertyName, value); // put as override property
    276281                    return;
    277                 thisObject->JSCallbackObject<Parent>::putDirect(exec->globalData(), propertyName, value); // put as override property
    278                 return;
    279             }
    280         }
    281     }
    282    
     282                }
     283            }
     284        }
     285    }
     286
    283287    return Parent::put(thisObject, exec, propertyName, value, slot);
    284288}
     
    292296    RefPtr<OpaqueJSString> propertyNameRef;
    293297   
    294     for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
    295         if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) {
    296             if (!propertyNameRef)
    297                 propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    298             JSValueRef exception = 0;
    299             bool result;
    300             {
    301                 APICallbackShim callbackShim(exec);
    302                 result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception);
    303             }
    304             if (exception)
    305                 throwError(exec, toJS(exec, exception));
    306             if (result || exception)
    307                 return true;
    308         }
    309        
    310         if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
    311             if (StaticValueEntry* entry = staticValues->get(propertyName.impl())) {
    312                 if (entry->attributes & kJSPropertyAttributeDontDelete)
    313                     return false;
    314                 return true;
    315             }
    316         }
    317        
    318         if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
    319             if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) {
    320                 if (entry->attributes & kJSPropertyAttributeDontDelete)
    321                     return false;
    322                 return true;
    323             }
    324         }
    325     }
    326    
     298    if (StringImpl* name = propertyName.publicName()) {
     299        for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
     300            if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) {
     301                if (!propertyNameRef)
     302                    propertyNameRef = OpaqueJSString::create(name);
     303                JSValueRef exception = 0;
     304                bool result;
     305                {
     306                    APICallbackShim callbackShim(exec);
     307                    result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception);
     308                }
     309                if (exception)
     310                    throwError(exec, toJS(exec, exception));
     311                if (result || exception)
     312                    return true;
     313            }
     314           
     315            if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
     316                if (StaticValueEntry* entry = staticValues->get(name)) {
     317                    if (entry->attributes & kJSPropertyAttributeDontDelete)
     318                        return false;
     319                    return true;
     320                }
     321            }
     322           
     323            if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
     324                if (StaticFunctionEntry* entry = staticFunctions->get(name)) {
     325                    if (entry->attributes & kJSPropertyAttributeDontDelete)
     326                        return false;
     327                    return true;
     328                }
     329            }
     330        }
     331    }
     332
    327333    return Parent::deleteProperty(thisObject, exec, propertyName);
    328334}
     
    510516    RefPtr<OpaqueJSString> propertyNameRef;
    511517   
    512     for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass)
    513         if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec))
    514             if (StaticValueEntry* entry = staticValues->get(propertyName.impl()))
    515                 if (JSObjectGetPropertyCallback getProperty = entry->getProperty) {
    516                     if (!propertyNameRef)
    517                         propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    518                     JSValueRef exception = 0;
    519                     JSValueRef value;
    520                     {
    521                         APICallbackShim callbackShim(exec);
    522                         value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
     518    if (StringImpl* name = propertyName.publicName()) {
     519        for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
     520            if (OpaqueJSClassStaticValuesTable* staticValues = jsClass->staticValues(exec)) {
     521                if (StaticValueEntry* entry = staticValues->get(name)) {
     522                    if (JSObjectGetPropertyCallback getProperty = entry->getProperty) {
     523                        if (!propertyNameRef)
     524                            propertyNameRef = OpaqueJSString::create(name);
     525                        JSValueRef exception = 0;
     526                        JSValueRef value;
     527                        {
     528                            APICallbackShim callbackShim(exec);
     529                            value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
     530                        }
     531                        if (exception) {
     532                            throwError(exec, toJS(exec, exception));
     533                            return jsUndefined();
     534                        }
     535                        if (value)
     536                            return toJS(exec, value);
    523537                    }
    524                     if (exception) {
    525                         throwError(exec, toJS(exec, exception));
    526                         return jsUndefined();
    527                     }
    528                     if (value)
    529                         return toJS(exec, value);
    530                 }
     538                }
     539            }
     540        }
     541    }
    531542
    532543    return JSValue();
     
    543554        return slot2.getValue(exec, propertyName);
    544555   
    545     for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) {
    546         if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
    547             if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) {
    548                 if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
    549                    
    550                     JSObject* o = JSCallbackFunction::create(exec, thisObj->globalObject(), callAsFunction, propertyName.ustring());
    551                     thisObj->putDirect(exec->globalData(), propertyName, o, entry->attributes);
    552                     return o;
    553                 }
    554             }
    555         }
    556     }
    557    
     556    if (StringImpl* name = propertyName.publicName()) {
     557        for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) {
     558            if (OpaqueJSClassStaticFunctionsTable* staticFunctions = jsClass->staticFunctions(exec)) {
     559                if (StaticFunctionEntry* entry = staticFunctions->get(name)) {
     560                    if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
     561                       
     562                        JSObject* o = JSCallbackFunction::create(exec, thisObj->globalObject(), callAsFunction, name);
     563                        thisObj->putDirect(exec->globalData(), propertyName, o, entry->attributes);
     564                        return o;
     565                    }
     566                }
     567            }
     568        }
     569    }
     570
    558571    return throwError(exec, createReferenceError(exec, "Static function property defined with NULL callAsFunction callback."));
    559572}
     
    567580    RefPtr<OpaqueJSString> propertyNameRef;
    568581   
    569     for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass)
    570         if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
    571             if (!propertyNameRef)
    572                 propertyNameRef = OpaqueJSString::create(propertyName.ustring());
    573             JSValueRef exception = 0;
    574             JSValueRef value;
    575             {
    576                 APICallbackShim callbackShim(exec);
    577                 value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
    578             }
    579             if (exception) {
    580                 throwError(exec, toJS(exec, exception));
    581                 return jsUndefined();
    582             }
    583             if (value)
    584                 return toJS(exec, value);
    585         }
    586            
     582    if (StringImpl* name = propertyName.publicName()) {
     583        for (JSClassRef jsClass = thisObj->classRef(); jsClass; jsClass = jsClass->parentClass) {
     584            if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) {
     585                if (!propertyNameRef)
     586                    propertyNameRef = OpaqueJSString::create(name);
     587                JSValueRef exception = 0;
     588                JSValueRef value;
     589                {
     590                    APICallbackShim callbackShim(exec);
     591                    value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception);
     592                }
     593                if (exception) {
     594                    throwError(exec, toJS(exec, exception));
     595                    return jsUndefined();
     596                }
     597                if (value)
     598                    return toJS(exec, value);
     599            }
     600        }
     601    }
     602
    587603    return throwError(exec, createReferenceError(exec, "hasProperty callback returned true for a property that doesn't exist."));
    588604}
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r117646 r117859  
    193193    runtime/Lookup.cpp
    194194    runtime/MathObject.cpp
     195    runtime/NameConstructor.cpp
     196    runtime/NameConstructor.h
     197    runtime/NameInstance.cpp
     198    runtime/NameInstance.h
     199    runtime/NamePrototype.cpp
     200    runtime/NamePrototype.h
    195201    runtime/NativeErrorConstructor.cpp
    196202    runtime/NativeErrorPrototype.cpp
     
    244250    runtime/JSONObject.cpp
    245251    runtime/MathObject.cpp
     252    runtime/NamePrototype.cpp
    246253    runtime/NumberConstructor.cpp
    247254    runtime/NumberPrototype.cpp
  • trunk/Source/JavaScriptCore/ChangeLog

    r117823 r117859  
     12012-05-15  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Add support for private names
     4        https://bugs.webkit.org/show_bug.cgi?id=86509
     5
     6        Reviewed by Oliver Hunt.
     7
     8        The spec isn't final, but we can start adding support to allow property maps
     9        to contain keys that aren't identifiers.
     10
     11        * API/JSCallbackObjectFunctions.h:
     12        (JSC::::getOwnPropertySlot):
     13        (JSC::::put):
     14        (JSC::::deleteProperty):
     15        (JSC::::getStaticValue):
     16        (JSC::::staticFunctionGetter):
     17        (JSC::::callbackGetter):
     18            - Only expose public named properties over the JSC API.
     19        * CMakeLists.txt:
     20        * DerivedSources.make:
     21        * DerivedSources.pri:
     22        * GNUmakefile.list.am:
     23        * JavaScriptCore.gypi:
     24        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
     25        * JavaScriptCore.xcodeproj/project.pbxproj:
     26        * Target.pri:
     27            - Added new files to build system.
     28        * dfg/DFGOperations.cpp:
     29        (JSC::DFG::operationPutByValInternal):
     30            - Added support for property access with name objects.
     31        * interpreter/CallFrame.h:
     32        (JSC::ExecState::privateNamePrototypeTable):
     33            - Added hash table for NamePrototype
     34        * interpreter/Interpreter.cpp:
     35        (JSC::Interpreter::privateExecute):
     36            - Added support for property access with name objects.
     37        * jit/JITStubs.cpp:
     38        (JSC::DEFINE_STUB_FUNCTION):
     39            - Added support for property access with name objects.
     40        * llint/LLIntSlowPaths.cpp:
     41        (JSC::LLInt::getByVal):
     42        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
     43        * runtime/CommonSlowPaths.h:
     44        (JSC::CommonSlowPaths::opIn):
     45        * runtime/JSActivation.cpp:
     46        (JSC::JSActivation::symbolTableGet):
     47        (JSC::JSActivation::symbolTablePut):
     48        (JSC::JSActivation::symbolTablePutWithAttributes):
     49            - Added support for property access with name objects.
     50        * runtime/JSGlobalData.cpp:
     51        (JSC):
     52        (JSC::JSGlobalData::JSGlobalData):
     53        (JSC::JSGlobalData::~JSGlobalData):
     54        * runtime/JSGlobalData.h:
     55        (JSGlobalData):
     56            - Added hash table for NamePrototype
     57        * runtime/JSGlobalObject.cpp:
     58        (JSC::JSGlobalObject::reset):
     59        * runtime/JSGlobalObject.h:
     60        (JSGlobalObject):
     61        (JSC::JSGlobalObject::privateNameStructure):
     62        (JSC::JSGlobalObject::symbolTableHasProperty):
     63            - Added new global properties.
     64        * runtime/JSType.h:
     65        * runtime/JSTypeInfo.h:
     66        (JSC::TypeInfo::isName):
     67            - Added type for NameInstances, for fast isName check.
     68        * runtime/JSVariableObject.cpp:
     69        (JSC::JSVariableObject::deleteProperty):
     70        (JSC::JSVariableObject::symbolTableGet):
     71        * runtime/JSVariableObject.h:
     72        (JSC::JSVariableObject::symbolTableGet):
     73        (JSC::JSVariableObject::symbolTablePut):
     74        (JSC::JSVariableObject::symbolTablePutWithAttributes):
     75            - symbol table lookup should take a PropertyName.
     76        * runtime/Lookup.cpp:
     77        (JSC::setUpStaticFunctionSlot):
     78        * runtime/Lookup.h:
     79        (JSC::HashTable::entry):
     80            - entry lookup should take a PropertyName.
     81        * runtime/NameConstructor.cpp: Added.
     82        (JSC):
     83        (JSC::NameConstructor::NameConstructor):
     84        (JSC::NameConstructor::finishCreation):
     85        (JSC::constructPrivateName):
     86        (JSC::NameConstructor::getConstructData):
     87        (JSC::NameConstructor::getCallData):
     88        * runtime/NameConstructor.h: Added.
     89        (JSC):
     90        (NameConstructor):
     91        (JSC::NameConstructor::create):
     92        (JSC::NameConstructor::createStructure):
     93            - Added constructor.
     94        * runtime/NameInstance.cpp: Added.
     95        (JSC):
     96        (JSC::NameInstance::NameInstance):
     97        (JSC::NameInstance::destroy):
     98        * runtime/NameInstance.h: Added.
     99        (JSC):
     100        (NameInstance):
     101        (JSC::NameInstance::createStructure):
     102        (JSC::NameInstance::create):
     103        (JSC::NameInstance::privateName):
     104        (JSC::NameInstance::nameString):
     105        (JSC::NameInstance::finishCreation):
     106        (JSC::isName):
     107            - Added instance.
     108        * runtime/NamePrototype.cpp: Added.
     109        (JSC):
     110        (JSC::NamePrototype::NamePrototype):
     111        (JSC::NamePrototype::finishCreation):
     112        (JSC::NamePrototype::getOwnPropertySlot):
     113        (JSC::NamePrototype::getOwnPropertyDescriptor):
     114        (JSC::privateNameProtoFuncToString):
     115        * runtime/NamePrototype.h: Added.
     116        (JSC):
     117        (NamePrototype):
     118        (JSC::NamePrototype::create):
     119        (JSC::NamePrototype::createStructure):
     120            - Added prototype.
     121        * runtime/PrivateName.h: Added.
     122        (JSC):
     123        (PrivateName):
     124        (JSC::PrivateName::PrivateName):
     125        (JSC::PrivateName::uid):
     126            - A private name object holds a StringImpl that can be used as a unique key in a property map.
     127        * runtime/PropertyMapHashTable.h:
     128        (JSC::PropertyTable::find):
     129        (JSC::PropertyTable::findWithString):
     130            - Strings should only match keys in the table that are identifiers.
     131        * runtime/PropertyName.h:
     132        (JSC::PropertyName::PropertyName):
     133        (PropertyName):
     134        (JSC::PropertyName::uid):
     135        (JSC::PropertyName::publicName):
     136        (JSC::PropertyName::asIndex):
     137        (JSC::operator==):
     138        (JSC::operator!=):
     139            - replaced impl() & ustring() with uid() [to get the raw impl] and publicName() [impl or null, if not an identifier].
     140        * runtime/Structure.cpp:
     141        (JSC::Structure::despecifyDictionaryFunction):
     142        (JSC::Structure::addPropertyTransitionToExistingStructure):
     143        (JSC::Structure::addPropertyTransition):
     144        (JSC::Structure::attributeChangeTransition):
     145        (JSC::Structure::get):
     146        (JSC::Structure::despecifyFunction):
     147        (JSC::Structure::putSpecificValue):
     148        (JSC::Structure::remove):
     149        (JSC::Structure::getPropertyNamesFromStructure):
     150        * runtime/Structure.h:
     151        (JSC::Structure::get):
     152            - call uid() to get a PropertyName raw impl, for use as a key.
     153
    11542012-04-30  Filip Pizlo  <fpizlo@apple.com>
    2155
  • trunk/Source/JavaScriptCore/DerivedSources.make

    r106606 r117859  
    4848    Lexer.lut.h \
    4949    MathObject.lut.h \
     50    NamePrototype.lut.h \
    5051    NumberConstructor.lut.h \
    5152    NumberPrototype.lut.h \
  • trunk/Source/JavaScriptCore/DerivedSources.pri

    r99274 r117859  
    1717    runtime/JSONObject.cpp \
    1818    runtime/MathObject.cpp \
     19    runtime/NamePrototype.cpp \
    1920    runtime/NumberConstructor.cpp \
    2021    runtime/NumberPrototype.cpp \
  • trunk/Source/JavaScriptCore/GNUmakefile.list.am

    r117783 r117859  
    2121        DerivedSources/JavaScriptCore/JSONObject.lut.h \
    2222        DerivedSources/JavaScriptCore/MathObject.lut.h \
     23    DerivedSources/JavaScriptCore/NamePrototype.lut.h \
    2324        DerivedSources/JavaScriptCore/NumberConstructor.lut.h \
    2425        DerivedSources/JavaScriptCore/NumberPrototype.lut.h \
     
    508509        Source/JavaScriptCore/runtime/MathObject.h \
    509510        Source/JavaScriptCore/runtime/MemoryStatistics.h \
     511        Source/JavaScriptCore/runtime/NameConstructor.cpp \
     512        Source/JavaScriptCore/runtime/NameConstructor.h \
     513        Source/JavaScriptCore/runtime/NameInstance.cpp \
     514        Source/JavaScriptCore/runtime/NameInstance.h \
     515        Source/JavaScriptCore/runtime/NamePrototype.cpp \
     516        Source/JavaScriptCore/runtime/NamePrototype.h \
    510517        Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp \
    511518        Source/JavaScriptCore/runtime/NativeErrorConstructor.h \
  • trunk/Source/JavaScriptCore/JavaScriptCore.gypi

    r115590 r117859  
    273273            'runtime/MathObject.h',
    274274            'runtime/MemoryStatistics.h',
     275            'runtime/NameConstructor.h',
     276            'runtime/NameInstance.h',
     277            'runtime/NamePrototype.h',
    275278            'runtime/NativeErrorConstructor.h',
    276279            'runtime/NativeErrorPrototype.h',
     
    498501            'runtime/MathObject.cpp',
    499502            'runtime/MemoryStatistics.cpp',
     503            'runtime/NameConstructor.cpp',
     504            'runtime/NameInstance.cpp',
     505            'runtime/NamePrototype.cpp',
    500506            'runtime/NativeErrorConstructor.cpp',
    501507            'runtime/NativeErrorPrototype.cpp',
     
    550556            '<(PRODUCT_DIR)/DerivedSources/JavaScriptCore/JSONObject.lut.h',
    551557            '<(PRODUCT_DIR)/DerivedSources/JavaScriptCore/MathObject.lut.h',
     558            '<(PRODUCT_DIR)/DerivedSources/JavaScriptCore/NamePrototype.lut.h',
    552559            '<(PRODUCT_DIR)/DerivedSources/JavaScriptCore/NumberConstructor.lut.h',
    553560            '<(PRODUCT_DIR)/DerivedSources/JavaScriptCore/NumberPrototype.lut.h',
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj

    r115590 r117859  
    959959                        </File>
    960960                        <File
     961                                RelativePath="..\..\runtime\NameConstructor.cpp"
     962                                >
     963                        </File>
     964                        <File
     965                                RelativePath="..\..\runtime\NameConstructor.h"
     966                                >
     967                        </File>
     968                        <File
     969                                RelativePath="..\..\runtime\NameInstance.cpp"
     970                                >
     971                        </File>
     972                        <File
     973                                RelativePath="..\..\runtime\NameInstance.h"
     974                                >
     975                        </File>
     976                        <File
     977                                RelativePath="..\..\runtime\NamePrototype.cpp"
     978                                >
     979                        </File>
     980                        <File
     981                                RelativePath="..\..\runtime\NamePrototype.h"
     982                                >
     983                        </File>
     984                        <File
    961985                                RelativePath="..\..\runtime\NativeErrorConstructor.cpp"
    962986                                >
     
    20562080                        <File
    20572081                                RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\MathObject.lut.h"
     2082                                >
     2083                        </File>
     2084                        <File
     2085                                RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\NamePrototype.lut.h"
    20582086                                >
    20592087                        </File>
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r117646 r117859  
    390390                86880F1F14328BB900B08D42 /* DFGSpeculativeJIT32_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86880F1B14328BB900B08D42 /* DFGSpeculativeJIT32_64.cpp */; };
    391391                86880F4D14353B2100B08D42 /* DFGSpeculativeJIT64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86880F4C14353B2100B08D42 /* DFGSpeculativeJIT64.cpp */; };
     392                868916B0155F286300CB2B9A /* PrivateName.h in Headers */ = {isa = PBXBuildFile; fileRef = 868916A9155F285400CB2B9A /* PrivateName.h */; settings = {ATTRIBUTES = (Private, ); }; };
    392393                869D04AF1193B54D00803475 /* CachedTranscendentalFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 869D04AE1193B54D00803475 /* CachedTranscendentalFunction.h */; settings = {ATTRIBUTES = (Private, ); }; };
    393394                869EBCB70E8C6D4A008722CC /* ResultType.h in Headers */ = {isa = PBXBuildFile; fileRef = 869EBCB60E8C6D4A008722CC /* ResultType.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    423424                86E116B10FE75AC800B512BC /* CodeLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E116B00FE75AC800B512BC /* CodeLocation.h */; };
    424425                86E85539111B9968001AF51E /* JSStringBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 86E85538111B9968001AF51E /* JSStringBuilder.h */; };
     426                86EBF2FF1560F06A008E9222 /* NameConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86EBF2F91560F036008E9222 /* NameConstructor.cpp */; };
     427                86EBF3001560F06A008E9222 /* NameConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 86EBF2FA1560F036008E9222 /* NameConstructor.h */; };
     428                86EBF3011560F06A008E9222 /* NameInstance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86EBF2FB1560F036008E9222 /* NameInstance.cpp */; };
     429                86EBF3021560F06A008E9222 /* NameInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = 86EBF2FC1560F036008E9222 /* NameInstance.h */; };
     430                86EBF3031560F06A008E9222 /* NamePrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86EBF2FD1560F036008E9222 /* NamePrototype.cpp */; };
     431                86EBF3041560F06A008E9222 /* NamePrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 86EBF2FE1560F036008E9222 /* NamePrototype.h */; };
    425432                86EC9DC41328DF82002B2AD7 /* DFGByteCodeParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86EC9DB41328DF82002B2AD7 /* DFGByteCodeParser.cpp */; };
    426433                86EC9DC51328DF82002B2AD7 /* DFGByteCodeParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 86EC9DB51328DF82002B2AD7 /* DFGByteCodeParser.h */; };
     
    10571064                86880F1B14328BB900B08D42 /* DFGSpeculativeJIT32_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGSpeculativeJIT32_64.cpp; path = dfg/DFGSpeculativeJIT32_64.cpp; sourceTree = "<group>"; };
    10581065                86880F4C14353B2100B08D42 /* DFGSpeculativeJIT64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGSpeculativeJIT64.cpp; path = dfg/DFGSpeculativeJIT64.cpp; sourceTree = "<group>"; };
     1066                868916A9155F285400CB2B9A /* PrivateName.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrivateName.h; sourceTree = "<group>"; };
    10591067                869D04AE1193B54D00803475 /* CachedTranscendentalFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedTranscendentalFunction.h; sourceTree = "<group>"; };
    10601068                869EBCB60E8C6D4A008722CC /* ResultType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResultType.h; sourceTree = "<group>"; };
     
    10961104                86E116B00FE75AC800B512BC /* CodeLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeLocation.h; sourceTree = "<group>"; };
    10971105                86E85538111B9968001AF51E /* JSStringBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStringBuilder.h; sourceTree = "<group>"; };
     1106                86EBF2F91560F036008E9222 /* NameConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NameConstructor.cpp; sourceTree = "<group>"; };
     1107                86EBF2FA1560F036008E9222 /* NameConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NameConstructor.h; sourceTree = "<group>"; };
     1108                86EBF2FB1560F036008E9222 /* NameInstance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NameInstance.cpp; sourceTree = "<group>"; };
     1109                86EBF2FC1560F036008E9222 /* NameInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NameInstance.h; sourceTree = "<group>"; };
     1110                86EBF2FD1560F036008E9222 /* NamePrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NamePrototype.cpp; sourceTree = "<group>"; };
     1111                86EBF2FE1560F036008E9222 /* NamePrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NamePrototype.h; sourceTree = "<group>"; };
    10981112                86EC9DB41328DF82002B2AD7 /* DFGByteCodeParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGByteCodeParser.cpp; path = dfg/DFGByteCodeParser.cpp; sourceTree = "<group>"; };
    10991113                86EC9DB51328DF82002B2AD7 /* DFGByteCodeParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGByteCodeParser.h; path = dfg/DFGByteCodeParser.h; sourceTree = "<group>"; };
     
    18111825                        isa = PBXGroup;
    18121826                        children = (
    1813                                 0F21C27914BE727300ADC64B /* CodeSpecializationKind.h */,
    1814                                 0F21C27A14BE727300ADC64B /* ExecutionHarness.h */,
    1815                                 0F15F15D14B7A73A005DE37D /* CommonSlowPaths.h */,
    18161827                                BCF605110E203EF800B9A64D /* ArgList.cpp */,
    18171828                                BCF605120E203EF800B9A64D /* ArgList.h */,
     
    18341845                                145C507F0D9DF63B0088F6B9 /* CallData.h */,
    18351846                                BC6AAAE40E1F426500AD87D8 /* ClassInfo.h */,
     1847                                0F21C27914BE727300ADC64B /* CodeSpecializationKind.h */,
    18361848                                65EA73620BAE35D1001BB560 /* CommonIdentifiers.cpp */,
    18371849                                65EA73630BAE35D1001BB560 /* CommonIdentifiers.h */,
     1850                                0F15F15D14B7A73A005DE37D /* CommonSlowPaths.h */,
    18381851                                969A09220ED1E09C00F1F681 /* Completion.cpp */,
    18391852                                F5BB2BC5030F772101FCFE1D /* Completion.h */,
     
    18611874                                86CA032D1038E8440028A609 /* Executable.cpp */,
    18621875                                86CAFEE21035DDE60028A609 /* Executable.h */,
     1876                                0F21C27A14BE727300ADC64B /* ExecutionHarness.h */,
    18631877                                BC2680C00E16D4E900A06E92 /* FunctionConstructor.cpp */,
    18641878                                BC2680C10E16D4E900A06E92 /* FunctionConstructor.h */,
     
    19321946                                90213E3B123A40C200D422F3 /* MemoryStatistics.cpp */,
    19331947                                90213E3C123A40C200D422F3 /* MemoryStatistics.h */,
     1948                                86EBF2F91560F036008E9222 /* NameConstructor.cpp */,
     1949                                86EBF2FA1560F036008E9222 /* NameConstructor.h */,
     1950                                86EBF2FB1560F036008E9222 /* NameInstance.cpp */,
     1951                                86EBF2FC1560F036008E9222 /* NameInstance.h */,
     1952                                86EBF2FD1560F036008E9222 /* NamePrototype.cpp */,
     1953                                86EBF2FE1560F036008E9222 /* NamePrototype.h */,
    19341954                                BC02E9080E1839DB000F9297 /* NativeErrorConstructor.cpp */,
    19351955                                BC02E9090E1839DB000F9297 /* NativeErrorConstructor.h */,
     
    19511971                                0FE228EA1436AB2300196C48 /* Options.cpp */,
    19521972                                0FE228EB1436AB2300196C48 /* Options.h */,
     1973                                868916A9155F285400CB2B9A /* PrivateName.h */,
    19531974                                A7FB60A3103F7DC20017A286 /* PropertyDescriptor.cpp */,
    19541975                                A7FB604B103F5EAB0017A286 /* PropertyDescriptor.h */,
     
    26092630                                14816E1C154CC56C00B8054C /* BlockAllocator.h in Headers */,
    26102631                                86158AB3155C8B4000B45C9C /* PropertyName.h in Headers */,
     2632                                868916B0155F286300CB2B9A /* PrivateName.h in Headers */,
     2633                                86EBF3001560F06A008E9222 /* NameConstructor.h in Headers */,
     2634                                86EBF3021560F06A008E9222 /* NameInstance.h in Headers */,
     2635                                86EBF3041560F06A008E9222 /* NamePrototype.h in Headers */,
    26112636                                0F1E3A67153A21E2000F9456 /* DFGSilentRegisterSavePlan.h in Headers */,
    26122637                                0F3B3A281544C997003ED0FF /* DFGCFGSimplificationPhase.h in Headers */,
     
    31753200                                863C6D9C1521111A00585E4E /* YarrCanonicalizeUCS2.cpp in Sources */,
    31763201                                14816E1B154CC56C00B8054C /* BlockAllocator.cpp in Sources */,
     3202                                86EBF2FF1560F06A008E9222 /* NameConstructor.cpp in Sources */,
     3203                                86EBF3011560F06A008E9222 /* NameInstance.cpp in Sources */,
     3204                                86EBF3031560F06A008E9222 /* NamePrototype.cpp in Sources */,
    31773205                                0F3B3A1A153E68F2003ED0FF /* DFGConstantFoldingPhase.cpp in Sources */,
    31783206                                0F3B3A271544C995003ED0FF /* DFGCFGSimplificationPhase.cpp in Sources */,
  • trunk/Source/JavaScriptCore/Target.pri

    r117646 r117859  
    201201    runtime/Lookup.cpp \
    202202    runtime/MathObject.cpp \
     203    runtime/NameConstructor.cpp \
     204    runtime/NameInstance.cpp \
     205    runtime/NamePrototype.cpp \
    203206    runtime/NativeErrorConstructor.cpp \
    204207    runtime/NativeErrorPrototype.cpp \
  • trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp

    r117729 r117859  
    3737#include "JSGlobalData.h"
    3838#include "JSStaticScopeObject.h"
     39#include "NameInstance.h"
    3940#include "Operations.h"
    4041
     
    201202    }
    202203
     204    if (isName(property)) {
     205        PutPropertySlot slot(strict);
     206        baseValue.put(exec, jsCast<NameInstance*>(property.asCell())->privateName(), value, slot);
     207        return;
     208    }
    203209
    204210    // Don't put to an object if toString throws an exception.
     
    308314    }
    309315
     316    if (isName(property))
     317        return JSValue::encode(baseValue.get(exec, jsCast<NameInstance*>(property.asCell())->privateName()));
     318
    310319    Identifier ident(exec, property.toString(exec)->value(exec));
    311320    return JSValue::encode(baseValue.get(exec, ident));
     
    330339            return JSValue::encode(result);
    331340    }
     341
     342    if (isName(property))
     343        return JSValue::encode(JSValue(base).get(exec, jsCast<NameInstance*>(property.asCell())->privateName()));
    332344
    333345    Identifier ident(exec, property.toString(exec)->value(exec));
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.h

    r115861 r117859  
    9191        static const HashTable* objectConstructorTable(CallFrame* callFrame) { return callFrame->globalData().objectConstructorTable; }
    9292        static const HashTable* objectPrototypeTable(CallFrame* callFrame) { return callFrame->globalData().objectPrototypeTable; }
     93        static const HashTable* privateNamePrototypeTable(CallFrame* callFrame) { return callFrame->globalData().privateNamePrototypeTable; }
    9394        static const HashTable* regExpTable(CallFrame* callFrame) { return callFrame->globalData().regExpTable; }
    9495        static const HashTable* regExpConstructorTable(CallFrame* callFrame) { return callFrame->globalData().regExpConstructorTable; }
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r117646 r117859  
    5151#include "JSStaticScopeObject.h"
    5252#include "JSString.h"
     53#include "NameInstance.h"
    5354#include "ObjectPrototype.h"
    5455#include "Operations.h"
     
    27962797        if (propName.getUInt32(i))
    27972798            callFrame->uncheckedR(dst) = jsBoolean(baseObj->hasProperty(callFrame, i));
     2799        else if (isName(propName))
     2800            callFrame->uncheckedR(dst) = jsBoolean(baseObj->hasProperty(callFrame, jsCast<NameInstance*>(propName.asCell())->privateName()));
    27982801        else {
    27992802            Identifier property(callFrame, propName.toString(callFrame)->value(callFrame));
     
    37763779            else
    37773780                result = baseValue.get(callFrame, i);
    3778         } else {
     3781        } else if (isName(subscript))
     3782            result = baseValue.get(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName());
     3783        else {
    37793784            Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
    37803785            result = baseValue.get(callFrame, property);
     
    38143819            } else
    38153820                baseValue.putByIndex(callFrame, i, callFrame->r(value).jsValue(), codeBlock->isStrictMode());
     3821        } else if (isName(subscript)) {
     3822            PutPropertySlot slot(codeBlock->isStrictMode());
     3823            baseValue.put(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName(), callFrame->r(value).jsValue(), slot);
    38163824        } else {
    38173825            Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
     
    38453853        if (subscript.getUInt32(i))
    38463854            result = baseObj->methodTable()->deletePropertyByIndex(baseObj, callFrame, i);
     3855        else if (isName(subscript))
     3856            result = baseObj->methodTable()->deleteProperty(baseObj, callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName());
    38473857        else {
    38483858            CHECK_FOR_EXCEPTION();
  • trunk/Source/JavaScriptCore/jit/JITStubs.cpp

    r117646 r117859  
    5555#include "JSStaticScopeObject.h"
    5656#include "JSString.h"
     57#include "NameInstance.h"
    5758#include "ObjectPrototype.h"
    5859#include "Operations.h"
     
    24482449        return JSValue::encode(result);
    24492450    }
    2450    
     2451
     2452    if (isName(subscript)) {
     2453        JSValue result = baseValue.get(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName());
     2454        CHECK_FOR_EXCEPTION();
     2455        return JSValue::encode(result);
     2456    }
     2457
    24512458    Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
    24522459    JSValue result = baseValue.get(callFrame, property);
     
    24752482                ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_get_by_val));
    24762483        }
    2477     } else {
     2484    } else if (isName(subscript))
     2485        result = baseValue.get(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName());
     2486    else {
    24782487        Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
    24792488        result = baseValue.get(callFrame, property);
     
    25212530        } else
    25222531            baseValue.putByIndex(callFrame, i, value, callFrame->codeBlock()->isStrictMode());
     2532    } else if (isName(subscript)) {
     2533        PutPropertySlot slot(callFrame->codeBlock()->isStrictMode());
     2534        baseValue.put(callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
    25232535    } else {
    25242536        Identifier property(callFrame, subscript.toString(callFrame)->value(callFrame));
     
    32423254        return JSValue::encode(jsBoolean(baseObj->hasProperty(callFrame, i)));
    32433255
     3256    if (isName(propName))
     3257        return JSValue::encode(jsBoolean(baseObj->hasProperty(callFrame, jsCast<NameInstance*>(propName.asCell())->privateName())));
     3258
    32443259    Identifier property(callFrame, propName.toString(callFrame)->value(callFrame));
    32453260    CHECK_FOR_EXCEPTION();
     
    33543369    if (subscript.getUInt32(i))
    33553370        result = baseObj->methodTable()->deletePropertyByIndex(baseObj, callFrame, i);
     3371    else if (isName(subscript))
     3372        result = baseObj->methodTable()->deleteProperty(baseObj, callFrame, jsCast<NameInstance*>(subscript.asCell())->privateName());
    33563373    else {
    33573374        CHECK_FOR_EXCEPTION();
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r117823 r117859  
    953953        return baseValue.get(exec, i);
    954954    }
     955
     956    if (isName(subscript))
     957        return baseValue.get(exec, jsCast<NameInstance*>(subscript.asCell())->privateName());
    955958   
    956959    Identifier property(exec, subscript.toString(exec)->value(exec));
     
    10051008        LLINT_END();
    10061009    }
    1007    
     1010
     1011    if (isName(subscript)) {
     1012        PutPropertySlot slot(exec->codeBlock()->isStrictMode());
     1013        baseValue.put(exec, jsCast<NameInstance*>(subscript.asCell())->privateName(), value, slot);
     1014        LLINT_END();
     1015    }
     1016
    10081017    Identifier property(exec, subscript.toString(exec)->value(exec));
    10091018    LLINT_CHECK_EXCEPTION();
     
    10261035    if (subscript.getUInt32(i))
    10271036        couldDelete = baseObject->methodTable()->deletePropertyByIndex(baseObject, exec, i);
     1037    else if (isName(subscript))
     1038        couldDelete = baseObject->methodTable()->deleteProperty(baseObject, exec, jsCast<NameInstance*>(subscript.asCell())->privateName());
    10281039    else {
    10291040        LLINT_CHECK_EXCEPTION();
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.h

    r115861 r117859  
    3131#include "ExceptionHelpers.h"
    3232#include "JSArray.h"
     33#include "NameInstance.h"
    3334
    3435namespace JSC {
     
    109110    if (propName.getUInt32(i))
    110111        return baseObj->hasProperty(exec, i);
     112
     113    if (isName(propName))
     114        return baseObj->hasProperty(exec, jsCast<NameInstance*>(propName.asCell())->privateName());
    111115
    112116    Identifier property(exec, propName.toString(exec)->value(exec));
  • trunk/Source/JavaScriptCore/runtime/JSActivation.cpp

    r116828 r117859  
    9393inline bool JSActivation::symbolTableGet(PropertyName propertyName, PropertySlot& slot)
    9494{
    95     SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
     95    SymbolTableEntry entry = symbolTable().inlineGet(propertyName.publicName());
    9696    if (entry.isNull())
    9797        return false;
     
    108108    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    109109   
    110     SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
     110    SymbolTableEntry entry = symbolTable().inlineGet(propertyName.publicName());
    111111    if (entry.isNull())
    112112        return false;
     
    142142    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    143143   
    144     SymbolTable::iterator iter = symbolTable().find(propertyName.impl());
     144    SymbolTable::iterator iter = symbolTable().find(propertyName.publicName());
    145145    if (iter == symbolTable().end())
    146146        return false;
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp

    r117729 r117859  
    8787JS_EXPORTDATA extern const HashTable objectConstructorTable;
    8888extern const HashTable objectPrototypeTable;
     89extern const HashTable privateNamePrototypeTable;
    8990extern const HashTable regExpTable;
    9091extern const HashTable regExpConstructorTable;
     
    136137    , objectConstructorTable(fastNew<HashTable>(JSC::objectConstructorTable))
    137138    , objectPrototypeTable(fastNew<HashTable>(JSC::objectPrototypeTable))
     139    , privateNamePrototypeTable(fastNew<HashTable>(JSC::privateNamePrototypeTable))
    138140    , regExpTable(fastNew<HashTable>(JSC::regExpTable))
    139141    , regExpConstructorTable(fastNew<HashTable>(JSC::regExpConstructorTable))
     
    242244    objectConstructorTable->deleteTable();
    243245    objectPrototypeTable->deleteTable();
     246    privateNamePrototypeTable->deleteTable();
    244247    regExpTable->deleteTable();
    245248    regExpConstructorTable->deleteTable();
     
    261264    fastDelete(const_cast<HashTable*>(objectConstructorTable));
    262265    fastDelete(const_cast<HashTable*>(objectPrototypeTable));
     266    fastDelete(const_cast<HashTable*>(privateNamePrototypeTable));
    263267    fastDelete(const_cast<HashTable*>(regExpTable));
    264268    fastDelete(const_cast<HashTable*>(regExpConstructorTable));
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.h

    r117729 r117859  
    193193        const HashTable* objectConstructorTable;
    194194        const HashTable* objectPrototypeTable;
     195        const HashTable* privateNamePrototypeTable;
    195196        const HashTable* regExpTable;
    196197        const HashTable* regExpConstructorTable;
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r116828 r117859  
    5757#include "Lookup.h"
    5858#include "MathObject.h"
     59#include "NameConstructor.h"
     60#include "NameInstance.h"
     61#include "NamePrototype.h"
    5962#include "NativeErrorConstructor.h"
    6063#include "NativeErrorPrototype.h"
     
    245248    m_errorStructure.set(exec->globalData(), this, ErrorInstance::createStructure(exec->globalData(), this, errorPrototype));
    246249
     250    NamePrototype* privateNamePrototype = NamePrototype::create(exec, NamePrototype::createStructure(exec->globalData(), this, m_objectPrototype.get()));
     251    m_privateNameStructure.set(exec->globalData(), this, NameInstance::createStructure(exec->globalData(), this, privateNamePrototype));
     252
    247253    // Constructors
    248254
     
    258264
    259265    m_errorConstructor.set(exec->globalData(), this, ErrorConstructor::create(exec, this, ErrorConstructor::createStructure(exec->globalData(), this, m_functionPrototype.get()), errorPrototype));
     266    JSCell* privateNameConstructor = NameConstructor::create(exec, this, NameConstructor::createStructure(exec->globalData(), this, m_functionPrototype.get()), privateNamePrototype);
    260267
    261268    Structure* nativeErrorPrototypeStructure = NativeErrorPrototype::createStructure(exec->globalData(), this, errorPrototype);
     
    277284    m_regExpPrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, m_regExpConstructor.get(), DontEnum);
    278285    errorPrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, m_errorConstructor.get(), DontEnum);
     286    privateNamePrototype->putDirectWithoutTransition(exec->globalData(), exec->propertyNames().constructor, privateNameConstructor, DontEnum);
    279287
    280288    putDirectWithoutTransition(exec->globalData(), Identifier(exec, "Object"), objectConstructor, DontEnum);
     
    293301    putDirectWithoutTransition(exec->globalData(), Identifier(exec, "TypeError"), m_typeErrorConstructor.get(), DontEnum);
    294302    putDirectWithoutTransition(exec->globalData(), Identifier(exec, "URIError"), m_URIErrorConstructor.get(), DontEnum);
     303    putDirectWithoutTransition(exec->globalData(), Identifier(exec, "Name"), privateNameConstructor, DontEnum);
    295304
    296305    m_evalFunction.set(exec->globalData(), this, JSFunction::create(exec, this, 1, exec->propertyNames().eval.ustring(), globalFuncEval));
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r116828 r117859  
    131131        size_t m_functionNameOffset;
    132132        WriteBarrier<Structure> m_numberObjectStructure;
     133        WriteBarrier<Structure> m_privateNameStructure;
    133134        WriteBarrier<Structure> m_regExpMatchesArrayStructure;
    134135        WriteBarrier<Structure> m_regExpStructure;
     
    264265        size_t functionNameOffset() const { return m_functionNameOffset; }
    265266        Structure* numberObjectStructure() const { return m_numberObjectStructure.get(); }
     267        Structure* privateNameStructure() const { return m_privateNameStructure.get(); }
    266268        Structure* internalFunctionStructure() const { return m_internalFunctionStructure.get(); }
    267269        Structure* regExpMatchesArrayStructure() const { return m_regExpMatchesArrayStructure.get(); }
     
    377379    inline bool JSGlobalObject::symbolTableHasProperty(PropertyName propertyName)
    378380    {
    379         SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
     381        SymbolTableEntry entry = symbolTable().inlineGet(propertyName.publicName());
    380382        return !entry.isNull();
    381383    }
  • trunk/Source/JavaScriptCore/runtime/JSType.h

    r106999 r117859  
    4646    FinalObjectType,
    4747    JSFunctionType,
     48    NameInstanceType,
    4849    NumberObjectType,
    4950    ErrorInstanceType,
  • trunk/Source/JavaScriptCore/runtime/JSTypeInfo.h

    r108444 r117859  
    6868        bool isFinalObject() const { return type() == FinalObjectType; }
    6969        bool isNumberObject() const { return type() == NumberObjectType; }
     70        bool isName() const { return type() == NameInstanceType; }
    7071
    7172        bool masqueradesAsUndefined() const { return isSetOnFlags1(MasqueradesAsUndefined); }
  • trunk/Source/JavaScriptCore/runtime/JSVariableObject.cpp

    r116828 r117859  
    4646{
    4747    JSVariableObject* thisObject = jsCast<JSVariableObject*>(cell);
    48     if (thisObject->symbolTable().contains(propertyName.impl()))
     48    if (thisObject->symbolTable().contains(propertyName.publicName()))
    4949        return false;
    5050
     
    6666bool JSVariableObject::symbolTableGet(PropertyName propertyName, PropertyDescriptor& descriptor)
    6767{
    68     SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
     68    SymbolTableEntry entry = symbolTable().inlineGet(propertyName.publicName());
    6969    if (!entry.isNull()) {
    7070        descriptor.setDescriptor(registerAt(entry.getIndex()).get(), entry.getAttributes() | DontDelete);
  • trunk/Source/JavaScriptCore/runtime/JSVariableObject.h

    r116828 r117859  
    103103    inline bool JSVariableObject::symbolTableGet(PropertyName propertyName, PropertySlot& slot)
    104104    {
    105         SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
     105        SymbolTableEntry entry = symbolTable().inlineGet(propertyName.publicName());
    106106        if (!entry.isNull()) {
    107107            slot.setValue(registerAt(entry.getIndex()).get());
     
    113113    inline bool JSVariableObject::symbolTableGet(PropertyName propertyName, PropertySlot& slot, bool& slotIsWriteable)
    114114    {
    115         SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
     115        SymbolTableEntry entry = symbolTable().inlineGet(propertyName.publicName());
    116116        if (!entry.isNull()) {
    117117            slot.setValue(registerAt(entry.getIndex()).get());
     
    127127        ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    128128
    129         SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
     129        SymbolTableEntry entry = symbolTable().inlineGet(propertyName.publicName());
    130130        if (entry.isNull())
    131131            return false;
     
    143143        ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    144144
    145         SymbolTable::iterator iter = symbolTable().find(propertyName.impl());
     145        SymbolTable::iterator iter = symbolTable().find(propertyName.publicName());
    146146        if (iter == symbolTable().end())
    147147            return false;
  • trunk/Source/JavaScriptCore/runtime/Lookup.cpp

    r116828 r117859  
    7777            return false;
    7878   
    79         JSFunction* function = JSFunction::create(exec, thisObj->globalObject(), entry->functionLength(), propertyName.ustring(), entry->function(), entry->intrinsic());
     79        StringImpl* name = propertyName.publicName();
     80        ASSERT(name);
     81       
     82        JSFunction* function = JSFunction::create(exec, thisObj->globalObject(), entry->functionLength(), name, entry->function(), entry->intrinsic());
    8083        thisObj->putDirect(exec->globalData(), propertyName, function, entry->attributes());
    8184        location = thisObj->getDirectLocation(exec->globalData(), propertyName);
  • trunk/Source/JavaScriptCore/runtime/Lookup.h

    r116828 r117859  
    200200
    201201    private:
    202         ALWAYS_INLINE const HashEntry* entry(PropertyName identifier) const
    203         {
     202        ALWAYS_INLINE const HashEntry* entry(PropertyName propertyName) const
     203        {
     204            StringImpl* impl = propertyName.publicName();
     205            if (!impl)
     206                return 0;
     207       
    204208            ASSERT(table);
    205209
    206             const HashEntry* entry = &table[identifier.impl()->existingHash() & compactHashSizeMask];
     210            const HashEntry* entry = &table[impl->existingHash() & compactHashSizeMask];
    207211
    208212            if (!entry->key())
     
    210214
    211215            do {
    212                 if (entry->key() == identifier.impl())
     216                if (entry->key() == impl)
    213217                    return entry;
    214218                entry = entry->next();
  • trunk/Source/JavaScriptCore/runtime/PropertyMapHashTable.h

    r92569 r117859  
    326326{
    327327    ASSERT(key);
    328     ASSERT(key->isIdentifier());
     328    ASSERT(key->isIdentifier() || key->isEmptyUnique());
    329329    unsigned hash = key->existingHash();
    330330    unsigned step = 0;
     
    370370        if (entryIndex == EmptyEntryIndex)
    371371            return std::make_pair((ValueType*)0, hash & m_indexMask);
    372         if (equal(key, table()[entryIndex - 1].key))
     372        const KeyType& keyInMap = table()[entryIndex - 1].key;
     373        if (equal(key, keyInMap) && keyInMap->isIdentifier())
    373374            return std::make_pair(&table()[entryIndex - 1], hash & m_indexMask);
    374375
  • trunk/Source/JavaScriptCore/runtime/PropertyName.h

    r116926 r117859  
    2828
    2929#include "Identifier.h"
     30#include "PrivateName.h"
    3031
    3132namespace JSC {
     
    8182        : m_impl(propertyName.impl())
    8283    {
     84        ASSERT(!m_impl || m_impl->isIdentifier());
    8385    }
    8486
    85     StringImpl* impl() const { return m_impl; }
    86     UString ustring() const { return m_impl; }
     87    PropertyName(const PrivateName& propertyName)
     88        : m_impl(propertyName.uid())
     89    {
     90        ASSERT(m_impl && m_impl->isEmptyUnique());
     91    }
     92
     93    StringImpl* uid() const
     94    {
     95        ASSERT(!m_impl || (m_impl->isIdentifier() == !m_impl->isEmptyUnique()));
     96        return m_impl;
     97    }
     98
     99    StringImpl* publicName() const
     100    {
     101        ASSERT(!m_impl || (m_impl->isIdentifier() == !m_impl->isEmptyUnique()));
     102        return m_impl->isIdentifier() ? m_impl : 0;
     103    }
    87104
    88105    static const uint32_t NotAnIndex = UINT_MAX;
     106
    89107    uint32_t asIndex()
    90108    {
    91         return toUInt32FromStringImpl(m_impl);
     109        ASSERT(!m_impl || (m_impl->isIdentifier() == !m_impl->isEmptyUnique()));
     110        return m_impl ? toUInt32FromStringImpl(m_impl) : NotAnIndex;
    92111    }
    93112
     
    98117inline bool operator==(PropertyName a, const Identifier& b)
    99118{
    100     return a.impl() == b.impl();
     119    return a.uid() == b.impl();
    101120}
    102121
    103122inline bool operator==(const Identifier& a, PropertyName b)
    104123{
    105     return a.impl() == b.impl();
     124    return a.impl() == b.uid();
    106125}
    107126
    108127inline bool operator==(PropertyName a, PropertyName b)
    109128{
    110     return a.impl() == b.impl();
     129    return a.uid() == b.uid();
    111130}
    112131
    113132inline bool operator!=(PropertyName a, const Identifier& b)
    114133{
    115     return a.impl() != b.impl();
     134    return a.uid() != b.impl();
    116135}
    117136
    118137inline bool operator!=(const Identifier& a, PropertyName b)
    119138{
    120     return a.impl() != b.impl();
     139    return a.impl() != b.uid();
    121140}
    122141
    123142inline bool operator!=(PropertyName a, PropertyName b)
    124143{
    125     return a.impl() != b.impl();
     144    return a.uid() != b.uid();
    126145}
    127146
  • trunk/Source/JavaScriptCore/runtime/Structure.cpp

    r117343 r117859  
    276276void Structure::despecifyDictionaryFunction(JSGlobalData& globalData, PropertyName propertyName)
    277277{
    278     StringImpl* rep = propertyName.impl();
     278    StringImpl* rep = propertyName.uid();
    279279
    280280    materializePropertyMapIfNecessary(globalData);
     
    293293    ASSERT(structure->isObject());
    294294
    295     if (Structure* existingTransition = structure->m_transitionTable.get(propertyName.impl(), attributes)) {
     295    if (Structure* existingTransition = structure->m_transitionTable.get(propertyName.uid(), attributes)) {
    296296        JSCell* specificValueInPrevious = existingTransition->m_specificValueInPrevious.get();
    297297        if (specificValueInPrevious && specificValueInPrevious != specificValue)
     
    314314    // in us adding a non-specific transition, and any subsequent lookup in
    315315    // Structure::addPropertyTransitionToExistingStructure will just use that.
    316     if (specificValue && structure->m_transitionTable.contains(propertyName.impl(), attributes))
     316    if (specificValue && structure->m_transitionTable.contains(propertyName.uid(), attributes))
    317317        specificValue = 0;
    318318
     
    337337    transition->m_cachedPrototypeChain.setMayBeNull(globalData, transition, structure->m_cachedPrototypeChain.get());
    338338    transition->m_previous.set(globalData, transition, structure);
    339     transition->m_nameInPrevious = propertyName.impl();
     339    transition->m_nameInPrevious = propertyName.uid();
    340340    transition->m_attributesInPrevious = attributes;
    341341    transition->m_specificValueInPrevious.setMayBeNull(globalData, transition, specificValue);
     
    426426
    427427    ASSERT(structure->m_propertyTable);
    428     PropertyMapEntry* entry = structure->m_propertyTable->find(propertyName.impl()).first;
     428    PropertyMapEntry* entry = structure->m_propertyTable->find(propertyName.uid()).first;
    429429    ASSERT(entry);
    430430    entry->attributes = attributes;
     
    651651        return WTF::notFound;
    652652
    653     PropertyMapEntry* entry = m_propertyTable->find(propertyName.impl()).first;
     653    PropertyMapEntry* entry = m_propertyTable->find(propertyName.uid()).first;
    654654    if (!entry)
    655655        return WTF::notFound;
     
    666666        return false;
    667667
    668     PropertyMapEntry* entry = m_propertyTable->find(propertyName.impl()).first;
     668    PropertyMapEntry* entry = m_propertyTable->find(propertyName.uid()).first;
    669669    if (!entry)
    670670        return false;
     
    694694        m_hasNonEnumerableProperties = true;
    695695
    696     StringImpl* rep = propertyName.impl();
     696    StringImpl* rep = propertyName.uid();
    697697
    698698    if (!m_propertyTable)
     
    716716    checkConsistency();
    717717
    718     StringImpl* rep = propertyName.impl();
     718    StringImpl* rep = propertyName.uid();
    719719
    720720    if (!m_propertyTable)
     
    754754    for (PropertyTable::iterator iter = m_propertyTable->begin(); iter != end; ++iter) {
    755755        ASSERT(m_hasNonEnumerableProperties || !(iter->attributes & DontEnum));
    756         if (!(iter->attributes & DontEnum) || (mode == IncludeDontEnumProperties)) {
     756        if (iter->key->isIdentifier() && (!(iter->attributes & DontEnum) || mode == IncludeDontEnumProperties)) {
    757757            if (knownUnique)
    758758                propertyNames.addKnownUnique(iter->key);
  • trunk/Source/JavaScriptCore/runtime/Structure.h

    r117343 r117859  
    318318            return notFound;
    319319
    320         PropertyMapEntry* entry = m_propertyTable->find(propertyName.impl()).first;
     320        PropertyMapEntry* entry = m_propertyTable->find(propertyName.uid()).first;
    321321        return entry ? entry->offset : notFound;
    322322    }
  • trunk/Source/WTF/ChangeLog

    r117815 r117859  
     12012-05-15  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Add support for private names
     4        https://bugs.webkit.org/show_bug.cgi?id=86509
     5
     6        Reviewed by Oliver Hunt.
     7
     8        The spec isn't final, but we can start adding support to allow property maps
     9        to contain keys that aren't identifiers.
     10
     11        * wtf/text/StringImpl.h:
     12        (WTF::StringImpl::StringImpl):
     13        (StringImpl):
     14        (WTF::StringImpl::createEmptyUnique):
     15        (WTF::StringImpl::isEmptyUnique):
     16            - Allow empty string impls to be allocated, which can be used as unique keys.
     17
    1182012-05-21  Emil A Eklund <eae@chromium.org> and Levi Weintraub  <leviw@chromium.org>
    219
  • trunk/Source/WTF/wtf/text/StringImpl.h

    r115669 r117859  
    158158    // Create a StringImpl adopting ownership of the provided buffer (BufferOwned)
    159159    StringImpl(const UChar* characters, unsigned length)
    160     : m_refCount(s_refCountIncrement)
    161     , m_length(length)
    162     , m_data16(characters)
    163     , m_buffer(0)
    164     , m_hashAndFlags(BufferOwned)
     160        : m_refCount(s_refCountIncrement)
     161        , m_length(length)
     162        , m_data16(characters)
     163        , m_buffer(0)
     164        , m_hashAndFlags(BufferOwned)
    165165    {
    166166        ASSERT(m_data16);
     
    194194        ASSERT(m_length);
    195195        ASSERT(m_substringBuffer->bufferOwnership() != BufferSubstring);
     196    }
     197
     198    enum CreateEmptyUnique_T { CreateEmptyUnique };
     199    StringImpl(CreateEmptyUnique_T)
     200        : m_refCount(s_refCountIncrement)
     201        , m_length(0)
     202        , m_data16(reinterpret_cast<const UChar*>(1))
     203        , m_buffer(0)
     204    {
     205        ASSERT(m_data16);
     206        // Set the hash early, so that all empty unique StringImpls have a hash,
     207        // and don't use the normal hashing algorithm - the unique nature of these
     208        // keys means that we don't need them to match any other string (in fact,
     209        // that's exactly the oposite of what we want!), and teh normal hash would
     210        // lead to lots of conflicts.
     211        unsigned hash = reinterpret_cast<uintptr_t>(this);
     212        hash <<= s_flagCount;
     213        if (!hash)
     214            hash = 1 << s_flagCount;
     215        m_hashAndFlags = hash | BufferInternal;
    196216    }
    197217
     
    258278    }
    259279
     280    static PassRefPtr<StringImpl> createEmptyUnique()
     281    {
     282        return adoptRef(new StringImpl(CreateEmptyUnique));
     283    }
     284
    260285    // Reallocate the StringImpl. The originalString must be only owned by the PassRefPtr,
    261286    // and the buffer ownership must be BufferInternal. Just like the input pointer of realloc(),
     
    324349        else
    325350            m_hashAndFlags &= ~s_hashFlagIsIdentifier;
     351    }
     352
     353    bool isEmptyUnique() const
     354    {
     355        return !length() && !isStatic();
    326356    }
    327357
  • trunk/Source/WebCore/ChangeLog

    r117858 r117859  
     12012-05-15  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Add support for private names
     4        https://bugs.webkit.org/show_bug.cgi?id=86509
     5
     6        Reviewed by Oliver Hunt.
     7
     8        The spec isn't final, but we can start adding support to allow property maps
     9        to contain keys that aren't identifiers.
     10
     11        Test: fast/js/names.html
     12
     13        * bindings/js/JSCSSStyleDeclarationCustom.cpp:
     14        (WebCore::cssPropertyIDForJSCSSPropertyName):
     15        * bindings/js/JSDOMBinding.cpp:
     16        (WebCore::findAtomicString):
     17        (WebCore::objectToStringFunctionGetter):
     18        * bindings/js/JSDOMBinding.h:
     19        (WebCore::propertyNameToString):
     20        (WebCore::propertyNameToAtomicString):
     21        * bindings/js/JSDOMWindowCustom.cpp:
     22        (WebCore::nonCachingStaticFunctionGetter):
     23        * bindings/js/JSHistoryCustom.cpp:
     24        (WebCore::nonCachingStaticBackFunctionGetter):
     25        (WebCore::nonCachingStaticForwardFunctionGetter):
     26        (WebCore::nonCachingStaticGoFunctionGetter):
     27        * bindings/js/JSLocationCustom.cpp:
     28        (WebCore::nonCachingStaticReplaceFunctionGetter):
     29        (WebCore::nonCachingStaticReloadFunctionGetter):
     30        (WebCore::nonCachingStaticAssignFunctionGetter):
     31        * bridge/c/c_class.cpp:
     32        (JSC::Bindings::CClass::methodsNamed):
     33        (JSC::Bindings::CClass::fieldNamed):
     34        * bridge/c/c_instance.cpp:
     35        (JSC::Bindings::CInstance::getMethod):
     36        * bridge/jni/jsc/JavaClassJSC.cpp:
     37        (JavaClass::methodsNamed):
     38        (JavaClass::fieldNamed):
     39        * bridge/jni/jsc/JavaInstanceJSC.cpp:
     40        * bridge/objc/objc_class.mm:
     41        (JSC::Bindings::ObjcClass::methodsNamed):
     42        (JSC::Bindings::ObjcClass::fieldNamed):
     43        (JSC::Bindings::ObjcClass::fallbackObject):
     44        * bridge/objc/objc_instance.mm:
     45        (ObjcInstance::setValueOfUndefinedField):
     46        (ObjcInstance::getValueOfUndefinedField):
     47            - Removed PropertyName::impl(), call publicName() to get the string associated with a name.
     48
    1492012-05-21  Tim Horton  <timothy_horton@apple.com>
    250
  • trunk/Source/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp

    r116828 r117859  
    182182    bool hadPixelOrPosPrefix = false;
    183183
    184     StringImpl* propertyNameString = propertyName.impl();
     184    StringImpl* propertyNameString = propertyName.publicName();
     185    if (!propertyNameString)
     186        return propertyInfo;
    185187    unsigned length = propertyNameString->length();
    186188    if (!length)
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp

    r116828 r117859  
    110110AtomicStringImpl* findAtomicString(PropertyName propertyName)
    111111{
    112     StringImpl* impl = propertyName.impl();
     112    StringImpl* impl = propertyName.publicName();
    113113    if (!impl)
    114114        return 0;
     
    246246JSValue objectToStringFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
    247247{
    248     return JSFunction::create(exec, exec->lexicalGlobalObject(), 0, propertyName.impl(), objectProtoFuncToString);
     248    return JSFunction::create(exec, exec->lexicalGlobalObject(), 0, propertyName.publicName(), objectProtoFuncToString);
    249249}
    250250
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r117795 r117859  
    374374    inline String propertyNameToString(JSC::PropertyName propertyName)
    375375    {
    376         return propertyName.impl();
     376        return propertyName.publicName();
    377377    }
    378378
     
    384384    inline AtomicString propertyNameToAtomicString(JSC::PropertyName propertyName)
    385385    {
    386         return AtomicString(propertyName.impl());
     386        return AtomicString(propertyName.publicName());
    387387    }
    388388
  • trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp

    r117646 r117859  
    9595JSValue nonCachingStaticFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
    9696{
    97     return JSFunction::create(exec, exec->lexicalGlobalObject(), length, propertyName.impl(), nativeFunction);
     97    return JSFunction::create(exec, exec->lexicalGlobalObject(), length, propertyName.publicName(), nativeFunction);
    9898}
    9999
  • trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp

    r116828 r117859  
    4141static JSValue nonCachingStaticBackFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
    4242{
    43     return JSFunction::create(exec, exec->lexicalGlobalObject(), 0, propertyName.impl(), jsHistoryPrototypeFunctionBack);
     43    return JSFunction::create(exec, exec->lexicalGlobalObject(), 0, propertyName.publicName(), jsHistoryPrototypeFunctionBack);
    4444}
    4545
    4646static JSValue nonCachingStaticForwardFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
    4747{
    48     return JSFunction::create(exec, exec->lexicalGlobalObject(), 0, propertyName.impl(), jsHistoryPrototypeFunctionForward);
     48    return JSFunction::create(exec, exec->lexicalGlobalObject(), 0, propertyName.publicName(), jsHistoryPrototypeFunctionForward);
    4949}
    5050
    5151static JSValue nonCachingStaticGoFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
    5252{
    53     return JSFunction::create(exec, exec->lexicalGlobalObject(), 1, propertyName.impl(), jsHistoryPrototypeFunctionGo);
     53    return JSFunction::create(exec, exec->lexicalGlobalObject(), 1, propertyName.publicName(), jsHistoryPrototypeFunctionGo);
    5454}
    5555
  • trunk/Source/WebCore/bindings/js/JSLocationCustom.cpp

    r116828 r117859  
    3333static JSValue nonCachingStaticReplaceFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
    3434{
    35     return JSFunction::create(exec, exec->lexicalGlobalObject(), 1, propertyName.impl(), jsLocationPrototypeFunctionReplace);
     35    return JSFunction::create(exec, exec->lexicalGlobalObject(), 1, propertyName.publicName(), jsLocationPrototypeFunctionReplace);
    3636}
    3737
    3838static JSValue nonCachingStaticReloadFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
    3939{
    40     return JSFunction::create(exec, exec->lexicalGlobalObject(), 0, propertyName.impl(), jsLocationPrototypeFunctionReload);
     40    return JSFunction::create(exec, exec->lexicalGlobalObject(), 0, propertyName.publicName(), jsLocationPrototypeFunctionReload);
    4141}
    4242
    4343static JSValue nonCachingStaticAssignFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
    4444{
    45     return JSFunction::create(exec, exec->lexicalGlobalObject(), 1, propertyName.impl(), jsLocationPrototypeFunctionAssign);
     45    return JSFunction::create(exec, exec->lexicalGlobalObject(), 1, propertyName.publicName(), jsLocationPrototypeFunctionAssign);
    4646}
    4747
  • trunk/Source/WebCore/bridge/c/c_class.cpp

    r116828 r117859  
    7474}
    7575
    76 MethodList CClass::methodsNamed(PropertyName identifier, Instance* instance) const
     76MethodList CClass::methodsNamed(PropertyName propertyName, Instance* instance) const
    7777{
    78     UString name(identifier.impl());
     78    UString name(propertyName.publicName());
    7979   
    8080    MethodList methodList;
     
    101101}
    102102
    103 Field* CClass::fieldNamed(PropertyName identifier, Instance* instance) const
     103Field* CClass::fieldNamed(PropertyName propertyName, Instance* instance) const
    104104{
    105     UString name(identifier.impl());
     105    UString name(propertyName.publicName());
    106106   
    107107    Field* aField = _fields.get(name.impl());
  • trunk/Source/WebCore/bridge/c/c_instance.cpp

    r116828 r117859  
    150150{
    151151    MethodList methodList = getClass()->methodsNamed(propertyName, this);
    152     return CRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.impl(), methodList);
     152    return CRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.publicName(), methodList);
    153153}
    154154
  • trunk/Source/WebCore/bridge/jni/jsc/JavaClassJSC.cpp

    r116828 r117859  
    115115}
    116116
    117 MethodList JavaClass::methodsNamed(PropertyName identifier, Instance*) const
     117MethodList JavaClass::methodsNamed(PropertyName propertyName, Instance*) const
    118118{
    119     MethodList* methodList = m_methods.get(identifier.ustring().impl());
     119    MethodList* methodList = m_methods.get(propertyName.publicName());
    120120
    121121    if (methodList)
     
    124124}
    125125
    126 Field* JavaClass::fieldNamed(PropertyName identifier, Instance*) const
     126Field* JavaClass::fieldNamed(PropertyName propertyName, Instance*) const
    127127{
    128     return m_fields.get(identifier.ustring().impl());
     128    return m_fields.get(propertyName.publicName());
    129129}
    130130
  • trunk/Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp

    r116828 r117859  
    154154{
    155155    MethodList methodList = getClass()->methodsNamed(propertyName, this);
    156     return JavaRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.ustring(), methodList);
     156    return JavaRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.publicName(), methodList);
    157157}
    158158
  • trunk/Source/WebCore/bridge/objc/objc_class.mm

    r116828 r117859  
    9696}
    9797
    98 MethodList ObjcClass::methodsNamed(PropertyName identifier, Instance*) const
    99 {
     98MethodList ObjcClass::methodsNamed(PropertyName propertyName, Instance*) const
     99{
     100    UString name(propertyName.publicName());
     101    if (name.isNull())
     102        return MethodList();
     103
    100104    MethodList methodList;
    101     if (Method* method = m_methodCache.get(identifier.impl())) {
     105    if (Method* method = m_methodCache.get(name.impl())) {
    102106        methodList.append(method);
    103107        return methodList;
    104108    }
    105109
    106     CString jsName = identifier.ustring().ascii();
     110    CString jsName = name.ascii();
    107111    JSNameConversionBuffer buffer;
    108112    convertJSMethodNameToObjc(jsName, buffer);
     
    133137                OwnPtr<Method> method = adoptPtr(new ObjcMethod(thisClass, objcMethodSelector));
    134138                methodList.append(method.get());
    135                 m_methodCache.add(identifier.impl(), method.release());
     139                m_methodCache.add(name.impl(), method.release());
    136140                break;
    137141            }
     
    144148}
    145149
    146 Field* ObjcClass::fieldNamed(PropertyName identifier, Instance* instance) const
    147 {
    148     Field* field = m_fieldCache.get(identifier.impl());
     150Field* ObjcClass::fieldNamed(PropertyName propertyName, Instance* instance) const
     151{
     152    UString name(propertyName.publicName());
     153    if (name.isNull())
     154        return 0;
     155
     156    Field* field = m_fieldCache.get(name.impl());
    149157    if (field)
    150158        return field;
     
    152160    ClassStructPtr thisClass = _isa;
    153161
    154     CString jsName = identifier.ustring().ascii();
     162    CString jsName = name.ascii();
    155163    RetainPtr<CFStringRef> fieldName(AdoptCF, CFStringCreateWithCString(NULL, jsName.data(), kCFStringEncodingASCII));
    156164    id targetObject = (static_cast<ObjcInstance*>(instance))->getObject();
     
    178186                OwnPtr<Field> newField = adoptPtr(new ObjcField((CFStringRef)keyName));
    179187                field = newField.get();
    180                 m_fieldCache.add(identifier.impl(), newField.release());
     188                m_fieldCache.add(name.impl(), newField.release());
    181189                break;
    182190            }
     
    209217                    OwnPtr<Field> newField = adoptPtr(new ObjcField(objcIVar));
    210218                    field = newField.get();
    211                     m_fieldCache.add(identifier.impl(), newField.release());
     219                    m_fieldCache.add(name.impl(), newField.release());
    212220                    break;
    213221                }
     
    229237    if (![targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)])
    230238        return jsUndefined();
    231     return ObjcFallbackObjectImp::create(exec, exec->lexicalGlobalObject(), objcInstance, propertyName.impl());
    232 }
    233 
    234 }
    235 }
     239    return ObjcFallbackObjectImp::create(exec, exec->lexicalGlobalObject(), objcInstance, propertyName.publicName());
     240}
     241
     242}
     243}
  • trunk/Source/WebCore/bridge/objc/objc_instance.mm

    r116828 r117859  
    219219{
    220220    MethodList methodList = getClass()->methodsNamed(propertyName, this);
    221     return ObjCRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.ustring(), methodList);
     221    return ObjCRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.publicName(), methodList);
    222222}
    223223
     
    402402}
    403403
    404 bool ObjcInstance::setValueOfUndefinedField(ExecState* exec, PropertyName property, JSValue aValue)
    405 {
     404bool ObjcInstance::setValueOfUndefinedField(ExecState* exec, PropertyName propertyName, JSValue aValue)
     405{
     406    UString name(propertyName.publicName());
     407    if (name.isNull())
     408        return false;
     409
    406410    id targetObject = getObject();
    407411    if (![targetObject respondsToSelector:@selector(setValue:forUndefinedKey:)])
     
    419423
    420424        @try {
    421             [targetObject setValue:objcValue.objectValue forUndefinedKey:[NSString stringWithCString:property.ustring().ascii().data() encoding:NSASCIIStringEncoding]];
     425            [targetObject setValue:objcValue.objectValue forUndefinedKey:[NSString stringWithCString:name.ascii().data() encoding:NSASCIIStringEncoding]];
    422426        } @catch(NSException* localException) {
    423427            // Do nothing.  Class did not override valueForUndefinedKey:.
     
    430434}
    431435
    432 JSValue ObjcInstance::getValueOfUndefinedField(ExecState* exec, PropertyName property) const
    433 {
     436JSValue ObjcInstance::getValueOfUndefinedField(ExecState* exec, PropertyName propertyName) const
     437{
     438    UString name(propertyName.publicName());
     439    if (name.isNull())
     440        return jsUndefined();
     441
    434442    JSValue result = jsUndefined();
    435443   
     
    445453   
    446454        @try {
    447             id objcValue = [targetObject valueForUndefinedKey:[NSString stringWithCString:property.ustring().ascii().data() encoding:NSASCIIStringEncoding]];
     455            id objcValue = [targetObject valueForUndefinedKey:[NSString stringWithCString:name.ascii().data() encoding:NSASCIIStringEncoding]];
    448456            result = convertObjcValueToValue(exec, &objcValue, ObjcObjectType, m_rootObject.get());
    449457        } @catch(NSException* localException) {
  • trunk/Source/WebCore/bridge/qt/qt_class.cpp

    r116828 r117859  
    7171    QtInstance* qtinst = static_cast<QtInstance*>(inst);
    7272
    73     const UString& ustring = identifier.ustring();
     73    UString ustring(identifier.publicName());
    7474    const QByteArray name = QString(reinterpret_cast<const QChar*>(ustring.characters()), ustring.length()).toAscii();
    7575
     
    134134
    135135    QObject* obj = qtinst->getObject();
    136     const UString& ustring = identifier.ustring();
     136    UString ustring(identifier.publicName());
    137137    const QString name(reinterpret_cast<const QChar*>(ustring.characters()), ustring.length());
    138138    const QByteArray ascii = name.toAscii();
  • trunk/Source/WebCore/bridge/qt/qt_instance.cpp

    r116828 r117859  
    254254        return jsNull();
    255255    MethodList methodList = m_class->methodsNamed(propertyName, this);
    256     return RuntimeMethod::create(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeMethod>(exec), propertyName.ustring(), methodList);
     256    return RuntimeMethod::create(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeMethod>(exec), propertyName.publicName(), methodList);
    257257}
    258258
  • trunk/Source/WebCore/bridge/qt/qt_pixmapruntime.cpp

    r116828 r117859  
    243243{
    244244    MethodList methodList = getClass()->methodsNamed(propertyName, this);
    245     return RuntimeMethod::create(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeMethod>(exec), propertyName.ustring(), methodList);
     245    return RuntimeMethod::create(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeMethod>(exec), propertyName.publicName(), methodList);
    246246}
    247247
     
    260260{
    261261    MethodList methods;
    262     if (identifier.ustring() == QtPixmapToDataUrlMethod::name())
     262    UString ustring(identifier.publicName());
     263    if (ustring == QtPixmapToDataUrlMethod::name())
    263264        methods.append(&qt_pixmap_metaData.toDataUrlMethod);
    264     else if (identifier.ustring() == QtPixmapToImageDataMethod::name())
     265    else if (ustring == QtPixmapToImageDataMethod::name())
    265266        methods.append(&qt_pixmap_metaData.toImageDataMethod);
    266     else if (identifier.ustring() == QtPixmapAssignToElementMethod::name())
     267    else if (ustring == QtPixmapAssignToElementMethod::name())
    267268        methods.append(&qt_pixmap_metaData.assignToElementMethod);
    268     else if (identifier.ustring() == QtPixmapToStringMethod::name())
     269    else if (ustring == QtPixmapToStringMethod::name())
    269270        methods.append(&qt_pixmap_metaData.toStringMethod);
    270271    return methods;
     
    273274Field* QtPixmapClass::fieldNamed(PropertyName identifier, Instance*) const
    274275{
    275     if (identifier.ustring() == QtPixmapWidthField::name())
     276    UString ustring(identifier.publicName());
     277    if (ustring == QtPixmapWidthField::name())
    276278        return &qt_pixmap_metaData.widthField;
    277     if (identifier.ustring() == QtPixmapHeightField::name())
     279    if (ustring == QtPixmapHeightField::name())
    278280        return &qt_pixmap_metaData.heightField;
    279281    return 0;
  • trunk/Source/WebCore/bridge/qt/qt_runtime.cpp

    r117650 r117859  
    15221522
    15231523    if (!d->m_connect)
    1524         d->m_connect.set(exec->globalData(), thisObj, QtRuntimeConnectionMethod::create(exec, ident.impl(), true, d->m_instance, d->m_index, d->m_signature));
     1524        d->m_connect.set(exec->globalData(), thisObj, QtRuntimeConnectionMethod::create(exec, ident.publicName(), true, d->m_instance, d->m_index, d->m_signature));
    15251525    return d->m_connect.get();
    15261526}
     
    15321532
    15331533    if (!d->m_disconnect)
    1534         d->m_disconnect.set(exec->globalData(), thisObj, QtRuntimeConnectionMethod::create(exec, ident.impl(), false, d->m_instance, d->m_index, d->m_signature));
     1534        d->m_disconnect.set(exec->globalData(), thisObj, QtRuntimeConnectionMethod::create(exec, ident.publicName(), false, d->m_instance, d->m_index, d->m_signature));
    15351535    return d->m_disconnect.get();
    15361536}
  • trunk/Source/WebCore/bridge/qt/qt_runtime_qt4.cpp

    r117650 r117859  
    15311531
    15321532    if (!d->m_connect)
    1533         d->m_connect.set(exec->globalData(), thisObj, QtRuntimeConnectionMethod::create(exec, ident.ustring(), true, d->m_instance, d->m_index, d->m_signature));
     1533        d->m_connect.set(exec->globalData(), thisObj, QtRuntimeConnectionMethod::create(exec, ident.publicName(), true, d->m_instance, d->m_index, d->m_signature));
    15341534    return d->m_connect.get();
    15351535}
     
    15411541
    15421542    if (!d->m_disconnect)
    1543         d->m_disconnect.set(exec->globalData(), thisObj, QtRuntimeConnectionMethod::create(exec, ident.ustring(), false, d->m_instance, d->m_index, d->m_signature));
     1543        d->m_disconnect.set(exec->globalData(), thisObj, QtRuntimeConnectionMethod::create(exec, ident.publicName(), false, d->m_instance, d->m_index, d->m_signature));
    15441544    return d->m_disconnect.get();
    15451545}
  • trunk/Source/WebKit/mac/ChangeLog

    r117771 r117859  
     12012-05-15  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Add support for private names
     4        https://bugs.webkit.org/show_bug.cgi?id=86509
     5
     6        Reviewed by Oliver Hunt.
     7
     8        The spec isn't final, but we can start adding support to allow property maps
     9        to contain keys that aren't identifiers.
     10
     11        * Plugins/Hosted/ProxyInstance.mm:
     12        (WebKit::ProxyClass::methodsNamed):
     13        (WebKit::ProxyClass::fieldNamed):
     14        (WebKit::ProxyInstance::getMethod):
     15        (WebKit::ProxyInstance::methodsNamed):
     16        (WebKit::ProxyInstance::fieldNamed):
     17            - Removed PropertyName::impl(), call publicName() to get the string associated with a name.
     18
    1192012-05-21  Caio Marcelo de Oliveira Filho  <caio.oliveira@openbossa.org>
    220
  • trunk/Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm

    r116828 r117859  
    5555};
    5656
    57 MethodList ProxyClass::methodsNamed(PropertyName identifier, Instance* instance) const
    58 {
    59     return static_cast<ProxyInstance*>(instance)->methodsNamed(identifier);
    60 }
    61 
    62 Field* ProxyClass::fieldNamed(PropertyName identifier, Instance* instance) const
    63 {
    64     return static_cast<ProxyInstance*>(instance)->fieldNamed(identifier);
     57MethodList ProxyClass::methodsNamed(PropertyName propertyName, Instance* instance) const
     58{
     59    return static_cast<ProxyInstance*>(instance)->methodsNamed(propertyName);
     60}
     61
     62Field* ProxyClass::fieldNamed(PropertyName propertyName, Instance* instance) const
     63{
     64    return static_cast<ProxyInstance*>(instance)->fieldNamed(propertyName);
    6565}
    6666
     
    217217{
    218218    MethodList methodList = getClass()->methodsNamed(propertyName, this);
    219     return ProxyRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.impl(), methodList);
     219    return ProxyRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName.publicName(), methodList);
    220220}
    221221
     
    347347}
    348348
    349 MethodList ProxyInstance::methodsNamed(PropertyName identifier)
    350 {
    351     if (!m_instanceProxy)
     349MethodList ProxyInstance::methodsNamed(PropertyName propertyName)
     350{
     351    UString name(propertyName.publicName());
     352    if (name.isNull())
    352353        return MethodList();
     354
     355    if (!m_instanceProxy)
     356        return MethodList();
    353357   
    354358    // If we already have an entry in the map, use it.
    355     MethodMap::iterator existingMapEntry = m_methods.find(identifier.impl());
     359    MethodMap::iterator existingMapEntry = m_methods.find(name.impl());
    356360    if (existingMapEntry != m_methods.end()) {
    357361        MethodList methodList;
     
    361365    }
    362366   
    363     uint64_t methodName = reinterpret_cast<uint64_t>(_NPN_GetStringIdentifier(identifier.ustring().ascii().data()));
     367    uint64_t methodName = reinterpret_cast<uint64_t>(_NPN_GetStringIdentifier(name.ascii().data()));
    364368    uint32_t requestID = m_instanceProxy->nextRequestID();
    365369   
     
    377381
    378382    // Add a new entry to the map unless an entry was added while we were in waitForReply.
    379     MethodMap::AddResult mapAddResult = m_methods.add(identifier.impl(), 0);
     383    MethodMap::AddResult mapAddResult = m_methods.add(name.impl(), 0);
    380384    if (mapAddResult.isNewEntry && reply->m_result)
    381385        mapAddResult.iterator->second = new ProxyMethod(methodName);
     
    387391}
    388392
    389 Field* ProxyInstance::fieldNamed(PropertyName identifier)
    390 {
    391     if (!m_instanceProxy)
     393Field* ProxyInstance::fieldNamed(PropertyName propertyName)
     394{
     395    UString name(propertyName.publicName());
     396    if (name.isNull())
    392397        return 0;
     398
     399    if (!m_instanceProxy)
     400        return 0;
    393401   
    394402    // If we already have an entry in the map, use it.
    395     FieldMap::iterator existingMapEntry = m_fields.find(identifier.impl());
     403    FieldMap::iterator existingMapEntry = m_fields.find(name.impl());
    396404    if (existingMapEntry != m_fields.end())
    397405        return existingMapEntry->second;
    398406   
    399     uint64_t propertyName = reinterpret_cast<uint64_t>(_NPN_GetStringIdentifier(identifier.ustring().ascii().data()));
     407    uint64_t identifier = reinterpret_cast<uint64_t>(_NPN_GetStringIdentifier(name.ascii().data()));
    400408    uint32_t requestID = m_instanceProxy->nextRequestID();
    401409   
    402410    if (_WKPHNPObjectHasProperty(m_instanceProxy->hostProxy()->port(),
    403411                                 m_instanceProxy->pluginID(), requestID,
    404                                  m_objectID, propertyName) != KERN_SUCCESS)
     412                                 m_objectID, identifier) != KERN_SUCCESS)
    405413        return 0;
    406414   
     
    413421   
    414422    // Add a new entry to the map unless an entry was added while we were in waitForReply.
    415     FieldMap::AddResult mapAddResult = m_fields.add(identifier.impl(), 0);
     423    FieldMap::AddResult mapAddResult = m_fields.add(name.impl(), 0);
    416424    if (mapAddResult.isNewEntry && reply->m_result)
    417         mapAddResult.iterator->second = new ProxyField(propertyName);
     425        mapAddResult.iterator->second = new ProxyField(identifier);
    418426    return mapAddResult.iterator->second;
    419427}
  • trunk/Source/WebKit2/ChangeLog

    r117820 r117859  
     12012-05-15  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Add support for private names
     4        https://bugs.webkit.org/show_bug.cgi?id=86509
     5
     6        Reviewed by Oliver Hunt.
     7
     8        The spec isn't final, but we can start adding support to allow property maps
     9        to contain keys that aren't identifiers.
     10
     11        * WebProcess/Plugins/Netscape/JSNPObject.cpp:
     12        (WebKit::npIdentifierFromIdentifier):
     13        (WebKit::JSNPObject::methodGetter):
     14            - Removed PropertyName::impl(), call publicName() to get the string associated with a name.
     15
    1162012-05-21  Hugo Parente Lima  <hugo.lima@openbossa.org>
    217
  • trunk/Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp

    r117212 r117859  
    4646namespace WebKit {
    4747
    48 static NPIdentifier npIdentifierFromIdentifier(PropertyName identifier)
    49 {
    50     return static_cast<NPIdentifier>(IdentifierRep::get(identifier.ustring().utf8().data()));
     48static NPIdentifier npIdentifierFromIdentifier(PropertyName propertyName)
     49{
     50    UString name(propertyName.publicName());
     51    if (name.isNull())
     52        return 0;
     53    return static_cast<NPIdentifier>(IdentifierRep::get(name.utf8().data()));
    5154}
    5255
     
    475478}
    476479
    477 JSValue JSNPObject::methodGetter(ExecState* exec, JSValue slotBase, PropertyName methodName)
     480JSValue JSNPObject::methodGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName)
    478481{
    479482    JSNPObject* thisObj = static_cast<JSNPObject*>(asObject(slotBase));
     
    483486        return throwInvalidAccessError(exec);
    484487
    485     NPIdentifier npIdentifier = npIdentifierFromIdentifier(methodName);
    486     return JSNPMethod::create(exec, thisObj->globalObject(), methodName.ustring(), npIdentifier);
     488    NPIdentifier npIdentifier = npIdentifierFromIdentifier(propertyName);
     489    return JSNPMethod::create(exec, thisObj->globalObject(), propertyName.publicName(), npIdentifier);
    487490}
    488491
Note: See TracChangeset for help on using the changeset viewer.