diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-08-21 16:51:17 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-08-28 17:50:41 +0000 |
commit | bead103138c0d9dff3c9f927c9c4e2f44ee7db4c (patch) | |
tree | 32b23e94d07b5169758b426b1ad614e240dae9cd /src/qml/jsruntime/qv4stackframe_p.h | |
parent | ec6996bcbed583177952f81f5bfaf1d67eb573ad (diff) |
Implement the dead temporal zone
With const and let it is possible to access the declared member before
initialization. This is expected to throw a type reference error at
run-time.
We initialize such variables with the empty value when entering their
scope and check upon access for that. For locals we place the lexically
scoped variables at the end. For register allocated lexical variables we
group them into one batch and remember the index/size.
Change-Id: Icb493ee0de0525bb682e1bc58981a4dfd33f750e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4stackframe_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4stackframe_p.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4stackframe_p.h b/src/qml/jsruntime/qv4stackframe_p.h index 878f9283e7..ca39a8f7bb 100644 --- a/src/qml/jsruntime/qv4stackframe_p.h +++ b/src/qml/jsruntime/qv4stackframe_p.h @@ -181,6 +181,15 @@ struct Q_QML_EXPORT CppStackFrame { const Value *end = jsFrame->args + nRegisters; for (Value *v = jsFrame->args + argc; v < end; ++v) *v = Encode::undefined(); + + if (v4Function && v4Function->compiledFunction) { + const int firstDeadZoneRegister = v4Function->compiledFunction->firstTemporalDeadZoneRegister; + const int registerDeadZoneSize = v4Function->compiledFunction->sizeOfRegisterTemporalDeadZone; + + const Value * tdzEnd = stackSpace + firstDeadZoneRegister + registerDeadZoneSize; + for (Value *v = stackSpace + firstDeadZoneRegister; v < tdzEnd; ++v) + *v = Primitive::emptyValue().asReturnedValue(); + } } #endif |