From bead103138c0d9dff3c9f927c9c4e2f44ee7db4c Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 21 Aug 2018 16:51:17 +0200 Subject: 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 --- src/qml/compiler/qv4instr_moth_p.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/qml/compiler/qv4instr_moth_p.h') diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index 25a07208c2..7c2cbf717e 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -118,6 +118,7 @@ QT_BEGIN_NAMESPACE #define INSTR_SetUnwindHandler(op) INSTRUCTION(op, SetUnwindHandler, 1, offset) #define INSTR_UnwindDispatch(op) INSTRUCTION(op, UnwindDispatch, 0) #define INSTR_UnwindToLabel(op) INSTRUCTION(op, UnwindToLabel, 2, level, offset) +#define INSTR_DeadTemporalZoneCheck(op) INSTRUCTION(op, DeadTemporalZoneCheck, 1, name) #define INSTR_ThrowException(op) INSTRUCTION(op, ThrowException, 0) #define INSTR_GetException(op) INSTRUCTION(op, GetException, 0) #define INSTR_SetException(op) INSTRUCTION(op, SetException, 0) @@ -192,6 +193,7 @@ QT_BEGIN_NAMESPACE #define INSTR_Sub(op) INSTRUCTION(op, Sub, 1, lhs) #define INSTR_LoadQmlContext(op) INSTRUCTION(op, LoadQmlContext, 1, result) #define INSTR_LoadQmlImportedScripts(op) INSTRUCTION(op, LoadQmlImportedScripts, 1, result) +#define INSTR_InitializeBlockDeadTemporalZone(op) INSTRUCTION(op, InitializeBlockDeadTemporalZone, 2, firstReg, count) #define FOR_EACH_MOTH_INSTR_ALL(F) \ F(Nop) \ @@ -295,6 +297,7 @@ QT_BEGIN_NAMESPACE F(SetUnwindHandler) \ F(UnwindDispatch) \ F(UnwindToLabel) \ + F(DeadTemporalZoneCheck) \ F(ThrowException) \ F(GetException) \ F(SetException) \ @@ -326,6 +329,7 @@ QT_BEGIN_NAMESPACE F(LoadSuperConstructor) \ F(PushScriptContext) \ F(PopScriptContext) \ + F(InitializeBlockDeadTemporalZone) \ F(Debug) \ #define MOTH_NUM_INSTRUCTIONS() (static_cast(Moth::Instr::Type::Debug_Wide) + 1) -- cgit v1.2.3