diff options
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 11 | ||||
-rw-r--r-- | src/qml/compiler/qv4compiler.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsapi/qjsengine.cpp | 13 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4stringobject.cpp | 11 |
4 files changed, 22 insertions, 19 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 1fba6c0d3c..6ee23690a6 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -151,7 +151,7 @@ struct JSClass struct String { quint32 flags; // isArrayIndex - QArrayData str; + qint32 size; // uint16 strdata[] static int calculateSize(const QString &str) { @@ -195,13 +195,12 @@ struct Unit const uint *offsetTable = reinterpret_cast<const uint*>((reinterpret_cast<const char *>(this)) + offsetToStringTable); const uint offset = offsetTable[idx]; const String *str = reinterpret_cast<const String*>(reinterpret_cast<const char *>(this) + offset); - if (str->str.size == 0) + if (str->size == 0) return QString(); - QStringDataPtr holder = { const_cast<QStringData *>(static_cast<const QStringData*>(&str->str)) }; - QString qstr(holder); + const QChar *characters = reinterpret_cast<const QChar *>(str + 1); if (flags & StaticData) - return qstr; - return QString(qstr.constData(), qstr.length()); + return QString::fromRawData(characters, str->size); + return QString(characters, str->size); } const uint *functionOffsetTable() const { return reinterpret_cast<const uint*>((reinterpret_cast<const char *>(this)) + offsetToFunctionTable); } diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp index 65ef5c4b5e..144ef8a79e 100644 --- a/src/qml/compiler/qv4compiler.cpp +++ b/src/qml/compiler/qv4compiler.cpp @@ -82,11 +82,7 @@ void QV4::Compiler::StringTableGenerator::serialize(uint *stringTable, char *dat QV4::CompiledData::String *s = (QV4::CompiledData::String*)(stringData); s->flags = 0; // ### - s->str.ref.atomic.store(-1); - s->str.size = qstr.length(); - s->str.alloc = 0; - s->str.capacityReserved = false; - s->str.offset = sizeof(QArrayData); + s->size = qstr.length(); memcpy(s + 1, qstr.constData(), (qstr.length() + 1)*sizeof(ushort)); stringData += QV4::CompiledData::String::calculateSize(qstr); diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index d05ada481a..9cb727dd63 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -235,7 +235,7 @@ void QJSEngine::collectGarbage() Evaluates \a program, using \a lineNumber as the base line number, and returns the result of the evaluation. - The script code will be evaluated in the current context. + The script code will be evaluated in the context of the global object. The evaluation of \a program can cause an exception in the engine; in this case the return value will be the exception @@ -261,8 +261,11 @@ void QJSEngine::collectGarbage() */ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, int lineNumber) { - QV4::Scope scope(d->m_v4Engine); - QV4::ExecutionContext *ctx = d->m_v4Engine->currentContext(); + QV4::ExecutionEngine *v4 = d->m_v4Engine; + QV4::Scope scope(v4); + QV4::ExecutionContext *ctx = v4->currentContext(); + if (ctx != v4->rootContext) + ctx = v4->pushGlobalContext(); QV4::ScopedValue result(scope); QV4::Script script(ctx, program, fileName, lineNumber); @@ -273,7 +276,9 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in result = script.run(); if (scope.engine->hasException) result = ctx->catchException(); - return new QJSValuePrivate(d->m_v4Engine, result); + if (ctx != v4->rootContext) + v4->popContext(); + return new QJSValuePrivate(v4, result); } /*! diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 7c38ae4f01..f1e51703a8 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -508,21 +508,24 @@ ReturnedValue StringPrototype::method_replace(CallContext *ctx) Scoped<RegExpObject> regExp(scope, searchValue); if (regExp) { uint offset = 0; + + // We extract the pointer here to work around a compiler bug on Android. + Scoped<RegExp> re(scope, regExp->value); while (true) { int oldSize = nMatchOffsets; - if (allocatedMatchOffsets < nMatchOffsets + regExp->value->captureCount() * 2) { - allocatedMatchOffsets = qMax(allocatedMatchOffsets * 2, nMatchOffsets + regExp->value->captureCount() * 2); + if (allocatedMatchOffsets < nMatchOffsets + re->captureCount() * 2) { + allocatedMatchOffsets = qMax(allocatedMatchOffsets * 2, nMatchOffsets + re->captureCount() * 2); uint *newOffsets = (uint *)malloc(allocatedMatchOffsets*sizeof(uint)); memcpy(newOffsets, matchOffsets, nMatchOffsets*sizeof(uint)); if (matchOffsets != _matchOffsets) free(matchOffsets); matchOffsets = newOffsets; } - if (regExp->value->match(string, offset, matchOffsets + oldSize) == JSC::Yarr::offsetNoMatch) { + if (re->match(string, offset, matchOffsets + oldSize) == JSC::Yarr::offsetNoMatch) { nMatchOffsets = oldSize; break; } - nMatchOffsets += regExp->value->captureCount() * 2; + nMatchOffsets += re->captureCount() * 2; if (!regExp->global) break; offset = qMax(offset + 1, matchOffsets[oldSize + 1]); |