aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-30 15:41:24 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-02 16:07:33 +0200
commit1e454c8aa6ad0782eee1c8c94ac2780954a08351 (patch)
treee3be185e878972ff018e9610fea15248877ca499 /src
parent430dfd326cb9d8dab8ebd11e83dd52e6d55c4229 (diff)
Remove more uses of Value
Change-Id: I889e760f75b485a28e1f2a2c26b2337ae9bfafac Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/compiler/qv4compileddata.cpp7
-rw-r--r--src/qml/compiler/qv4compileddata_p.h2
-rw-r--r--src/qml/compiler/qv4instr_moth_p.h4
-rw-r--r--src/qml/compiler/qv4isel_masm.cpp36
-rw-r--r--src/qml/compiler/qv4isel_masm_p.h24
-rw-r--r--src/qml/compiler/qv4isel_moth_p.h2
-rw-r--r--src/qml/compiler/qv4isel_util_p.h4
-rw-r--r--src/qml/compiler/qv4ssa.cpp8
-rw-r--r--src/qml/jsruntime/qv4context.cpp31
-rw-r--r--src/qml/jsruntime/qv4context_p.h12
-rw-r--r--src/qml/jsruntime/qv4dateobject_p.h8
-rw-r--r--src/qml/jsruntime/qv4debugging.cpp33
-rw-r--r--src/qml/jsruntime/qv4debugging_p.h2
-rw-r--r--src/qml/jsruntime/qv4engine.cpp6
-rw-r--r--src/qml/jsruntime/qv4engine_p.h4
-rw-r--r--src/qml/jsruntime/qv4exception.cpp8
-rw-r--r--src/qml/jsruntime/qv4exception_gcc.cpp3
-rw-r--r--src/qml/jsruntime/qv4exception_p.h6
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp8
-rw-r--r--src/qml/jsruntime/qv4functionobject_p.h6
-rw-r--r--src/qml/jsruntime/qv4object.cpp4
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp2
-rw-r--r--src/qml/jsruntime/qv4property_p.h2
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp4
-rw-r--r--src/qml/jsruntime/qv4value_def_p.h2
-rw-r--r--src/qml/jsruntime/qv4value_p.h4
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp2
27 files changed, 118 insertions, 116 deletions
diff --git a/src/qml/compiler/qv4compileddata.cpp b/src/qml/compiler/qv4compileddata.cpp
index 4139a7ee0d..5c1c41814d 100644
--- a/src/qml/compiler/qv4compileddata.cpp
+++ b/src/qml/compiler/qv4compileddata.cpp
@@ -81,9 +81,9 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine)
for (int i = 0; i < data->stringTableSize; ++i)
runtimeStrings[i] = engine->newIdentifier(data->stringAt(i));
- runtimeRegularExpressions = new QV4::Value[data->regexpTableSize];
+ runtimeRegularExpressions = new QV4::SafeValue[data->regexpTableSize];
// memset the regexps to 0 in case a GC run happens while we're within the loop below
- memset(runtimeRegularExpressions, 0, data->regexpTableSize * sizeof(QV4::Value));
+ memset(runtimeRegularExpressions, 0, data->regexpTableSize * sizeof(QV4::SafeValue));
for (int i = 0; i < data->regexpTableSize; ++i) {
const CompiledData::RegExp *re = data->regexpAt(i);
int flags = 0;
@@ -93,8 +93,7 @@ QV4::Function *CompilationUnit::linkToEngine(ExecutionEngine *engine)
flags |= QQmlJS::V4IR::RegExp::RegExp_IgnoreCase;
if (re->flags & CompiledData::RegExp::RegExp_Multiline)
flags |= QQmlJS::V4IR::RegExp::RegExp_Multiline;
- QV4::RegExpObject *obj = engine->newRegExpObject(data->stringAt(re->stringIndex), flags)->getPointer();
- runtimeRegularExpressions[i] = QV4::Value::fromObject(obj);
+ runtimeRegularExpressions[i] = engine->newRegExpObject(data->stringAt(re->stringIndex), flags);
}
if (data->lookupTableSize) {
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index 5159ac5a06..6784707607 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -467,7 +467,7 @@ struct Q_QML_EXPORT CompilationUnit
QV4::SafeString *runtimeStrings; // Array
QV4::Lookup *runtimeLookups;
- QV4::Value *runtimeRegularExpressions;
+ QV4::SafeValue *runtimeRegularExpressions;
QV4::InternalClass **runtimeClasses;
QVector<QV4::Function *> runtimeFunctions;
// QVector<QV4::Function *> runtimeFunctionsSortedByAddress;
diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h
index 100b6f65a6..f8ccfff92f 100644
--- a/src/qml/compiler/qv4instr_moth_p.h
+++ b/src/qml/compiler/qv4instr_moth_p.h
@@ -130,7 +130,7 @@ struct Param {
TempType = 3,
ScopedLocalType = 4
};
- QV4::Value value;
+ QV4::Primitive value;
unsigned type : 3;
unsigned scope : 29;
unsigned index;
@@ -141,7 +141,7 @@ struct Param {
bool isTemp() const { return type == TempType; }
bool isScopedLocal() const { return type == ScopedLocalType; }
- static Param createValue(const QV4::Value &v)
+ static Param createValue(const QV4::Primitive &v)
{
Param p;
p.type = ValueType;
diff --git a/src/qml/compiler/qv4isel_masm.cpp b/src/qml/compiler/qv4isel_masm.cpp
index b7ce1cc86e..6dabbce5f8 100644
--- a/src/qml/compiler/qv4isel_masm.cpp
+++ b/src/qml/compiler/qv4isel_masm.cpp
@@ -280,12 +280,12 @@ Assembler::Pointer Assembler::loadTempAddress(RegisterID reg, V4IR::Temp *t)
case V4IR::Temp::Formal:
case V4IR::Temp::ScopedFormal: {
loadPtr(Address(context, qOffsetOf(CallContext, callData)), reg);
- offset = sizeof(CallData) + (t->index - 1) * sizeof(Value);
+ offset = sizeof(CallData) + (t->index - 1) * sizeof(SafeValue);
} break;
case V4IR::Temp::Local:
case V4IR::Temp::ScopedLocal: {
loadPtr(Address(context, qOffsetOf(CallContext, locals)), reg);
- offset = t->index * sizeof(Value);
+ offset = t->index * sizeof(SafeValue);
} break;
case V4IR::Temp::StackSlot: {
return stackSlotPointer(t);
@@ -351,14 +351,14 @@ void Assembler::copyValue(Result result, V4IR::Expr* source)
storeDouble(FPGpr0, result);
#endif
} else if (V4IR::Const *c = source->asConst()) {
- QV4::Value v = convertToValue(c);
+ QV4::Primitive v = convertToValue(c);
storeValue(v, result);
} else {
Q_UNREACHABLE();
}
}
-void Assembler::storeValue(QV4::Value value, V4IR::Temp* destination)
+void Assembler::storeValue(QV4::Primitive value, V4IR::Temp* destination)
{
Address addr = loadTempAddress(ScratchRegister, destination);
storeValue(value, addr);
@@ -664,7 +664,7 @@ void InstructionSelection::run(int functionIndex)
const int locals = _as->stackLayout().calculateJSStackFrameSize();
_as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext, engine)), Assembler::ScratchRegister);
_as->loadPtr(Address(Assembler::ScratchRegister, qOffsetOf(ExecutionEngine, jsStackTop)), Assembler::LocalsRegister);
- _as->addPtr(Assembler::TrustedImm32(sizeof(QV4::Value)*locals), Assembler::LocalsRegister);
+ _as->addPtr(Assembler::TrustedImm32(sizeof(QV4::SafeValue)*locals), Assembler::LocalsRegister);
_as->storePtr(Assembler::LocalsRegister, Address(Assembler::ScratchRegister, qOffsetOf(ExecutionEngine, jsStackTop)));
for (int i = 0, ei = _function->basicBlocks.size(); i != ei; ++i) {
@@ -1189,19 +1189,19 @@ void InstructionSelection::swapValues(V4IR::Temp *sourceTemp, V4IR::Temp *target
_as->load32(addr, Assembler::ScratchRegister);
_as->store32((Assembler::RegisterID) registerTemp->index, addr);
addr.offset += 4;
- QV4::Value tag;
+ quint32 tag;
switch (registerTemp->type) {
case V4IR::BoolType:
- tag = QV4::Primitive::fromBoolean(false);
+ tag = QV4::Value::_Boolean_Type;
break;
case V4IR::SInt32Type:
- tag = QV4::Primitive::fromInt32(0);
+ tag = QV4::Value::_Integer_Type;
break;
default:
- tag = QV4::Primitive::undefinedValue();
+ tag = QV4::Value::Undefined_Type;
Q_UNREACHABLE();
}
- _as->store32(Assembler::TrustedImm32(tag.tag), addr);
+ _as->store32(Assembler::TrustedImm32(tag), addr);
_as->move(Assembler::ScratchRegister, (Assembler::RegisterID) registerTemp->index);
}
}
@@ -1774,19 +1774,19 @@ void InstructionSelection::visitRet(V4IR::Ret *s)
} else {
_as->zeroExtend32ToPtr((Assembler::RegisterID) t->index,
Assembler::ReturnValueRegister);
- QV4::Value upper;
+ quint64 tag;
switch (t->type) {
case V4IR::SInt32Type:
- upper = QV4::Primitive::fromInt32(0);
+ tag = QV4::Value::_Integer_Type;
break;
case V4IR::BoolType:
- upper = QV4::Primitive::fromBoolean(false);
+ tag = QV4::Value::_Boolean_Type;
break;
default:
- upper = QV4::Primitive::undefinedValue();
+ tag = QV4::Value::Undefined_Type;
Q_UNREACHABLE();
}
- _as->or64(Assembler::TrustedImm64(((int64_t) upper.tag) << 32),
+ _as->or64(Assembler::TrustedImm64(tag << 32),
Assembler::ReturnValueRegister);
}
} else {
@@ -1794,7 +1794,7 @@ void InstructionSelection::visitRet(V4IR::Ret *s)
}
#endif
} else if (V4IR::Const *c = s->expr->asConst()) {
- QV4::Value retVal = convertToValue(c);
+ QV4::Primitive retVal = convertToValue(c);
#if CPU(X86)
_as->move(Assembler::TrustedImm32(retVal.int_32), JSC::X86Registers::eax);
_as->move(Assembler::TrustedImm32(retVal.tag), JSC::X86Registers::edx);
@@ -1810,7 +1810,7 @@ void InstructionSelection::visitRet(V4IR::Ret *s)
}
const int locals = _as->stackLayout().calculateJSStackFrameSize();
- _as->subPtr(Assembler::TrustedImm32(sizeof(QV4::Value)*locals), Assembler::LocalsRegister);
+ _as->subPtr(Assembler::TrustedImm32(sizeof(QV4::SafeValue)*locals), Assembler::LocalsRegister);
_as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext, engine)), Assembler::ScratchRegister);
_as->storePtr(Assembler::LocalsRegister, Address(Assembler::ScratchRegister, qOffsetOf(ExecutionEngine, jsStackTop)));
@@ -1847,7 +1847,7 @@ int InstructionSelection::prepareCallData(V4IR::ExprList* args, V4IR::Expr *this
}
Pointer p = _as->stackLayout().callDataAddress(qOffsetOf(CallData, tag));
- _as->store32(Assembler::TrustedImm32(QV4::Value::Integer_Type), p);
+ _as->store32(Assembler::TrustedImm32(QV4::Value::_Integer_Type), p);
p = _as->stackLayout().callDataAddress(qOffsetOf(CallData, argc));
_as->store32(Assembler::TrustedImm32(argc), p);
p = _as->stackLayout().callDataAddress(qOffsetOf(CallData, thisObject));
diff --git a/src/qml/compiler/qv4isel_masm_p.h b/src/qml/compiler/qv4isel_masm_p.h
index fd84b03b77..20b0c1b7e8 100644
--- a/src/qml/compiler/qv4isel_masm_p.h
+++ b/src/qml/compiler/qv4isel_masm_p.h
@@ -323,8 +323,8 @@ public:
int calculateJSStackFrameSize() const
{
- const int locals = (localCount + sizeof(QV4::CallData)/sizeof(QV4::Value) - 1 + maxOutgoingArgumentCount) + 1;
- int frameSize = locals * sizeof(QV4::Value);
+ const int locals = (localCount + sizeof(QV4::CallData)/sizeof(QV4::SafeValue) - 1 + maxOutgoingArgumentCount) + 1;
+ int frameSize = locals * sizeof(QV4::SafeValue);
return frameSize;
}
@@ -334,7 +334,7 @@ public:
Q_ASSERT(idx < localCount);
Pointer addr = callDataAddress(0);
- addr.offset -= sizeof(QV4::Value) * (idx + 1);
+ addr.offset -= sizeof(QV4::SafeValue) * (idx + 1);
return addr;
}
@@ -346,11 +346,11 @@ public:
Q_ASSERT(argument < maxOutgoingArgumentCount);
const int index = maxOutgoingArgumentCount - argument;
- return Pointer(Assembler::LocalsRegister, sizeof(QV4::Value) * (-index));
+ return Pointer(Assembler::LocalsRegister, sizeof(QV4::SafeValue) * (-index));
}
Pointer callDataAddress(int offset = 0) const {
- return Pointer(Assembler::LocalsRegister, -(sizeof(QV4::CallData) + sizeof(QV4::Value) * (maxOutgoingArgumentCount - 1)) + offset);
+ return Pointer(Assembler::LocalsRegister, -(sizeof(QV4::CallData) + sizeof(QV4::SafeValue) * (maxOutgoingArgumentCount - 1)) + offset);
}
Address savedRegPointer(int offset) const
@@ -358,7 +358,7 @@ public:
Q_ASSERT(offset >= 0);
Q_ASSERT(offset < savedRegCount);
- const int off = offset * sizeof(QV4::Value);
+ const int off = offset * sizeof(QV4::SafeValue);
return Address(Assembler::StackFrameRegister, - calleeSavedRegisterSpace() - off);
}
@@ -610,7 +610,7 @@ public:
void storeUInt32ReturnValue(RegisterID dest)
{
- Pointer tmp(StackPointerRegister, -int(sizeof(QV4::Value)));
+ Pointer tmp(StackPointerRegister, -int(sizeof(QV4::SafeValue)));
storeReturnValue(tmp);
toUInt32Register(tmp, dest);
}
@@ -622,7 +622,7 @@ public:
xor64(ScratchRegister, ReturnValueRegister);
move64ToDouble(ReturnValueRegister, dest);
#else
- Pointer tmp(StackPointerRegister, -int(sizeof(QV4::Value)));
+ Pointer tmp(StackPointerRegister, -int(sizeof(QV4::SafeValue)));
storeReturnValue(tmp);
loadDouble(tmp, dest);
#endif
@@ -817,14 +817,14 @@ public:
JSC::MacroAssembler::storeDouble(FPGpr0, target);
}
- void storeValue(QV4::Value value, RegisterID destination)
+ void storeValue(QV4::Primitive value, RegisterID destination)
{
Q_UNUSED(value);
Q_UNUSED(destination);
Q_UNREACHABLE();
}
- void storeValue(QV4::Value value, Address destination)
+ void storeValue(QV4::Primitive value, Address destination)
{
#ifdef VALUE_FITS_IN_REGISTER
store64(TrustedImm64(value.val), destination);
@@ -835,7 +835,7 @@ public:
#endif
}
- void storeValue(QV4::Value value, V4IR::Temp* temp);
+ void storeValue(QV4::Primitive value, V4IR::Temp* temp);
void enterStandardStackFrame();
void leaveStandardStackFrame();
@@ -1120,7 +1120,7 @@ public:
Address tagAddr = addr;
tagAddr.offset += 4;
- QV4::Value v = convertToValue(c);
+ QV4::Primitive v = convertToValue(c);
store32(TrustedImm32(v.int_32), addr);
store32(TrustedImm32(v.tag), tagAddr);
return Pointer(addr);
diff --git a/src/qml/compiler/qv4isel_moth_p.h b/src/qml/compiler/qv4isel_moth_p.h
index 8482e358e2..ca03c5fa30 100644
--- a/src/qml/compiler/qv4isel_moth_p.h
+++ b/src/qml/compiler/qv4isel_moth_p.h
@@ -154,7 +154,7 @@ private:
int scratchTempIndex() const { return _function->tempCount; }
int callDataStart() const { return scratchTempIndex() + 1; }
- int outgoingArgumentTempStart() const { return callDataStart() + qOffsetOf(QV4::CallData, args)/sizeof(QV4::Value); }
+ int outgoingArgumentTempStart() const { return callDataStart() + qOffsetOf(QV4::CallData, args)/sizeof(QV4::SafeValue); }
int frameSize() const { return outgoingArgumentTempStart() + _function->maxNumberOfArguments; }
template <int Instr>
diff --git a/src/qml/compiler/qv4isel_util_p.h b/src/qml/compiler/qv4isel_util_p.h
index 12a606e70c..5084de8ec9 100644
--- a/src/qml/compiler/qv4isel_util_p.h
+++ b/src/qml/compiler/qv4isel_util_p.h
@@ -63,11 +63,11 @@ inline bool canConvertToUnsignedInteger(double value)
return uval == value && !(value == 0 && isNegative(value));
}
-inline QV4::Value convertToValue(V4IR::Const *c)
+inline QV4::Primitive convertToValue(V4IR::Const *c)
{
switch (c->type) {
case V4IR::MissingType:
- return QV4::Value::emptyValue();
+ return QV4::Primitive::emptyValue();
case V4IR::NullType:
return QV4::Primitive::nullValue();
case V4IR::UndefinedType:
diff --git a/src/qml/compiler/qv4ssa.cpp b/src/qml/compiler/qv4ssa.cpp
index 3d6cd442fd..deadf471ea 100644
--- a/src/qml/compiler/qv4ssa.cpp
+++ b/src/qml/compiler/qv4ssa.cpp
@@ -2223,8 +2223,8 @@ bool tryOptimizingComparison(Expr *&expr)
if (!rightConst || rightConst->type == StringType || rightConst->type == VarType)
return false;
- QV4::Value l = convertToValue(leftConst);
- QV4::Value r = convertToValue(rightConst);
+ QV4::Primitive l = convertToValue(leftConst);
+ QV4::Primitive r = convertToValue(rightConst);
switch (b->op) {
case OpGt:
@@ -2439,8 +2439,8 @@ void optimizeSSA(Function *function, DefUsesCalculator &defUses)
if (!rightConst || rightConst->type == StringType || rightConst->type == VarType)
continue;
- QV4::Value lc = convertToValue(leftConst);
- QV4::Value rc = convertToValue(rightConst);
+ QV4::Primitive lc = convertToValue(leftConst);
+ QV4::Primitive rc = convertToValue(rightConst);
double l = __qmljs_to_number(&lc);
double r = __qmljs_to_number(&rc);
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index f229ad6742..9dc5e2fe53 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -51,7 +51,7 @@
using namespace QV4;
-CallContext *ExecutionContext::newCallContext(void *stackSpace, Value *locals, FunctionObject *function, CallData *callData)
+CallContext *ExecutionContext::newCallContext(void *stackSpace, SafeValue *locals, FunctionObject *function, CallData *callData)
{
CallContext *c = (CallContext *)stackSpace;
#ifndef QT_NO_DEBUG
@@ -121,13 +121,13 @@ CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData
c->lookups = c->compilationUnit->runtimeLookups;
}
- c->locals = (Value *)(c + 1);
+ c->locals = (SafeValue *)(c + 1);
if (function->varCount)
std::fill(c->locals, c->locals + function->varCount, Primitive::undefinedValue());
c->callData = reinterpret_cast<CallData *>(c->locals + function->varCount);
- ::memcpy(c->callData, callData, sizeof(CallData) + (callData->argc - 1) * sizeof(Value));
+ ::memcpy(c->callData, callData, sizeof(CallData) + (callData->argc - 1) * sizeof(SafeValue));
if (callData->argc < function->formalParameterCount)
std::fill(c->callData->args + c->callData->argc, c->callData->args + function->formalParameterCount, Primitive::undefinedValue());
c->callData->argc = qMax((uint)callData->argc, function->formalParameterCount);
@@ -143,7 +143,7 @@ WithContext *ExecutionContext::newWithContext(ObjectRef with)
return w;
}
-CatchContext *ExecutionContext::newCatchContext(String *exceptionVarName, const Value &exceptionValue)
+CatchContext *ExecutionContext::newCatchContext(const StringRef exceptionVarName, const ValueRef exceptionValue)
{
CatchContext *c = static_cast<CatchContext *>(engine->memoryManager->allocContext(sizeof(CatchContext)));
engine->current = c;
@@ -214,9 +214,9 @@ void GlobalContext::initGlobalContext(ExecutionEngine *eng)
{
initBaseContext(Type_GlobalContext, eng, /*parentContext*/0);
callData = reinterpret_cast<CallData *>(this + 1);
- callData->tag = QV4::Value::Integer_Type;
+ callData->tag = QV4::Value::_Integer_Type;
callData->argc = 0;
- callData->thisObject = Value::fromObject(eng->globalObject);
+ callData->thisObject = eng->globalObject;
global = 0;
}
@@ -231,7 +231,7 @@ void WithContext::initWithContext(ExecutionContext *p, ObjectRef with)
withObject = with.getPointer();
}
-void CatchContext::initCatchContext(ExecutionContext *p, String *exceptionVarName, const Value &exceptionValue)
+void CatchContext::initCatchContext(ExecutionContext *p, const StringRef exceptionVarName, const ValueRef exceptionValue)
{
initBaseContext(Type_CatchContext, p->engine, p);
strictMode = p->strictMode;
@@ -268,7 +268,7 @@ void CallContext::initQmlContext(ExecutionContext *parentContext, ObjectRef qml,
lookups = compilationUnit->runtimeLookups;
}
- locals = (Value *)(this + 1);
+ locals = (SafeValue *)(this + 1);
if (function->varCount)
std::fill(locals, locals + function->varCount, Primitive::undefinedValue());
}
@@ -286,7 +286,7 @@ bool ExecutionContext::deleteProperty(const StringRef name)
return w->withObject->deleteProperty(name);
} else if (ctx->type == Type_CatchContext) {
CatchContext *c = static_cast<CatchContext *>(ctx);
- if (c->exceptionVarName->isEqualTo(name))
+ if (c->exceptionVarName->stringValue()->isEqualTo(name))
return false;
} else if (ctx->type >= Type_CallContext) {
CallContext *c = static_cast<CallContext *>(ctx);
@@ -343,8 +343,7 @@ void ExecutionContext::mark()
w->withObject->mark();
} else if (type == Type_CatchContext) {
CatchContext *c = static_cast<CatchContext *>(this);
- if (c->exceptionVarName)
- c->exceptionVarName->mark();
+ c->exceptionVarName->mark();
c->exceptionValue.mark();
} else if (type == Type_GlobalContext) {
GlobalContext *g = static_cast<GlobalContext *>(this);
@@ -362,7 +361,7 @@ void ExecutionContext::setProperty(const StringRef name, const ValueRef value)
w->put(name, value);
return;
}
- } else if (ctx->type == Type_CatchContext && static_cast<CatchContext *>(ctx)->exceptionVarName->isEqualTo(name)) {
+ } else if (ctx->type == Type_CatchContext && static_cast<CatchContext *>(ctx)->exceptionVarName->stringValue()->isEqualTo(name)) {
static_cast<CatchContext *>(ctx)->exceptionValue = *value;
return;
} else {
@@ -423,7 +422,7 @@ ReturnedValue ExecutionContext::getProperty(const StringRef name)
else if (ctx->type == Type_CatchContext) {
hasCatchScope = true;
CatchContext *c = static_cast<CatchContext *>(ctx);
- if (c->exceptionVarName->isEqualTo(name))
+ if (c->exceptionVarName->stringValue()->isEqualTo(name))
return c->exceptionValue.asReturnedValue();
}
@@ -488,7 +487,7 @@ ReturnedValue ExecutionContext::getPropertyNoThrow(const StringRef name)
else if (ctx->type == Type_CatchContext) {
hasCatchScope = true;
CatchContext *c = static_cast<CatchContext *>(ctx);
- if (c->exceptionVarName->isEqualTo(name))
+ if (c->exceptionVarName->stringValue()->isEqualTo(name))
return c->exceptionValue.asReturnedValue();
}
@@ -553,7 +552,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, ObjectR
else if (ctx->type == Type_CatchContext) {
hasCatchScope = true;
CatchContext *c = static_cast<CatchContext *>(ctx);
- if (c->exceptionVarName->isEqualTo(name))
+ if (c->exceptionVarName->stringValue()->isEqualTo(name))
return c->exceptionValue.asReturnedValue();
}
@@ -579,7 +578,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, ObjectR
}
if (f->function && f->function->isNamedExpression()
&& name->isEqualTo(f->function->name))
- return Value::fromObject(c->function).asReturnedValue();
+ return c->function->asReturnedValue();
}
else if (ctx->type == Type_GlobalContext) {
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index 7f9ef77b40..d368dc6c81 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -112,10 +112,10 @@ struct Q_QML_EXPORT ExecutionContext
interpreterInstructionPointer = 0;
}
- CallContext *newCallContext(void *stackSpace, Value *locals, FunctionObject *f, CallData *callData);
+ CallContext *newCallContext(void *stackSpace, SafeValue *locals, FunctionObject *f, CallData *callData);
CallContext *newCallContext(FunctionObject *f, CallData *callData);
WithContext *newWithContext(ObjectRef with);
- CatchContext *newCatchContext(String* exceptionVarName, const QV4::Value &exceptionValue);
+ CatchContext *newCatchContext(const StringRef exceptionVarName, const ValueRef exceptionValue);
CallContext *newQmlContext(FunctionObject *f, ObjectRef qml);
String * const *formals() const;
@@ -163,7 +163,7 @@ struct CallContext : public SimpleCallContext
void initQmlContext(ExecutionContext *parentContext, ObjectRef qml, QV4::FunctionObject *function);
bool needsOwnArguments() const;
- Value *locals;
+ SafeValue *locals;
Object *activation;
};
@@ -176,10 +176,10 @@ struct GlobalContext : public ExecutionContext
struct CatchContext : public ExecutionContext
{
- void initCatchContext(ExecutionContext *p, String *exceptionVarName, const QV4::Value &exceptionValue);
+ void initCatchContext(ExecutionContext *p, const StringRef exceptionVarName, const ValueRef exceptionValue);
- String *exceptionVarName;
- Value exceptionValue;
+ SafeString exceptionVarName;
+ SafeValue exceptionValue;
};
struct WithContext : public ExecutionContext
diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h
index 56588580ff..5cd03024c5 100644
--- a/src/qml/jsruntime/qv4dateobject_p.h
+++ b/src/qml/jsruntime/qv4dateobject_p.h
@@ -53,19 +53,21 @@ namespace QV4 {
struct DateObject: Object {
Q_MANAGED
- Value value;
- DateObject(ExecutionEngine *engine, const Value &value): Object(engine->dateClass), value(value) {
+ SafeValue value;
+ DateObject(ExecutionEngine *engine, const ValueRef date): Object(engine->dateClass) {
vtbl = &static_vtbl;
type = Type_DateObject;
+ value = date;
}
DateObject(ExecutionEngine *engine, const QDateTime &value);
QDateTime toQDateTime() const;
protected:
- DateObject(InternalClass *ic): Object(ic), value(Primitive::fromDouble(qSNaN())) {
+ DateObject(InternalClass *ic): Object(ic) {
vtbl = &static_vtbl;
type = Type_DateObject;
+ value = Primitive::fromDouble(qSNaN());
}
};
diff --git a/src/qml/jsruntime/qv4debugging.cpp b/src/qml/jsruntime/qv4debugging.cpp
index f95178c8f7..41ed34ea18 100644
--- a/src/qml/jsruntime/qv4debugging.cpp
+++ b/src/qml/jsruntime/qv4debugging.cpp
@@ -172,7 +172,7 @@ void Debugger::maybeBreakAtInstruction(const uchar *code, bool breakPointHit)
applyPendingBreakPoints();
}
-void Debugger::aboutToThrow(const QV4::Value &value)
+void Debugger::aboutToThrow(const QV4::ValueRef value)
{
qDebug() << "*** We are about to throw...";
}
@@ -205,43 +205,43 @@ void Debugger::applyPendingBreakPoints()
m_havePendingBreakPoints = false;
}
-static void realDumpValue(QV4::Value v, QV4::ExecutionContext *ctx, std::string prefix)
+static void realDumpValue(const QV4::ValueRef v, QV4::ExecutionContext *ctx, std::string prefix)
{
using namespace QV4;
using namespace std;
Scope scope(ctx);
- cout << prefix << "tag: " << hex << v.tag << dec << endl << prefix << "\t-> ";
- switch (v.type()) {
+ cout << prefix << "tag: " << hex << v->tag << dec << endl << prefix << "\t-> ";
+ switch (v->type()) {
case Value::Undefined_Type: cout << "Undefined"; return;
case Value::Null_Type: cout << "Null"; return;
case Value::Boolean_Type: cout << "Boolean"; break;
case Value::Integer_Type: cout << "Integer"; break;
- case Value::Managed_Type: cout << v.managed()->className().toUtf8().data(); break;
+ case Value::Managed_Type: cout << v->managed()->className().toUtf8().data(); break;
default: cout << "UNKNOWN" << endl; return;
}
cout << endl;
- if (v.isBoolean()) {
- cout << prefix << "\t-> " << (v.booleanValue() ? "TRUE" : "FALSE") << endl;
+ if (v->isBoolean()) {
+ cout << prefix << "\t-> " << (v->booleanValue() ? "TRUE" : "FALSE") << endl;
return;
}
- if (v.isInteger()) {
- cout << prefix << "\t-> " << v.integerValue() << endl;
+ if (v->isInteger()) {
+ cout << prefix << "\t-> " << v->integerValue() << endl;
return;
}
- if (v.isDouble()) {
- cout << prefix << "\t-> " << v.doubleValue() << endl;
+ if (v->isDouble()) {
+ cout << prefix << "\t-> " << v->doubleValue() << endl;
return;
}
- if (v.isString()) {
+ if (v->isString()) {
// maybe check something on the Managed object?
- cout << prefix << "\t-> @" << hex << v.stringValue() << endl;
- cout << prefix << "\t-> \"" << qPrintable(v.stringValue()->toQString()) << "\"" << endl;
+ cout << prefix << "\t-> @" << hex << v->stringValue() << endl;
+ cout << prefix << "\t-> \"" << qPrintable(v->stringValue()->toQString()) << "\"" << endl;
return;
}
@@ -274,17 +274,18 @@ static void realDumpValue(QV4::Value v, QV4::ExecutionContext *ctx, std::string
cout << prefix << "properties:" << endl;
ForEachIteratorObject it(ctx, o);
ScopedValue name(scope);
+ ScopedValue pval(scope);
for (name = it.nextPropertyName(); !name->isNull(); name = it.nextPropertyName()) {
cout << prefix << "\t\"" << qPrintable(name->stringValue()->toQString()) << "\"" << endl;
PropertyAttributes attrs;
Property *d = o->__getOwnProperty__(ScopedString(scope, name), &attrs);
- Value pval = Value::fromReturnedValue(o->getValue(d, attrs));
+ pval = o->getValue(d, attrs);
cout << prefix << "\tvalue:" << endl;
realDumpValue(pval, ctx, prefix + "\t");
}
}
-void dumpValue(QV4::Value v, QV4::ExecutionContext *ctx)
+void dumpValue(const QV4::ValueRef v, QV4::ExecutionContext *ctx)
{
realDumpValue(v, ctx, std::string(""));
}
diff --git a/src/qml/jsruntime/qv4debugging_p.h b/src/qml/jsruntime/qv4debugging_p.h
index 908854865d..e44f415da4 100644
--- a/src/qml/jsruntime/qv4debugging_p.h
+++ b/src/qml/jsruntime/qv4debugging_p.h
@@ -102,7 +102,7 @@ public: // compile-time interface
void maybeBreakAtInstruction(const uchar *code, bool breakPointHit);
public: // execution hooks
- void aboutToThrow(const Value &value);
+ void aboutToThrow(const ValueRef value);
private:
// requires lock to be held
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 7b9071ed43..8032197174 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -367,9 +367,9 @@ Returned<FunctionObject> *ExecutionEngine::newBuiltinFunction(ExecutionContext *
return f->asReturned<FunctionObject>();
}
-Returned<BoundFunction> *ExecutionEngine::newBoundFunction(ExecutionContext *scope, FunctionObject *target, Value boundThis, const QVector<Value> &boundArgs)
+Returned<BoundFunction> *ExecutionEngine::newBoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const QVector<SafeValue> &boundArgs)
{
- assert(target);
+ Q_ASSERT(target);
BoundFunction *f = new (memoryManager) BoundFunction(scope, target, boundThis, boundArgs);
return f->asReturned<BoundFunction>();
@@ -441,7 +441,7 @@ Returned<ArrayObject> *ExecutionEngine::newArrayObject(InternalClass *ic)
}
-Returned<DateObject> *ExecutionEngine::newDateObject(const Value &value)
+Returned<DateObject> *ExecutionEngine::newDateObject(const ValueRef value)
{
DateObject *object = new (memoryManager) DateObject(this, value);
return object->asReturned<DateObject>();
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index d93202df6e..79a4d3bef6 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -267,7 +267,7 @@ struct Q_QML_EXPORT ExecutionEngine
ExecutionContext *popContext();
Returned<FunctionObject> *newBuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(SimpleCallContext *));
- Returned<BoundFunction> *newBoundFunction(ExecutionContext *scope, FunctionObject *target, Value boundThis, const QVector<Value> &boundArgs);
+ Returned<BoundFunction> *newBoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const QVector<SafeValue> &boundArgs);
Returned<Object> *newObject();
Returned<Object> *newObject(InternalClass *internalClass);
@@ -283,7 +283,7 @@ struct Q_QML_EXPORT ExecutionEngine
Returned<ArrayObject> *newArrayObject(const QStringList &list);
Returned<ArrayObject> *newArrayObject(InternalClass *ic);
- Returned<DateObject> *newDateObject(const Value &value);
+ Returned<DateObject> *newDateObject(const ValueRef value);
Returned<DateObject> *newDateObject(const QDateTime &dt);
Returned<RegExpObject> *newRegExpObject(const QString &pattern, int flags);
diff --git a/src/qml/jsruntime/qv4exception.cpp b/src/qml/jsruntime/qv4exception.cpp
index 2c42e6f773..64e6bef1fd 100644
--- a/src/qml/jsruntime/qv4exception.cpp
+++ b/src/qml/jsruntime/qv4exception.cpp
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
using namespace QV4;
-void Exception::throwException(ExecutionContext *context, const Value &value)
+void Exception::throwException(ExecutionContext *context, const ValueRef value)
{
if (context->engine->debugger)
context->engine->debugger->aboutToThrow(value);
@@ -86,13 +86,13 @@ void Exception::throwException(ExecutionContext *context, const Value &value)
throwInternal(context, value);
}
-Exception::Exception(ExecutionContext *throwingContext, const Value &exceptionValue)
+Exception::Exception(ExecutionContext *throwingContext, const ValueRef exceptionValue)
: e(throwingContext->engine)
{
e->exceptionValue = exceptionValue;
this->throwingContext = throwingContext->engine->current;
accepted = false;
- if (ErrorObject *error = exceptionValue.asErrorObject())
+ if (ErrorObject *error = exceptionValue->asErrorObject())
m_stackTrace = error->stackTrace;
else
m_stackTrace = throwingContext->engine->stackTrace();
@@ -122,7 +122,7 @@ void Exception::partiallyUnwindContext(ExecutionContext *catchingContext)
}
#if !defined(V4_CXX_ABI_EXCEPTION)
-void Exception::throwInternal(ExecutionContext *throwingContext, const Value &exceptionValue)
+void Exception::throwInternal(ExecutionContext *throwingContext, const ValueRef exceptionValue)
{
throw Exception(throwingContext, exceptionValue);
}
diff --git a/src/qml/jsruntime/qv4exception_gcc.cpp b/src/qml/jsruntime/qv4exception_gcc.cpp
index 0324a06e0b..5eb5fc2178 100644
--- a/src/qml/jsruntime/qv4exception_gcc.cpp
+++ b/src/qml/jsruntime/qv4exception_gcc.cpp
@@ -41,6 +41,7 @@
#include "qv4exception_p.h"
+#include <private/qv4scopedvalue_p.h>
#include <unwind.h>
#include <cxxabi.h>
#include <bits/atomic_word.h>
@@ -108,7 +109,7 @@ QT_BEGIN_NAMESPACE
using namespace QV4;
-void Exception::throwInternal(ExecutionContext *throwingContext, const Value &exceptionValue)
+void Exception::throwInternal(ExecutionContext *throwingContext, const ValueRef exceptionValue)
{
void *rawException = abi::__cxa_allocate_exception(sizeof(QV4::Exception));
gcc_refcounted_compatible_exception *refCountedException = reinterpret_cast<gcc_refcounted_compatible_exception *>(rawException) - 1;
diff --git a/src/qml/jsruntime/qv4exception_p.h b/src/qml/jsruntime/qv4exception_p.h
index 4777e56fa9..a373ef205b 100644
--- a/src/qml/jsruntime/qv4exception_p.h
+++ b/src/qml/jsruntime/qv4exception_p.h
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
struct Q_QML_EXPORT Exception {
- static void Q_NORETURN throwException(ExecutionContext *throwingContext, const Value &exceptionValue);
+ static void Q_NORETURN throwException(ExecutionContext *throwingContext, const ValueRef exceptionValue);
~Exception();
@@ -66,13 +66,13 @@ struct Q_QML_EXPORT Exception {
private:
void *operator new(size_t, void *p) { return p; }
- explicit Exception(ExecutionContext *throwingContext, const Value &exceptionValue);
+ explicit Exception(ExecutionContext *throwingContext, const ValueRef exceptionValue);
ExecutionEngine *e;
ExecutionContext *throwingContext;
bool accepted;
ExecutionEngine::StackTrace m_stackTrace;
- static void Q_NORETURN throwInternal(ExecutionContext *throwingContext, const Value &exceptionValue);
+ static void Q_NORETURN throwInternal(ExecutionContext *throwingContext, const ValueRef exceptionValue);
};
} // namespace QV4
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 59b23bebbf..11580b00c4 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -385,11 +385,11 @@ ReturnedValue FunctionPrototype::method_bind(SimpleCallContext *ctx)
ctx->throwTypeError();
ScopedValue boundThis(scope, ctx->argument(0));
- QVector<Value> boundArgs;
+ QVector<SafeValue> boundArgs;
for (uint i = 1; i < ctx->callData->argc; ++i)
boundArgs += ctx->callData->args[i];
- return ctx->engine->newBoundFunction(ctx->engine->rootContext, target.getPointer(), boundThis, boundArgs)->asReturnedValue();
+ return ctx->engine->newBoundFunction(ctx->engine->rootContext, target, boundThis, boundArgs)->asReturnedValue();
}
DEFINE_MANAGED_VTABLE(ScriptFunction);
@@ -663,13 +663,13 @@ DEFINE_MANAGED_VTABLE(IndexedBuiltinFunction);
DEFINE_MANAGED_VTABLE(BoundFunction);
-BoundFunction::BoundFunction(ExecutionContext *scope, FunctionObject *target, Value boundThis, const QVector<Value> &boundArgs)
+BoundFunction::BoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const QVector<SafeValue> &boundArgs)
: FunctionObject(scope, 0)
, target(target)
- , boundThis(boundThis)
, boundArgs(boundArgs)
{
vtbl = &static_vtbl;
+ this->boundThis = boundThis;
Scope s(scope);
ScopedValue protectThis(s, this);
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h
index 29bfa31418..24231165df 100644
--- a/src/qml/jsruntime/qv4functionobject_p.h
+++ b/src/qml/jsruntime/qv4functionobject_p.h
@@ -225,10 +225,10 @@ struct SimpleScriptFunction: FunctionObject {
struct BoundFunction: FunctionObject {
Q_MANAGED
FunctionObject *target;
- Value boundThis;
- QVector<Value> boundArgs;
+ SafeValue boundThis;
+ QVector<SafeValue> boundArgs;
- BoundFunction(ExecutionContext *scope, FunctionObject *target, Value boundThis, const QVector<Value> &boundArgs);
+ BoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const QVector<SafeValue> &boundArgs);
~BoundFunction() {}
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 399cd2e0bd..eaa3b592f0 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -1283,7 +1283,7 @@ void Object::arrayReserve(uint n)
arrayData = newArrayData;
if (sparseArray) {
for (uint i = arrayFreeList; i < arrayAlloc; ++i) {
- arrayData[i].value = Value::emptyValue();
+ arrayData[i].value = Primitive::emptyValue();
arrayData[i].value = Primitive::fromInt32(i + 1);
}
} else {
@@ -1363,7 +1363,7 @@ bool Object::setArrayLength(uint newLen) {
} else {
arrayAttributes[it - arrayData].clear();
}
- it->value = Value::emptyValue();
+ it->value = Primitive::emptyValue();
}
}
arrayDataLen = newLen;
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index 20a5c51692..4693834144 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -601,7 +601,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, const ValueRef
}
if (attrs->isGeneric())
- desc->value = Value::emptyValue();
+ desc->value = Primitive::emptyValue();
}
diff --git a/src/qml/jsruntime/qv4property_p.h b/src/qml/jsruntime/qv4property_p.h
index 258a190602..9763de5adf 100644
--- a/src/qml/jsruntime/qv4property_p.h
+++ b/src/qml/jsruntime/qv4property_p.h
@@ -89,7 +89,7 @@ struct Property {
static Property genericDescriptor() {
Property pd;
- pd.value = Value::emptyValue();
+ pd.value = Primitive::emptyValue();
return pd;
}
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 1dd35fcee2..b5c48af9e7 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -878,7 +878,7 @@ ReturnedValue __qmljs_construct_property(ExecutionContext *context, const ValueR
void __qmljs_throw(ExecutionContext *context, const ValueRef value)
{
- Exception::throwException(context, *value);
+ Exception::throwException(context, value);
}
ReturnedValue __qmljs_builtin_typeof(ExecutionContext *ctx, const ValueRef value)
@@ -943,7 +943,7 @@ ExecutionContext *__qmljs_builtin_push_with_scope(const ValueRef o, ExecutionCon
ExecutionContext *__qmljs_builtin_push_catch_scope(const StringRef exceptionVarName, const ValueRef exceptionValue, ExecutionContext *ctx)
{
- return ctx->newCatchContext(exceptionVarName.getPointer(), *exceptionValue);
+ return ctx->newCatchContext(exceptionVarName, exceptionValue);
}
ExecutionContext *__qmljs_builtin_pop_scope(ExecutionContext *ctx)
diff --git a/src/qml/jsruntime/qv4value_def_p.h b/src/qml/jsruntime/qv4value_def_p.h
index 76f41dca71..11b70ef37c 100644
--- a/src/qml/jsruntime/qv4value_def_p.h
+++ b/src/qml/jsruntime/qv4value_def_p.h
@@ -273,7 +273,6 @@ struct Q_QML_EXPORT Value
return val;
}
- static Value emptyValue();
static Value fromObject(Object *o);
static Value fromManaged(Managed *o);
@@ -357,6 +356,7 @@ struct SafeValue : public Value
struct Q_QML_EXPORT Primitive : public Value
{
+ static Primitive emptyValue();
static Primitive fromBoolean(bool b);
static Primitive fromInt32(int i);
static Primitive undefinedValue();
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 604062b4a2..e751a07992 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -121,9 +121,9 @@ inline Primitive Primitive::nullValue()
return v;
}
-inline Value Value::emptyValue()
+inline Primitive Primitive::emptyValue()
{
- Value v;
+ Primitive v;
v.tag = Value::Empty_Type;
v.uint_32 = 0;
return v;
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index d89300f7af..52832feb73 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -160,7 +160,7 @@ static inline QV4::Value *getValueRef(QV4::ExecutionContext *context,
if (param.isValue()) {
VMSTATS(paramIsValue);
- return const_cast<QV4::Value *>(&param.value);
+ return const_cast<QV4::Value *>(&static_cast<const QV4::Value &>(param.value));
} else if (param.isArgument()) {
VMSTATS(paramIsArg);
QV4::ExecutionContext *c = context;