Move Data of Variant and ArgumentsObject into Heap namespace

Change-Id: Id2092a15c9fb5341d9b5cf4a9ac7a978308e4174
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
Lars Knoll 2014-11-04 15:25:09 +01:00 committed by Simon Hausmann
parent f3f86c5eae
commit 980e7fae0a
10 changed files with 121 additions and 89 deletions

View File

@ -38,16 +38,16 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(ArgumentsObject);
ArgumentsObject::Data::Data(CallContext *context)
Heap::ArgumentsObject::ArgumentsObject(QV4::CallContext *context)
: Heap::Object(context->d()->strictMode ? context->d()->engine->strictArgumentsObjectClass : context->d()->engine->argumentsObjectClass)
, context(context)
, fullyCreated(false)
{
Q_ASSERT(internalClass->vtable == staticVTable());
Q_ASSERT(internalClass->vtable == QV4::ArgumentsObject::staticVTable());
ExecutionEngine *v4 = context->d()->engine;
Scope scope(v4);
Scoped<ArgumentsObject> args(scope, this);
Scoped<QV4::ArgumentsObject> args(scope, this);
args->setArrayType(Heap::ArrayData::Complex);

View File

@ -40,51 +40,67 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
namespace Heap {
struct ArgumentsGetterFunction : FunctionObject {
inline ArgumentsGetterFunction(QV4::ExecutionContext *scope, uint index);
uint index;
};
struct ArgumentsSetterFunction : FunctionObject {
inline ArgumentsSetterFunction(QV4::ExecutionContext *scope, uint index);
uint index;
};
struct ArgumentsObject : Object {
enum {
LengthPropertyIndex = 0,
CalleePropertyIndex = 1,
CallerPropertyIndex = 3
};
ArgumentsObject(QV4::CallContext *context);
QV4::CallContext *context;
bool fullyCreated;
MemberData *mappedArguments;
};
}
struct ArgumentsGetterFunction: FunctionObject
{
struct Data : Heap::FunctionObject {
Data(ExecutionContext *scope, uint index)
: Heap::FunctionObject(scope)
, index(index)
{
setVTable(staticVTable());
}
uint index;
};
V4_OBJECT(FunctionObject)
V4_OBJECT2(ArgumentsGetterFunction, FunctionObject)
uint index() const { return d()->index; }
static ReturnedValue call(Managed *that, CallData *d);
};
inline
Heap::ArgumentsGetterFunction::ArgumentsGetterFunction(QV4::ExecutionContext *scope, uint index)
: Heap::FunctionObject(scope)
, index(index)
{
setVTable(QV4::ArgumentsGetterFunction::staticVTable());
}
struct ArgumentsSetterFunction: FunctionObject
{
struct Data : Heap::FunctionObject {
Data(ExecutionContext *scope, uint index)
: Heap::FunctionObject(scope)
, index(index)
{
setVTable(staticVTable());
}
uint index;
};
V4_OBJECT(FunctionObject)
V4_OBJECT2(ArgumentsSetterFunction, FunctionObject)
uint index() const { return d()->index; }
static ReturnedValue call(Managed *that, CallData *callData);
};
inline
Heap::ArgumentsSetterFunction::ArgumentsSetterFunction(QV4::ExecutionContext *scope, uint index)
: Heap::FunctionObject(scope)
, index(index)
{
setVTable(QV4::ArgumentsSetterFunction::staticVTable());
}
struct ArgumentsObject: Object {
struct Data : Heap::Object {
Data(CallContext *context);
CallContext *context;
bool fullyCreated;
Heap::MemberData *mappedArguments;
};
V4_OBJECT(Object)
V4_OBJECT2(ArgumentsObject, Object)
Q_MANAGED_TYPE(ArgumentsObject)
CallContext *context() const { return d()->context; }
@ -96,11 +112,6 @@ struct ArgumentsObject: Object {
!static_cast<ArgumentsObject *>(m)->context()->d()->strictMode;
}
enum {
LengthPropertyIndex = 0,
CalleePropertyIndex = 1,
CallerPropertyIndex = 3
};
bool defineOwnProperty(ExecutionContext *ctx, uint index, const Property &desc, PropertyAttributes attrs);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
static void putIndexed(Managed *m, uint index, const ValueRef value);

View File

@ -41,10 +41,10 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(ArrayCtor);
ArrayCtor::Data::Data(ExecutionContext *scope)
Heap::ArrayCtor::ArrayCtor(QV4::ExecutionContext *scope)
: Heap::FunctionObject(scope, QStringLiteral("Array"))
{
setVTable(staticVTable());
setVTable(QV4::ArrayCtor::staticVTable());
}
ReturnedValue ArrayCtor::construct(Managed *m, CallData *callData)

View File

@ -41,13 +41,17 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
namespace Heap {
struct ArrayCtor : FunctionObject {
ArrayCtor(QV4::ExecutionContext *scope);
};
}
struct ArrayCtor: FunctionObject
{
struct Data : Heap::FunctionObject {
Data(ExecutionContext *scope);
};
V4_OBJECT(FunctionObject)
V4_OBJECT2(ArrayCtor, FunctionObject)
static ReturnedValue construct(Managed *m, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);

View File

@ -38,10 +38,10 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(BooleanCtor);
DEFINE_OBJECT_VTABLE(BooleanObject);
BooleanCtor::Data::Data(ExecutionContext *scope)
Heap::BooleanCtor::BooleanCtor(QV4::ExecutionContext *scope)
: Heap::FunctionObject(scope, QStringLiteral("Boolean"))
{
setVTable(staticVTable());
setVTable(QV4::BooleanCtor::staticVTable());
}
ReturnedValue BooleanCtor::construct(Managed *m, CallData *callData)

View File

@ -41,13 +41,17 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
namespace Heap {
struct BooleanCtor : FunctionObject {
BooleanCtor(QV4::ExecutionContext *scope);
};
}
struct BooleanCtor: FunctionObject
{
struct Data : Heap::FunctionObject {
Data(ExecutionContext *scope);
};
V4_OBJECT(FunctionObject)
V4_OBJECT2(BooleanCtor, FunctionObject)
static ReturnedValue construct(Managed *, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);

View File

@ -634,10 +634,10 @@ static double getLocalTZA()
DEFINE_OBJECT_VTABLE(DateObject);
DateObject::Data::Data(ExecutionEngine *engine, const QDateTime &date)
Heap::DateObject::DateObject(QV4::ExecutionEngine *engine, const QDateTime &date)
: Heap::Object(engine->dateClass)
{
setVTable(staticVTable());
setVTable(QV4::DateObject::staticVTable());
value.setDouble(date.isValid() ? date.toMSecsSinceEpoch() : qSNaN());
}
@ -648,10 +648,10 @@ QDateTime DateObject::toQDateTime() const
DEFINE_OBJECT_VTABLE(DateCtor);
DateCtor::Data::Data(ExecutionContext *scope)
Heap::DateCtor::DateCtor(QV4::ExecutionContext *scope)
: Heap::FunctionObject(scope, QStringLiteral("Date"))
{
setVTable(staticVTable());
setVTable(QV4::DateCtor::staticVTable());
}
ReturnedValue DateCtor::construct(Managed *m, CallData *callData)

View File

@ -43,23 +43,27 @@ class QDateTime;
namespace QV4 {
namespace Heap {
struct DateObject : Object {
DateObject(QV4::ExecutionEngine *engine, const ValueRef date)
: Object(engine->dateClass)
{
value = date;
}
DateObject(QV4::ExecutionEngine *engine, const QDateTime &date);
inline DateObject(InternalClass *ic);
Value value;
};
struct DateCtor : FunctionObject {
DateCtor(QV4::ExecutionContext *scope);
};
}
struct DateObject: Object {
struct Data : Heap::Object {
Data(ExecutionEngine *engine, const ValueRef date)
: Heap::Object(engine->dateClass)
{
value = date;
}
Data(ExecutionEngine *engine, const QDateTime &date);
Data(InternalClass *ic)
: Heap::Object(ic)
{
Q_ASSERT(internalClass->vtable == staticVTable());
value = Primitive::fromDouble(qSNaN());
}
Value value;
};
V4_OBJECT(Object)
V4_OBJECT2(DateObject, Object)
Q_MANAGED_TYPE(DateObject)
@ -70,12 +74,16 @@ struct DateObject: Object {
QDateTime toQDateTime() const;
};
Heap::DateObject::DateObject(InternalClass *ic)
: Heap::Object(ic)
{
Q_ASSERT(internalClass->vtable == QV4::DateObject::staticVTable());
value = Primitive::fromDouble(qSNaN());
}
struct DateCtor: FunctionObject
{
struct Data : Heap::FunctionObject {
Data(ExecutionContext *scope);
};
V4_OBJECT(FunctionObject)
V4_OBJECT2(DateCtor, FunctionObject)
static ReturnedValue construct(Managed *, CallData *callData);
static ReturnedValue call(Managed *that, CallData *);

View File

@ -43,12 +43,12 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(VariantObject);
VariantObject::Data::Data(InternalClass *ic)
Heap::VariantObject::VariantObject(InternalClass *ic)
: Heap::Object(ic)
{
}
VariantObject::Data::Data(ExecutionEngine *engine, const QVariant &value)
Heap::VariantObject::VariantObject(QV4::ExecutionEngine *engine, const QVariant &value)
: Heap::Object(engine->variantClass)
{
data = value;

View File

@ -56,20 +56,25 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
namespace Heap {
struct VariantObject : Object, public ExecutionEngine::ScarceResourceData
{
VariantObject(InternalClass *ic);
VariantObject(QV4::ExecutionEngine *engine, const QVariant &value);
~VariantObject() {
if (isScarce())
node.remove();
}
bool isScarce() const;
int vmePropertyReferenceCount;
};
}
struct VariantObject : Object
{
struct Data : Heap::Object, public ExecutionEngine::ScarceResourceData
{
Data(InternalClass *ic);
Data(ExecutionEngine *engine, const QVariant &value);
~Data() {
if (isScarce())
node.remove();
}
bool isScarce() const;
int vmePropertyReferenceCount;
};
V4_OBJECT(Object)
V4_OBJECT2(VariantObject, Object)
static QVariant toVariant(const ValueRef v);