Ignore:
Timestamp:
May 23, 2015, 11:41:53 AM (10 years ago)
Author:
Yusuke Suzuki
Message:

Introduce UniquedStringImpl and SymbolImpl to separate symbolic strings from AtomicStringImpl
https://bugs.webkit.org/show_bug.cgi?id=144848

Reviewed by Darin Adler.

Source/JavaScriptCore:

Use UniquedStringImpl, SymbolImpl and AtomicStringImpl.

  • API/JSCallbackObject.h:
  • builtins/BuiltinNames.h:

(JSC::BuiltinNames::isPrivateName):

  • bytecode/BytecodeIntrinsicRegistry.h:
  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::CodeBlock):

  • bytecode/ComplexGetStatus.cpp:

(JSC::ComplexGetStatus::computeFor):

  • bytecode/ComplexGetStatus.h:
  • bytecode/GetByIdStatus.cpp:

(JSC::GetByIdStatus::computeFromLLInt):
(JSC::GetByIdStatus::computeFor):
(JSC::GetByIdStatus::computeForStubInfo):

  • bytecode/GetByIdStatus.h:
  • bytecode/Instruction.h:

(JSC::Instruction::Instruction):

  • bytecode/PutByIdStatus.cpp:

(JSC::PutByIdStatus::computeFromLLInt):
(JSC::PutByIdStatus::computeFor):
(JSC::PutByIdStatus::computeForStubInfo):

  • bytecode/PutByIdStatus.h:
  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::visibleNameForParameter):
(JSC::BytecodeGenerator::hasConstant):
(JSC::BytecodeGenerator::addConstant):

  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/NodesCodegen.cpp:

(JSC::PropertyListNode::emitBytecode):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::parseBlock):
(JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):

  • dfg/DFGDesiredIdentifiers.cpp:

(JSC::DFG::DesiredIdentifiers::addLazily):
(JSC::DFG::DesiredIdentifiers::at):
(JSC::DFG::DesiredIdentifiers::reallyAdd):

  • dfg/DFGDesiredIdentifiers.h:

(JSC::DFG::DesiredIdentifiers::operator[]):

  • dfg/DFGFixupPhase.cpp:

(JSC::DFG::FixupPhase::fixupNode):
(JSC::DFG::FixupPhase::isStringPrototypeMethodSane):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileIn):

  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::SpeculativeJIT::identifierUID):
(JSC::DFG::SpeculativeJIT::callOperation):

  • ftl/FTLCompile.cpp:

(JSC::FTL::mmAllocateDataSection):

  • ftl/FTLInlineCacheDescriptor.h:

(JSC::FTL::InlineCacheDescriptor::InlineCacheDescriptor):
(JSC::FTL::InlineCacheDescriptor::uid):
(JSC::FTL::GetByIdDescriptor::GetByIdDescriptor):
(JSC::FTL::PutByIdDescriptor::PutByIdDescriptor):
(JSC::FTL::CheckInDescriptor::CheckInDescriptor):

  • ftl/FTLIntrinsicRepository.h:
  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::LowerDFGToLLVM::compilePutById):
(JSC::FTL::LowerDFGToLLVM::compileIn):
(JSC::FTL::LowerDFGToLLVM::compileMaterializeCreateActivation):
(JSC::FTL::LowerDFGToLLVM::getById):

  • ftl/FTLOperations.cpp:

(JSC::FTL::operationMaterializeObjectInOSR):

  • ftl/FTLSlowPathCall.cpp:

(JSC::FTL::callOperation):

  • ftl/FTLSlowPathCall.h:
  • jit/JIT.h:
  • jit/JITInlines.h:

(JSC::JIT::callOperation):

  • jit/JITOperations.cpp:
  • jit/JITOperations.h:
  • parser/Nodes.cpp:

(JSC::ProgramNode::setClosedVariables):

  • parser/Nodes.h:

(JSC::ScopeNode::captures):
(JSC::ScopeNode::setClosedVariables):
(JSC::ProgramNode::closedVariables):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseInner):
(JSC::Parser<LexerType>::didFinishParsing):
(JSC::Parser<LexerType>::parseContinueStatement):

  • parser/Parser.h:

(JSC::Scope::Scope):
(JSC::Scope::pushLabel):
(JSC::Scope::getLabel):
(JSC::Scope::declareCallee):
(JSC::Scope::declareVariable):
(JSC::Scope::declareParameter):
(JSC::Scope::declareBoundParameter):
(JSC::Scope::useVariable):
(JSC::Scope::copyCapturedVariablesToVector):
(JSC::Parser::closedVariables):
(JSC::ScopeLabelInfo::ScopeLabelInfo): Deleted.

  • parser/SourceProviderCacheItem.h:

(JSC::SourceProviderCacheItem::usedVariables):
(JSC::SourceProviderCacheItem::writtenVariables):
(JSC::SourceProviderCacheItem::create):

  • runtime/CommonIdentifiers.cpp:

(JSC::CommonIdentifiers::isPrivateName):

  • runtime/CommonIdentifiers.h:
  • runtime/Identifier.h:

(JSC::Identifier::impl):
(JSC::Identifier::Identifier):
(JSC::parseIndex):
(JSC::IdentifierRepHash::hash):

  • runtime/IdentifierInlines.h:

(JSC::Identifier::fromUid):

  • runtime/IntendedStructureChain.cpp:

(JSC::IntendedStructureChain::mayInterceptStoreTo):

  • runtime/IntendedStructureChain.h:
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):

  • runtime/Lookup.h:

(JSC::HashTable::entry):

  • runtime/MapData.h:
  • runtime/ObjectConstructor.cpp:

(JSC::objectConstructorGetOwnPropertySymbols):

  • runtime/PrivateName.h:

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

  • runtime/PropertyMapHashTable.h:
  • runtime/PropertyName.h:

(JSC::PropertyName::PropertyName):
(JSC::PropertyName::uid):
(JSC::PropertyName::publicName):
(JSC::parseIndex):

  • runtime/PropertyNameArray.h:

(JSC::PropertyNameArray::addKnownUnique):
(JSC::PropertyNameArray::add):

  • runtime/Structure.cpp:

(JSC::StructureTransitionTable::contains):
(JSC::StructureTransitionTable::get):
(JSC::StructureTransitionTable::add):
(JSC::Structure::addPropertyTransitionToExistingStructureImpl):
(JSC::Structure::addPropertyTransitionToExistingStructureConcurrently):
(JSC::Structure::getConcurrently):
(JSC::Structure::add):
(JSC::Structure::remove):
(JSC::Structure::toStructureShape):

  • runtime/Structure.h:

(JSC::PropertyMapEntry::PropertyMapEntry):

  • runtime/StructureInlines.h:

(JSC::Structure::getConcurrently):

  • runtime/StructureTransitionTable.h:

(JSC::StructureTransitionTable::Hash::hash):

  • runtime/Symbol.cpp:

(JSC::Symbol::Symbol):

  • runtime/Symbol.h:
  • runtime/SymbolConstructor.cpp:

(JSC::symbolConstructorFor):
(JSC::symbolConstructorKeyFor):

  • runtime/SymbolTable.cpp:

(JSC::SymbolTable::uniqueIDForVariable):
(JSC::SymbolTable::globalTypeSetForVariable):

  • runtime/SymbolTable.h:
  • runtime/TypeSet.cpp:

(JSC::StructureShape::addProperty):
(JSC::StructureShape::propertyHash):

  • runtime/TypeSet.h:

Source/WebCore:

Use UniquedStringImpl, SymbolImpl and AtomicStringImpl.

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::JSDOMWindow::getOwnPropertySlotByIndex):

  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneSerializer::write):

Source/WTF:

he current AtomicStringImpl accidentally means the symbol OR atomic StringImpl.
t's not correct to its name and it's error prone.

In this patch, we'll introduce/changes classes into WTF.

  1. UniquedStringImpl
It's derived class from StringImpl. And it represents symbol
atomic StringImpl.
  1. SymbolImpl

It's derived class from UniquedStringImpl. Only symbol strings can become this.
It ensures the given StringImpl is symbol in compile time.

  1. AtomicStringImpl

It's derived class from UniquedStringImpl. Only atomic (non-normal && non-symbol) strings can become this.
It ensures the given StringImpl is atomic in compile time.

And, in this time, I just accept UniqueStringImpl in AtomicString. As the result,

  1. Now AtomicStringImpl issue is fixed. Its SymbolImpl is separated and UniquedStringImpl is introduced.
  2. But AtomicString still have both symbol and atomic strings.

