コード例 #1
0
void QScriptStaticScopeObject::addSymbolTableProperty(const JSC::Identifier& name, JSC::JSValue value, unsigned attributes)
{
    int index = growRegisterArray(1);
    JSC::SymbolTableEntry newEntry(index, attributes | JSC::DontDelete);
    symbolTable().add(name.ustring().rep(), newEntry);
    registerAt(index) = value;
}
コード例 #2
0
inline bool JSLexicalEnvironment::symbolTablePut(ExecState* exec, PropertyName propertyName, JSValue value, bool shouldThrow)
{
    VM& vm = exec->vm();
    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    
    WriteBarrierBase<Unknown>* reg;
    {
        GCSafeConcurrentJITLocker locker(symbolTable()->m_lock, exec->vm().heap);
        SymbolTable::Map::iterator iter = symbolTable()->find(locker, propertyName.uid());
        if (iter == symbolTable()->end(locker))
            return false;
        ASSERT(!iter->value.isNull());
        if (iter->value.isReadOnly()) {
            if (shouldThrow)
                throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
            return true;
        }
        // Defend against the inspector asking for a var after it has been optimized out.
        if (!isValid(iter->value))
            return false;
        if (VariableWatchpointSet* set = iter->value.watchpointSet())
            set->invalidate(VariableWriteFireDetail(this, propertyName)); // Don't mess around - if we had found this statically, we would have invcalidated it.
        reg = &registerAt(iter->value.getIndex());
    }
    reg->set(vm, this, value);
    return true;
}
コード例 #3
0
void JSGlobalObject::addFunction(ExecState* exec, const Identifier& propertyName, JSValue value)
{
    removeDirect(exec->vm(), propertyName); // Newly declared functions overwrite existing properties.
    NewGlobalVar var = addGlobalVar(propertyName, IsVariable);
    registerAt(var.registerNumber).set(exec->vm(), this, value);
    if (var.set)
        var.set->notifyWrite(value);
}
コード例 #4
0
bool JSVariableObject::symbolTableGet(const Identifier& propertyName, PropertyDescriptor& descriptor)
{
    SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
    if (!entry.isNull()) {
        descriptor.setDescriptor(registerAt(entry.getIndex()).jsValue(), entry.getAttributes() | DontDelete);
        return true;
    }
    return false;
}
コード例 #5
0
inline bool JSActivation::symbolTableGet(const Identifier& propertyName, PropertySlot& slot)
{
    SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
    if (!entry.isNull()) {
        ASSERT(entry.getIndex() < static_cast<int>(d()->functionExecutable->capturedVariableCount()));
        slot.setRegisterSlot(&registerAt(entry.getIndex()));
        return true;
    }
    return false;
}
コード例 #6
0
ファイル: JSActivation.cpp プロジェクト: sysrqb/chromium-src
inline bool JSActivation::symbolTableGet(const Identifier& propertyName, PropertySlot& slot)
{
    SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
    if (entry.isNull())
        return false;
    if (entry.getIndex() >= m_numCapturedVars)
        return false;

    slot.setValue(registerAt(entry.getIndex()).get());
    return true;
}
コード例 #7
0
/*!
    Creates a static scope object with a fixed set of undeletable properties.

    It's not possible to add new properties to the object after construction.
*/
QScriptStaticScopeObject::QScriptStaticScopeObject(WTF::NonNullPassRefPtr<JSC::Structure> structure,
                                                   int propertyCount, const PropertyInfo* props)
    : JSC::JSVariableObject(structure, new Data(/*canGrow=*/false))
{
    int index = growRegisterArray(propertyCount);
    for (int i = 0; i < propertyCount; ++i, --index) {
        const PropertyInfo& prop = props[i];
        JSC::SymbolTableEntry entry(index, prop.attributes);
        symbolTable().add(prop.identifier.ustring().rep(), entry);
        registerAt(index) = prop.value;
    }
}
コード例 #8
0
inline bool JSActivation::symbolTablePut(const Identifier& propertyName, JSValue value)
{
    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    
    SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
    if (entry.isNull())
        return false;
    if (entry.isReadOnly())
        return true;
    ASSERT(entry.getIndex() < static_cast<int>(d()->functionExecutable->capturedVariableCount()));
    registerAt(entry.getIndex()) = value;
    return true;
}
コード例 #9
0
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 (isTornOff() && !isValid(entry))
        return false;

    descriptor.setDescriptor(registerAt(entry.getIndex()).get(), entry.getAttributes());
    return true;
}
コード例 #10
0
inline bool JSLexicalEnvironment::symbolTableGet(PropertyName propertyName, PropertySlot& slot)
{
    SymbolTableEntry entry = symbolTable()->inlineGet(propertyName.uid());
    if (entry.isNull())
        return false;

    // Defend against the inspector asking for a var after it has been optimized out.
    if (!isValid(entry))
        return false;

    slot.setValue(this, DontEnum, registerAt(entry.getIndex()).get());
    return true;
}
コード例 #11
0
inline bool JSLexicalEnvironment::symbolTableGet(PropertyName propertyName, PropertyDescriptor& descriptor)
{
    SymbolTableEntry entry = symbolTable()->inlineGet(propertyName.uid());
    if (entry.isNull())
        return false;

    // Defend against the inspector asking for a var after it has been optimized out.
    if (!isValid(entry))
        return false;

    descriptor.setDescriptor(registerAt(entry.getIndex()).get(), entry.getAttributes());
    return true;
}
コード例 #12
0
inline bool JSActivation::symbolTableGet(PropertyName propertyName, PropertySlot& slot)
{
    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 (isTornOff() && !isValid(entry))
        return false;

    slot.setValue(this, DontEnum, registerAt(entry.getIndex()).get());
    return true;
}
コード例 #13
0
void JSGlobalObject::addStaticGlobals(GlobalPropertyInfo* globals, int count)
{
    addRegisters(count);

    for (int i = 0; i < count; ++i) {
        GlobalPropertyInfo& global = globals[i];
        ASSERT(global.attributes & DontDelete);
        
        int index = symbolTable()->size();
        SymbolTableEntry newEntry(index, global.attributes);
        symbolTable()->add(global.identifier.impl(), newEntry);
        registerAt(index).set(vm(), this, global.value);
    }
}
コード例 #14
0
inline bool JSActivation::symbolTablePutWithAttributes(const Identifier& propertyName, JSValue value, unsigned attributes)
{
    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    
    SymbolTable::iterator iter = symbolTable().find(propertyName.impl());
    if (iter == symbolTable().end())
        return false;
    SymbolTableEntry& entry = iter->second;
    ASSERT(!entry.isNull());
    if (entry.getIndex() >= static_cast<int>(d()->functionExecutable->capturedVariableCount()))
        return false;
    entry.setAttributes(attributes);
    registerAt(entry.getIndex()) = value;
    return true;
}
コード例 #15
0
ファイル: JSActivation.cpp プロジェクト: sysrqb/chromium-src
inline bool JSActivation::symbolTablePut(JSGlobalData& globalData, const Identifier& propertyName, JSValue value)
{
    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    
    SymbolTableEntry entry = symbolTable().inlineGet(propertyName.impl());
    if (entry.isNull())
        return false;
    if (entry.isReadOnly())
        return true;
    if (entry.getIndex() >= m_numCapturedVars)
        return false;

    registerAt(entry.getIndex()).set(globalData, this, value);
    return true;
}
コード例 #16
0
ファイル: JSActivation.cpp プロジェクト: sysrqb/chromium-src
inline bool JSActivation::symbolTablePutWithAttributes(JSGlobalData& globalData, const Identifier& propertyName, JSValue value, unsigned attributes)
{
    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    
    SymbolTable::iterator iter = symbolTable().find(propertyName.impl());
    if (iter == symbolTable().end())
        return false;
    SymbolTableEntry& entry = iter->second;
    ASSERT(!entry.isNull());
    if (entry.getIndex() >= m_numCapturedVars)
        return false;

    entry.setAttributes(attributes);
    registerAt(entry.getIndex()).set(globalData, this, value);
    return true;
}
コード例 #17
0
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.impl());
    if (entry.isNull())
        return false;
    if (entry.isReadOnly()) {
        if (shouldThrow)
            throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
        return true;
    }
    if (m_isTornOff && entry.getIndex() >= m_numCapturedVars)
        return false;

    registerAt(entry.getIndex()).set(globalData, this, value);
    return true;
}
コード例 #18
0
inline bool JSActivation::symbolTablePutWithAttributes(VM& vm, PropertyName propertyName, JSValue value, unsigned attributes)
{
    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    
    WriteBarrierBase<Unknown>* reg;
    {
        ConcurrentJITLocker locker(symbolTable()->m_lock);
        SymbolTable::Map::iterator iter = symbolTable()->find(locker, propertyName.publicName());
        if (iter == symbolTable()->end(locker))
            return false;
        SymbolTableEntry& entry = iter->value;
        ASSERT(!entry.isNull());
        if (!isValid(entry))
            return false;
        
        entry.setAttributes(attributes);
        reg = &registerAt(entry.getIndex());
    }
    reg->set(vm, this, value);
    return true;
}
コード例 #19
0
inline bool JSActivation::symbolTablePut(ExecState* exec, PropertyName propertyName, JSValue value, bool shouldThrow)
{
    VM& vm = exec->vm();
    ASSERT(!Heap::heap(value) || Heap::heap(value) == Heap::heap(this));
    
    SymbolTableEntry entry = symbolTable()->inlineGet(propertyName.publicName());
    if (entry.isNull())
        return false;
    if (entry.isReadOnly()) {
        if (shouldThrow)
            throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
        return true;
    }

    // Defend against the inspector asking for a var after it has been optimized out.
    if (isTornOff() && !isValid(entry))
        return false;

    registerAt(entry.getIndex()).set(vm, this, value);
    return true;
}
コード例 #20
0
ファイル: JNE.cpp プロジェクト: S4H/VipEngine
#include "catch.h"

