From 86f88521fbea59e8ec53e50cc1e3e68a61f53c40 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 23 Jun 2018 22:25:53 +0200 Subject: Replace Identifier by PropertyKey Change all uses of Identifier to use the new PropertyKey class and get rid of Identifier. Change-Id: Ib7e83b06a3c923235e145b6e083fe980dc240452 Reviewed-by: Simon Hausmann --- src/qml/jsapi/qjsvalue.cpp | 2 +- src/qml/jsruntime/qv4argumentsobject.cpp | 10 ++-- src/qml/jsruntime/qv4argumentsobject_p.h | 10 ++-- src/qml/jsruntime/qv4arrayobject.cpp | 26 ++++----- src/qml/jsruntime/qv4context.cpp | 10 ++-- src/qml/jsruntime/qv4dateobject.cpp | 2 +- src/qml/jsruntime/qv4identifier.cpp | 45 ++++------------ src/qml/jsruntime/qv4identifier_p.h | 40 +++----------- src/qml/jsruntime/qv4identifiertable.cpp | 24 ++++----- src/qml/jsruntime/qv4identifiertable_p.h | 16 +++--- src/qml/jsruntime/qv4internalclass.cpp | 48 ++++++++--------- src/qml/jsruntime/qv4internalclass_p.h | 30 +++++------ src/qml/jsruntime/qv4lookup.cpp | 8 +-- src/qml/jsruntime/qv4lookup_p.h | 2 +- src/qml/jsruntime/qv4managed_p.h | 2 +- src/qml/jsruntime/qv4object.cpp | 24 ++++----- src/qml/jsruntime/qv4object_p.h | 50 +++++++++--------- src/qml/jsruntime/qv4objectiterator.cpp | 2 +- src/qml/jsruntime/qv4objectproto.cpp | 12 ++--- src/qml/jsruntime/qv4propertykey.cpp | 10 ++++ src/qml/jsruntime/qv4propertykey_p.h | 91 ++++++++++++++++++++------------ src/qml/jsruntime/qv4proxy.cpp | 12 ++--- src/qml/jsruntime/qv4proxy_p.h | 12 ++--- src/qml/jsruntime/qv4qmlcontext.cpp | 4 +- src/qml/jsruntime/qv4qmlcontext_p.h | 4 +- src/qml/jsruntime/qv4qobjectwrapper.cpp | 6 +-- src/qml/jsruntime/qv4qobjectwrapper_p.h | 6 +-- src/qml/jsruntime/qv4reflect.cpp | 8 +-- src/qml/jsruntime/qv4runtime.cpp | 17 +++--- src/qml/jsruntime/qv4scopedvalue_p.h | 3 ++ src/qml/jsruntime/qv4sequenceobject.cpp | 6 +-- src/qml/jsruntime/qv4string.cpp | 8 +-- src/qml/jsruntime/qv4string_p.h | 8 +-- src/qml/jsruntime/qv4stringobject.cpp | 6 +-- src/qml/jsruntime/qv4stringobject_p.h | 4 +- src/qml/jsruntime/qv4symbol.cpp | 2 +- src/qml/jsruntime/qv4symbol_p.h | 2 +- src/qml/jsruntime/qv4typedarray.cpp | 4 +- src/qml/jsruntime/qv4typedarray_p.h | 4 +- src/qml/jsruntime/qv4value.cpp | 4 +- src/qml/qml/qqmllistwrapper.cpp | 4 +- src/qml/qml/qqmllistwrapper_p.h | 4 +- src/qml/qml/qqmltypewrapper.cpp | 8 +-- src/qml/qml/qqmltypewrapper_p.h | 8 +-- src/qml/qml/qqmlvaluetypewrapper.cpp | 6 +-- src/qml/qml/qqmlvaluetypewrapper_p.h | 6 +-- src/qml/qml/qqmlxmlhttprequest.cpp | 8 +-- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 2 +- src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 2 +- src/qml/qml/v8/qv8engine.cpp | 2 +- src/qml/types/qqmldelegatemodel.cpp | 2 +- src/qml/types/qqmllistmodel.cpp | 4 +- src/qml/types/qqmllistmodel_p_p.h | 4 +- 53 files changed, 312 insertions(+), 332 deletions(-) (limited to 'src/qml') diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index b68f2bd600..01e8600574 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -1209,7 +1209,7 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value) } QV4::ScopedValue v(scope, QJSValuePrivate::convertedToValue(engine, value)); - Identifier id = arrayIndex != UINT_MAX ? Identifier::fromArrayIndex(arrayIndex) : engine->id_uintMax()->identifier(); + PropertyKey id = arrayIndex != UINT_MAX ? PropertyKey::fromArrayIndex(arrayIndex) : engine->id_uintMax()->identifier(); o->put(id, v); if (engine->hasException) engine->catchException(); diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 7a914a9c13..ab242ddd92 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -120,7 +120,7 @@ void ArgumentsObject::fullyCreate() d()->fullyCreated = true; } -bool ArgumentsObject::defineOwnProperty(Managed *m, Identifier id, const Property *desc, PropertyAttributes attrs) +bool ArgumentsObject::defineOwnProperty(Managed *m, PropertyKey id, const Property *desc, PropertyAttributes attrs) { if (!id.isArrayIndex()) return Object::defineOwnProperty(m, id, desc, attrs); @@ -169,7 +169,7 @@ bool ArgumentsObject::defineOwnProperty(Managed *m, Identifier id, const Propert return result; } -ReturnedValue ArgumentsObject::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +ReturnedValue ArgumentsObject::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { const ArgumentsObject *args = static_cast(m); if (id.isArrayIndex() && !args->fullyCreated()) { @@ -183,7 +183,7 @@ ReturnedValue ArgumentsObject::get(const Managed *m, Identifier id, const Value return Object::get(m, id, receiver, hasProperty); } -bool ArgumentsObject::put(Managed *m, Identifier id, const Value &value, Value *receiver) +bool ArgumentsObject::put(Managed *m, PropertyKey id, const Value &value, Value *receiver) { ArgumentsObject *args = static_cast(m); if (id.isArrayIndex()) { @@ -199,7 +199,7 @@ bool ArgumentsObject::put(Managed *m, Identifier id, const Value &value, Value * return Object::put(m, id, value, receiver); } -bool ArgumentsObject::deleteProperty(Managed *m, Identifier id) +bool ArgumentsObject::deleteProperty(Managed *m, PropertyKey id) { ArgumentsObject *args = static_cast(m); if (!args->fullyCreated()) @@ -207,7 +207,7 @@ bool ArgumentsObject::deleteProperty(Managed *m, Identifier id) return Object::deleteProperty(m, id); } -PropertyAttributes ArgumentsObject::getOwnProperty(Managed *m, Identifier id, Property *p) +PropertyAttributes ArgumentsObject::getOwnProperty(Managed *m, PropertyKey id, Property *p) { const ArgumentsObject *args = static_cast(m); if (!id.isArrayIndex() || args->fullyCreated()) diff --git a/src/qml/jsruntime/qv4argumentsobject_p.h b/src/qml/jsruntime/qv4argumentsobject_p.h index 07ff44028b..54d41e7749 100644 --- a/src/qml/jsruntime/qv4argumentsobject_p.h +++ b/src/qml/jsruntime/qv4argumentsobject_p.h @@ -146,11 +146,11 @@ struct ArgumentsObject: Object { return m->vtable() == staticVTable(); } - static bool defineOwnProperty(Managed *m, Identifier id, const Property *desc, PropertyAttributes attrs); - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty); - static bool put(Managed *m, Identifier id, const Value &value, Value *receiver); - static bool deleteProperty(Managed *m, Identifier id); - static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p); + static bool defineOwnProperty(Managed *m, PropertyKey id, const Property *desc, PropertyAttributes attrs); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool put(Managed *m, PropertyKey id, const Value &value, Value *receiver); + static bool deleteProperty(Managed *m, PropertyKey id); + static PropertyAttributes getOwnProperty(Managed *m, PropertyKey id, Property *p); static qint64 getLength(const Managed *m); void fullyCreate(); diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 0016244232..39c0fe2150 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -247,7 +247,7 @@ ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const V mappedValue = *nextValue; } - if (a->getOwnProperty(Identifier::fromArrayIndex(k)) == Attr_Invalid) { + if (a->getOwnProperty(PropertyKey::fromArrayIndex(k)) == Attr_Invalid) { a->arraySet(k, mappedValue); } else { // Don't return: we need to close the iterator. @@ -289,7 +289,7 @@ ReturnedValue ArrayPrototype::method_from(const FunctionObject *builtin, const V mappedValue = kValue; } - if (a->getOwnProperty(Identifier::fromArrayIndex(k)) != Attr_Invalid) + if (a->getOwnProperty(PropertyKey::fromArrayIndex(k)) != Attr_Invalid) return scope.engine->throwTypeError(QString::fromLatin1("Cannot redefine property: %1").arg(k)); a->arraySet(k, mappedValue); @@ -318,7 +318,7 @@ ReturnedValue ArrayPrototype::method_of(const FunctionObject *builtin, const Val int k = 0; while (k < argc) { - if (a->getOwnProperty(Identifier::fromArrayIndex(k)) != Attr_Invalid) { + if (a->getOwnProperty(PropertyKey::fromArrayIndex(k)) != Attr_Invalid) { return scope.engine->throwTypeError(QString::fromLatin1("Cannot redefine property: %1").arg(k)); } a->arraySet(k, argv[k]); @@ -450,7 +450,7 @@ ReturnedValue ArrayPrototype::method_copyWithin(const FunctionObject *b, const V instance->setIndexed(to, fromVal, QV4::Object::DoThrowOnRejection); CHECK_EXCEPTION(); } else { - bool didDelete = instance->deleteProperty(Identifier::fromArrayIndex(to)); + bool didDelete = instance->deleteProperty(PropertyKey::fromArrayIndex(to)); CHECK_EXCEPTION(); if (!didDelete) { return scope.engine->throwTypeError(); @@ -624,7 +624,7 @@ ReturnedValue ArrayPrototype::method_pop(const FunctionObject *b, const Value *t ScopedValue result(scope, instance->get(len - 1)); CHECK_EXCEPTION(); - if (!instance->deleteProperty(Identifier::fromArrayIndex(len - 1))) + if (!instance->deleteProperty(PropertyKey::fromArrayIndex(len - 1))) return scope.engine->throwTypeError(); if (instance->isArrayObject()) @@ -715,12 +715,12 @@ ReturnedValue ArrayPrototype::method_reverse(const FunctionObject *b, const Valu if (hiExists) ok = instance->put(lo, hval); else - ok = instance->deleteProperty(Identifier::fromArrayIndex(lo)); + ok = instance->deleteProperty(PropertyKey::fromArrayIndex(lo)); if (ok) { if (loExists) ok = instance->put(hi, lval); else - ok = instance->deleteProperty(Identifier::fromArrayIndex(hi)); + ok = instance->deleteProperty(PropertyKey::fromArrayIndex(hi)); } if (!ok) return scope.engine->throwTypeError(); @@ -763,11 +763,11 @@ ReturnedValue ArrayPrototype::method_shift(const FunctionObject *b, const Value if (exists) ok = instance->put(k - 1, v); else - ok = instance->deleteProperty(Identifier::fromArrayIndex(k - 1)); + ok = instance->deleteProperty(PropertyKey::fromArrayIndex(k - 1)); if (!ok) return scope.engine->throwTypeError(); } - bool ok = instance->deleteProperty(Identifier::fromArrayIndex(len - 1)); + bool ok = instance->deleteProperty(PropertyKey::fromArrayIndex(len - 1)); if (!ok) return scope.engine->throwTypeError(); } @@ -891,12 +891,12 @@ ReturnedValue ArrayPrototype::method_splice(const FunctionObject *b, const Value if (exists) ok = instance->put(k + itemCount, v); else - ok = instance->deleteProperty(Identifier::fromArrayIndex(k + itemCount)); + ok = instance->deleteProperty(PropertyKey::fromArrayIndex(k + itemCount)); if (!ok) return scope.engine->throwTypeError(); } for (uint k = len; k > len - deleteCount + itemCount; --k) { - if (!instance->deleteProperty(Identifier::fromArrayIndex(k - 1))) + if (!instance->deleteProperty(PropertyKey::fromArrayIndex(k - 1))) return scope.engine->throwTypeError(); } } else if (itemCount > deleteCount) { @@ -909,7 +909,7 @@ ReturnedValue ArrayPrototype::method_splice(const FunctionObject *b, const Value if (exists) ok = instance->put(k + itemCount - 1, v); else - ok = instance->deleteProperty(Identifier::fromArrayIndex(k + itemCount - 1)); + ok = instance->deleteProperty(PropertyKey::fromArrayIndex(k + itemCount - 1)); if (!ok) return scope.engine->throwTypeError(); --k; @@ -949,7 +949,7 @@ ReturnedValue ArrayPrototype::method_unshift(const FunctionObject *b, const Valu if (exists) ok = instance->put(k + argc - 1, v); else - ok = instance->deleteProperty(Identifier::fromArrayIndex(k + argc - 1)); + ok = instance->deleteProperty(PropertyKey::fromArrayIndex(k + argc - 1)); if (!ok) return scope.engine->throwTypeError(); } diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 0ae79c8b36..f01ec33c64 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -178,7 +178,7 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable) ctx = ctx->d()->outer; } - Identifier id = name->toPropertyKey(); + PropertyKey id = name->toPropertyKey(); if (activation->getOwnProperty(id) != Attr_Invalid) return; ScopedProperty desc(scope); @@ -191,7 +191,7 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable) bool ExecutionContext::deleteProperty(String *name) { name->makeIdentifier(); - Identifier id = name->identifier(); + PropertyKey id = name->identifier(); Heap::ExecutionContext *ctx = d(); for (; ctx; ctx = ctx->outer) { @@ -227,7 +227,7 @@ bool ExecutionContext::deleteProperty(String *name) ExecutionContext::Error ExecutionContext::setProperty(String *name, const Value &value) { name->makeIdentifier(); - Identifier id = name->identifier(); + PropertyKey id = name->identifier(); QV4::ExecutionEngine *v4 = engine(); Heap::ExecutionContext *ctx = d(); @@ -290,7 +290,7 @@ ReturnedValue ExecutionContext::getProperty(String *name) case Heap::ExecutionContext::Type_BlockContext: case Heap::ExecutionContext::Type_CallContext: { Heap::CallContext *c = static_cast(ctx); - Identifier id = name->identifier(); + PropertyKey id = name->identifier(); uint index = c->internalClass->find(id); if (index < UINT_MAX) @@ -327,7 +327,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Value *base) case Heap::ExecutionContext::Type_CallContext: { Heap::CallContext *c = static_cast(ctx); name->makeIdentifier(); - Identifier id = name->identifier(); + PropertyKey id = name->identifier(); uint index = c->internalClass->find(id); if (index < UINT_MAX) diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 092c36e52a..5b81d91879 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -1524,7 +1524,7 @@ ReturnedValue DatePrototype::method_symbolToPrimitive(const FunctionObject *f, c return e->throwTypeError(); String *hint = argv->stringValue(); - Identifier id = hint->identifier(); + PropertyKey id = hint->identifier(); if (id == e->id_default()->identifier()) hint = e->id_string(); else if (id != e->id_string()->identifier() && id != e->id_number()->identifier()) diff --git a/src/qml/jsruntime/qv4identifier.cpp b/src/qml/jsruntime/qv4identifier.cpp index 1e9a807848..fb2e9c29c2 100644 --- a/src/qml/jsruntime/qv4identifier.cpp +++ b/src/qml/jsruntime/qv4identifier.cpp @@ -44,33 +44,6 @@ QT_BEGIN_NAMESPACE namespace QV4 { -bool Identifier::isString() const -{ - return isStringOrSymbol() && asStringOrSymbol()->internalClass->vtable->isString; -} - -bool Identifier::isSymbol() const -{ - return isStringOrSymbol() && !asStringOrSymbol()->internalClass->vtable->isString && asStringOrSymbol()->internalClass->vtable->isStringOrSymbol; -} - -Heap::StringOrSymbol *Identifier::toStringOrSymbol(ExecutionEngine *e) -{ - if (isArrayIndex()) - return Primitive::fromUInt32(asArrayIndex()).toString(e); - return static_cast(asStringOrSymbol()); -} - -QString Identifier::toQString() const -{ - if (isArrayIndex()) - return QString::number(asArrayIndex()); - Heap::Base *b = asStringOrSymbol(); - Q_ASSERT(b->internalClass->vtable->isStringOrSymbol); - Heap::StringOrSymbol *s = static_cast(b); - return s->toQString(); -} - static const uchar prime_deltas[] = { 0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 9, 25, 3, 1, 21, 3, 21, 7, 15, 9, 5, 3, 29, 15, 0, 0, 0, 0, 0 @@ -128,7 +101,7 @@ void IdentifierHash::detach() } -IdentifierHashEntry *IdentifierHash::addEntry(Identifier identifier) +IdentifierHashEntry *IdentifierHash::addEntry(PropertyKey identifier) { Q_ASSERT(identifier.isStringOrSymbol()); @@ -144,7 +117,7 @@ IdentifierHashEntry *IdentifierHash::addEntry(Identifier identifier) const IdentifierHashEntry &e = d->entries[i]; if (!e.identifier.isValid()) continue; - uint idx = e.identifier.id % newAlloc; + uint idx = e.identifier.id() % newAlloc; while (newEntries[idx].identifier.isValid()) { ++idx; idx %= newAlloc; @@ -156,7 +129,7 @@ IdentifierHashEntry *IdentifierHash::addEntry(Identifier identifier) d->alloc = newAlloc; } - uint idx = identifier.id % d->alloc; + uint idx = identifier.id() % d->alloc; while (d->entries[idx].identifier.isValid()) { Q_ASSERT(d->entries[idx].identifier != identifier); ++idx; @@ -167,13 +140,13 @@ IdentifierHashEntry *IdentifierHash::addEntry(Identifier identifier) return d->entries + idx; } -const IdentifierHashEntry *IdentifierHash::lookup(Identifier identifier) const +const IdentifierHashEntry *IdentifierHash::lookup(PropertyKey identifier) const { if (!d || !identifier.isStringOrSymbol()) return nullptr; Q_ASSERT(d->entries); - uint idx = identifier.id % d->alloc; + uint idx = identifier.id() % d->alloc; while (1) { if (!d->entries[idx].identifier.isValid()) return nullptr; @@ -189,7 +162,7 @@ const IdentifierHashEntry *IdentifierHash::lookup(const QString &str) const if (!d) return nullptr; - Identifier id = d->identifierTable->identifier(str); + PropertyKey id = d->identifierTable->identifier(str); return lookup(id); } @@ -197,19 +170,19 @@ const IdentifierHashEntry *IdentifierHash::lookup(String *str) const { if (!d) return nullptr; - Identifier id = d->identifierTable->identifier(str); + PropertyKey id = d->identifierTable->identifier(str); if (id.isValid()) return lookup(id); return lookup(str->toQString()); } -const Identifier IdentifierHash::toIdentifier(const QString &str) const +const PropertyKey IdentifierHash::toIdentifier(const QString &str) const { Q_ASSERT(d); return d->identifierTable->identifier(str); } -const Identifier IdentifierHash::toIdentifier(Heap::String *str) const +const PropertyKey IdentifierHash::toIdentifier(Heap::String *str) const { Q_ASSERT(d); return d->identifierTable->identifier(str); diff --git a/src/qml/jsruntime/qv4identifier_p.h b/src/qml/jsruntime/qv4identifier_p.h index bf6d5cb7f6..32de8b7c8d 100644 --- a/src/qml/jsruntime/qv4identifier_p.h +++ b/src/qml/jsruntime/qv4identifier_p.h @@ -52,42 +52,14 @@ #include #include +#include QT_BEGIN_NAMESPACE namespace QV4 { -struct Identifier -{ - // id's are either pointers to Heap::String or Heap::Symbol from the Identifier table. - // For Symbol is can simply point to itself. - // This gives us automative GC'ing of identifiers - // In addition, an identifier can have the lowest bit set, and then indicates an array index - quint64 id; - - static Identifier invalid() { return Identifier{ 0 }; } - static Identifier fromArrayIndex(uint idx) { return Identifier{ (quint64(idx) << 1) | 1 }; } - bool isStringOrSymbol() const { return id && !(id & 1); } - uint asArrayIndex() const { return (id & 1) ? (id >> 1) : std::numeric_limits::max(); } - uint isArrayIndex() const { return (id & 1); } - static Identifier fromStringOrSymbol(Heap::StringOrSymbol *b) { return Identifier{ reinterpret_cast(b) }; } - Heap::StringOrSymbol *asStringOrSymbol() const { return (id & 1) ? nullptr : reinterpret_cast(id); } - - bool isValid() const { return id != 0; } - bool isString() const; - bool isSymbol() const; - - Q_QML_EXPORT QString toQString() const; - Heap::StringOrSymbol *toStringOrSymbol(ExecutionEngine *e); - - bool operator ==(const Identifier &other) const { return id == other.id; } - bool operator !=(const Identifier &other) const { return id != other.id; } - bool operator <(const Identifier &other) const { return id < other.id; } -}; - - struct IdentifierHashEntry { - Identifier identifier; + PropertyKey identifier; int value; }; @@ -131,12 +103,12 @@ struct IdentifierHash QString findId(int value) const; protected: - IdentifierHashEntry *addEntry(Identifier i); - const IdentifierHashEntry *lookup(Identifier identifier) const; + IdentifierHashEntry *addEntry(PropertyKey i); + const IdentifierHashEntry *lookup(PropertyKey identifier) const; const IdentifierHashEntry *lookup(const QString &str) const; const IdentifierHashEntry *lookup(String *str) const; - const Identifier toIdentifier(const QString &str) const; - const Identifier toIdentifier(Heap::String *str) const; + const PropertyKey toIdentifier(const QString &str) const; + const PropertyKey toIdentifier(Heap::String *str) const; }; diff --git a/src/qml/jsruntime/qv4identifiertable.cpp b/src/qml/jsruntime/qv4identifiertable.cpp index b4e12cab17..f6e0ef330a 100644 --- a/src/qml/jsruntime/qv4identifiertable.cpp +++ b/src/qml/jsruntime/qv4identifiertable.cpp @@ -81,7 +81,7 @@ void IdentifierTable::addEntry(Heap::StringOrSymbol *str) if (str->subtype == Heap::String::StringType_ArrayIndex) return; - str->identifier = Identifier::fromStringOrSymbol(str); + str->identifier = PropertyKey::fromStringOrSymbol(str); bool grow = (alloc <= size*2); @@ -110,7 +110,7 @@ void IdentifierTable::addEntry(Heap::StringOrSymbol *str) Heap::StringOrSymbol *e = entriesById[i]; if (!e) continue; - uint idx = e->identifier.id % newAlloc; + uint idx = e->identifier.id() % newAlloc; while (newEntries[idx]) { ++idx; idx %= newAlloc; @@ -130,7 +130,7 @@ void IdentifierTable::addEntry(Heap::StringOrSymbol *str) } entriesByHash[idx] = str; - idx = str->identifier.id % alloc; + idx = str->identifier.id() % alloc; while (entriesById[idx]) { ++idx; idx %= alloc; @@ -190,13 +190,13 @@ Heap::Symbol *IdentifierTable::insertSymbol(const QString &s) } -Identifier IdentifierTable::identifierImpl(const Heap::String *str) +PropertyKey IdentifierTable::identifierImpl(const Heap::String *str) { if (str->identifier.isValid()) return str->identifier; uint hash = str->hashValue(); if (str->subtype == Heap::String::StringType_ArrayIndex) { - str->identifier = Identifier::fromArrayIndex(hash); + str->identifier = PropertyKey::fromArrayIndex(hash); return str->identifier; } @@ -214,7 +214,7 @@ Identifier IdentifierTable::identifierImpl(const Heap::String *str) return str->identifier; } -Heap::StringOrSymbol *IdentifierTable::resolveId(Identifier i) const +Heap::StringOrSymbol *IdentifierTable::resolveId(PropertyKey i) const { uint arrayIdx = i.asArrayIndex(); if (arrayIdx < UINT_MAX) @@ -222,7 +222,7 @@ Heap::StringOrSymbol *IdentifierTable::resolveId(Identifier i) const if (!i.isValid()) return nullptr; - uint idx = i.id % alloc; + uint idx = i.id() % alloc; while (1) { Heap::StringOrSymbol *e = entriesById[idx]; if (!e || e->identifier == i) @@ -232,14 +232,14 @@ Heap::StringOrSymbol *IdentifierTable::resolveId(Identifier i) const } } -Heap::String *IdentifierTable::stringForId(Identifier i) const +Heap::String *IdentifierTable::stringForId(PropertyKey i) const { Heap::StringOrSymbol *s = resolveId(i); Q_ASSERT(s && s->internalClass->vtable->isString); return static_cast(s); } -Heap::Symbol *IdentifierTable::symbolForId(Identifier i) const +Heap::Symbol *IdentifierTable::symbolForId(PropertyKey i) const { Heap::StringOrSymbol *s = resolveId(i); Q_ASSERT(!s || !s->internalClass->vtable->isString); @@ -300,18 +300,18 @@ int sweepTable(Heap::StringOrSymbol **table, int alloc, std::function(entriesByHash, alloc, [](Heap::StringOrSymbol *entry) {return entry->hashValue(); }); - int freed = sweepTable(entriesById, alloc, [](Heap::StringOrSymbol *entry) {return entry->identifier.id; }); + int freed = sweepTable(entriesById, alloc, [](Heap::StringOrSymbol *entry) {return entry->identifier.id(); }); Q_UNUSED(f); Q_ASSERT(f == freed); size -= freed; } -Identifier IdentifierTable::identifier(const QString &s) +PropertyKey IdentifierTable::identifier(const QString &s) { return insertString(s)->identifier; } -Identifier IdentifierTable::identifier(const char *s, int len) +PropertyKey IdentifierTable::identifier(const char *s, int len) { uint subtype; uint hash = String::createHashValue(s, len, &subtype); diff --git a/src/qml/jsruntime/qv4identifiertable_p.h b/src/qml/jsruntime/qv4identifiertable_p.h index 6e6600d055..9d9f7c02cf 100644 --- a/src/qml/jsruntime/qv4identifiertable_p.h +++ b/src/qml/jsruntime/qv4identifiertable_p.h @@ -82,23 +82,23 @@ public: Heap::String *insertString(const QString &s); Heap::Symbol *insertSymbol(const QString &s); - Identifier identifier(const Heap::String *str) { + PropertyKey identifier(const Heap::String *str) { if (str->identifier.isValid()) return str->identifier; return identifierImpl(str); } - Identifier identifier(const QV4::String *str) { + PropertyKey identifier(const QV4::String *str) { return identifier(str->d()); } - Identifier identifier(const QString &s); - Identifier identifier(const char *s, int len); + PropertyKey identifier(const QString &s); + PropertyKey identifier(const char *s, int len); - Identifier identifierImpl(const Heap::String *str); + PropertyKey identifierImpl(const Heap::String *str); - Heap::StringOrSymbol *resolveId(Identifier i) const; - Q_QML_PRIVATE_EXPORT Heap::String *stringForId(Identifier i) const; - Q_QML_PRIVATE_EXPORT Heap::Symbol *symbolForId(Identifier i) const; + Heap::StringOrSymbol *resolveId(PropertyKey i) const; + Q_QML_PRIVATE_EXPORT Heap::String *stringForId(PropertyKey i) const; + Q_QML_PRIVATE_EXPORT Heap::Symbol *symbolForId(PropertyKey i) const; void markObjects(MarkStack *markStack); void sweep(); diff --git a/src/qml/jsruntime/qv4internalclass.cpp b/src/qml/jsruntime/qv4internalclass.cpp index da8b581639..c890dc0550 100644 --- a/src/qml/jsruntime/qv4internalclass.cpp +++ b/src/qml/jsruntime/qv4internalclass.cpp @@ -77,7 +77,7 @@ void PropertyHash::addEntry(const PropertyHash::Entry &entry, int classSize) if (classSize < d->size || grow) detach(grow, classSize); - uint idx = entry.identifier.id % d->alloc; + uint idx = entry.identifier.id() % d->alloc; while (d->entries[idx].identifier.isValid()) { ++idx; idx %= d->alloc; @@ -86,7 +86,7 @@ void PropertyHash::addEntry(const PropertyHash::Entry &entry, int classSize) ++d->size; } -int PropertyHash::removeIdentifier(Identifier identifier, int classSize) +int PropertyHash::removeIdentifier(PropertyKey identifier, int classSize) { int val = -1; PropertyHashData *dd = new PropertyHashData(d->numBits); @@ -98,7 +98,7 @@ int PropertyHash::removeIdentifier(Identifier identifier, int classSize) val = e.index; continue; } - uint idx = e.identifier.id % dd->alloc; + uint idx = e.identifier.id() % dd->alloc; while (dd->entries[idx].identifier.isValid()) { ++idx; idx %= dd->alloc; @@ -124,7 +124,7 @@ void PropertyHash::detach(bool grow, int classSize) const Entry &e = d->entries[i]; if (!e.identifier.isValid() || e.index >= static_cast(classSize)) continue; - uint idx = e.identifier.id % dd->alloc; + uint idx = e.identifier.id() % dd->alloc; while (dd->entries[idx].identifier.isValid()) { ++idx; idx %= dd->alloc; @@ -143,7 +143,7 @@ void InternalClass::init(ExecutionEngine *engine) { Base::init(); new (&propertyTable) PropertyHash(); - new (&nameMap) SharedInternalClassData(); + new (&nameMap) SharedInternalClassData(); new (&propertyData) SharedInternalClassData(); new (&transitions) std::vector(); @@ -168,7 +168,7 @@ void InternalClass::init(Heap::InternalClass *other) Base::init(); Q_ASSERT(!other->isFrozen); new (&propertyTable) PropertyHash(other->propertyTable); - new (&nameMap) SharedInternalClassData(other->nameMap); + new (&nameMap) SharedInternalClassData(other->nameMap); new (&propertyData) SharedInternalClassData(other->propertyData); new (&transitions) std::vector(); @@ -197,7 +197,7 @@ void InternalClass::destroy() parent->removeChildEntry(this); propertyTable.~PropertyHash(); - nameMap.~SharedInternalClassData(); + nameMap.~SharedInternalClassData(); propertyData.~SharedInternalClassData(); transitions.~vector(); engine = nullptr; @@ -225,7 +225,7 @@ static void removeFromPropertyData(QV4::Object *object, int idx, bool accessor = o->setProperty(v4, size + 1, Primitive::undefinedValue()); } -void InternalClass::changeMember(QV4::Object *object, Identifier id, PropertyAttributes data, uint *index) +void InternalClass::changeMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, uint *index) { Q_ASSERT(id.isStringOrSymbol()); uint idx; @@ -261,12 +261,12 @@ static void addDummyEntry(InternalClass *newClass, PropertyHash::Entry e) { // add a dummy entry, since we need two entries for accessors newClass->propertyTable.addEntry(e, newClass->size); - newClass->nameMap.add(newClass->size, Identifier::invalid()); + newClass->nameMap.add(newClass->size, PropertyKey::invalid()); newClass->propertyData.add(newClass->size, PropertyAttributes()); ++newClass->size; } -Heap::InternalClass *InternalClass::changeMember(Identifier identifier, PropertyAttributes data, uint *index) +Heap::InternalClass *InternalClass::changeMember(PropertyKey identifier, PropertyAttributes data, uint *index) { data.resolve(); uint idx = find(identifier); @@ -288,11 +288,11 @@ Heap::InternalClass *InternalClass::changeMember(Identifier identifier, Property if (data.isAccessor() != propertyData.at(idx).isAccessor()) { // this changes the layout of the class, so we need to rebuild the data newClass->propertyTable = PropertyHash(); - newClass->nameMap = SharedInternalClassData(); + newClass->nameMap = SharedInternalClassData(); newClass->propertyData = SharedInternalClassData(); newClass->size = 0; for (uint i = 0; i < size; ++i) { - Identifier identifier = nameMap.at(i); + PropertyKey identifier = nameMap.at(i); PropertyHash::Entry e = { identifier, newClass->size }; if (i && !identifier.isValid()) e.identifier = nameMap.at(i - 1); @@ -328,7 +328,7 @@ Heap::InternalClass *InternalClass::changePrototypeImpl(Heap::Object *proto) Q_ASSERT(prototype != proto); Q_ASSERT(!proto || proto->internalClass->isUsedAsProto); - Transition temp = { { Identifier::invalid() }, nullptr, Transition::PrototypeChange }; + Transition temp = { { PropertyKey::invalid() }, nullptr, Transition::PrototypeChange }; temp.prototype = proto; Transition &t = lookupOrInsertTransition(temp); @@ -348,7 +348,7 @@ Heap::InternalClass *InternalClass::changeVTableImpl(const VTable *vt) { Q_ASSERT(vtable != vt); - Transition temp = { { Identifier::invalid() }, nullptr, Transition::VTableChange }; + Transition temp = { { PropertyKey::invalid() }, nullptr, Transition::VTableChange }; temp.vtable = vt; Transition &t = lookupOrInsertTransition(temp); @@ -370,7 +370,7 @@ Heap::InternalClass *InternalClass::nonExtensible() if (!extensible) return this; - Transition temp = { { Identifier::invalid() }, nullptr, Transition::NotExtensible}; + Transition temp = { { PropertyKey::invalid() }, nullptr, Transition::NotExtensible}; Transition &t = lookupOrInsertTransition(temp); if (t.lookup) return t.lookup; @@ -383,7 +383,7 @@ Heap::InternalClass *InternalClass::nonExtensible() return newClass; } -void InternalClass::addMember(QV4::Object *object, Identifier id, PropertyAttributes data, uint *index) +void InternalClass::addMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, uint *index) { Q_ASSERT(id.isStringOrSymbol()); data.resolve(); @@ -400,7 +400,7 @@ void InternalClass::addMember(QV4::Object *object, Identifier id, PropertyAttrib object->setInternalClass(newClass); } -Heap::InternalClass *InternalClass::addMember(Identifier identifier, PropertyAttributes data, uint *index) +Heap::InternalClass *InternalClass::addMember(PropertyKey identifier, PropertyAttributes data, uint *index) { Q_ASSERT(identifier.isStringOrSymbol()); data.resolve(); @@ -411,7 +411,7 @@ Heap::InternalClass *InternalClass::addMember(Identifier identifier, PropertyAtt return addMemberImpl(identifier, data, index); } -Heap::InternalClass *InternalClass::addMemberImpl(Identifier identifier, PropertyAttributes data, uint *index) +Heap::InternalClass *InternalClass::addMemberImpl(PropertyKey identifier, PropertyAttributes data, uint *index) { Transition temp = { { identifier }, nullptr, (int)data.flags() }; Transition &t = lookupOrInsertTransition(temp); @@ -451,7 +451,7 @@ void InternalClass::removeChildEntry(InternalClass *child) } -void InternalClass::removeMember(QV4::Object *object, Identifier identifier) +void InternalClass::removeMember(QV4::Object *object, PropertyKey identifier) { Heap::InternalClass *oldClass = object->internalClass(); Q_ASSERT(oldClass->propertyTable.lookup(identifier) < oldClass->size); @@ -464,7 +464,7 @@ void InternalClass::removeMember(QV4::Object *object, Identifier identifier) Heap::InternalClass *newClass = oldClass->engine->newClass(oldClass); // simply make the entry inaccessible int idx = newClass->propertyTable.removeIdentifier(identifier, oldClass->size); - newClass->nameMap.set(idx, Identifier::invalid()); + newClass->nameMap.set(idx, PropertyKey::invalid()); newClass->propertyData.set(idx, PropertyAttributes()); t.lookup = newClass; Q_ASSERT(t.lookup); @@ -496,7 +496,7 @@ Heap::InternalClass *InternalClass::sealed() return this; } - Transition temp = { { Identifier::invalid() }, nullptr, InternalClassTransition::Sealed }; + Transition temp = { { PropertyKey::invalid() }, nullptr, InternalClassTransition::Sealed }; Transition &t = lookupOrInsertTransition(temp); if (t.lookup) { @@ -542,7 +542,7 @@ Heap::InternalClass *InternalClass::frozen() return this; } - Transition temp = { { Identifier::invalid() }, nullptr, InternalClassTransition::Frozen }; + Transition temp = { { PropertyKey::invalid() }, nullptr, InternalClassTransition::Frozen }; Transition &t = lookupOrInsertTransition(temp); if (t.lookup) { @@ -590,7 +590,7 @@ Heap::InternalClass *InternalClass::asProtoClass() if (isUsedAsProto) return this; - Transition temp = { { Identifier::invalid() }, nullptr, Transition::ProtoClass }; + Transition temp = { { PropertyKey::invalid() }, nullptr, Transition::ProtoClass }; Transition &t = lookupOrInsertTransition(temp); if (t.lookup) return t.lookup; @@ -632,7 +632,7 @@ void InternalClass::markObjects(Heap::Base *b, MarkStack *stack) ic->parent->mark(stack); for (uint i = 0; i < ic->size; ++i) { - Identifier id = ic->nameMap.at(i); + PropertyKey id = ic->nameMap.at(i); if (Heap::Base *b = id.asStringOrSymbol()) b->mark(stack); } diff --git a/src/qml/jsruntime/qv4internalclass_p.h b/src/qml/jsruntime/qv4internalclass_p.h index 5a1a3ff687..888eedcaba 100644 --- a/src/qml/jsruntime/qv4internalclass_p.h +++ b/src/qml/jsruntime/qv4internalclass_p.h @@ -53,7 +53,7 @@ #include "qv4global_p.h" #include -#include +#include #include QT_BEGIN_NAMESPACE @@ -67,7 +67,7 @@ struct PropertyHashData; struct PropertyHash { struct Entry { - Identifier identifier; + PropertyKey identifier; uint index; }; @@ -79,8 +79,8 @@ struct PropertyHash PropertyHash &operator=(const PropertyHash &other); void addEntry(const Entry &entry, int classSize); - uint lookup(Identifier identifier) const; - int removeIdentifier(Identifier identifier, int classSize); + uint lookup(PropertyKey identifier) const; + int removeIdentifier(PropertyKey identifier, int classSize); void detach(bool grow, int classSize); }; @@ -126,11 +126,11 @@ inline PropertyHash &PropertyHash::operator=(const PropertyHash &other) -inline uint PropertyHash::lookup(Identifier identifier) const +inline uint PropertyHash::lookup(PropertyKey identifier) const { Q_ASSERT(d->entries); - uint idx = identifier.id % d->alloc; + uint idx = identifier.id() % d->alloc; while (1) { if (d->entries[idx].identifier == identifier) return d->entries[idx].index; @@ -234,7 +234,7 @@ struct SharedInternalClassData { struct InternalClassTransition { union { - Identifier id; + PropertyKey id; const VTable *vtable; Heap::Object *prototype; }; @@ -268,7 +268,7 @@ struct InternalClass : Base { InternalClass *parent; PropertyHash propertyTable; // id to valueIndex - SharedInternalClassData nameMap; + SharedInternalClassData nameMap; SharedInternalClassData propertyData; typedef InternalClassTransition Transition; @@ -287,12 +287,12 @@ struct InternalClass : Base { Q_REQUIRED_RESULT InternalClass *nonExtensible(); - static void addMember(QV4::Object *object, Identifier id, PropertyAttributes data, uint *index); - Q_REQUIRED_RESULT InternalClass *addMember(Identifier identifier, PropertyAttributes data, uint *index = nullptr); - Q_REQUIRED_RESULT InternalClass *changeMember(Identifier identifier, PropertyAttributes data, uint *index = nullptr); - static void changeMember(QV4::Object *object, Identifier id, PropertyAttributes data, uint *index = nullptr); - static void removeMember(QV4::Object *object, Identifier identifier); - uint find(const Identifier id) + static void addMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, uint *index); + Q_REQUIRED_RESULT InternalClass *addMember(PropertyKey identifier, PropertyAttributes data, uint *index = nullptr); + Q_REQUIRED_RESULT InternalClass *changeMember(PropertyKey identifier, PropertyAttributes data, uint *index = nullptr); + static void changeMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, uint *index = nullptr); + static void removeMember(QV4::Object *object, PropertyKey identifier); + uint find(const PropertyKey id) { Q_ASSERT(id.isStringOrSymbol()); @@ -327,7 +327,7 @@ struct InternalClass : Base { private: Q_QML_EXPORT InternalClass *changeVTableImpl(const VTable *vt); Q_QML_EXPORT InternalClass *changePrototypeImpl(Heap::Object *proto); - InternalClass *addMemberImpl(Identifier identifier, PropertyAttributes data, uint *index); + InternalClass *addMemberImpl(PropertyKey identifier, PropertyAttributes data, uint *index); void removeChildEntry(InternalClass *child); friend struct ExecutionEngine; diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 594648373a..43628ad4f5 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE using namespace QV4; -void Lookup::resolveProtoGetter(Identifier name, const Heap::Object *proto) +void Lookup::resolveProtoGetter(PropertyKey name, const Heap::Object *proto) { while (proto) { uint index = proto->internalClass->find(name); @@ -70,7 +70,7 @@ void Lookup::resolveProtoGetter(Identifier name, const Heap::Object *proto) ReturnedValue Lookup::resolveGetter(ExecutionEngine *engine, const Object *object) { Heap::Object *obj = object->d(); - Identifier name = engine->identifierTable->identifier(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); + PropertyKey name = engine->identifierTable->identifier(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); if (name.isArrayIndex()) { indexedLookup.index = name.asArrayIndex(); getter = getterIndexed; @@ -131,7 +131,7 @@ ReturnedValue Lookup::resolvePrimitiveGetter(ExecutionEngine *engine, const Valu primitiveLookup.proto = engine->numberPrototype()->d(); } - Identifier name = engine->identifierTable->identifier(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); + PropertyKey name = engine->identifierTable->identifier(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); protoLookup.protoId = primitiveLookup.proto->internalClass->protoId; resolveProtoGetter(name, primitiveLookup.proto); @@ -145,7 +145,7 @@ ReturnedValue Lookup::resolvePrimitiveGetter(ExecutionEngine *engine, const Valu ReturnedValue Lookup::resolveGlobalGetter(ExecutionEngine *engine) { Object *o = engine->globalObject; - Identifier name = engine->identifierTable->identifier(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); + PropertyKey name = engine->identifierTable->identifier(engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]); protoLookup.protoId = o->internalClass()->protoId; resolveProtoGetter(name, o->d()); diff --git a/src/qml/jsruntime/qv4lookup_p.h b/src/qml/jsruntime/qv4lookup_p.h index 7fb9976135..c7555539b4 100644 --- a/src/qml/jsruntime/qv4lookup_p.h +++ b/src/qml/jsruntime/qv4lookup_p.h @@ -122,7 +122,7 @@ struct Lookup { ReturnedValue resolveGetter(ExecutionEngine *engine, const Object *object); ReturnedValue resolvePrimitiveGetter(ExecutionEngine *engine, const Value &object); ReturnedValue resolveGlobalGetter(ExecutionEngine *engine); - void resolveProtoGetter(Identifier name, const Heap::Object *proto); + void resolveProtoGetter(PropertyKey name, const Heap::Object *proto); static ReturnedValue getterGeneric(Lookup *l, ExecutionEngine *engine, const Value &object); static ReturnedValue getterTwoClasses(Lookup *l, ExecutionEngine *engine, const Value &object); diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 6983b52c83..5d07421be2 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -282,7 +282,7 @@ struct InternalClass : Managed Q_REQUIRED_RESULT Heap::InternalClass *changePrototype(Heap::Object *proto) { return d()->changePrototype(proto); } - Q_REQUIRED_RESULT Heap::InternalClass *addMember(Identifier identifier, PropertyAttributes data, uint *index = 0) { + Q_REQUIRED_RESULT Heap::InternalClass *addMember(PropertyKey identifier, PropertyAttributes data, uint *index = 0) { return d()->addMember(identifier, data, index); } diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 38e5b14b89..0ce5328193 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -268,7 +268,7 @@ void Object::setPrototypeUnchecked(const Object *p) } // Section 8.12.2 -PropertyIndex Object::getValueOrSetter(Identifier id, PropertyAttributes *attrs) +PropertyIndex Object::getValueOrSetter(PropertyKey id, PropertyAttributes *attrs) { if (id.isArrayIndex()) { uint index = id.asArrayIndex(); @@ -317,7 +317,7 @@ ReturnedValue Object::call(const FunctionObject *f, const Value *, const Value * return f->engine()->throwTypeError(); } -ReturnedValue Object::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +ReturnedValue Object::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { if (id.isArrayIndex()) return static_cast(m)->internalGetIndexed(id.asArrayIndex(), receiver, hasProperty); @@ -326,12 +326,12 @@ ReturnedValue Object::get(const Managed *m, Identifier id, const Value *receiver return static_cast(m)->internalGet(name, receiver, hasProperty); } -bool Object::put(Managed *m, Identifier id, const Value &value, Value *receiver) +bool Object::put(Managed *m, PropertyKey id, const Value &value, Value *receiver) { return static_cast(m)->internalPut(id, value, receiver); } -bool Object::deleteProperty(Managed *m, Identifier id) +bool Object::deleteProperty(Managed *m, PropertyKey id) { return static_cast(m)->internalDeleteProperty(id); } @@ -383,7 +383,7 @@ void Object::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint * } while (it->memberIndex < o->internalClass()->size) { - Identifier n = o->internalClass()->nameMap.at(it->memberIndex); + PropertyKey n = o->internalClass()->nameMap.at(it->memberIndex); if (!n.isStringOrSymbol() || !n.asStringOrSymbol()->internalClass->vtable->isString) { // accessor properties have a dummy entry with n == 0 // symbol entries are supposed to be skipped @@ -413,7 +413,7 @@ ReturnedValue Object::internalGet(StringOrSymbol *name, const Value *receiver, b Q_ASSERT(name->asArrayIndex() == UINT_MAX); name->makeIdentifier(); - Identifier id = name->identifier(); + PropertyKey id = name->identifier(); Heap::Object *o = d(); while (o) { @@ -469,7 +469,7 @@ ReturnedValue Object::internalGetIndexed(uint index, const Value *receiver, bool // Section 8.12.5 -bool Object::internalPut(Identifier id, const Value &value, Value *receiver) +bool Object::internalPut(PropertyKey id, const Value &value, Value *receiver) { ExecutionEngine *engine = this->engine(); if (engine->hasException) @@ -563,7 +563,7 @@ bool Object::internalPut(Identifier id, const Value &value, Value *receiver) } // Section 8.12.7 -bool Object::internalDeleteProperty(Identifier id) +bool Object::internalDeleteProperty(PropertyKey id) { if (internalClass()->engine->hasException) return false; @@ -766,7 +766,7 @@ ReturnedValue Object::instanceOf(const Object *typeObject, const Value &var) return Encode(false); } -bool Object::hasProperty(const Managed *m, Identifier id) +bool Object::hasProperty(const Managed *m, PropertyKey id) { Scope scope(m->engine()); ScopedObject o(scope, m); @@ -781,7 +781,7 @@ bool Object::hasProperty(const Managed *m, Identifier id) return false; } -PropertyAttributes Object::getOwnProperty(Managed *m, Identifier id, Property *p) +PropertyAttributes Object::getOwnProperty(Managed *m, PropertyKey id, Property *p) { PropertyAttributes attrs; Object *o = static_cast(m); @@ -809,7 +809,7 @@ PropertyAttributes Object::getOwnProperty(Managed *m, Identifier id, Property *p return Attr_Invalid; } -bool Object::defineOwnProperty(Managed *m, Identifier id, const Property *p, PropertyAttributes attrs) +bool Object::defineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs) { Object *o = static_cast(m); Scope scope(o); @@ -976,7 +976,7 @@ QStringList ArrayObject::toQStringList() const return result; } -bool ArrayObject::defineOwnProperty(Managed *m, Identifier id, const Property *p, PropertyAttributes attrs) +bool ArrayObject::defineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs) { Q_ASSERT(m->isArrayObject()); ArrayObject *a = static_cast(m); diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 00ec790692..e604cdb190 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -169,12 +169,12 @@ struct ObjectVTable VTable vTable; ReturnedValue (*call)(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); ReturnedValue (*callAsConstructor)(const FunctionObject *, const Value *argv, int argc); - ReturnedValue (*get)(const Managed *, Identifier id, const Value *receiver, bool *hasProperty); - bool (*put)(Managed *, Identifier id, const Value &value, Value *receiver); - bool (*deleteProperty)(Managed *m, Identifier id); - bool (*hasProperty)(const Managed *m, Identifier id); - PropertyAttributes (*getOwnProperty)(Managed *m, Identifier id, Property *p); - bool (*defineOwnProperty)(Managed *m, Identifier id, const Property *p, PropertyAttributes attrs); + ReturnedValue (*get)(const Managed *, PropertyKey id, const Value *receiver, bool *hasProperty); + bool (*put)(Managed *, PropertyKey id, const Value &value, Value *receiver); + bool (*deleteProperty)(Managed *m, PropertyKey id); + bool (*hasProperty)(const Managed *m, PropertyKey id); + PropertyAttributes (*getOwnProperty)(Managed *m, PropertyKey id, Property *p); + bool (*defineOwnProperty)(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs); bool (*isExtensible)(const Managed *); bool (*preventExtensions)(Managed *); Heap::Object *(*getPrototypeOf)(const Managed *); @@ -245,17 +245,17 @@ struct Q_QML_EXPORT Object: Managed { const ObjectVTable *vtable() const { return reinterpret_cast(d()->vtable()); } - PropertyAttributes getOwnProperty(Identifier id, Property *p = nullptr) { + PropertyAttributes getOwnProperty(PropertyKey id, Property *p = nullptr) { return vtable()->getOwnProperty(this, id, p); } - PropertyIndex getValueOrSetter(Identifier id, PropertyAttributes *attrs); + PropertyIndex getValueOrSetter(PropertyKey id, PropertyAttributes *attrs); - bool hasProperty(Identifier id) const { + bool hasProperty(PropertyKey id) const { return vtable()->hasProperty(this, id); } - bool defineOwnProperty(Identifier id, const Property *p, PropertyAttributes attrs) { + bool defineOwnProperty(PropertyKey id, const Property *p, PropertyAttributes attrs) { return vtable()->defineOwnProperty(this, id, p, attrs); } @@ -374,20 +374,20 @@ public: inline ReturnedValue get(StringOrSymbol *name, bool *hasProperty = nullptr, const Value *receiver = nullptr) const { if (!receiver) receiver = this; return vtable()->get(this, name->toPropertyKey(), receiver, hasProperty); } inline ReturnedValue get(uint idx, bool *hasProperty = nullptr, const Value *receiver = nullptr) const - { if (!receiver) receiver = this; return vtable()->get(this, Identifier::fromArrayIndex(idx), receiver, hasProperty); } + { if (!receiver) receiver = this; return vtable()->get(this, PropertyKey::fromArrayIndex(idx), receiver, hasProperty); } QT_DEPRECATED inline ReturnedValue getIndexed(uint idx, bool *hasProperty = nullptr) const { return get(idx, hasProperty); } - inline ReturnedValue get(Identifier id, const Value *receiver = nullptr, bool *hasProperty = nullptr) const + inline ReturnedValue get(PropertyKey id, const Value *receiver = nullptr, bool *hasProperty = nullptr) const { if (!receiver) receiver = this; return vtable()->get(this, id, receiver, hasProperty); } // use the set variants instead, to customize throw behavior inline bool put(StringOrSymbol *name, const Value &v, Value *receiver = nullptr) { if (!receiver) receiver = this; return vtable()->put(this, name->toPropertyKey(), v, receiver); } inline bool put(uint idx, const Value &v, Value *receiver = nullptr) - { if (!receiver) receiver = this; return vtable()->put(this, Identifier::fromArrayIndex(idx), v, receiver); } + { if (!receiver) receiver = this; return vtable()->put(this, PropertyKey::fromArrayIndex(idx), v, receiver); } QT_DEPRECATED inline bool putIndexed(uint idx, const Value &v) { return put(idx, v); } - inline bool put(Identifier id, const Value &v, Value *receiver = nullptr) + inline bool put(PropertyKey id, const Value &v, Value *receiver = nullptr) { if (!receiver) receiver = this; return vtable()->put(this, id, v, receiver); } enum ThrowOnFailure { @@ -399,7 +399,7 @@ public: // which is much more efficient for the array case. inline bool setIndexed(uint idx, const Value &v, ThrowOnFailure shouldThrow) { - bool ret = vtable()->put(this, Identifier::fromArrayIndex(idx), v, this); + bool ret = vtable()->put(this, PropertyKey::fromArrayIndex(idx), v, this); // ES6: 7.3.3, 6: If success is false and Throw is true, throw a TypeError exception. if (!ret && shouldThrow == ThrowOnFailure::DoThrowOnRejection) { ExecutionEngine *e = engine(); @@ -428,7 +428,7 @@ public: return ret; } - bool deleteProperty(Identifier id) + bool deleteProperty(PropertyKey id) { return vtable()->deleteProperty(this, id); } void advanceIterator(ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes) { vtable()->advanceIterator(this, it, name, index, p, attributes); } @@ -439,12 +439,12 @@ public: protected: static ReturnedValue callAsConstructor(const FunctionObject *f, const Value *argv, int argc); static ReturnedValue call(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver,bool *hasProperty); - static bool put(Managed *m, Identifier id, const Value &value, Value *receiver); - static bool deleteProperty(Managed *m, Identifier id); - static bool hasProperty(const Managed *m, Identifier id); - static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p); - static bool defineOwnProperty(Managed *m, Identifier id, const Property *p, PropertyAttributes attrs); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver,bool *hasProperty); + static bool put(Managed *m, PropertyKey id, const Value &value, Value *receiver); + static bool deleteProperty(Managed *m, PropertyKey id); + static bool hasProperty(const Managed *m, PropertyKey id); + static PropertyAttributes getOwnProperty(Managed *m, PropertyKey id, Property *p); + static bool defineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs); static bool isExtensible(const Managed *m); static bool preventExtensions(Managed *); static Heap::Object *getPrototypeOf(const Managed *); @@ -457,8 +457,8 @@ private: bool internalDefineOwnProperty(ExecutionEngine *engine, uint index, StringOrSymbol *member, const Property *p, PropertyAttributes attrs); ReturnedValue internalGet(StringOrSymbol *name, const Value *receiver, bool *hasProperty) const; ReturnedValue internalGetIndexed(uint index, const Value *receiver, bool *hasProperty) const; - bool internalPut(Identifier id, const Value &value, Value *receiver); - bool internalDeleteProperty(Identifier id); + bool internalPut(PropertyKey id, const Value &value, Value *receiver); + bool internalDeleteProperty(PropertyKey id); friend struct ObjectIterator; friend struct ObjectPrototype; @@ -535,7 +535,7 @@ struct ArrayObject: Object { QStringList toQStringList() const; protected: - static bool defineOwnProperty(Managed *m, Identifier id, const Property *p, PropertyAttributes attrs); + static bool defineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs); }; diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp index b656c16739..dab8041f0b 100644 --- a/src/qml/jsruntime/qv4objectiterator.cpp +++ b/src/qml/jsruntime/qv4objectiterator.cpp @@ -104,7 +104,7 @@ void ObjectIterator::next(Value *name, uint *index, Property *pd, PropertyAttrib n = *name; bool shadowed = false; while (o->d() != current->heapObject()) { - Identifier id = n ? (n->makeIdentifier(), n->identifier()) : Identifier::fromArrayIndex(*index); + PropertyKey id = n ? (n->makeIdentifier(), n->identifier()) : PropertyKey::fromArrayIndex(*index); if (id.isValid() && o->getOwnProperty(id) != Attr_Invalid) { shadowed = true; break; diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 3287912c7d..81d50a01db 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -169,7 +169,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptor(const FunctionObj return QV4::Encode::undefined(); ScopedProperty desc(scope); - PropertyAttributes attrs = O->getOwnProperty(name->toIdentifier(), desc); + PropertyAttributes attrs = O->getOwnProperty(name, desc); return fromPropertyDescriptor(scope.engine, desc, attrs); } @@ -199,7 +199,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertySymbols(const FunctionObject ScopedValue n(scope); ScopedArrayObject array(scope, scope.engine->newArrayObject()); for (uint i = 0; i < ic->size; ++i) { - Identifier id = ic->nameMap.at(i); + PropertyKey id = ic->nameMap.at(i); n = id.asStringOrSymbol(); if (!n || !n->isSymbol()) continue; @@ -296,7 +296,7 @@ ReturnedValue ObjectPrototype::method_defineProperty(const FunctionObject *b, co if (scope.engine->hasException) return QV4::Encode::undefined(); - if (!O->defineOwnProperty(name->toIdentifier(), pd, attrs)) + if (!O->defineOwnProperty(name, pd, attrs)) THROW_TYPE_ERROR(); return O.asReturnedValue(); @@ -335,7 +335,7 @@ ReturnedValue ObjectPrototype::method_defineProperties(const FunctionObject *b, if (name) ok = O->defineOwnProperty(name->toPropertyKey(), n, nattrs); else - ok = O->defineOwnProperty(Identifier::fromArrayIndex(index), n, nattrs); + ok = O->defineOwnProperty(PropertyKey::fromArrayIndex(index), n, nattrs); if (!ok) THROW_TYPE_ERROR(); } @@ -584,7 +584,7 @@ ReturnedValue ObjectPrototype::method_hasOwnProperty(const FunctionObject *b, co ScopedObject O(scope, thisObject->toObject(scope.engine)); if (scope.engine->hasException) return QV4::Encode::undefined(); - bool r = O->getOwnProperty(P->toIdentifier()) != Attr_Invalid; + bool r = O->getOwnProperty(P) != Attr_Invalid; return Encode(r); } @@ -617,7 +617,7 @@ ReturnedValue ObjectPrototype::method_propertyIsEnumerable(const FunctionObject ScopedObject o(scope, thisObject->toObject(scope.engine)); if (scope.engine->hasException) return QV4::Encode::undefined(); - PropertyAttributes attrs = o->getOwnProperty(p->toIdentifier()); + PropertyAttributes attrs = o->getOwnProperty(p); return Encode(attrs.isEnumerable()); } diff --git a/src/qml/jsruntime/qv4propertykey.cpp b/src/qml/jsruntime/qv4propertykey.cpp index 4678748ee8..e5e96bedb8 100644 --- a/src/qml/jsruntime/qv4propertykey.cpp +++ b/src/qml/jsruntime/qv4propertykey.cpp @@ -49,6 +49,16 @@ QV4::Heap::StringOrSymbol *QV4::PropertyKey::toStringOrSymbol(QV4::ExecutionEngi return static_cast(asStringOrSymbol()); } +bool QV4::PropertyKey::isString() const { + Heap::StringOrSymbol *s = asStringOrSymbol(); + return s && s->internalClass->vtable->isString; +} + +bool QV4::PropertyKey::isSymbol() const { + Heap::Base *s = asStringOrSymbol(); + return s && !s->internalClass->vtable->isString && s->internalClass->vtable->isStringOrSymbol; +} + QString QV4::PropertyKey::toQString() const { if (isArrayIndex()) diff --git a/src/qml/jsruntime/qv4propertykey_p.h b/src/qml/jsruntime/qv4propertykey_p.h index 2e33562514..00bf8fb195 100644 --- a/src/qml/jsruntime/qv4propertykey_p.h +++ b/src/qml/jsruntime/qv4propertykey_p.h @@ -50,8 +50,7 @@ // We mean it. // -#include -#include +#include QT_BEGIN_NAMESPACE @@ -59,8 +58,9 @@ class QString; namespace QV4 { -struct PropertyKey : private Value +struct PropertyKey { +private: // Property keys are Strings, Symbols or unsigned integers. // For convenience we derive them from Values, allowing us to store them // on the JS stack @@ -71,46 +71,69 @@ struct PropertyKey : private Value // * If the key is a Symbol it simply points to the referenced symbol object // * if the key is an array index (a uint < UINT_MAX), it's encoded as an // integer value - int id; - - static PropertyKey invalid() { PropertyKey key; key.setRawValue(0); return key; } - static PropertyKey fromArrayIndex(uint idx) { PropertyKey key; key.setInt_32(static_cast(idx)); return key; } - bool isStringOrSymbol() const { return isManaged(); } - uint asArrayIndex() const { return isManaged() ? std::numeric_limits::max() : value(); } - uint isArrayIndex() const { return !isManaged(); } - static PropertyKey fromStringOrSymbol(Heap::StringOrSymbol *b) - { PropertyKey key; key.setM(reinterpret_cast(b)); return key; } - Heap::StringOrSymbol *asStringOrSymbol() const { return reinterpret_cast(heapObject()); } - - bool isString() const { - Heap::Base *s = heapObject(); - return s && s->internalClass->vtable->isString; + quint64 val; + + // Important: Always keep this in sync with the definitions for Integers and heap objects in Value + static const quint64 ArrayIndexMask = 0x3800000000000ull; + enum { + IsManagedOrUndefined_Shift = 64-15, + }; + inline bool isManaged() const { return (val >> IsManagedOrUndefined_Shift) == 0; } + inline quint32 value() const { return val & quint64(~quint32(0)); } + +#if QT_POINTER_SIZE == 8 + QML_NEARLY_ALWAYS_INLINE Heap::StringOrSymbol *m() const + { + Heap::StringOrSymbol *b; + memcpy(&b, &val, 8); + return b; } - - bool isSymbol() const { - Heap::Base *s = heapObject(); - return s && s->internalClass->vtable->isString && s->internalClass->vtable->isStringOrSymbol; + QML_NEARLY_ALWAYS_INLINE void setM(Heap::StringOrSymbol *b) + { + memcpy(&val, &b, 8); } - - // ### temporary until we transitioned Identifier to PropertyKey - static PropertyKey fromIdentifier(Identifier id) { - if (id.isArrayIndex()) - return PropertyKey::fromArrayIndex(id.asArrayIndex()); - return PropertyKey::fromStringOrSymbol(id.asStringOrSymbol()); +#elif QT_POINTER_SIZE == 4 + QML_NEARLY_ALWAYS_INLINE Heap::StringOrSymbol *m() const + { + Q_STATIC_ASSERT(sizeof(Heap::StringOrSymbol*) == sizeof(quint32)); + Heap::StringOrSymbol *b; + quint32 v = value(); + memcpy(&b, &v, 4); + return b; } + QML_NEARLY_ALWAYS_INLINE void setM(Heap::StringOrSymbol *b) + { + quint32 v; + memcpy(&v, &b, 4); + val = v; + } +#endif - Identifier toIdentifier() const { - if (isArrayIndex()) - return Identifier::fromArrayIndex(asArrayIndex()); - return Identifier::fromStringOrSymbol(asStringOrSymbol()); +public: + static PropertyKey invalid() { PropertyKey key; key.val = 0; return key; } + static PropertyKey fromArrayIndex(uint idx) { PropertyKey key; key.val = ArrayIndexMask | static_cast(idx); return key; } + bool isStringOrSymbol() const { return isManaged() && val != 0; } + uint asArrayIndex() const { return (isManaged() || val == 0) ? std::numeric_limits::max() : static_cast(val & 0xffffffff); } + uint isArrayIndex() const { return !isManaged() && val != 0; } + bool isValid() const { return val != 0; } + static PropertyKey fromStringOrSymbol(Heap::StringOrSymbol *b) + { PropertyKey key; key.setM(b); return key; } + Heap::StringOrSymbol *asStringOrSymbol() const { + if (!isManaged()) + return nullptr; + return m(); } + bool isString() const; + bool isSymbol() const; + Q_QML_EXPORT QString toQString() const; Heap::StringOrSymbol *toStringOrSymbol(ExecutionEngine *e); + quint64 id() const { return val; } - bool operator ==(const PropertyKey &other) const { return id == other.id; } - bool operator !=(const PropertyKey &other) const { return id != other.id; } - bool operator <(const PropertyKey &other) const { return id < other.id; } + bool operator ==(const PropertyKey &other) const { return val == other.val; } + bool operator !=(const PropertyKey &other) const { return val != other.val; } + bool operator <(const PropertyKey &other) const { return val < other.val; } }; } diff --git a/src/qml/jsruntime/qv4proxy.cpp b/src/qml/jsruntime/qv4proxy.cpp index c5c7480f9a..ee660e7ebf 100644 --- a/src/qml/jsruntime/qv4proxy.cpp +++ b/src/qml/jsruntime/qv4proxy.cpp @@ -55,7 +55,7 @@ void Heap::ProxyObject::init(const QV4::Object *target, const QV4::Object *handl this->handler.set(e, handler->d()); } -ReturnedValue ProxyObject::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +ReturnedValue ProxyObject::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { Scope scope(m); const ProxyObject *o = static_cast(m); @@ -96,7 +96,7 @@ ReturnedValue ProxyObject::get(const Managed *m, Identifier id, const Value *rec return trapResult->asReturnedValue(); } -bool ProxyObject::put(Managed *m, Identifier id, const Value &value, Value *receiver) +bool ProxyObject::put(Managed *m, PropertyKey id, const Value &value, Value *receiver) { Scope scope(m); const ProxyObject *o = static_cast(m); @@ -136,7 +136,7 @@ bool ProxyObject::put(Managed *m, Identifier id, const Value &value, Value *rece return true; } -bool ProxyObject::deleteProperty(Managed *m, Identifier id) +bool ProxyObject::deleteProperty(Managed *m, PropertyKey id) { Scope scope(m); const ProxyObject *o = static_cast(m); @@ -172,7 +172,7 @@ bool ProxyObject::deleteProperty(Managed *m, Identifier id) return true; } -bool ProxyObject::hasProperty(const Managed *m, Identifier id) +bool ProxyObject::hasProperty(const Managed *m, PropertyKey id) { Scope scope(m); const ProxyObject *o = static_cast(m); @@ -208,7 +208,7 @@ bool ProxyObject::hasProperty(const Managed *m, Identifier id) return result; } -PropertyAttributes ProxyObject::getOwnProperty(Managed *m, Identifier id, Property *p) +PropertyAttributes ProxyObject::getOwnProperty(Managed *m, PropertyKey id, Property *p) { Scope scope(m); const ProxyObject *o = static_cast(m); @@ -278,7 +278,7 @@ PropertyAttributes ProxyObject::getOwnProperty(Managed *m, Identifier id, Proper return resultAttributes; } -bool ProxyObject::defineOwnProperty(Managed *m, Identifier id, const Property *p, PropertyAttributes attrs) +bool ProxyObject::defineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs) { Scope scope(m); const ProxyObject *o = static_cast(m); diff --git a/src/qml/jsruntime/qv4proxy_p.h b/src/qml/jsruntime/qv4proxy_p.h index 626aef0624..5d99dbad22 100644 --- a/src/qml/jsruntime/qv4proxy_p.h +++ b/src/qml/jsruntime/qv4proxy_p.h @@ -85,13 +85,13 @@ struct ProxyObject: Object { Q_MANAGED_TYPE(ProxyObject) V4_INTERNALCLASS(ProxyObject) - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); static ReturnedValue get(const Managed *m, uint index, bool *hasProperty); - static bool put(Managed *m, Identifier id, const Value &value, Value *receiver); - static bool deleteProperty(Managed *m, Identifier id); - static bool hasProperty(const Managed *m, Identifier id); - static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p); - static bool defineOwnProperty(Managed *m, Identifier id, const Property *p, PropertyAttributes attrs); + static bool put(Managed *m, PropertyKey id, const Value &value, Value *receiver); + static bool deleteProperty(Managed *m, PropertyKey id); + static bool hasProperty(const Managed *m, PropertyKey id); + static PropertyAttributes getOwnProperty(Managed *m, PropertyKey id, Property *p); + static bool defineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs); static bool isExtensible(const Managed *m); static bool preventExtensions(Managed *); static Heap::Object *getPrototypeOf(const Managed *); diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp index e04d8bb0e9..aa607c2d9a 100644 --- a/src/qml/jsruntime/qv4qmlcontext.cpp +++ b/src/qml/jsruntime/qv4qmlcontext.cpp @@ -78,7 +78,7 @@ void Heap::QQmlContextWrapper::destroy() Object::destroy(); } -ReturnedValue QQmlContextWrapper::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +ReturnedValue QQmlContextWrapper::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { Q_ASSERT(m->as()); @@ -229,7 +229,7 @@ ReturnedValue QQmlContextWrapper::get(const Managed *m, Identifier id, const Val return Encode::undefined(); } -bool QQmlContextWrapper::put(Managed *m, Identifier id, const Value &value, Value *receiver) +bool QQmlContextWrapper::put(Managed *m, PropertyKey id, const Value &value, Value *receiver) { Q_ASSERT(m->as()); diff --git a/src/qml/jsruntime/qv4qmlcontext_p.h b/src/qml/jsruntime/qv4qmlcontext_p.h index 737a0d9b6e..2f76b8efd7 100644 --- a/src/qml/jsruntime/qv4qmlcontext_p.h +++ b/src/qml/jsruntime/qv4qmlcontext_p.h @@ -98,8 +98,8 @@ struct Q_QML_EXPORT QQmlContextWrapper : Object void setReadOnly(bool b) { d()->readOnly = b; } - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty); - static bool put(Managed *m, Identifier id, const Value &value, Value *receiver); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool put(Managed *m, PropertyKey id, const Value &value, Value *receiver); }; struct Q_QML_EXPORT QmlContext : public ExecutionContext diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 3fd5564847..1292f4d814 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -693,7 +693,7 @@ ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object) return (engine->memoryManager->allocate(object))->asReturnedValue(); } -QV4::ReturnedValue QObjectWrapper::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +QV4::ReturnedValue QObjectWrapper::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { if (!id.isString()) return Object::get(m, id, receiver, hasProperty); @@ -705,7 +705,7 @@ QV4::ReturnedValue QObjectWrapper::get(const Managed *m, Identifier id, const Va return that->getQmlProperty(qmlContext, n, IgnoreRevision, hasProperty, /*includeImports*/ true); } -bool QObjectWrapper::put(Managed *m, Identifier id, const Value &value, Value *receiver) +bool QObjectWrapper::put(Managed *m, PropertyKey id, const Value &value, Value *receiver) { if (!id.isString()) return Object::put(m, id, value, receiver); @@ -735,7 +735,7 @@ bool QObjectWrapper::put(Managed *m, Identifier id, const Value &value, Value *r return true; } -PropertyAttributes QObjectWrapper::getOwnProperty(Managed *m, Identifier id, Property *p) +PropertyAttributes QObjectWrapper::getOwnProperty(Managed *m, PropertyKey id, Property *p) { if (id.isString()) { QObjectWrapper *that = static_cast(m); diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index 9471f72b80..da5eb4db81 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -193,9 +193,9 @@ protected: static QQmlPropertyData *findProperty(ExecutionEngine *engine, QObject *o, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local); QQmlPropertyData *findProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const; - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty); - static bool put(Managed *m, Identifier id, const Value &value, Value *receiver); - static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool put(Managed *m, PropertyKey id, const Value &value, Value *receiver); + static PropertyAttributes getOwnProperty(Managed *m, PropertyKey id, Property *p); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); static ReturnedValue method_connect(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); diff --git a/src/qml/jsruntime/qv4reflect.cpp b/src/qml/jsruntime/qv4reflect.cpp index 41aa4b402e..2bfd2bc401 100644 --- a/src/qml/jsruntime/qv4reflect.cpp +++ b/src/qml/jsruntime/qv4reflect.cpp @@ -132,7 +132,7 @@ ReturnedValue Reflect::method_defineProperty(const FunctionObject *f, const Valu if (scope.engine->hasException) return QV4::Encode::undefined(); - bool result = O->defineOwnProperty(name->toIdentifier(), pd, attrs); + bool result = O->defineOwnProperty(name, pd, attrs); return Encode(result); } @@ -161,7 +161,7 @@ ReturnedValue Reflect::method_get(const FunctionObject *f, const Value *, const return Encode::undefined(); ScopedValue receiver(scope, argc > 2 ? argv[2] : *o); - return Encode(o->get(name->toIdentifier(), receiver)); + return Encode(o->get(name, receiver)); } ReturnedValue Reflect::method_getOwnPropertyDescriptor(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) @@ -202,7 +202,7 @@ ReturnedValue Reflect::method_has(const FunctionObject *f, const Value *, const ScopedPropertyKey name(scope, index->toPropertyKey(scope.engine)); if (scope.engine->hasException) return false; - (void) o->get(name->toIdentifier(), nullptr, &hasProperty); + (void) o->get(name, nullptr, &hasProperty); return Encode(hasProperty); } @@ -249,7 +249,7 @@ ReturnedValue Reflect::method_set(const FunctionObject *f, const Value *, const ScopedPropertyKey propertyKey(scope, index->toPropertyKey(scope.engine)); if (scope.engine->hasException) return false; - bool result = o->put(propertyKey->toIdentifier(), val, receiver); + bool result = o->put(propertyKey, val, receiver); return Encode(result); } diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index eee94a2f60..6969dd4eee 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -331,12 +331,12 @@ bool Runtime::method_deleteProperty(ExecutionEngine *engine, const Value &base, uint n = index.asArrayIndex(); if (n < UINT_MAX) - return o->deleteProperty(Identifier::fromArrayIndex(n)); + return o->deleteProperty(PropertyKey::fromArrayIndex(n)); ScopedPropertyKey key(scope, index.toPropertyKey(engine)); if (engine->hasException) return false; - return o->deleteProperty(key->toIdentifier()); + return o->deleteProperty(key); } bool Runtime::method_deleteName(ExecutionEngine *engine, int nameIndex) @@ -374,7 +374,7 @@ QV4::ReturnedValue Runtime::method_in(ExecutionEngine *engine, const Value &left ScopedPropertyKey s(scope, left.toPropertyKey(engine)); if (scope.hasException()) return Encode::undefined(); - bool r = ro->hasProperty(s->toIdentifier()); + bool r = ro->hasProperty(s); return Encode(r); } @@ -640,7 +640,7 @@ static Q_NEVER_INLINE ReturnedValue getElementFallback(ExecutionEngine *engine, ScopedPropertyKey name(scope, index.toPropertyKey(engine)); if (scope.hasException()) return Encode::undefined(); - return o->get(name->toIdentifier()); + return o->get(name); } ReturnedValue Runtime::method_loadElement(ExecutionEngine *engine, const Value &object, const Value &index) @@ -686,7 +686,7 @@ static Q_NEVER_INLINE bool setElementFallback(ExecutionEngine *engine, const Val ScopedPropertyKey name(scope, index.toPropertyKey(engine)); if (engine->hasException) return false; - return o->put(name->toIdentifier(), value); + return o->put(name, value); } void Runtime::method_storeElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value) @@ -1205,7 +1205,7 @@ ReturnedValue Runtime::method_callElement(ExecutionEngine *engine, Value *base, if (engine->hasException) return Encode::undefined(); - ScopedFunctionObject f(scope, static_cast(base)->get(str->toIdentifier())); + ScopedFunctionObject f(scope, static_cast(base)->get(str)); if (!f) return engine->throwTypeError(); @@ -1467,7 +1467,7 @@ ReturnedValue Runtime::method_objectLiteral(ExecutionEngine *engine, int classId pd->value = Primitive::emptyValue(); pd->set = args[2]; } - bool ok = o->defineOwnProperty(name->toIdentifier(), pd, (arg == ObjectLiteralArgument::Value ? Attr_Data : Attr_Accessor)); + bool ok = o->defineOwnProperty(name, pd, (arg == ObjectLiteralArgument::Value ? Attr_Data : Attr_Accessor)); if (!ok) return engine->throwTypeError(); @@ -1537,7 +1537,6 @@ ReturnedValue Runtime::method_createClass(ExecutionEngine *engine, int classInde } else { propertyName = PropertyKey::fromStringOrSymbol(unit->runtimeStrings[methods[i].name]); } - Identifier id = propertyName->toIdentifier(); QV4::Function *f = unit->runtimeFunctions[methods[i].function]; Q_ASSERT(f); function = FunctionObject::createMemberFunction(current, f); @@ -1560,7 +1559,7 @@ ReturnedValue Runtime::method_createClass(ExecutionEngine *engine, int classInde attributes = Attr_Data|Attr_NotEnumerable; break; } - receiver->defineOwnProperty(id, property, attributes); + receiver->defineOwnProperty(propertyName, property, attributes); } return constructor->asReturnedValue(); diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 1a5837935c..1f66c4a47e 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -264,6 +264,9 @@ struct ScopedPropertyKey PropertyKey *operator->() { return ptr; } + operator PropertyKey() const { + return *ptr; + } PropertyKey *ptr; }; diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 0826384614..d5e6ed3612 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -563,13 +563,13 @@ public: QMetaObject::metacall(d()->object, QMetaObject::WriteProperty, d()->propertyIndex, a); } - static QV4::ReturnedValue get(const QV4::Managed *that, Identifier id, const Value *receiver, bool *hasProperty) + static QV4::ReturnedValue get(const QV4::Managed *that, PropertyKey id, const Value *receiver, bool *hasProperty) { if (!id.isArrayIndex()) return Object::get(that, id, receiver, hasProperty); return static_cast *>(that)->containerGetIndexed(id.asArrayIndex(), hasProperty); } - static bool put(Managed *that, Identifier id, const QV4::Value &value, Value *receiver) + static bool put(Managed *that, PropertyKey id, const QV4::Value &value, Value *receiver) { if (id.isArrayIndex()) return static_cast *>(that)->containerPutIndexed(id.asArrayIndex(), value); @@ -577,7 +577,7 @@ public: } static QV4::PropertyAttributes queryIndexed(const QV4::Managed *that, uint index) { return static_cast *>(that)->containerQueryIndexed(index); } - static bool deleteProperty(QV4::Managed *that, Identifier id) + static bool deleteProperty(QV4::Managed *that, PropertyKey id) { if (id.isArrayIndex()) { uint index = id.asArrayIndex(); diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index 50943525f1..ce5bc7f13e 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -55,7 +55,7 @@ using namespace QV4; void Heap::StringOrSymbol::markObjects(Heap::Base *that, MarkStack *markStack) { StringOrSymbol *s = static_cast(that); - Heap::Base *id = s->identifier.asStringOrSymbol(); + Heap::StringOrSymbol *id = s->identifier.asStringOrSymbol(); if (id) id->mark(markStack); } @@ -185,7 +185,7 @@ void Heap::String::simplifyString() const text = result.data_ptr(); text->ref.ref(); const ComplexString *cs = static_cast(this); - identifier = Identifier::invalid(); + identifier = PropertyKey::invalid(); cs->left = cs->right = nullptr; internalClass->engine->memoryManager->changeUnmanagedHeapSizeUsage(qptrdiff(text->size) * (qptrdiff)sizeof(QChar)); @@ -250,10 +250,10 @@ void Heap::StringOrSymbol::createHashValue() const stringHash = QV4::String::calculateHashValue(ch, end, &subtype); } -Identifier StringOrSymbol::toPropertyKey() const { +PropertyKey StringOrSymbol::toPropertyKey() const { uint index = asArrayIndex(); if (index < UINT_MAX) - return Identifier::fromArrayIndex(index); + return PropertyKey::fromArrayIndex(index); makeIdentifier(); return identifier(); } diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index 2e3ca977bf..81cb54d9cc 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE namespace QV4 { struct ExecutionEngine; -struct Identifier; +struct PropertyKey; namespace Heap { @@ -77,7 +77,7 @@ struct Q_QML_PRIVATE_EXPORT StringOrSymbol : Base }; mutable QStringData *text; - mutable Identifier identifier; + mutable PropertyKey identifier; mutable uint subtype; mutable uint stringHash; @@ -174,11 +174,11 @@ struct Q_QML_PRIVATE_EXPORT StringOrSymbol : public Managed { }; inline void makeIdentifier() const; - Identifier identifier() const { return d()->identifier; } + PropertyKey identifier() const { return d()->identifier; } uint asArrayIndex() const; - Identifier toPropertyKey() const; + PropertyKey toPropertyKey() const; inline QString toQString() const { return d()->toQString(); diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index b21506b11e..8294e6cf36 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -97,7 +97,7 @@ uint Heap::StringObject::length() const return string->length(); } -bool StringObject::deleteProperty(Managed *m, Identifier id) +bool StringObject::deleteProperty(Managed *m, PropertyKey id) { Q_ASSERT(m->as()); if (id.isArrayIndex()) { @@ -119,7 +119,7 @@ void StringObject::advanceIterator(Managed *m, ObjectIterator *it, Value *name, *index = it->arrayIndex; ++it->arrayIndex; Property pd; - PropertyAttributes a = s->getOwnProperty(Identifier::fromArrayIndex(*index), &pd); + PropertyAttributes a = s->getOwnProperty(PropertyKey::fromArrayIndex(*index), &pd); if (!(it->flags & ObjectIterator::EnumerableOnly) || a.isEnumerable()) { *attrs = a; p->copy(&pd, a); @@ -137,7 +137,7 @@ void StringObject::advanceIterator(Managed *m, ObjectIterator *it, Value *name, return Object::advanceIterator(m, it, name, index, p, attrs); } -PropertyAttributes StringObject::getOwnProperty(Managed *m, Identifier id, Property *p) +PropertyAttributes StringObject::getOwnProperty(Managed *m, PropertyKey id, Property *p) { PropertyAttributes attributes = Object::getOwnProperty(m, id, p); if (attributes != Attr_Invalid) diff --git a/src/qml/jsruntime/qv4stringobject_p.h b/src/qml/jsruntime/qv4stringobject_p.h index af53be0ada..6b3861d6ed 100644 --- a/src/qml/jsruntime/qv4stringobject_p.h +++ b/src/qml/jsruntime/qv4stringobject_p.h @@ -100,9 +100,9 @@ struct StringObject: Object { using Object::getOwnProperty; protected: - static bool deleteProperty(Managed *m, Identifier id); + static bool deleteProperty(Managed *m, PropertyKey id); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attrs); - static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p); + static PropertyAttributes getOwnProperty(Managed *m, PropertyKey id, Property *p); }; struct StringCtor: FunctionObject diff --git a/src/qml/jsruntime/qv4symbol.cpp b/src/qml/jsruntime/qv4symbol.cpp index ff1d47cd84..1204a716ab 100644 --- a/src/qml/jsruntime/qv4symbol.cpp +++ b/src/qml/jsruntime/qv4symbol.cpp @@ -50,7 +50,7 @@ DEFINE_OBJECT_VTABLE(SymbolObject); void Heap::Symbol::init(const QString &s) { Q_ASSERT(s.at(0) == QLatin1Char('@')); - identifier = Identifier::fromStringOrSymbol(this); + identifier = PropertyKey::fromStringOrSymbol(this); QString desc(s); text = desc.data_ptr(); text->ref.ref(); diff --git a/src/qml/jsruntime/qv4symbol_p.h b/src/qml/jsruntime/qv4symbol_p.h index ed04b436ef..7673fab549 100644 --- a/src/qml/jsruntime/qv4symbol_p.h +++ b/src/qml/jsruntime/qv4symbol_p.h @@ -117,7 +117,7 @@ struct SymbolObject : Object V4_INTERNALCLASS(SymbolObject) V4_PROTOTYPE(symbolPrototype) - static bool put(Managed *, Identifier, const Value &, Value *) { return false; } + static bool put(Managed *, PropertyKey, const Value &, Value *) { return false; } }; } diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp index ec319524a2..09865b55f3 100644 --- a/src/qml/jsruntime/qv4typedarray.cpp +++ b/src/qml/jsruntime/qv4typedarray.cpp @@ -367,7 +367,7 @@ Heap::TypedArray *TypedArray::create(ExecutionEngine *e, Heap::TypedArray::Type return e->memoryManager->allocObject(ic->d(), t); } -ReturnedValue TypedArray::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +ReturnedValue TypedArray::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { if (!id.isArrayIndex()) return Object::get(m, id, receiver, hasProperty); @@ -388,7 +388,7 @@ ReturnedValue TypedArray::get(const Managed *m, Identifier id, const Value *rece return a->d()->type->read(a->d()->buffer->data->data(), byteOffset); } -bool TypedArray::put(Managed *m, Identifier id, const Value &value, Value *receiver) +bool TypedArray::put(Managed *m, PropertyKey id, const Value &value, Value *receiver) { if (!id.isArrayIndex()) return Object::put(m, id, value, receiver); diff --git a/src/qml/jsruntime/qv4typedarray_p.h b/src/qml/jsruntime/qv4typedarray_p.h index 5171bcb83c..f08dfc8101 100644 --- a/src/qml/jsruntime/qv4typedarray_p.h +++ b/src/qml/jsruntime/qv4typedarray_p.h @@ -140,8 +140,8 @@ struct Q_QML_PRIVATE_EXPORT TypedArray : Object } using Object::get; - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty); - static bool put(Managed *m, Identifier id, const Value &value, Value *receiver); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool put(Managed *m, PropertyKey id, const Value &value, Value *receiver); }; struct IntrinsicTypedArrayCtor: FunctionObject diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index 6b22967bfa..934fb2fbaa 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -238,7 +238,7 @@ QV4::PropertyKey Value::toPropertyKey(ExecutionEngine *e) const Scope scope(e); ScopedStringOrSymbol s(scope, this); s->makeIdentifier(); - return PropertyKey::fromIdentifier(s->identifier()); + return s->identifier(); } Scope scope(e); ScopedValue v(scope, RuntimeHelpers::toPrimitive(*this, STRING_HINT)); @@ -248,7 +248,7 @@ QV4::PropertyKey Value::toPropertyKey(ExecutionEngine *e) const return PropertyKey::invalid(); ScopedStringOrSymbol s(scope, v); s->makeIdentifier(); - return PropertyKey::fromIdentifier(s->identifier()); + return s->identifier(); } #endif // V4_BOOTSTRAP diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index 5c88d4c2a5..a6e0f5cc33 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -102,7 +102,7 @@ QVariant QmlListWrapper::toVariant() const } -ReturnedValue QmlListWrapper::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +ReturnedValue QmlListWrapper::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { Q_ASSERT(m->as()); const QmlListWrapper *w = static_cast(m); @@ -130,7 +130,7 @@ ReturnedValue QmlListWrapper::get(const Managed *m, Identifier id, const Value * return Object::get(m, id, receiver, hasProperty); } -bool QmlListWrapper::put(Managed *m, Identifier id, const Value &value, Value *receiver) +bool QmlListWrapper::put(Managed *m, PropertyKey id, const Value &value, Value *receiver) { // doesn't do anything. Should we throw? Q_UNUSED(m); diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h index 0c57fe1f47..16dabed764 100644 --- a/src/qml/qml/qqmllistwrapper_p.h +++ b/src/qml/qml/qqmllistwrapper_p.h @@ -93,8 +93,8 @@ struct Q_QML_EXPORT QmlListWrapper : Object QVariant toVariant() const; - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty); - static bool put(Managed *m, Identifier id, const Value &value, Value *receiver); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool put(Managed *m, PropertyKey id, const Value &value, Value *receiver); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); }; diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 2e28a9e222..51df0a1fa6 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -167,7 +167,7 @@ static ReturnedValue throwLowercaseEnumError(QV4::ExecutionEngine *v4, String *n return v4->throwTypeError(message); } -ReturnedValue QQmlTypeWrapper::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +ReturnedValue QQmlTypeWrapper::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { Q_ASSERT(m->as()); @@ -304,7 +304,7 @@ ReturnedValue QQmlTypeWrapper::get(const Managed *m, Identifier id, const Value } -bool QQmlTypeWrapper::put(Managed *m, Identifier id, const Value &value, Value *receiver) +bool QQmlTypeWrapper::put(Managed *m, PropertyKey id, const Value &value, Value *receiver) { if (!id.isString()) return Object::put(m, id, value, receiver); @@ -350,7 +350,7 @@ bool QQmlTypeWrapper::put(Managed *m, Identifier id, const Value &value, Value * return false; } -PropertyAttributes QQmlTypeWrapper::getOwnProperty(Managed *m, Identifier id, Property *p) +PropertyAttributes QQmlTypeWrapper::getOwnProperty(Managed *m, PropertyKey id, Property *p) { if (id.isString()) { Scope scope(m); @@ -428,7 +428,7 @@ QQmlType Heap::QQmlScopedEnumWrapper::type() const return QQmlType(typePrivate); } -ReturnedValue QQmlScopedEnumWrapper::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +ReturnedValue QQmlScopedEnumWrapper::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { Q_ASSERT(m->as()); if (!id.isString()) diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h index d14f128bfb..01c3f8b0d0 100644 --- a/src/qml/qml/qqmltypewrapper_p.h +++ b/src/qml/qml/qqmltypewrapper_p.h @@ -112,9 +112,9 @@ struct Q_QML_EXPORT QQmlTypeWrapper : Object Heap::QQmlTypeWrapper::TypeNameMode = Heap::QQmlTypeWrapper::IncludeEnums); - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty); - static bool put(Managed *m, Identifier id, const Value &value, Value *receiver); - static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool put(Managed *m, PropertyKey id, const Value &value, Value *receiver); + static PropertyAttributes getOwnProperty(Managed *m, PropertyKey id, Property *p); static bool isEqualTo(Managed *that, Managed *o); static ReturnedValue instanceOf(const Object *typeObject, const Value &var); }; @@ -124,7 +124,7 @@ struct Q_QML_EXPORT QQmlScopedEnumWrapper : Object V4_OBJECT2(QQmlScopedEnumWrapper, Object) V4_NEEDS_DESTROY - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); }; } diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index bd612221be..2dd76ccd84 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -241,7 +241,7 @@ bool QQmlValueTypeWrapper::isEqualTo(Managed *m, Managed *other) return false; } -PropertyAttributes QQmlValueTypeWrapper::getOwnProperty(Managed *m, Identifier id, Property *p) +PropertyAttributes QQmlValueTypeWrapper::getOwnProperty(Managed *m, PropertyKey id, Property *p) { if (id.isString()) { Scope scope(m); @@ -359,7 +359,7 @@ ReturnedValue QQmlValueTypeWrapper::method_toString(const FunctionObject *b, con return Encode(b->engine()->newString(result)); } -ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { Q_ASSERT(m->as()); @@ -423,7 +423,7 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, Identifier id, const V #undef VALUE_TYPE_ACCESSOR } -bool QQmlValueTypeWrapper::put(Managed *m, Identifier id, const Value &value, Value *receiver) +bool QQmlValueTypeWrapper::put(Managed *m, PropertyKey id, const Value &value, Value *receiver) { if (!id.isString()) return Object::put(m, id, value, receiver); diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h index 9966671baa..655530725e 100644 --- a/src/qml/qml/qqmlvaluetypewrapper_p.h +++ b/src/qml/qml/qqmlvaluetypewrapper_p.h @@ -106,10 +106,10 @@ public: int typeId() const; bool write(QObject *target, int propertyIndex) const; - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty); - static bool put(Managed *m, Identifier id, const Value &value, Value *receiver); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); + static bool put(Managed *m, PropertyKey id, const Value &value, Value *receiver); static bool isEqualTo(Managed *m, Managed *other); - static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p); + static PropertyAttributes getOwnProperty(Managed *m, PropertyKey id, Property *p); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); static ReturnedValue method_toString(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 2ed4743862..2e5ce29f21 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -228,7 +228,7 @@ public: static ReturnedValue create(ExecutionEngine *, NodeImpl *, const QList &); // JS API - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); }; void Heap::NamedNodeMap::init(NodeImpl *data, const QList &list) @@ -249,7 +249,7 @@ public: V4_NEEDS_DESTROY // JS API - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); // C++ API static ReturnedValue create(ExecutionEngine *, NodeImpl *); @@ -886,7 +886,7 @@ bool Node::isNull() const return d()->d == nullptr; } -ReturnedValue NamedNodeMap::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +ReturnedValue NamedNodeMap::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { Q_ASSERT(m->as()); @@ -931,7 +931,7 @@ ReturnedValue NamedNodeMap::create(ExecutionEngine *v4, NodeImpl *data, const QL return (v4->memoryManager->allocate(data, list))->asReturnedValue(); } -ReturnedValue NodeList::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +ReturnedValue NodeList::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { Q_ASSERT(m->as()); const NodeList *r = static_cast(m); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 22b8bddd66..b3b63ff8a6 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -197,7 +197,7 @@ ReturnedValue QtObject::findAndAdd(const QString *name, bool &foundProperty) con return Encode::undefined(); } -ReturnedValue QtObject::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +ReturnedValue QtObject::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { bool hasProp = false; if (hasProperty == nullptr) { diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index 06555568d3..95d51135c6 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -93,7 +93,7 @@ struct QtObject : Object { V4_OBJECT2(QtObject, Object) - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); static ReturnedValue method_isQtObject(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 6b6449c20e..78c9fe822b 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -208,7 +208,7 @@ void QV8Engine::initializeGlobal() { for (uint i = 0; i < m_v4Engine->globalObject->internalClass()->size; ++i) { if (m_v4Engine->globalObject->internalClass()->nameMap.at(i).isString()) { - QV4::Identifier id = m_v4Engine->globalObject->internalClass()->nameMap.at(i); + QV4::PropertyKey id = m_v4Engine->globalObject->internalClass()->nameMap.at(i); m_illegalNames.insert(id.toQString()); } } diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 030f924e2a..7f3b850e4e 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -3383,7 +3383,7 @@ public: quint32 count() const { return d()->changes->count(); } const QQmlChangeSet::Change &at(int index) const { return d()->changes->at(index); } - static QV4::ReturnedValue get(const QV4::Managed *m, QV4::Identifier id, const QV4::Value *receiver, bool *hasProperty) + static QV4::ReturnedValue get(const QV4::Managed *m, QV4::PropertyKey id, const QV4::Value *receiver, bool *hasProperty) { if (id.isArrayIndex()) { uint index = id.asArrayIndex(); diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp index 6933f1e432..27e9df0c0b 100644 --- a/src/qml/types/qqmllistmodel.cpp +++ b/src/qml/types/qqmllistmodel.cpp @@ -1564,7 +1564,7 @@ void ModelNodeMetaObject::emitDirectNotifies(const int *changedRoles, int roleCo namespace QV4 { -bool ModelObject::put(Managed *m, Identifier id, const Value &value, Value *receiver) +bool ModelObject::put(Managed *m, PropertyKey id, const Value &value, Value *receiver) { if (!id.isString()) return Object::put(m, id, value, receiver); @@ -1584,7 +1584,7 @@ bool ModelObject::put(Managed *m, Identifier id, const Value &value, Value *rece return true; } -ReturnedValue ModelObject::get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty) +ReturnedValue ModelObject::get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) { if (!id.isString()) return Object::get(m, id, receiver, hasProperty); diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index a0fd4a3310..fe88877837 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -173,8 +173,8 @@ struct ModelObject : public QObjectWrapper { struct ModelObject : public QObjectWrapper { - static bool put(Managed *m, Identifier id, const Value& value, Value *receiver); - static ReturnedValue get(const Managed *m, Identifier id, const Value *receiver, bool *hasProperty); + static bool put(Managed *m, PropertyKey id, const Value& value, Value *receiver); + static ReturnedValue get(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); V4_OBJECT2(ModelObject, QObjectWrapper) -- cgit v1.2.3