From 3f1d0b27a11a1d560c11057d2a801224d1613d60 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 23 Jul 2014 13:56:43 +0200 Subject: Changed Value to store Managed::Data pointers directly This is a step towards storing direct heap object pointers for the values on the JS stack, to avoid the costly indirection for data access. Change-Id: Ibb57ed6cf52a7088bbc95ee04ae3a4cb25b8c045 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4scopedvalue_p.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/qml/jsruntime/qv4scopedvalue_p.h') diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index b1b4d5da8d..5cc8495bba 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -112,7 +112,7 @@ struct ScopedValue ScopedValue(const Scope &scope, HeapObject *o) { ptr = scope.engine->jsStackTop++; - ptr->m = reinterpret_cast(o); + ptr->m = o; #if QT_POINTER_SIZE == 4 ptr->tag = QV4::Value::Managed_Type; #endif @@ -155,7 +155,7 @@ struct ScopedValue } ScopedValue &operator=(HeapObject *o) { - ptr->m = reinterpret_cast(o); + ptr->m = o; #if QT_POINTER_SIZE == 4 ptr->tag = QV4::Value::Managed_Type; #endif @@ -204,7 +204,7 @@ struct Scoped inline void setPointer(Managed *p) { #if QT_POINTER_SIZE == 8 - ptr->val = (quint64)p; + ptr->val = (quint64)(p ? &p->data : 0); #else *ptr = p ? QV4::Value::fromManaged(p) : QV4::Primitive::undefinedValue(); #endif @@ -230,7 +230,7 @@ struct Scoped Scoped(const Scope &scope, HeapObject *o) { Value v; - v.m = reinterpret_cast(o); + v.m = o; #if QT_POINTER_SIZE == 4 v.tag = QV4::Value::Managed_Type; #endif @@ -317,7 +317,7 @@ struct Scoped Scoped &operator=(HeapObject *o) { Value v; - v.m = reinterpret_cast(o); + v.m = o; #if QT_POINTER_SIZE == 4 v.tag = QV4::Value::Managed_Type; #endif @@ -361,10 +361,10 @@ struct Scoped } bool operator!() const { - return !ptr->managed(); + return !ptr->m; } operator void *() const { - return ptr->managed(); + return ptr->m; } T *getPointer() { @@ -379,6 +379,8 @@ struct Scoped #endif } + Returned *asReturned() const { return Returned::create(static_cast(ptr->heapObject())); } + Value *ptr; }; @@ -478,7 +480,7 @@ inline Returned *Value::as() template inline TypedValue &TypedValue::operator =(T *t) { - m = t; + m = t ? &t->data : 0; #if QT_POINTER_SIZE == 4 tag = Managed_Type; #endif @@ -488,7 +490,7 @@ inline TypedValue &TypedValue::operator =(T *t) template inline TypedValue &TypedValue::operator =(const Scoped &v) { - m = v.ptr->managed(); + m = v.ptr->m; #if QT_POINTER_SIZE == 4 tag = Managed_Type; #endif @@ -519,7 +521,7 @@ inline TypedValue &TypedValue::operator=(const TypedValue &t) template inline Returned * TypedValue::ret() const { - return Returned::create(static_cast(managed())); + return Returned::create(static_cast(heapObject())); } inline Primitive::operator ValueRef() -- cgit v1.2.3