1. 04 Oct, 2013 1 commit
    • oliver@apple.com's avatar
      Support for-of syntax · 20a9bf08
      oliver@apple.com authored
      https://bugs.webkit.org/show_bug.cgi?id=122339
      
      Reviewed by Geoffrey Garen.
      
      Source/JavaScriptCore:
      
      Add support for for-of syntax to JSC.  As part of doing this I had to make
      us support unique empty strings as identifiers.  In a follow on patch i'm
      going to remove the distinction entirely as it's purely a complicating
      separation.
      
      Otherwise the logic here is fairly self-explanatory.
      
      * bytecompiler/BytecodeGenerator.cpp:
      (JSC::BytecodeGenerator::addConstant):
      (JSC::BytecodeGenerator::emitCall):
      * bytecompiler/BytecodeGenerator.h:
      * bytecompiler/NodesCodegen.cpp:
      (JSC::CallArguments::CallArguments):
      (JSC::ForOfNode::emitBytecode):
      * jit/JITOperations.cpp:
      * parser/ASTBuilder.h:
      (JSC::ASTBuilder::createForOfLoop):
      * parser/NodeConstructors.h:
      (JSC::EnumerationNode::EnumerationNode):
      (JSC::ForInNode::ForInNode):
      (JSC::ForOfNode::ForOfNode):
      * parser/Nodes.h:
      * parser/Parser.cpp:
      (JSC::::parseVarDeclarationList):
      (JSC::::parseForStatement):
      * parser/Parser.h:
      (JSC::Parser::isofToken):
      * parser/SyntaxChecker.h:
      (JSC::SyntaxChecker::createForOfLoop):
      * runtime/ArrayIteratorPrototype.cpp:
      (JSC::ArrayIteratorPrototype::finishCreation):
      (JSC::arrayIteratorPrototypeIterate):
      * runtime/ArrayPrototype.cpp:
      (JSC::ArrayPrototype::create):
      (JSC::ArrayPrototype::finishCreation):
      * runtime/ArrayPrototype.h:
      * runtime/CommonIdentifiers.cpp:
      (JSC::CommonIdentifiers::CommonIdentifiers):
      * runtime/CommonIdentifiers.h:
      * runtime/Identifier.h:
      (JSC::Identifier::from):
      * runtime/JSCJSValue.cpp:
      (JSC::JSValue::dumpInContext):
      * runtime/JSGlobalObject.cpp:
      (JSC::JSGlobalObject::reset):
      * runtime/JSObject.cpp:
      (JSC::JSObject::putDirectNativeFunction):
      * runtime/PrivateName.h:
      (JSC::PrivateName::PrivateName):
      * runtime/PropertyName.h:
      (JSC::PropertyName::PropertyName):
      
      Source/WTF:
      
      Update assertions and add a helper function to StringImpl
      to save repeated unique or identifier calls.
      
      * wtf/text/StringImpl.h:
      (WTF::StringImpl::isIdentifierOrUnique):
      (WTF::StringImpl::setIsIdentifier):
      (WTF::StringImpl::setIsAtomic):
      
      LayoutTests:
      
      Add test cases for the one type that supports for-of so far
      
      * js/basic-for-of-expected.txt: Added.
      * js/basic-for-of.html: Added.
      * js/regress/for-of-iterate-array-entries.html: Added.
      * js/regress/for-of-iterate-array-keys.html: Added.
      * js/regress/for-of-iterate-array-values.html: Added.
      * js/regress/script-tests/for-of-iterate-array-entries.js: Added.
      (foo):
      * js/regress/script-tests/for-of-iterate-array-keys.js: Added.
      (foo):
      * js/regress/script-tests/for-of-iterate-array-values.js: Added.
      (foo):
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156910 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      20a9bf08
  2. 21 May, 2012 1 commit
    • barraclough@apple.com's avatar
      Add support for private names · 6c9b264e
      barraclough@apple.com authored
      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.
      
      
      
      git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117859 268f45cc-cd09-0410-ab3c-d52691b4dbfc
      6c9b264e