Remove 'argc' field of OP_CALLGLOBAL.
authorDavid Anderson <dvander@alliedmods.net>
Tue Jul 03 13:53:34 2012 -0400 (2012-07-03)
changeset 46735503e448a0
parent 45 25b995bc75a0
child 47 050939c6181e
Remove 'argc' field of OP_CALLGLOBAL.
jitcraft/BytecodeCompiler.cpp
jitcraft/BytecodeEmitter.h
jitcraft/Interpreter.cpp
jitcraft/Opcodes.tbl
     1.1 --- a/jitcraft/BytecodeCompiler.cpp	Tue Jul 03 09:25:18 2012 -0700
     1.2 +++ b/jitcraft/BytecodeCompiler.cpp	Tue Jul 03 13:53:34 2012 -0400
     1.3 @@ -626,7 +626,8 @@
     1.4          }
     1.5      }
     1.6  
     1.7 -    __ callglobal(node->arguments()->size(), 0);
     1.8 +    __ callglobal(node->callee()->toNameProxy()->binding()->toNamedFunction()->slot());
     1.9 +    __ drop(node->arguments()->size());
    1.10  }
    1.11  
    1.12  void
     2.1 --- a/jitcraft/BytecodeEmitter.h	Tue Jul 03 09:25:18 2012 -0700
     2.2 +++ b/jitcraft/BytecodeEmitter.h	Tue Jul 03 13:53:34 2012 -0400
     2.3 @@ -117,6 +117,11 @@
     2.4          return &objects_;
     2.5      }
     2.6  
     2.7 +    void drop(unsigned amt) {
     2.8 +        assert(amt <= stackDepth_);
     2.9 +        stackDepth_ -= amt;
    2.10 +    }
    2.11 +
    2.12    public:
    2.13      // A label represents a local control-flow target in the bytecode. A label
    2.14      // may be in three states:
    2.15 @@ -267,13 +272,10 @@
    2.16      void stop() {
    2.17          singleByteOp(OP_STOP);
    2.18      }
    2.19 -    void callglobal(unsigned nargs, unsigned index) {
    2.20 +    void callglobal(unsigned index) {
    2.21          ensure(OP_CALLGLOBAL_LENGTH);
    2.22          writeOp(OP_CALLGLOBAL);
    2.23 -        writeUint32(nargs);
    2.24          writeUint32(index);
    2.25 -
    2.26 -        stackDepth_ -= nargs;
    2.27      }
    2.28      void getarray(PrimitiveType type) {
    2.29          switch (type) {
     3.1 --- a/jitcraft/Interpreter.cpp	Tue Jul 03 09:25:18 2012 -0700
     3.2 +++ b/jitcraft/Interpreter.cpp	Tue Jul 03 13:53:34 2012 -0400
     3.3 @@ -365,12 +365,10 @@
     3.4  
     3.5  case OP_CALLGLOBAL:
     3.6  {
     3.7 -    unsigned argc = READ_UINT32(top.pc);
     3.8 -    unsigned index = READ_UINT32(top.pc + 4);
     3.9 +    unsigned index = READ_UINT32(top.pc);
    3.10      Local<Function> newFun(zone, frame->code()->module()->getFunction(index));
    3.11      frame = zone->stack().pushFrame(frame, newFun);
    3.12      assert(frame);
    3.13 -    assert(newFun->nargs() == argc);
    3.14  
    3.15      locals = frame->locals();
    3.16      continue;
     4.1 --- a/jitcraft/Opcodes.tbl	Tue Jul 03 09:25:18 2012 -0700
     4.2 +++ b/jitcraft/Opcodes.tbl	Tue Jul 03 13:53:34 2012 -0400
     4.3 @@ -73,11 +73,11 @@
     4.4  // Unconditional terminator placed at the end of code.
     4.5  OPDEF(OP_STOP,          19,         "stop",         1,      0,  0)
     4.6  
     4.7 -// Call a function with N arguments. Arguments are pushed in reverse order.
     4.8 +// Call a function with N arguments.
     4.9  //
    4.10  // CALLGLOBAL - followed by an extra immediate, containing the function index
    4.11  // in the code's global.
    4.12 -OPDEF(OP_CALLGLOBAL,    20,         "callglobal",   9,      -1, 1)
    4.13 +OPDEF(OP_CALLGLOBAL,    20,         "callglobal",   5,      -1, 1)
    4.14  
    4.15  // Similar to GET/LOCAL, except for arguments.
    4.16  OPDEF(OP_GETARG,        21,         "getarg",       5,      0,  1)