This should be solved in the separated patch.

  • WTF.vcxproj/WTF.vcxproj:
  • WTF.vcxproj/WTF.vcxproj.filters:
  • WTF.xcodeproj/project.pbxproj:
  • wtf/CMakeLists.txt:
  • wtf/PrintStream.cpp:
  • wtf/PrintStream.h:

(WTF::printInternal):

  • wtf/text/AtomicString.h:

(WTF::AtomicString::AtomicString):

  • wtf/text/AtomicStringImpl.h:
  • wtf/text/StringImpl.cpp:

(WTF::StringImpl::~StringImpl):
(WTF::StringImpl::createSymbol):
(WTF::StringImpl::createSymbolEmpty):

  • wtf/text/StringImpl.h:
  • wtf/text/SymbolImpl.h: Copied from Source/JavaScriptCore/runtime/PrivateName.h.
  • wtf/text/SymbolRegistry.cpp:

(WTF::SymbolRegistry::symbolForKey):
(WTF::SymbolRegistry::keyForSymbol):
(WTF::SymbolRegistry::remove):

  • wtf/text/SymbolRegistry.h:
  • wtf/text/UniquedStringImpl.h: Copied from Source/JavaScriptCore/runtime/PrivateName.h.

Tools:

Use UniquedStringImpl, SymbolImpl and AtomicStringImpl.

  • TestWebKitAPI/Tests/WTF/StringImpl.cpp:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/builtins/BuiltinNames.h

    r182343 r184828  
    3838    const Identifier& name##PrivateName() const { return m_##name##PrivateName; }
    3939
    40 #define INITIALISE_BUILTIN_SYMBOLS(name) INITIALISE_BUILTIN_NAMES(name), m_##name##Symbol(Identifier::fromUid(PrivateName(ASCIILiteral("Symbol." #name))))
     40#define INITIALISE_BUILTIN_SYMBOLS(name) INITIALISE_BUILTIN_NAMES(name), m_##name##Symbol(Identifier::fromUid(PrivateName(PrivateName::Description, ASCIILiteral("Symbol." #name))))
    4141#define DECLARE_BUILTIN_SYMBOLS(name) DECLARE_BUILTIN_NAMES(name) const Identifier m_##name##Symbol;
    4242#define DECLARE_BUILTIN_SYMBOL_ACCESSOR(name) \
     
    6565    }
    6666
    67     bool isPrivateName(StringImpl* uid) const;
     67    bool isPrivateName(SymbolImpl& uid) const;
     68    bool isPrivateName(UniquedStringImpl& uid) const;
    6869    bool isPrivateName(const Identifier&) const;
    6970    const Identifier* getPrivateName(const Identifier&) const;
     
    7980    JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(DECLARE_BUILTIN_NAMES)
    8081    JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(DECLARE_BUILTIN_SYMBOLS)
    81     typedef HashMap<RefPtr<StringImpl>, const Identifier*, IdentifierRepHash> BuiltinNamesMap;
     82    typedef HashMap<RefPtr<UniquedStringImpl>, const Identifier*, IdentifierRepHash> BuiltinNamesMap;
    8283    BuiltinNamesMap m_publicToPrivateMap;
    8384    BuiltinNamesMap m_privateToPublicMap;
     
    9192#undef DECLARE_BUILTIN_SYMBOL_ACCESSOR
    9293
    93 inline bool BuiltinNames::isPrivateName(StringImpl* uid) const
     94inline bool BuiltinNames::isPrivateName(SymbolImpl& uid) const
    9495{
    95     if (!uid->isSymbol())
     96    return m_privateToPublicMap.contains(&uid);
     97}
     98
     99inline bool BuiltinNames::isPrivateName(UniquedStringImpl& uid) const
     100{
     101    if (!uid.isSymbol())
    96102        return false;
    97     return m_privateToPublicMap.contains(uid);
     103    return m_privateToPublicMap.contains(&uid);
    98104}
    99105
    100106inline bool BuiltinNames::isPrivateName(const Identifier& ident) const
    101107{
    102     return isPrivateName(ident.impl());
     108    if (ident.isNull())
     109        return false;
     110    return isPrivateName(*ident.impl());
    103111}
    104112
Note: See TracChangeset for help on using the changeset viewer.