aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2014-11-11 18:08:20 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-11-15 00:32:45 +0100
commitad342b052473a8ec8c693591a8a882313ccd7d62 (patch)
tree502172a96bd56cda918a5552017f95308ee15f9f /src/qml/jsruntime
parentd4d92ab002bab0fdb8ddbac4babad260ed75d090 (diff)
Changed MemoryManager::alloc<T> to return Heap::T* instead of T*
Change-Id: Iede1ba624d1313fbe2f8e5e979e936f1f32efdc9 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4context.cpp4
-rw-r--r--src/qml/jsruntime/qv4engine.cpp36
-rw-r--r--src/qml/jsruntime/qv4errorobject_p.h10
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4functionobject_p.h4
-rw-r--r--src/qml/jsruntime/qv4mm_p.h24
6 files changed, 46 insertions, 36 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 86a5535d04..603b76630c 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -83,12 +83,12 @@ Returned<CallContext> *ExecutionContext::newCallContext(FunctionObject *function
Heap::WithContext *ExecutionContext::newWithContext(Object *with)
{
- return d()->engine->memoryManager->alloc<WithContext>(d()->engine, with)->getPointer()->d();
+ return d()->engine->memoryManager->alloc<WithContext>(d()->engine, with);
}
Heap::CatchContext *ExecutionContext::newCatchContext(String *exceptionVarName, const ValueRef exceptionValue)
{
- return d()->engine->memoryManager->alloc<CatchContext>(d()->engine, exceptionVarName, exceptionValue)->getPointer()->d();
+ return d()->engine->memoryManager->alloc<CatchContext>(d()->engine, exceptionVarName, exceptionValue);
}
Heap::CallContext *ExecutionContext::newQmlContext(FunctionObject *f, Object *qml)
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 0bb05896b0..1080831ee7 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -337,21 +337,21 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
sequencePrototype = ScopedValue(scope, memoryManager->alloc<SequencePrototype>(arrayClass));
- objectCtor = memoryManager->alloc<ObjectCtor>(rootContext);
- stringCtor = memoryManager->alloc<StringCtor>(rootContext);
- numberCtor = memoryManager->alloc<NumberCtor>(rootContext);
- booleanCtor = memoryManager->alloc<BooleanCtor>(rootContext);
- arrayCtor = memoryManager->alloc<ArrayCtor>(rootContext);
- functionCtor = memoryManager->alloc<FunctionCtor>(rootContext);
- dateCtor = memoryManager->alloc<DateCtor>(rootContext);
- regExpCtor = memoryManager->alloc<RegExpCtor>(rootContext);
- errorCtor = memoryManager->alloc<ErrorCtor>(rootContext);
- evalErrorCtor = memoryManager->alloc<EvalErrorCtor>(rootContext);
- rangeErrorCtor = memoryManager->alloc<RangeErrorCtor>(rootContext);
- referenceErrorCtor = memoryManager->alloc<ReferenceErrorCtor>(rootContext);
- syntaxErrorCtor = memoryManager->alloc<SyntaxErrorCtor>(rootContext);
- typeErrorCtor = memoryManager->alloc<TypeErrorCtor>(rootContext);
- uRIErrorCtor = memoryManager->alloc<URIErrorCtor>(rootContext);
+ objectCtor = Value::fromHeapObject(memoryManager->alloc<ObjectCtor>(rootContext));
+ stringCtor = Value::fromHeapObject(memoryManager->alloc<StringCtor>(rootContext));
+ numberCtor = Value::fromHeapObject(memoryManager->alloc<NumberCtor>(rootContext));
+ booleanCtor = Value::fromHeapObject(memoryManager->alloc<BooleanCtor>(rootContext));
+ arrayCtor = Value::fromHeapObject(memoryManager->alloc<ArrayCtor>(rootContext));
+ functionCtor = Value::fromHeapObject(memoryManager->alloc<FunctionCtor>(rootContext));
+ dateCtor = Value::fromHeapObject(memoryManager->alloc<DateCtor>(rootContext));
+ regExpCtor = Value::fromHeapObject(memoryManager->alloc<RegExpCtor>(rootContext));
+ errorCtor = Value::fromHeapObject(memoryManager->alloc<ErrorCtor>(rootContext));
+ evalErrorCtor = Value::fromHeapObject(memoryManager->alloc<EvalErrorCtor>(rootContext));
+ rangeErrorCtor = Value::fromHeapObject(memoryManager->alloc<RangeErrorCtor>(rootContext));
+ referenceErrorCtor = Value::fromHeapObject(memoryManager->alloc<ReferenceErrorCtor>(rootContext));
+ syntaxErrorCtor = Value::fromHeapObject(memoryManager->alloc<SyntaxErrorCtor>(rootContext));
+ typeErrorCtor = Value::fromHeapObject(memoryManager->alloc<TypeErrorCtor>(rootContext));
+ uRIErrorCtor = Value::fromHeapObject(memoryManager->alloc<URIErrorCtor>(rootContext));
static_cast<ObjectPrototype *>(objectPrototype.getPointer())->init(this, objectCtor.asObject());
static_cast<StringPrototype *>(stringPrototype.getPointer())->init(this, stringCtor.asObject());
@@ -375,18 +375,18 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
// typed arrays
- arrayBufferCtor = memoryManager->alloc<ArrayBufferCtor>(rootContext);
+ arrayBufferCtor = Value::fromHeapObject(memoryManager->alloc<ArrayBufferCtor>(rootContext));
Scoped<ArrayBufferPrototype> arrayBufferPrototype(scope, memoryManager->alloc<ArrayBufferPrototype>(objectClass));
arrayBufferPrototype->init(this, arrayBufferCtor.asObject());
arrayBufferClass = InternalClass::create(this, ArrayBuffer::staticVTable(), arrayBufferPrototype);
- dataViewCtor = memoryManager->alloc<DataViewCtor>(rootContext);
+ dataViewCtor = Value::fromHeapObject(memoryManager->alloc<DataViewCtor>(rootContext));
Scoped<DataViewPrototype> dataViewPrototype(scope, memoryManager->alloc<DataViewPrototype>(objectClass));
dataViewPrototype->init(this, dataViewCtor.asObject());
dataViewClass = InternalClass::create(this, DataView::staticVTable(), dataViewPrototype);
for (int i = 0; i < Heap::TypedArray::NTypes; ++i) {
- typedArrayCtors[i] = memoryManager->alloc<TypedArrayCtor>(rootContext, Heap::TypedArray::Type(i));
+ typedArrayCtors[i] = Value::fromHeapObject(memoryManager->alloc<TypedArrayCtor>(rootContext, Heap::TypedArray::Type(i)));
Scoped<TypedArrayPrototype> typedArrayPrototype(scope, memoryManager->alloc<TypedArrayPrototype>(this, Heap::TypedArray::Type(i)));
typedArrayPrototype->init(this, static_cast<TypedArrayCtor *>(typedArrayCtors[i].asObject()));
typedArrayClasses[i] = InternalClass::create(this, TypedArray::staticVTable(), typedArrayPrototype);
diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h
index 7a18447f4b..2585c3e639 100644
--- a/src/qml/jsruntime/qv4errorobject_p.h
+++ b/src/qml/jsruntime/qv4errorobject_p.h
@@ -145,14 +145,20 @@ inline ErrorObject *value_cast(const Value &v) {
struct EvalErrorObject: ErrorObject {
typedef Heap::EvalErrorObject Data;
+ const Data *d() const { return static_cast<const Data *>(ErrorObject::d()); }
+ Data *d() { return static_cast<Data *>(ErrorObject::d()); }
};
struct RangeErrorObject: ErrorObject {
typedef Heap::RangeErrorObject Data;
+ const Data *d() const { return static_cast<const Data *>(ErrorObject::d()); }
+ Data *d() { return static_cast<Data *>(ErrorObject::d()); }
};
struct ReferenceErrorObject: ErrorObject {
typedef Heap::ReferenceErrorObject Data;
+ const Data *d() const { return static_cast<const Data *>(ErrorObject::d()); }
+ Data *d() { return static_cast<Data *>(ErrorObject::d()); }
};
struct SyntaxErrorObject: ErrorObject {
@@ -161,10 +167,14 @@ struct SyntaxErrorObject: ErrorObject {
struct TypeErrorObject: ErrorObject {
typedef Heap::TypeErrorObject Data;
+ const Data *d() const { return static_cast<const Data *>(ErrorObject::d()); }
+ Data *d() { return static_cast<Data *>(ErrorObject::d()); }
};
struct URIErrorObject: ErrorObject {
typedef Heap::URIErrorObject Data;
+ const Data *d() const { return static_cast<const Data *>(ErrorObject::d()); }
+ Data *d() { return static_cast<Data *>(ErrorObject::d()); }
};
struct ErrorCtor: FunctionObject
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index b6e766e568..34fe17d0eb 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -189,8 +189,8 @@ Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *sco
function->compiledFunction->flags & CompiledData::Function::HasCatchOrWith ||
function->compiledFunction->nFormals > QV4::Global::ReservedArgumentCount ||
function->isNamedExpression())
- return scope->d()->engine->memoryManager->alloc<ScriptFunction>(scope, function)->getPointer()->d();
- return scope->d()->engine->memoryManager->alloc<SimpleScriptFunction>(scope, function, createProto)->getPointer()->d();
+ return scope->d()->engine->memoryManager->alloc<ScriptFunction>(scope, function);
+ return scope->d()->engine->memoryManager->alloc<SimpleScriptFunction>(scope, function, createProto);
}
DEFINE_OBJECT_VTABLE(FunctionCtor);
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h
index 3b6294f559..56d11b2450 100644
--- a/src/qml/jsruntime/qv4functionobject_p.h
+++ b/src/qml/jsruntime/qv4functionobject_p.h
@@ -179,7 +179,7 @@ struct Q_QML_EXPORT BuiltinFunction: FunctionObject {
static Heap::BuiltinFunction *create(ExecutionContext *scope, String *name, ReturnedValue (*code)(CallContext *))
{
- return scope->engine()->memoryManager->alloc<BuiltinFunction>(scope, name, code)->getPointer()->d();
+ return scope->engine()->memoryManager->alloc<BuiltinFunction>(scope, name, code);
}
static ReturnedValue construct(Managed *, CallData *);
@@ -230,7 +230,7 @@ struct BoundFunction: FunctionObject {
static Heap::BoundFunction *create(ExecutionContext *scope, FunctionObject *target, const ValueRef boundThis, QV4::MemberData *boundArgs)
{
- return scope->engine()->memoryManager->alloc<BoundFunction>(scope, target, boundThis, boundArgs)->getPointer()->d();
+ return scope->engine()->memoryManager->alloc<BoundFunction>(scope, target, boundThis, boundArgs);
}
Heap::FunctionObject *target() { return d()->target; }
diff --git a/src/qml/jsruntime/qv4mm_p.h b/src/qml/jsruntime/qv4mm_p.h
index f2267e5852..ddee32116c 100644
--- a/src/qml/jsruntime/qv4mm_p.h
+++ b/src/qml/jsruntime/qv4mm_p.h
@@ -94,57 +94,57 @@ public:
}
template <typename ManagedType>
- Returned<ManagedType> *alloc()
+ typename ManagedType::Data *alloc()
{
Scope scope(engine());
Scoped<ManagedType> t(scope, static_cast<ManagedType*>(allocManaged(sizeof(typename ManagedType::Data))));
(void)new (t->d()) typename ManagedType::Data();
- return t.asReturned();
+ return t->d();
}
template <typename ManagedType, typename Arg1>
- Returned<ManagedType> *alloc(Arg1 arg1)
+ typename ManagedType::Data *alloc(Arg1 arg1)
{
Scope scope(engine());
Scoped<ManagedType> t(scope, static_cast<ManagedType*>(allocManaged(sizeof(typename ManagedType::Data))));
(void)new (t->d()) typename ManagedType::Data(arg1);
- return t.asReturned();
+ return t->d();
}
template <typename ManagedType, typename Arg1, typename Arg2>
- Returned<ManagedType> *alloc(Arg1 arg1, Arg2 arg2)
+ typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2)
{
Scope scope(engine());
Scoped<ManagedType> t(scope, static_cast<ManagedType*>(allocManaged(sizeof(typename ManagedType::Data))));
(void)new (t->d()) typename ManagedType::Data(arg1, arg2);
- return t.asReturned();
+ return t->d();
}
template <typename ManagedType, typename Arg1, typename Arg2, typename Arg3>
- Returned<ManagedType> *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3)
+ typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3)
{
Scope scope(engine());
Scoped<ManagedType> t(scope, static_cast<ManagedType*>(allocManaged(sizeof(typename ManagedType::Data))));
(void)new (t->d()) typename ManagedType::Data(arg1, arg2, arg3);
- return t.asReturned();
+ return t->d();
}
template <typename ManagedType, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
- Returned<ManagedType> *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
+ typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
{
Scope scope(engine());
Scoped<ManagedType> t(scope, static_cast<ManagedType*>(allocManaged(sizeof(typename ManagedType::Data))));
(void)new (t->d()) typename ManagedType::Data(arg1, arg2, arg3, arg4);
- return t.asReturned();
+ return t->d();
}
template <typename ManagedType, typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
- Returned<ManagedType> *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
+ typename ManagedType::Data *alloc(Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
{
Scope scope(engine());
Scoped<ManagedType> t(scope, static_cast<ManagedType*>(allocManaged(sizeof(typename ManagedType::Data))));
(void)new (t->d()) typename ManagedType::Data(arg1, arg2, arg3, arg4, arg5);
- return t.asReturned();
+ return t->d();
}
bool isGCBlocked() const;