From a9304f20747c011063ec7a142dd39b5e5b21fcb4 Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Wed, 16 Jul 2014 06:37:23 -0700 Subject: [PATCH] move more opcodes into invoke --- frame.js | 135 ++++++++++++++++++++++++++----------------------------- 1 file changed, 63 insertions(+), 72 deletions(-) diff --git a/frame.js b/frame.js index 023be3b6..1aa964db 100644 --- a/frame.js +++ b/frame.js @@ -381,6 +381,69 @@ Frame.prototype.invoke = function(op, methodInfo) { break; refArray[idx] = val; break; + case 0x57: // pop + stack.pop(); + break; + case 0x58: // pop2 + stack.pop2(); + break; + case 0x59: // dup + var val = stack.pop(); + stack.push(val); + stack.push(val); + break; + case 0x5a: // dup_x1 + var val1 = stack.pop(); + var val2 = stack.pop(); + stack.push(val1); + stack.push(val2); + stack.push(val1); + break; + case 0x5b: // dup_x2 + var val1 = stack.pop(); + var val2 = stack.pop(); + var val3 = stack.pop(); + stack.push(val1); + stack.push(val3); + stack.push(val2); + stack.push(val1); + break; + case 0x5c: // dup2 + var val1 = stack.pop(); + var val2 = stack.pop(); + stack.push(val2); + stack.push(val1); + stack.push(val2); + stack.push(val1); + break; + case 0x5d: // dup2_x1 + var val1 = stack.pop(); + var val2 = stack.pop(); + var val3 = stack.pop(); + stack.push(val2); + stack.push(val1); + stack.push(val3); + stack.push(val2); + stack.push(val1); + break; + case 0x5e: // dup2_x2 + var val1 = stack.pop(); + var val2 = stack.pop(); + var val3 = stack.pop(); + var val4 = stack.pop(); + stack.push(val2); + stack.push(val1); + stack.push(val4); + stack.push(val3); + stack.push(val2); + stack.push(val1); + break; + case 0x5f: // swap + var val1 = stack.pop(); + var val2 = stack.pop(); + stack.push(val1); + stack.push(val2); + break; case OPCODES.return: callee.popFrame(); @@ -407,78 +470,6 @@ Frame.prototype.invoke = function(op, methodInfo) { }; } -Frame.prototype.pop = function() { - this.stack.pop(); -} - -Frame.prototype.pop2 = function() { - this.stack.pop2(); -} - -Frame.prototype.dup = function() { - var val = this.stack.pop(); - this.stack.push(val); - this.stack.push(val); -} - -Frame.prototype.dup_x1 = function() { - var val1 = this.stack.pop(); - var val2 = this.stack.pop(); - this.stack.push(val1); - this.stack.push(val2); - this.stack.push(val1); -} - -Frame.prototype.dup_x2 = function() { - var val1 = this.stack.pop(); - var val2 = this.stack.pop(); - var val3 = this.stack.pop(); - this.stack.push(val1); - this.stack.push(val3); - this.stack.push(val2); - this.stack.push(val1); -} - -Frame.prototype.dup2 = function() { - var val1 = this.stack.pop(); - var val2 = this.stack.pop(); - this.stack.push(val2); - this.stack.push(val1); - this.stack.push(val2); - this.stack.push(val1); -} - -Frame.prototype.dup2_x1 = function() { - var val1 = this.stack.pop(); - var val2 = this.stack.pop(); - var val3 = this.stack.pop(); - this.stack.push(val2); - this.stack.push(val1); - this.stack.push(val3); - this.stack.push(val2); - this.stack.push(val1); -} - -Frame.prototype.dup2_x2 = function() { - var val1 = this.stack.pop(); - var val2 = this.stack.pop(); - var val3 = this.stack.pop(); - var val4 = this.stack.pop(); - this.stack.push(val2); - this.stack.push(val1); - this.stack.push(val4); - this.stack.push(val3); - this.stack.push(val2); - this.stack.push(val1); -} - -Frame.prototype.swap = function() { - var val1 = this.stack.pop(); - var val2 = this.stack.pop(); - this.stack.push(val1); - this.stack.push(val2); -} - Frame.prototype.iinc = function() { var wide = this.isWide(); var idx = wide ? this.read16() : this.read8();