diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-04-11 14:13:24 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-10-16 13:35:34 +0200 |
commit | ad3e13d97367aade27b328306a19d78f68331fa8 (patch) | |
tree | c7b0b0571f36526e49dc112f29122098a80feda1 /src/qml/jsruntime | |
parent | 8c614803451ead4ef186d3992dc8fd8d0b93fa37 (diff) |
JSRuntime: Provide an optional symbol table
The method names are only used for debugging purposes. We don't need to
pass them through production code. Centralize the names of all the
runtime methods in a symbol table and only look them up when actually
printing them.
Change-Id: I0d9d7db04b961841242acdbaaa7a2ba29b1f4ff2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 127 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtimeapi_p.h | 2 |
2 files changed, 129 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index aaa198c62a..21a0017728 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -2316,6 +2316,133 @@ Bool Runtime::CompareStrictNotEqual::call(const Value &left, const Value &right) return ! RuntimeHelpers::strictEqual(left, right); } +template<typename Operation> +static inline const void *symbol() +{ + return reinterpret_cast<void *>(&Operation::call); +} + +QHash<const void *, const char *> Runtime::symbolTable() +{ + static const QHash<const void *, const char *> symbols({ +#ifndef V4_BOOTSTRAP + {symbol<CallGlobalLookup>(), "CallGlobalLookup" }, + {symbol<CallQmlContextPropertyLookup>(), "CallQmlContextPropertyLookup" }, + {symbol<CallName>(), "CallName" }, + {symbol<CallProperty>(), "CallProperty" }, + {symbol<CallPropertyLookup>(), "CallPropertyLookup" }, + {symbol<CallElement>(), "CallElement" }, + {symbol<CallValue>(), "CallValue" }, + {symbol<CallWithReceiver>(), "CallWithReceiver" }, + {symbol<CallPossiblyDirectEval>(), "CallPossiblyDirectEval" }, + {symbol<CallWithSpread>(), "CallWithSpread" }, + {symbol<TailCall>(), "TailCall" }, + + {symbol<Construct>(), "Construct" }, + {symbol<ConstructWithSpread>(), "ConstructWithSpread" }, + + {symbol<StoreNameStrict>(), "StoreNameStrict" }, + {symbol<StoreNameSloppy>(), "StoreNameSloppy" }, + {symbol<StoreProperty>(), "StoreProperty" }, + {symbol<StoreElement>(), "StoreElement" }, + {symbol<LoadProperty>(), "LoadProperty" }, + {symbol<LoadName>(), "LoadName" }, + {symbol<LoadElement>(), "LoadElement" }, + {symbol<LoadSuperProperty>(), "LoadSuperProperty" }, + {symbol<StoreSuperProperty>(), "StoreSuperProperty" }, + {symbol<LoadSuperConstructor>(), "LoadSuperConstructor" }, + {symbol<LoadGlobalLookup>(), "LoadGlobalLookup" }, + {symbol<LoadQmlContextPropertyLookup>(), "LoadQmlContextPropertyLookup" }, + {symbol<GetLookup>(), "GetLookup" }, + {symbol<SetLookupStrict>(), "SetLookupStrict" }, + {symbol<SetLookupSloppy>(), "SetLookupSloppy" }, + + {symbol<TypeofValue>(), "TypeofValue" }, + {symbol<TypeofName>(), "TypeofName" }, + + {symbol<DeleteProperty_NoThrow>(), "DeleteProperty_NoThrow" }, + {symbol<DeleteProperty>(), "DeleteProperty" }, + {symbol<DeleteName_NoThrow>(), "DeleteName_NoThrow" }, + {symbol<DeleteName>(), "DeleteName" }, + + {symbol<ThrowException>(), "ThrowException" }, + {symbol<PushCallContext>(), "PushCallContext" }, + {symbol<PushWithContext>(), "PushWithContext" }, + {symbol<PushCatchContext>(), "PushCatchContext" }, + {symbol<PushBlockContext>(), "PushBlockContext" }, + {symbol<CloneBlockContext>(), "CloneBlockContext" }, + {symbol<PushScriptContext>(), "PushScriptContext" }, + {symbol<PopScriptContext>(), "PopScriptContext" }, + {symbol<ThrowReferenceError>(), "ThrowReferenceError" }, + {symbol<ThrowOnNullOrUndefined>(), "ThrowOnNullOrUndefined" }, + + {symbol<Closure>(), "Closure" }, + + {symbol<ConvertThisToObject>(), "ConvertThisToObject" }, + {symbol<DeclareVar>(), "DeclareVar" }, + {symbol<CreateMappedArgumentsObject>(), "CreateMappedArgumentsObject" }, + {symbol<CreateUnmappedArgumentsObject>(), "CreateUnmappedArgumentsObject" }, + {symbol<CreateRestParameter>(), "CreateRestParameter" }, + + {symbol<ArrayLiteral>(), "ArrayLiteral" }, + {symbol<ObjectLiteral>(), "ObjectLiteral" }, + {symbol<CreateClass>(), "CreateClass" }, + + {symbol<GetIterator>(), "GetIterator" }, + {symbol<IteratorNext>(), "IteratorNext" }, + {symbol<IteratorNextForYieldStar>(), "IteratorNextForYieldStar" }, + {symbol<IteratorClose>(), "IteratorClose" }, + {symbol<DestructureRestElement>(), "DestructureRestElement" }, + + {symbol<ToObject>(), "ToObject" }, + {symbol<ToBoolean>(), "ToBoolean" }, + {symbol<ToNumber>(), "ToNumber" }, + + {symbol<UMinus>(), "UMinus" }, + + {symbol<Instanceof>(), "Instanceof" }, + {symbol<In>(), "In" }, + {symbol<Add>(), "Add" }, + {symbol<Sub>(), "Sub" }, + {symbol<Mul>(), "Mul" }, + {symbol<Div>(), "Div" }, + {symbol<Mod>(), "Mod" }, + {symbol<Exp>(), "Exp" }, + {symbol<BitAnd>(), "BitAnd" }, + {symbol<BitOr>(), "BitOr" }, + {symbol<BitXor>(), "BitXor" }, + {symbol<Shl>(), "Shl" }, + {symbol<Shr>(), "Shr" }, + {symbol<UShr>(), "UShr" }, + {symbol<GreaterThan>(), "GreaterThan" }, + {symbol<LessThan>(), "LessThan" }, + {symbol<GreaterEqual>(), "GreaterEqual" }, + {symbol<LessEqual>(), "LessEqual" }, + {symbol<Equal>(), "Equal" }, + {symbol<NotEqual>(), "NotEqual" }, + {symbol<StrictEqual>(), "StrictEqual" }, + {symbol<StrictNotEqual>(), "StrictNotEqual" }, + + {symbol<CompareGreaterThan>(), "CompareGreaterThan" }, + {symbol<CompareLessThan>(), "CompareLessThan" }, + {symbol<CompareGreaterEqual>(), "CompareGreaterEqual" }, + {symbol<CompareLessEqual>(), "CompareLessEqual" }, + {symbol<CompareEqual>(), "CompareEqual" }, + {symbol<CompareNotEqual>(), "CompareNotEqual" }, + {symbol<CompareStrictEqual>(), "CompareStrictEqual" }, + {symbol<CompareStrictNotEqual>(), "CompareStrictNotEqual" }, + + {symbol<CompareInstanceof>(), "CompareInstanceOf" }, + {symbol<CompareIn>(), "CompareIn" }, + + {symbol<RegexpLiteral>(), "RegexpLiteral" }, + {symbol<GetTemplateObject>(), "GetTemplateObject" } +#endif + }); + + return symbols; +} + } // namespace QV4 QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h index 05ffb84d58..d155187e48 100644 --- a/src/qml/jsruntime/qv4runtimeapi_p.h +++ b/src/qml/jsruntime/qv4runtimeapi_p.h @@ -501,6 +501,8 @@ struct Q_QML_PRIVATE_EXPORT Runtime { static const int tailCall_argv = -3; static const int tailCall_argc = -4; }; + + static QHash<const void *, const char *> symbolTable(); }; static_assert(std::is_standard_layout<Runtime>::value, "Runtime needs to be standard layout in order for us to be able to use offsetof"); |