Don't exceed SMI bounds
authorAaron Kennedy <aaron.kennedy@nokia.com>
Mon, 4 Jul 2011 01:57:47 +0000 (11:57 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 4 Jul 2011 05:27:00 +0000 (07:27 +0200)
If we use an integer that is greater than the maximum SMI value on
32-bit systems (like ARM), v8 allocates the integer as a HeapNumber
which is unbelievably slower.

Change-Id: I518b5947627631a2621344b656afa0dde002fe82
Reviewed-on: http://codereview.qt.nokia.com/1025
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
src/declarative/qml/v8/qv8qobjectwrapper.cpp

index bf9229b..7e5bd4e 100644 (file)
@@ -174,8 +174,8 @@ static v8::Handle<v8::Value> name ## ValueGetter(v8::Local<v8::String>, const v8
  \
     uint32_t data = info.Data()->Uint32Value(); \
     int index = data & 0x7FFF; \
-    int notify = (data & 0x7FFF0000) >> 16; \
-    if (notify == 0x7FFF) notify = -1; \
+    int notify = (data & 0x0FFF0000) >> 16; \
+    if (notify == 0x0FFF) notify = -1; \
  \
     QDeclarativeEnginePrivate *ep = resource->engine->engine()?QDeclarativeEnginePrivate::get(resource->engine->engine()):0; \
     if (ep && notify /* 0 means constant */ && ep->captureProperties) { \
@@ -200,8 +200,8 @@ static v8::Handle<v8::Value> name ## ValueGetterDirect(v8::Local<v8::String>, co
  \
     uint32_t data = info.Data()->Uint32Value(); \
     int index = data & 0x7FFF; \
-    int notify = (data & 0x7FFF0000) >> 16; \
-    if (notify == 0x7FFF) notify = -1; \
+    int notify = (data & 0x0FFF0000) >> 16; \
+    if (notify == 0x0FFF) notify = -1; \
  \
     QDeclarativeEnginePrivate *ep = resource->engine->engine()?QDeclarativeEnginePrivate::get(resource->engine->engine()):0; \
     if (ep && notify /* 0 means constant */ && ep->captureProperties) { \
@@ -801,7 +801,7 @@ v8::Local<v8::Object> QDeclarativePropertyCache::newQObject(QObject *object, QV8
         for (StringCache::ConstIterator iter = stringCache.begin(); iter != stringCache.end(); ++iter) {
             Data *property = *iter;
             if (property->isFunction() || 
-                property->coreIndex >= 0x7FFF || property->notifyIndex >= 0x7FFF || 
+                property->coreIndex >= 0x7FFF || property->notifyIndex >= 0x0FFF || 
                 property->coreIndex == 0)
                 continue;
 
@@ -828,8 +828,8 @@ v8::Local<v8::Object> QDeclarativePropertyCache::newQObject(QObject *object, QV8
             if (fastgetter) {
                 int notifyIndex = property->notifyIndex;
                 if (property->isConstant()) notifyIndex = 0;
-                else if (notifyIndex == -1) notifyIndex = 0x7FFF;
-                uint32_t data = (notifyIndex & 0x7FFF) << 16 | property->coreIndex;
+                else if (notifyIndex == -1) notifyIndex = 0x0FFF;
+                uint32_t data = (notifyIndex & 0x0FFF) << 16 | property->coreIndex;
 
                 QString name = iter.key();
                 if (name == toString || name == destroy)