Note on underwhelming performance when using a dynamically generated array of opcode functions specifying ".bind(this)" on every one (which is why I don't do it)

This commit is contained in:
Jeff Parsons 2016-05-12 00:12:57 -07:00
commit a02454467b
4 changed files with 10 additions and 7 deletions

View file

@ -1,5 +1,5 @@
/**
* @fileoverview Implements the PC8080 CPU component.
* @fileoverview Controls the PC8080 CPU component.
* @author <a href="mailto:Jeff@pcjs.org">Jeff Parsons</a>
* @version 1.0
* Created 2016-Apr-18

View file

@ -2874,7 +2874,7 @@ CPUDef.opRST7 = function()
* but I suspect that would vary quite a bit across JavaScript engines; for now, I'm putting my
* money on array lookup.
*/
CPUDef.aOps = [
CPUDef.aOps8080 = [
/* 0x00-0x03 */ CPUDef.opNOP, CPUDef.opLXIB, CPUDef.opSTAXB, CPUDef.opINXB,
/* 0x04-0x07 */ CPUDef.opINRB, CPUDef.opDCRB, CPUDef.opMVIB, CPUDef.opRLC,
/* 0x08-0x0B */ CPUDef.opNOP, CPUDef.opDADB, CPUDef.opLDAXB, CPUDef.opDCXB,

View file

@ -1,5 +1,5 @@
/**
* @fileoverview Implements the PC8080 CPU module.
* @fileoverview Implements the PC8080 CPU component.
* @author <a href="mailto:Jeff@pcjs.org">Jeff Parsons</a>
* @version 1.0
* Created 2016-Apr-18
@ -123,11 +123,17 @@ CPUSim.prototype.addHaltCheck = function(fn)
/**
* initProcessor()
*
* Interestingly, if I dynamically generate aOps as an array of functions bound to "this", using the bind()
* method, overall performance is worse. You would think that eliminating the need to use the call() method
* on every opcode function invocation would be helpful, but it's not. I'm not sure exactly why yet; perhaps
* a Closure Compiler optimization is defeated when generating the function array at run-time instead of at
* compile-time.
*
* @this {CPUSim}
*/
CPUSim.prototype.initProcessor = function()
{
this.aOps = CPUDef.aOps;
this.aOps = CPUDef.aOps8080;
};
/**