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

@ -157,9 +157,6 @@ function C1PVideo(parmsVideo, canvas, context, imgChars)
* it still being labelled "experimental technology". Let's hope the browsers standardize * it still being labelled "experimental technology". Let's hope the browsers standardize
* on this. I see other options emerging, like the CSS property "image-rendering: pixelated" * on this. I see other options emerging, like the CSS property "image-rendering: pixelated"
* that's apparently been added to Chrome. Sigh. * that's apparently been added to Chrome. Sigh.
*
* TODO: Investigate why imageSmoothingEnabled seems to have little effect on the imgChars
* images we draw in updateWindow().
*/ */
var i, sEvent, asWebPrefixes = ['', 'moz', 'ms', 'webkit']; var i, sEvent, asWebPrefixes = ['', 'moz', 'ms', 'webkit'];
var fSmoothing = parmsVideo['smoothing']; var fSmoothing = parmsVideo['smoothing'];

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> * @author <a href="mailto:Jeff@pcjs.org">Jeff Parsons</a>
* @version 1.0 * @version 1.0
* Created 2016-Apr-18 * 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 * but I suspect that would vary quite a bit across JavaScript engines; for now, I'm putting my
* money on array lookup. * money on array lookup.
*/ */
CPUDef.aOps = [ CPUDef.aOps8080 = [
/* 0x00-0x03 */ CPUDef.opNOP, CPUDef.opLXIB, CPUDef.opSTAXB, CPUDef.opINXB, /* 0x00-0x03 */ CPUDef.opNOP, CPUDef.opLXIB, CPUDef.opSTAXB, CPUDef.opINXB,
/* 0x04-0x07 */ CPUDef.opINRB, CPUDef.opDCRB, CPUDef.opMVIB, CPUDef.opRLC, /* 0x04-0x07 */ CPUDef.opINRB, CPUDef.opDCRB, CPUDef.opMVIB, CPUDef.opRLC,
/* 0x08-0x0B */ CPUDef.opNOP, CPUDef.opDADB, CPUDef.opLDAXB, CPUDef.opDCXB, /* 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> * @author <a href="mailto:Jeff@pcjs.org">Jeff Parsons</a>
* @version 1.0 * @version 1.0
* Created 2016-Apr-18 * Created 2016-Apr-18
@ -123,11 +123,17 @@ CPUSim.prototype.addHaltCheck = function(fn)
/** /**
* initProcessor() * 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} * @this {CPUSim}
*/ */
CPUSim.prototype.initProcessor = function() CPUSim.prototype.initProcessor = function()
{ {
this.aOps = CPUDef.aOps; this.aOps = CPUDef.aOps8080;
}; };
/** /**