@typeberry/jam 0.2.0-f9e8db5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap-importer.mjs +18 -0
- package/bootstrap-importer.mjs.map +1 -1
- package/index.js +18 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
package/bootstrap-importer.mjs
CHANGED
|
@@ -19213,6 +19213,24 @@ class Interpreter {
|
|
|
19213
19213
|
getMemoryPage(pageNumber) {
|
|
19214
19214
|
return this.memory.getPageDump(tryAsPageNumber(pageNumber));
|
|
19215
19215
|
}
|
|
19216
|
+
calculateBlockGasCost() {
|
|
19217
|
+
const codeLength = this.code.length;
|
|
19218
|
+
const blocks = new Map();
|
|
19219
|
+
let currentBlock = "0";
|
|
19220
|
+
let gasCost = 0;
|
|
19221
|
+
const getNextIstructionIndex = (index) => index + 1 + this.mask.getNoOfBytesToNextInstruction(index + 1);
|
|
19222
|
+
for (let index = 0; index < codeLength; index = getNextIstructionIndex(index)) {
|
|
19223
|
+
const instruction = this.code[index];
|
|
19224
|
+
if (this.basicBlocks.isBeginningOfBasicBlock(index)) {
|
|
19225
|
+
blocks.set(currentBlock, gasCost);
|
|
19226
|
+
currentBlock = index.toString();
|
|
19227
|
+
gasCost = 0;
|
|
19228
|
+
}
|
|
19229
|
+
gasCost += instructionGasMap[instruction];
|
|
19230
|
+
}
|
|
19231
|
+
blocks.set(currentBlock, gasCost);
|
|
19232
|
+
return blocks;
|
|
19233
|
+
}
|
|
19216
19234
|
}
|
|
19217
19235
|
|
|
19218
19236
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/index.ts
|