#include "core.h"
#include "vipglobals.h"
#include "memory.h"

TEST_CASE("JNE INSTRUCTION", "[Engine][Core][Instructions][JNE]") {
    auto m = new Memory();
    auto c = new Core(m);

    SECTION("") {
        *m->codeMemAt(0) = 0x00C;
        *m->codeMemAt(1) = 0x123;

        c->cycle();
        REQUIRE( *(c->registerAt(R0)) == 0x123);
    }

    delete c;
}
コード例 #21
0
ファイル: BCSR.cpp プロジェクト: S4H/VipEngine
#include "catch.h"

#include "core.h"
#include "vipglobals.h"
#include "memory.h"

TEST_CASE("BCSR INSTRUCTION", "[Engine][Core][Instructions][BCSR]") {
    auto m = new Memory();
    auto c = new Core(m);

    SECTION("BCSR") {
        *m->codeMemAt(0) = 0x9EF;
        *c->registerAt(SR) = 0x00F;

        REQUIRE( *c->registerAt(SR) == 0x00F);
        c->cycle();
        REQUIRE( *(c->registerAt(SR)) == 0x000);
    }

    delete c;
}
コード例 #22
0
ファイル: ADDC.cpp プロジェクト: S4H/VipEngine
#include "catch.h"

#include "core.h"
#include "vipglobals.h"
#include "memory.h"

