From ccad30c741bbd105ec8c01b0e5e235f446cf48d8 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Tue, 28 May 2013 14:32:47 +0200 Subject: [PATCH] Bug 876398 - Compile JSOP_POPN with Baseline and Ion. r=djvj --- js/src/ion/BaselineCompiler.cpp | 7 +++++++ js/src/ion/BaselineCompiler.h | 1 + js/src/ion/IonBuilder.cpp | 5 +++++ js/src/jit-test/tests/ion/popn.js | 11 +++++++++++ 4 files changed, 24 insertions(+) create mode 100644 js/src/jit-test/tests/ion/popn.js diff --git a/js/src/ion/BaselineCompiler.cpp b/js/src/ion/BaselineCompiler.cpp index 3b47c43fff4..bfdc58b32a4 100644 --- a/js/src/ion/BaselineCompiler.cpp +++ b/js/src/ion/BaselineCompiler.cpp @@ -623,6 +623,13 @@ BaselineCompiler::emit_JSOP_POP() return true; } +bool +BaselineCompiler::emit_JSOP_POPN() +{ + frame.popn(GET_UINT16(pc)); + return true; +} + bool BaselineCompiler::emit_JSOP_DUP() { diff --git a/js/src/ion/BaselineCompiler.h b/js/src/ion/BaselineCompiler.h index 6aa7cd9ed44..7e687d5c2a2 100644 --- a/js/src/ion/BaselineCompiler.h +++ b/js/src/ion/BaselineCompiler.h @@ -35,6 +35,7 @@ namespace ion { _(JSOP_LABEL) \ _(JSOP_NOTEARG) \ _(JSOP_POP) \ + _(JSOP_POPN) \ _(JSOP_DUP) \ _(JSOP_DUP2) \ _(JSOP_SWAP) \ diff --git a/js/src/ion/IonBuilder.cpp b/js/src/ion/IonBuilder.cpp index 83a0e2bd38e..aff3a65e9d1 100644 --- a/js/src/ion/IonBuilder.cpp +++ b/js/src/ion/IonBuilder.cpp @@ -1244,6 +1244,11 @@ IonBuilder::inspectOpcode(JSOp op) return true; return maybeInsertResume(); + case JSOP_POPN: + for (uint32_t i = 0, n = GET_UINT16(pc); i < n; i++) + current->pop(); + return true; + case JSOP_NEWINIT: { if (GET_UINT8(pc) == JSProto_Array) diff --git a/js/src/jit-test/tests/ion/popn.js b/js/src/jit-test/tests/ion/popn.js new file mode 100644 index 00000000000..06e2f5fb85d --- /dev/null +++ b/js/src/jit-test/tests/ion/popn.js @@ -0,0 +1,11 @@ +function f() { + var t = 0; + for (var j = 0; j < 10; j++) { + for (var i = 0; i < 9; ++i) { + var [r, g, b] = [1, i, -10]; + t += r + g + b; + } + } + return t; +} +assertEq(f(), -450);