diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-09-04 12:19:10 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-10-05 11:18:16 +0000 |
commit | 052d22e116957a170e290a49d077d3e9f290a237 (patch) | |
tree | 8d63f1b622a7c93d8b845c3d77f796f5ad18493b /src/qml/jsruntime/qv4functionobject.cpp | |
parent | 08342d761369c3755778f6d69fa6f5907ae1aead (diff) |
ES7: Implement Tail Position Calls in the runtime
Change-Id: If1629109722496b3fd10b36b2376548440f2fee9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index f6b279ddaf..93cc55f8ad 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -498,7 +498,7 @@ ReturnedValue ArrowFunction::virtualCall(const FunctionObject *fo, const Value * { ExecutionEngine *engine = fo->engine(); CppStackFrame frame; - frame.init(engine, fo->function(), argv, argc); + frame.init(engine, fo->function(), argv, argc, true); frame.setupJSFrame(engine->jsStackTop, *fo, fo->scope(), thisObject ? *thisObject : Value::undefinedValue(), Value::undefinedValue()); @@ -506,7 +506,12 @@ ReturnedValue ArrowFunction::virtualCall(const FunctionObject *fo, const Value * frame.push(); engine->jsStackTop += frame.requiredJSStackFrameSize(); - ReturnedValue result = Moth::VME::exec(&frame, engine); + ReturnedValue result; + + do { + frame.pendingTailCall = false; + result = Moth::VME::exec(&frame, engine); + } while (frame.pendingTailCall); frame.pop(); @@ -530,6 +535,7 @@ void Heap::ArrowFunction::init(QV4::ExecutionContext *scope, Function *function, Q_ASSERT(internalClass && internalClass->verifyIndex(s.engine->id_length()->propertyKey(), Index_Length)); setProperty(s.engine, Index_Length, Value::fromInt32(int(function->compiledFunction->length))); + canBeTailCalled = true; } void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function) |