diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-09-10 19:10:20 +0200 |
commit | 284837daa07b29d6a63a748544a90b1f5842ac5c (patch) | |
tree | ecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/JavaScriptCore/runtime/JSActivation.cpp | |
parent | 2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff) | |
download | qtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz |
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSActivation.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/JSActivation.cpp | 102 |
1 files changed, 72 insertions, 30 deletions
diff --git a/Source/JavaScriptCore/runtime/JSActivation.cpp b/Source/JavaScriptCore/runtime/JSActivation.cpp index 5417b0023..ae403ce46 100644 --- a/Source/JavaScriptCore/runtime/JSActivation.cpp +++ b/Source/JavaScriptCore/runtime/JSActivation.cpp @@ -42,7 +42,13 @@ ASSERT_CLASS_FITS_IN_CELL(JSActivation); const ClassInfo JSActivation::s_info = { "JSActivation", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSActivation) }; JSActivation::JSActivation(CallFrame* callFrame, FunctionExecutable* functionExecutable) - : Base(callFrame->globalData(), callFrame->globalData().activationStructure.get(), functionExecutable->symbolTable(), callFrame->registers()) + : Base( + callFrame->globalData(), + callFrame->lexicalGlobalObject()->activationStructure(), + callFrame->registers(), + callFrame->scope() + ) + , m_registerArray(callFrame->globalData(), this, 0) , m_numCapturedArgs(max(callFrame->argumentCount(), functionExecutable->parameterCount())) , m_numCapturedVars(functionExecutable->capturedVariableCount()) , m_isTornOff(false) @@ -51,20 +57,10 @@ JSActivation::JSActivation(CallFrame* callFrame, FunctionExecutable* functionExe { } -void JSActivation::finishCreation(CallFrame* callFrame) +void JSActivation::finishCreation(CallFrame* callFrame, FunctionExecutable* functionExecutable) { - Base::finishCreation(callFrame->globalData()); + Base::finishCreation(callFrame->globalData(), functionExecutable->symbolTable()); ASSERT(inherits(&s_info)); - - // We have to manually ref and deref the symbol table as JSVariableObject - // doesn't know about SharedSymbolTable - static_cast<SharedSymbolTable*>(m_symbolTable)->ref(); - callFrame->globalData().heap.addFinalizer(this, &finalize); -} - -void JSActivation::finalize(JSCell* cell) -{ - static_cast<SharedSymbolTable*>(jsCast<JSActivation*>(cell)->m_symbolTable)->deref(); } void JSActivation::visitChildren(JSCell* cell, SlotVisitor& visitor) @@ -76,25 +72,27 @@ void JSActivation::visitChildren(JSCell* cell, SlotVisitor& visitor) Base::visitChildren(thisObject, visitor); // No need to mark our registers if they're still in the RegisterFile. - WriteBarrier<Unknown>* registerArray = thisObject->m_registerArray.get(); + PropertyStorage registerArray = thisObject->m_registerArray.get(); if (!registerArray) return; - - visitor.appendValues(registerArray, thisObject->m_numCapturedArgs); - // Skip 'this' and call frame, except for callee and scope chain. - int offset = CallFrame::offsetFor(thisObject->m_numCapturedArgs + 1); - visitor.append(registerArray + offset + RegisterFile::ScopeChain); - visitor.append(registerArray + offset + RegisterFile::Callee); - - visitor.appendValues(registerArray + offset, thisObject->m_numCapturedVars); + visitor.copyAndAppend(bitwise_cast<void**>(®isterArray), thisObject->registerArraySizeInBytes(), reinterpret_cast<JSValue*>(registerArray), thisObject->registerArraySize()); + thisObject->m_registerArray.set(registerArray, StorageBarrier::Unchecked); + thisObject->m_registers = registerArray + thisObject->registerOffset(); + + // Update the arguments object, since it points at our buffer. + CallFrame* callFrame = CallFrame::create(reinterpret_cast<Register*>(thisObject->m_registers)); + if (JSValue v = callFrame->uncheckedR(unmodifiedArgumentsRegister(thisObject->m_argumentsRegister)).jsValue()) + jsCast<Arguments*>(v)->setRegisters(thisObject->m_registers); } inline bool JSActivation::symbolTableGet(PropertyName propertyName, PropertySlot& slot) { - SymbolTableEntry entry = symbolTable().inlineGet(propertyName.publicName()); + SymbolTableEntry entry = symbolTable()->inlineGet(propertyName.publicName()); if (entry.isNull()) return false; + + // Defend against the inspector asking for a var after it has been optimized out. if (m_isTornOff && entry.getIndex() >= m_numCapturedVars) return false; @@ -102,12 +100,26 @@ inline bool JSActivation::symbolTableGet(PropertyName propertyName, PropertySlot return true; } +inline bool JSActivation::symbolTableGet(PropertyName propertyName, PropertyDescriptor& descriptor) +{ + SymbolTableEntry entry = symbolTable()->inlineGet(propertyName.publicName()); + if (entry.isNull()) + return false; + + // Defend against the inspector asking for a var after it has been optimized out. + if (m_isTornOff && entry.getIndex() >= m_numCapturedVars) + return false; + + descriptor.setDescriptor(registerAt(entry.getIndex()).get(), entry.getAttributes()); + return true; +} + inline bool JSActivation::symbolTablePut(ExecState* exec, PropertyName propertyName, JSValue value, bool shouldThrow) { JSGlobalData& globalData = exec->globalData(); ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); - SymbolTableEntry entry = symbolTable().inlineGet(propertyName.publicName()); + SymbolTableEntry entry = symbolTable()->inlineGet(propertyName.publicName()); if (entry.isNull()) return false; if (entry.isReadOnly()) { @@ -115,6 +127,8 @@ inline bool JSActivation::symbolTablePut(ExecState* exec, PropertyName propertyN throwTypeError(exec, StrictModeReadonlyPropertyWriteError); return true; } + + // Defend against the inspector asking for a var after it has been optimized out. if (m_isTornOff && entry.getIndex() >= m_numCapturedVars) return false; @@ -125,8 +139,12 @@ inline bool JSActivation::symbolTablePut(ExecState* exec, PropertyName propertyN void JSActivation::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) { JSActivation* thisObject = jsCast<JSActivation*>(object); - SymbolTable::const_iterator end = thisObject->symbolTable().end(); - for (SymbolTable::const_iterator it = thisObject->symbolTable().begin(); it != end; ++it) { + + if (mode == IncludeDontEnumProperties) + propertyNames.add(exec->propertyNames().arguments); + + SymbolTable::const_iterator end = thisObject->symbolTable()->end(); + for (SymbolTable::const_iterator it = thisObject->symbolTable()->begin(); it != end; ++it) { if (it->second.getAttributes() & DontEnum && mode != IncludeDontEnumProperties) continue; if (it->second.getIndex() >= thisObject->m_numCapturedVars) @@ -141,8 +159,8 @@ inline bool JSActivation::symbolTablePutWithAttributes(JSGlobalData& globalData, { ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this)); - SymbolTable::iterator iter = symbolTable().find(propertyName.publicName()); - if (iter == symbolTable().end()) + SymbolTable::iterator iter = symbolTable()->find(propertyName.publicName()); + if (iter == symbolTable()->end()) return false; SymbolTableEntry& entry = iter->second; ASSERT(!entry.isNull()); @@ -157,9 +175,13 @@ inline bool JSActivation::symbolTablePutWithAttributes(JSGlobalData& globalData, bool JSActivation::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot) { JSActivation* thisObject = jsCast<JSActivation*>(cell); + if (propertyName == exec->propertyNames().arguments) { - slot.setCustom(thisObject, thisObject->getArgumentsGetter()); - return true; + // Defend against the inspector asking for the arguments object after it has been optimized out. + if (!thisObject->m_isTornOff) { + slot.setCustom(thisObject, thisObject->getArgumentsGetter()); + return true; + } } if (thisObject->symbolTableGet(propertyName, slot)) @@ -177,6 +199,26 @@ bool JSActivation::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyNam return false; } +bool JSActivation::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor) +{ + JSActivation* thisObject = jsCast<JSActivation*>(object); + + if (propertyName == exec->propertyNames().arguments) { + // Defend against the inspector asking for the arguments object after it has been optimized out. + if (!thisObject->m_isTornOff) { + PropertySlot slot; + JSActivation::getOwnPropertySlot(thisObject, exec, propertyName, slot); + descriptor.setDescriptor(slot.getValue(exec, propertyName), DontEnum); + return true; + } + } + + if (thisObject->symbolTableGet(propertyName, descriptor)) + return true; + + return Base::getOwnPropertyDescriptor(object, exec, propertyName, descriptor); +} + void JSActivation::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot) { JSActivation* thisObject = jsCast<JSActivation*>(cell); |