aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jit
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-03-26 22:59:28 +0200
committerLars Knoll <lars.knoll@qt.io>2018-05-02 14:17:46 +0000
commit20d30b6b3a253eebedc927dbb91685bbec52cfee (patch)
tree0e91a6c519829bd279258f3fe807519e6c8a1e3d /src/qml/jit
parentd499a995292629d3522f5e77b7c958bacdf5d0ae (diff)
Add support for proper lexical scoping
This is still to some extend work in progress as lexically scoped for loops won't yet do the right thing. let and const variables are still accessible before they are declared, and the global scope doesn't yet have a proper context for lexically declared variables. Change-Id: Ie39f74a8fccdaead437fbf07f9fc228a444c26ed Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jit')
-rw-r--r--src/qml/jit/qv4jit.cpp21
-rw-r--r--src/qml/jit/qv4jit_p.h1
2 files changed, 22 insertions, 0 deletions
diff --git a/src/qml/jit/qv4jit.cpp b/src/qml/jit/qv4jit.cpp
index aa9c244a60..4a2e2b959c 100644
--- a/src/qml/jit/qv4jit.cpp
+++ b/src/qml/jit/qv4jit.cpp
@@ -629,6 +629,24 @@ void BaselineJIT::generate_PushWithContext(int reg)
as->checkException();
}
+static void pushBlockContextHelper(QV4::Value *stack, int reg, int index)
+{
+ stack[reg] = stack[CallData::Context];
+ ExecutionContext *c = static_cast<ExecutionContext *>(stack + CallData::Context);
+ stack[CallData::Context] = Runtime::method_createBlockContext(c, index);
+}
+
+void BaselineJIT::generate_PushBlockContext(int reg, int index)
+{
+ as->saveAccumulatorInFrame();
+ as->prepareCallWithArgCount(3);
+ as->passInt32AsArg(index, 2);
+ as->passInt32AsArg(reg, 1);
+ as->passRegAsArg(0, 0);
+ JIT_GENERATE_RUNTIME_CALL(pushBlockContextHelper, Assembler::IgnoreResult);
+}
+
+
void BaselineJIT::generate_PopContext(int reg) { as->popContext(reg); }
void BaselineJIT::generate_ForeachIteratorObject()
@@ -1177,6 +1195,9 @@ void BaselineJIT::collectLabelsInBytecode()
MOTH_BEGIN_INSTR(PushWithContext)
MOTH_END_INSTR(PushWithContext)
+ MOTH_BEGIN_INSTR(PushBlockContext)
+ MOTH_END_INSTR(PushBlockContext)
+
MOTH_BEGIN_INSTR(PopContext)
MOTH_END_INSTR(PopContext)
diff --git a/src/qml/jit/qv4jit_p.h b/src/qml/jit/qv4jit_p.h
index 7861cdec38..3e81807754 100644
--- a/src/qml/jit/qv4jit_p.h
+++ b/src/qml/jit/qv4jit_p.h
@@ -177,6 +177,7 @@ public:
void generate_CreateCallContext() override;
void generate_PushCatchContext(int name, int reg) override;
void generate_PushWithContext(int reg) override;
+ void generate_PushBlockContext(int reg, int index) override;
void generate_PopContext(int reg) override;
void generate_ForeachIteratorObject() override;
void generate_ForeachNextPropertyName() override;