TEST_CASE("ADDC INSTRUCTION", "[Engine][Core][Instructions][ADDC]") {
    auto m = new Memory();
    auto c = new Core(m);

    SECTION("ADDC R0, R0") {
        *c->registerAt(R0) = 0x123;

        *m->codeMemAt(0) = 0x500;

        REQUIRE(*c->registerAt(R0) == 0x123);
        c->cycle();
        REQUIRE( *(c->registerAt(R0)) == 0x246);
    }
    delete c;
}
コード例 #23
0
ファイル: RCN.cpp プロジェクト: S4H/VipEngine
#include "catch.h"

#include "core.h"
#include "vipglobals.h"
#include "memory.h"

TEST_CASE("RCN INSTRUCTION", "[Engine][Core][Instructions][RCN]") {
    auto m = new Memory();
    auto c = new Core(m);

    SECTION("RCN 5") {
        *m->codeMemAt(0) = 0xa73;

        REQUIRE( c->getRCN() == 1);
        c->cycle();
        REQUIRE( c->getRCN() == 3);

        *m->codeMemAt(1) = 0x930;
        *c->registerAt(R0) = 0x010;

        REQUIRE( *c->registerAt(R0) == 0x010);
        c->cycle();
        REQUIRE( *c->registerAt(R0) == 0x080);
    }

    delete c;
}