summaryrefslogtreecommitdiffstats
path: root/js/src/vm
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-24 12:23:14 +0100
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-03-24 12:23:14 +0100
commit2bb0252ab48a97a72c33cef9cbe54e86563f15c9 (patch)
tree1b792a95a2ddaed8f3a16e7367b72fff73a51a51 /js/src/vm
parent4b487efb58bfba4c3f67d898e86b9f6daaab59b2 (diff)
downloadUXP-2bb0252ab48a97a72c33cef9cbe54e86563f15c9.tar
UXP-2bb0252ab48a97a72c33cef9cbe54e86563f15c9.tar.gz
UXP-2bb0252ab48a97a72c33cef9cbe54e86563f15c9.tar.lz
UXP-2bb0252ab48a97a72c33cef9cbe54e86563f15c9.tar.xz
UXP-2bb0252ab48a97a72c33cef9cbe54e86563f15c9.zip
Bug 1147371: Implement IteratorClose for array destructuring
Issue #74
Diffstat (limited to 'js/src/vm')
-rw-r--r--js/src/vm/Interpreter.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp
index 489d0a155..923c824ce 100644
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -1171,19 +1171,13 @@ ProcessTryNotes(JSContext* cx, EnvironmentIter& ei, InterpreterRegs& regs)
SettleOnTryNote(cx, tn, ei, regs);
return FinallyContinuation;
- case JSTRY_FOR_IN:
- case JSTRY_ITERCLOSE: {
+ case JSTRY_FOR_IN: {
/* This is similar to JSOP_ENDITER in the interpreter loop. */
DebugOnly<jsbytecode*> pc = regs.fp()->script()->main() + tn->start + tn->length;
- MOZ_ASSERT_IF(tn->kind == JSTRY_FOR_IN, JSOp(*pc) == JSOP_ENDITER);
+ MOZ_ASSERT(JSOp(*pc) == JSOP_ENDITER);
Value* sp = regs.spForStackDepth(tn->stackDepth);
RootedObject obj(cx, &sp[-1].toObject());
- bool ok;
- if (tn->kind == JSTRY_FOR_IN)
- ok = UnwindIteratorForException(cx, obj);
- else
- ok = IteratorCloseForException(cx, obj);
- if (!ok) {
+ if (!UnwindIteratorForException(cx, obj)) {
// We should only settle on the note only if
// UnwindIteratorForException itself threw, as
// onExceptionUnwind should be called anew with the new
@@ -1195,6 +1189,33 @@ ProcessTryNotes(JSContext* cx, EnvironmentIter& ei, InterpreterRegs& regs)
break;
}
+ case JSTRY_ITERCLOSE: {
+ // The iterator object is at the top of the stack.
+ Value* sp = regs.spForStackDepth(tn->stackDepth);
+ RootedObject iterObject(cx, &sp[-1].toObject());
+ if (!IteratorCloseForException(cx, iterObject)) {
+ SettleOnTryNote(cx, tn, ei, regs);
+ return ErrorReturnContinuation;
+ }
+ break;
+ }
+
+ case JSTRY_DESTRUCTURING_ITERCLOSE: {
+ // Whether the destructuring iterator is done is at the top of the
+ // stack. The iterator object is second from the top.
+ MOZ_ASSERT(tn->stackDepth > 1);
+ Value* sp = regs.spForStackDepth(tn->stackDepth);
+ MOZ_ASSERT(sp[-1].isBoolean());
+ if (sp[-1].isFalse()) {
+ RootedObject iterObject(cx, &sp[-2].toObject());
+ if (!IteratorCloseForException(cx, iterObject)) {
+ SettleOnTryNote(cx, tn, ei, regs);
+ return ErrorReturnContinuation;
+ }
+ }
+ break;
+ }
+
case JSTRY_FOR_OF:
case JSTRY_LOOP:
break;