|
|
|
@ -6,26 +6,7 @@ class DataCollector { |
|
|
|
|
constructor(instrumentationData={}, viaIR){ |
|
|
|
|
this.instrumentationData = instrumentationData; |
|
|
|
|
|
|
|
|
|
this.validOpcodes = { |
|
|
|
|
"PUSH1": true, |
|
|
|
|
"DUP1": viaIR, |
|
|
|
|
"DUP2": viaIR, |
|
|
|
|
"DUP3": viaIR, |
|
|
|
|
"DUP4": viaIR, |
|
|
|
|
"DUP5": viaIR, |
|
|
|
|
"DUP6": viaIR, |
|
|
|
|
"DUP7": viaIR, |
|
|
|
|
"DUP8": viaIR, |
|
|
|
|
"DUP9": viaIR, |
|
|
|
|
"DUP10": viaIR, |
|
|
|
|
"DUP11": viaIR, |
|
|
|
|
"DUP12": viaIR, |
|
|
|
|
"DUP13": viaIR, |
|
|
|
|
"DUP14": viaIR, |
|
|
|
|
"DUP15": viaIR, |
|
|
|
|
"DUP16": viaIR, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.validOpcodes = this._getOpcodes(viaIR); |
|
|
|
|
this.lastHash = null; |
|
|
|
|
this.viaIR = viaIR; |
|
|
|
|
this.pcZeroCounter = 0; |
|
|
|
@ -98,6 +79,29 @@ class DataCollector { |
|
|
|
|
return hash; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generates a list of all the opcodes to inspect for instrumentation hashes |
|
|
|
|
* When viaIR is true, it includes all DUPs and PUSHs, so things are a little slower. |
|
|
|
|
* @param {boolean} viaIR |
|
|
|
|
*/ |
|
|
|
|
_getOpcodes(viaIR) { |
|
|
|
|
let opcodes = { |
|
|
|
|
"PUSH1": true |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
for (let i = 2; i <= 32; i++) { |
|
|
|
|
const key = "PUSH" + i; |
|
|
|
|
opcodes[key] = viaIR; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
for (let i = 1; i <= 16; i++ ) { |
|
|
|
|
const key = "DUP" + i; |
|
|
|
|
opcodes[key] = viaIR; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return opcodes; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Unit test helper |
|
|
|
|
* @param {Object} data Instrumenter.instrumentationData |
|
|
|
|