Ignore:
Timestamp:
Jul 24, 2013, 8:59:04 PM (12 years ago)
Author:
[email protected]
Message:

fourthTier: SymbolTable should be thread-safe
https://bugs.webkit.org/show_bug.cgi?id=115301

Reviewed by Geoffrey Garen.

Makes SymbolTable thread-safe. Relies on SymbolTableEntry already being immutable,
other than the WatchpointSet; but the WatchpointSet already has a righteous
concurrency protocol. So, this patch just protects the SymbolTable's HashMap.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::nameForRegister):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::addVar):

  • runtime/Executable.cpp:

(JSC::ProgramExecutable::addGlobalVar):

  • runtime/JSActivation.cpp:

(JSC::JSActivation::getOwnNonIndexPropertyNames):
(JSC::JSActivation::symbolTablePutWithAttributes):

  • runtime/JSSymbolTableObject.cpp:

(JSC::JSSymbolTableObject::getOwnNonIndexPropertyNames):

  • runtime/JSSymbolTableObject.h:

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

  • runtime/SymbolTable.cpp:

(JSC::SymbolTable::SymbolTable):
(JSC::SymbolTable::~SymbolTable):

  • runtime/SymbolTable.h:

(JSC::SymbolTable::find):
(JSC::SymbolTable::get):
(JSC::SymbolTable::inlineGet):
(JSC::SymbolTable::begin):
(JSC::SymbolTable::end):
(JSC::SymbolTable::size):
(JSC::SymbolTable::add):
(JSC::SymbolTable::set):
(JSC::SymbolTable::contains):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSActivation.cpp

    r148696 r153132  
    114114        propertyNames.add(exec->propertyNames().arguments);
    115115
    116     SymbolTable::const_iterator end = thisObject->symbolTable()->end();
    117     for (SymbolTable::const_iterator it = thisObject->symbolTable()->begin(); it != end; ++it) {
    118         if (it->value.getAttributes() & DontEnum && mode != IncludeDontEnumProperties)
    119             continue;
    120         if (!thisObject->isValid(it->value))
    121             continue;
    122         propertyNames.add(Identifier(exec, it->key.get()));
     116    {
     117        SymbolTable::Locker locker(thisObject->symbolTable()->m_lock);
     118        SymbolTable::Map::iterator end = thisObject->symbolTable()->end(locker);
     119        for (SymbolTable::Map::iterator it = thisObject->symbolTable()->begin(locker); it != end; ++it) {
     120            if (it->value.getAttributes() & DontEnum && mode != IncludeDontEnumProperties)
     121                continue;
     122            if (!thisObject->isValid(it->value))
     123                continue;
     124            propertyNames.add(Identifier(exec, it->key.get()));
     125        }
    123126    }
    124127    // Skip the JSVariableObject implementation of getOwnNonIndexPropertyNames
     
    130133    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    131134   
    132     SymbolTable::iterator iter = symbolTable()->find(propertyName.publicName());
    133     if (iter == symbolTable()->end())
    134         return false;
    135     SymbolTableEntry& entry = iter->value;
    136     ASSERT(!entry.isNull());
    137     if (!isValid(entry))
    138         return false;
    139 
    140     entry.setAttributes(attributes);
    141     registerAt(entry.getIndex()).set(vm, this, value);
     135    WriteBarrierBase<Unknown>* reg;
     136    {
     137        SymbolTable::Locker locker(symbolTable()->m_lock);
     138        SymbolTable::Map::iterator iter = symbolTable()->find(locker, propertyName.publicName());
     139        if (iter == symbolTable()->end(locker))
     140            return false;
     141        SymbolTableEntry& entry = iter->value;
     142        ASSERT(!entry.isNull());
     143        if (!isValid(entry))
     144            return false;
     145       
     146        entry.setAttributes(attributes);
     147        reg = &registerAt(entry.getIndex());
     148    }
     149    reg->set(vm, this, value);
    142150    return true;
    143151}
Note: See TracChangeset for help on using the changeset viewer.