@aptre/v86 0.5.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/LICENSE +22 -0
- package/LICENSE.MIT +22 -0
- package/Readme.md +237 -0
- package/dist/v86.browser.js +26666 -0
- package/dist/v86.browser.js.map +7 -0
- package/dist/v86.js +26632 -0
- package/dist/v86.js.map +7 -0
- package/gen/generate_analyzer.ts +512 -0
- package/gen/generate_interpreter.ts +522 -0
- package/gen/generate_jit.ts +624 -0
- package/gen/rust_ast.ts +107 -0
- package/gen/util.ts +35 -0
- package/gen/x86_table.ts +1836 -0
- package/lib/9p.ts +1547 -0
- package/lib/filesystem.ts +1879 -0
- package/lib/marshall.ts +168 -0
- package/lib/softfloat/softfloat.c +32501 -0
- package/lib/zstd/zstddeclib.c +13520 -0
- package/package.json +75 -0
- package/src/acpi.ts +267 -0
- package/src/browser/dummy_screen.ts +106 -0
- package/src/browser/fake_network.ts +1771 -0
- package/src/browser/fetch_network.ts +361 -0
- package/src/browser/filestorage.ts +124 -0
- package/src/browser/inbrowser_network.ts +57 -0
- package/src/browser/keyboard.ts +564 -0
- package/src/browser/main.ts +3415 -0
- package/src/browser/mouse.ts +255 -0
- package/src/browser/network.ts +142 -0
- package/src/browser/print_stats.ts +336 -0
- package/src/browser/screen.ts +978 -0
- package/src/browser/serial.ts +316 -0
- package/src/browser/speaker.ts +1223 -0
- package/src/browser/starter.ts +1688 -0
- package/src/browser/wisp_network.ts +332 -0
- package/src/browser/worker_bus.ts +64 -0
- package/src/buffer.ts +652 -0
- package/src/bus.ts +78 -0
- package/src/const.ts +128 -0
- package/src/cpu.ts +2891 -0
- package/src/dma.ts +474 -0
- package/src/elf.ts +251 -0
- package/src/floppy.ts +1778 -0
- package/src/ide.ts +3455 -0
- package/src/io.ts +504 -0
- package/src/iso9660.ts +317 -0
- package/src/kernel.ts +250 -0
- package/src/lib.ts +645 -0
- package/src/log.ts +149 -0
- package/src/main.ts +199 -0
- package/src/ne2k.ts +1589 -0
- package/src/pci.ts +815 -0
- package/src/pit.ts +406 -0
- package/src/ps2.ts +820 -0
- package/src/rtc.ts +537 -0
- package/src/rust/analysis.rs +101 -0
- package/src/rust/codegen.rs +2660 -0
- package/src/rust/config.rs +3 -0
- package/src/rust/control_flow.rs +425 -0
- package/src/rust/cpu/apic.rs +658 -0
- package/src/rust/cpu/arith.rs +1207 -0
- package/src/rust/cpu/call_indirect.rs +2 -0
- package/src/rust/cpu/cpu.rs +4501 -0
- package/src/rust/cpu/fpu.rs +923 -0
- package/src/rust/cpu/global_pointers.rs +112 -0
- package/src/rust/cpu/instructions.rs +2486 -0
- package/src/rust/cpu/instructions_0f.rs +5261 -0
- package/src/rust/cpu/ioapic.rs +316 -0
- package/src/rust/cpu/memory.rs +351 -0
- package/src/rust/cpu/misc_instr.rs +613 -0
- package/src/rust/cpu/mod.rs +16 -0
- package/src/rust/cpu/modrm.rs +133 -0
- package/src/rust/cpu/pic.rs +402 -0
- package/src/rust/cpu/sse_instr.rs +361 -0
- package/src/rust/cpu/string.rs +701 -0
- package/src/rust/cpu/vga.rs +175 -0
- package/src/rust/cpu_context.rs +69 -0
- package/src/rust/dbg.rs +98 -0
- package/src/rust/gen/analyzer.rs +3807 -0
- package/src/rust/gen/analyzer0f.rs +3992 -0
- package/src/rust/gen/interpreter.rs +4447 -0
- package/src/rust/gen/interpreter0f.rs +5404 -0
- package/src/rust/gen/jit.rs +5080 -0
- package/src/rust/gen/jit0f.rs +5547 -0
- package/src/rust/gen/mod.rs +14 -0
- package/src/rust/jit.rs +2443 -0
- package/src/rust/jit_instructions.rs +7881 -0
- package/src/rust/js_api.rs +6 -0
- package/src/rust/leb.rs +46 -0
- package/src/rust/lib.rs +29 -0
- package/src/rust/modrm.rs +330 -0
- package/src/rust/opstats.rs +249 -0
- package/src/rust/page.rs +15 -0
- package/src/rust/paging.rs +25 -0
- package/src/rust/prefix.rs +15 -0
- package/src/rust/profiler.rs +155 -0
- package/src/rust/regs.rs +38 -0
- package/src/rust/softfloat.rs +286 -0
- package/src/rust/state_flags.rs +27 -0
- package/src/rust/wasmgen/mod.rs +2 -0
- package/src/rust/wasmgen/wasm_builder.rs +1047 -0
- package/src/rust/wasmgen/wasm_opcodes.rs +221 -0
- package/src/rust/zstd.rs +105 -0
- package/src/sb16.ts +1928 -0
- package/src/state.ts +359 -0
- package/src/uart.ts +472 -0
- package/src/vga.ts +2791 -0
- package/src/virtio.ts +1756 -0
- package/src/virtio_balloon.ts +273 -0
- package/src/virtio_console.ts +372 -0
- package/src/virtio_net.ts +326 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { pads } from '../lib.js'
|
|
2
|
+
|
|
3
|
+
interface CPU {
|
|
4
|
+
wm: {
|
|
5
|
+
exports: Record<string, (...args: any[]) => any>
|
|
6
|
+
}
|
|
7
|
+
wasm_memory: WebAssembly.Memory
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function stats_to_string(cpu: CPU): string {
|
|
11
|
+
return print_misc_stats(cpu) + print_instruction_counts(cpu)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function print_misc_stats(cpu: CPU): string {
|
|
15
|
+
let text = ''
|
|
16
|
+
|
|
17
|
+
const stat_names = [
|
|
18
|
+
'COMPILE',
|
|
19
|
+
'COMPILE_SKIPPED_NO_NEW_ENTRY_POINTS',
|
|
20
|
+
'COMPILE_WRONG_ADDRESS_SPACE',
|
|
21
|
+
'COMPILE_CUT_OFF_AT_END_OF_PAGE',
|
|
22
|
+
'COMPILE_WITH_LOOP_SAFETY',
|
|
23
|
+
'COMPILE_PAGE',
|
|
24
|
+
'COMPILE_PAGE/COMPILE',
|
|
25
|
+
'COMPILE_BASIC_BLOCK',
|
|
26
|
+
'COMPILE_DUPLICATED_BASIC_BLOCK',
|
|
27
|
+
'COMPILE_WASM_BLOCK',
|
|
28
|
+
'COMPILE_WASM_LOOP',
|
|
29
|
+
'COMPILE_DISPATCHER',
|
|
30
|
+
'COMPILE_ENTRY_POINT',
|
|
31
|
+
'COMPILE_WASM_TOTAL_BYTES',
|
|
32
|
+
'COMPILE_WASM_TOTAL_BYTES/COMPILE_PAGE',
|
|
33
|
+
'RUN_INTERPRETED',
|
|
34
|
+
'RUN_INTERPRETED_NEW_PAGE',
|
|
35
|
+
'RUN_INTERPRETED_PAGE_HAS_CODE',
|
|
36
|
+
'RUN_INTERPRETED_PAGE_HAS_ENTRY_AFTER_PAGE_WALK',
|
|
37
|
+
'RUN_INTERPRETED_NEAR_END_OF_PAGE',
|
|
38
|
+
'RUN_INTERPRETED_DIFFERENT_STATE',
|
|
39
|
+
'RUN_INTERPRETED_DIFFERENT_STATE_CPL3',
|
|
40
|
+
'RUN_INTERPRETED_DIFFERENT_STATE_FLAT',
|
|
41
|
+
'RUN_INTERPRETED_DIFFERENT_STATE_IS32',
|
|
42
|
+
'RUN_INTERPRETED_DIFFERENT_STATE_SS32',
|
|
43
|
+
'RUN_INTERPRETED_MISSED_COMPILED_ENTRY_RUN_INTERPRETED',
|
|
44
|
+
'RUN_INTERPRETED_STEPS',
|
|
45
|
+
'RUN_FROM_CACHE',
|
|
46
|
+
'RUN_FROM_CACHE_STEPS',
|
|
47
|
+
'RUN_FROM_CACHE_STEPS/RUN_FROM_CACHE',
|
|
48
|
+
'RUN_FROM_CACHE_STEPS/RUN_INTERPRETED_STEPS',
|
|
49
|
+
'DIRECT_EXIT',
|
|
50
|
+
'INDIRECT_JUMP',
|
|
51
|
+
'INDIRECT_JUMP_NO_ENTRY',
|
|
52
|
+
'NORMAL_PAGE_CHANGE',
|
|
53
|
+
'NORMAL_FALLTHRU',
|
|
54
|
+
'NORMAL_FALLTHRU_WITH_TARGET_BLOCK',
|
|
55
|
+
'NORMAL_BRANCH',
|
|
56
|
+
'NORMAL_BRANCH_WITH_TARGET_BLOCK',
|
|
57
|
+
'CONDITIONAL_JUMP',
|
|
58
|
+
'CONDITIONAL_JUMP_PAGE_CHANGE',
|
|
59
|
+
'CONDITIONAL_JUMP_EXIT',
|
|
60
|
+
'CONDITIONAL_JUMP_FALLTHRU',
|
|
61
|
+
'CONDITIONAL_JUMP_FALLTHRU_WITH_TARGET_BLOCK',
|
|
62
|
+
'CONDITIONAL_JUMP_BRANCH',
|
|
63
|
+
'CONDITIONAL_JUMP_BRANCH_WITH_TARGET_BLOCK',
|
|
64
|
+
'DISPATCHER_SMALL',
|
|
65
|
+
'DISPATCHER_LARGE',
|
|
66
|
+
'LOOP',
|
|
67
|
+
'LOOP_SAFETY',
|
|
68
|
+
'CONDITION_OPTIMISED',
|
|
69
|
+
'CONDITION_UNOPTIMISED',
|
|
70
|
+
'CONDITION_UNOPTIMISED_PF',
|
|
71
|
+
'CONDITION_UNOPTIMISED_UNHANDLED_L',
|
|
72
|
+
'CONDITION_UNOPTIMISED_UNHANDLED_LE',
|
|
73
|
+
'FAILED_PAGE_CHANGE',
|
|
74
|
+
'SAFE_READ_FAST',
|
|
75
|
+
'SAFE_READ_SLOW_PAGE_CROSSED',
|
|
76
|
+
'SAFE_READ_SLOW_NOT_VALID',
|
|
77
|
+
'SAFE_READ_SLOW_NOT_USER',
|
|
78
|
+
'SAFE_READ_SLOW_IN_MAPPED_RANGE',
|
|
79
|
+
'SAFE_WRITE_FAST',
|
|
80
|
+
'SAFE_WRITE_SLOW_PAGE_CROSSED',
|
|
81
|
+
'SAFE_WRITE_SLOW_NOT_VALID',
|
|
82
|
+
'SAFE_WRITE_SLOW_NOT_USER',
|
|
83
|
+
'SAFE_WRITE_SLOW_IN_MAPPED_RANGE',
|
|
84
|
+
'SAFE_WRITE_SLOW_READ_ONLY',
|
|
85
|
+
'SAFE_WRITE_SLOW_HAS_CODE',
|
|
86
|
+
'SAFE_READ_WRITE_FAST',
|
|
87
|
+
'SAFE_READ_WRITE_SLOW_PAGE_CROSSED',
|
|
88
|
+
'SAFE_READ_WRITE_SLOW_NOT_VALID',
|
|
89
|
+
'SAFE_READ_WRITE_SLOW_NOT_USER',
|
|
90
|
+
'SAFE_READ_WRITE_SLOW_IN_MAPPED_RANGE',
|
|
91
|
+
'SAFE_READ_WRITE_SLOW_READ_ONLY',
|
|
92
|
+
'SAFE_READ_WRITE_SLOW_HAS_CODE',
|
|
93
|
+
'PAGE_FAULT',
|
|
94
|
+
'TLB_MISS',
|
|
95
|
+
'MAIN_LOOP',
|
|
96
|
+
'MAIN_LOOP_IDLE',
|
|
97
|
+
'DO_MANY_CYCLES',
|
|
98
|
+
'CYCLE_INTERNAL',
|
|
99
|
+
'INVALIDATE_ALL_MODULES_NO_FREE_WASM_INDICES',
|
|
100
|
+
'INVALIDATE_MODULE_WRITTEN_WHILE_COMPILED',
|
|
101
|
+
'INVALIDATE_MODULE_UNUSED_AFTER_OVERWRITE',
|
|
102
|
+
'INVALIDATE_MODULE_DIRTY_PAGE',
|
|
103
|
+
'INVALIDATE_PAGE_HAD_CODE',
|
|
104
|
+
'INVALIDATE_PAGE_HAD_ENTRY_POINTS',
|
|
105
|
+
'DIRTY_PAGE_DID_NOT_HAVE_CODE',
|
|
106
|
+
'RUN_FROM_CACHE_EXIT_SAME_PAGE',
|
|
107
|
+
'RUN_FROM_CACHE_EXIT_NEAR_END_OF_PAGE',
|
|
108
|
+
'RUN_FROM_CACHE_EXIT_DIFFERENT_PAGE',
|
|
109
|
+
'CLEAR_TLB',
|
|
110
|
+
'FULL_CLEAR_TLB',
|
|
111
|
+
'TLB_FULL',
|
|
112
|
+
'TLB_GLOBAL_FULL',
|
|
113
|
+
'MODRM_SIMPLE_REG',
|
|
114
|
+
'MODRM_SIMPLE_REG_WITH_OFFSET',
|
|
115
|
+
'MODRM_SIMPLE_CONST_OFFSET',
|
|
116
|
+
'MODRM_COMPLEX',
|
|
117
|
+
'SEG_OFFSET_OPTIMISED',
|
|
118
|
+
'SEG_OFFSET_NOT_OPTIMISED',
|
|
119
|
+
'SEG_OFFSET_NOT_OPTIMISED_ES',
|
|
120
|
+
'SEG_OFFSET_NOT_OPTIMISED_FS',
|
|
121
|
+
'SEG_OFFSET_NOT_OPTIMISED_GS',
|
|
122
|
+
'SEG_OFFSET_NOT_OPTIMISED_NOT_FLAT',
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
let j = 0
|
|
126
|
+
const stat_values: Record<string, number> = {}
|
|
127
|
+
for (let i = 0; i < stat_names.length; i++) {
|
|
128
|
+
const name = stat_names[i]
|
|
129
|
+
let value: number | string
|
|
130
|
+
if (name.includes('/')) {
|
|
131
|
+
j++ // skip profiler_stat_get
|
|
132
|
+
const [left, right] = name.split('/')
|
|
133
|
+
value = stat_values[left] / stat_values[right]
|
|
134
|
+
} else {
|
|
135
|
+
const stat = (stat_values[name] = cpu.wm.exports[
|
|
136
|
+
'profiler_stat_get'
|
|
137
|
+
](i - j) as number)
|
|
138
|
+
value =
|
|
139
|
+
stat >= 100e6
|
|
140
|
+
? Math.round(stat / 1e6) + 'm'
|
|
141
|
+
: stat >= 100e3
|
|
142
|
+
? Math.round(stat / 1e3) + 'k'
|
|
143
|
+
: stat
|
|
144
|
+
}
|
|
145
|
+
text += name + '=' + value + '\n'
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
text += '\n'
|
|
149
|
+
|
|
150
|
+
const tlb_entries = cpu.wm.exports[
|
|
151
|
+
'get_valid_tlb_entries_count'
|
|
152
|
+
]() as number
|
|
153
|
+
const global_tlb_entries = cpu.wm.exports[
|
|
154
|
+
'get_valid_global_tlb_entries_count'
|
|
155
|
+
]() as number
|
|
156
|
+
const nonglobal_tlb_entries = tlb_entries - global_tlb_entries
|
|
157
|
+
|
|
158
|
+
text +=
|
|
159
|
+
'TLB_ENTRIES=' +
|
|
160
|
+
tlb_entries +
|
|
161
|
+
' (' +
|
|
162
|
+
global_tlb_entries +
|
|
163
|
+
' global, ' +
|
|
164
|
+
nonglobal_tlb_entries +
|
|
165
|
+
' non-global)\n'
|
|
166
|
+
text +=
|
|
167
|
+
'WASM_TABLE_FREE=' +
|
|
168
|
+
cpu.wm.exports['jit_get_wasm_table_index_free_list_count']() +
|
|
169
|
+
'\n'
|
|
170
|
+
text += 'JIT_CACHE_SIZE=' + cpu.wm.exports['jit_get_cache_size']() + '\n'
|
|
171
|
+
text += 'FLAT_SEGMENTS=' + cpu.wm.exports['has_flat_segmentation']() + '\n'
|
|
172
|
+
|
|
173
|
+
text +=
|
|
174
|
+
'wasm memory size: ' + (cpu.wasm_memory.buffer.byteLength >> 20) + 'm\n'
|
|
175
|
+
|
|
176
|
+
text += 'Config:\n'
|
|
177
|
+
text += 'JIT_DISABLED=' + cpu.wm.exports['get_jit_config'](0) + '\n'
|
|
178
|
+
text += 'MAX_PAGES=' + cpu.wm.exports['get_jit_config'](1) + '\n'
|
|
179
|
+
text +=
|
|
180
|
+
'JIT_USE_LOOP_SAFETY=' +
|
|
181
|
+
Boolean(cpu.wm.exports['get_jit_config'](2)) +
|
|
182
|
+
'\n'
|
|
183
|
+
text +=
|
|
184
|
+
'MAX_EXTRA_BASIC_BLOCKS=' + cpu.wm.exports['get_jit_config'](3) + '\n'
|
|
185
|
+
|
|
186
|
+
return text
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function print_instruction_counts(cpu: CPU): string {
|
|
190
|
+
return [
|
|
191
|
+
print_instruction_counts_offset(cpu, false, false, false, false),
|
|
192
|
+
print_instruction_counts_offset(cpu, true, false, false, false),
|
|
193
|
+
print_instruction_counts_offset(cpu, false, true, false, false),
|
|
194
|
+
print_instruction_counts_offset(cpu, false, false, true, false),
|
|
195
|
+
print_instruction_counts_offset(cpu, false, false, false, true),
|
|
196
|
+
].join('\n\n')
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
interface InstructionCount {
|
|
200
|
+
opcode: number
|
|
201
|
+
count: number
|
|
202
|
+
is_mem: boolean
|
|
203
|
+
fixed_g: number
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function print_instruction_counts_offset(
|
|
207
|
+
cpu: CPU,
|
|
208
|
+
compiled: boolean,
|
|
209
|
+
jit_exit: boolean,
|
|
210
|
+
unguarded_register: boolean,
|
|
211
|
+
wasm_size: boolean,
|
|
212
|
+
): string {
|
|
213
|
+
let text = ''
|
|
214
|
+
|
|
215
|
+
const counts: InstructionCount[] = []
|
|
216
|
+
|
|
217
|
+
const label = compiled
|
|
218
|
+
? 'compiled'
|
|
219
|
+
: jit_exit
|
|
220
|
+
? 'jit exit'
|
|
221
|
+
: unguarded_register
|
|
222
|
+
? 'unguarded register'
|
|
223
|
+
: wasm_size
|
|
224
|
+
? 'wasm size'
|
|
225
|
+
: 'executed'
|
|
226
|
+
|
|
227
|
+
for (let opcode = 0; opcode < 0x100; opcode++) {
|
|
228
|
+
for (let fixed_g = 0; fixed_g < 8; fixed_g++) {
|
|
229
|
+
for (const is_mem of [false, true]) {
|
|
230
|
+
const count = cpu.wm.exports['get_opstats_buffer'](
|
|
231
|
+
compiled,
|
|
232
|
+
jit_exit,
|
|
233
|
+
unguarded_register,
|
|
234
|
+
wasm_size,
|
|
235
|
+
opcode,
|
|
236
|
+
false,
|
|
237
|
+
is_mem,
|
|
238
|
+
fixed_g,
|
|
239
|
+
) as number
|
|
240
|
+
counts.push({ opcode, count, is_mem, fixed_g })
|
|
241
|
+
|
|
242
|
+
const count_0f = cpu.wm.exports['get_opstats_buffer'](
|
|
243
|
+
compiled,
|
|
244
|
+
jit_exit,
|
|
245
|
+
unguarded_register,
|
|
246
|
+
wasm_size,
|
|
247
|
+
opcode,
|
|
248
|
+
true,
|
|
249
|
+
is_mem,
|
|
250
|
+
fixed_g,
|
|
251
|
+
) as number
|
|
252
|
+
counts.push({
|
|
253
|
+
opcode: 0x0f00 | opcode,
|
|
254
|
+
count: count_0f,
|
|
255
|
+
is_mem,
|
|
256
|
+
fixed_g,
|
|
257
|
+
})
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
let total = 0
|
|
263
|
+
const prefixes = new Set([
|
|
264
|
+
0x26, 0x2e, 0x36, 0x3e, 0x64, 0x65, 0x66, 0x67, 0xf0, 0xf2, 0xf3,
|
|
265
|
+
])
|
|
266
|
+
for (const { count, opcode } of counts) {
|
|
267
|
+
if (!prefixes.has(opcode)) {
|
|
268
|
+
total += count
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (total === 0) {
|
|
273
|
+
return ''
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const per_opcode = new Uint32Array(0x100)
|
|
277
|
+
const per_opcode0f = new Uint32Array(0x100)
|
|
278
|
+
|
|
279
|
+
for (const { opcode, count } of counts) {
|
|
280
|
+
if ((opcode & 0xff00) === 0x0f00) {
|
|
281
|
+
per_opcode0f[opcode & 0xff] += count
|
|
282
|
+
} else {
|
|
283
|
+
per_opcode[opcode & 0xff] += count
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
text += '------------------\n'
|
|
288
|
+
text += 'Total: ' + total + '\n'
|
|
289
|
+
|
|
290
|
+
const factor = total > 1e7 ? 1000 : 1
|
|
291
|
+
|
|
292
|
+
const max_count = Math.max(
|
|
293
|
+
...counts.map(({ count }) => Math.round(count / factor)),
|
|
294
|
+
)
|
|
295
|
+
const pad_length = String(max_count).length
|
|
296
|
+
|
|
297
|
+
text += `Instruction counts ${label} (in ${factor}):\n`
|
|
298
|
+
|
|
299
|
+
for (let i = 0; i < 0x100; i++) {
|
|
300
|
+
text +=
|
|
301
|
+
i.toString(16).padStart(2, '0') +
|
|
302
|
+
':' +
|
|
303
|
+
pads(Math.round(per_opcode[i] / factor), pad_length)
|
|
304
|
+
|
|
305
|
+
if (i % 16 === 15) text += '\n'
|
|
306
|
+
else text += ' '
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
text += '\n'
|
|
310
|
+
text += `Instruction counts ${label} (0f, in ${factor}):\n`
|
|
311
|
+
|
|
312
|
+
for (let i = 0; i < 0x100; i++) {
|
|
313
|
+
text +=
|
|
314
|
+
(i & 0xff).toString(16).padStart(2, '0') +
|
|
315
|
+
':' +
|
|
316
|
+
pads(Math.round(per_opcode0f[i] / factor), pad_length)
|
|
317
|
+
|
|
318
|
+
if (i % 16 === 15) text += '\n'
|
|
319
|
+
else text += ' '
|
|
320
|
+
}
|
|
321
|
+
text += '\n'
|
|
322
|
+
|
|
323
|
+
const top_counts = counts
|
|
324
|
+
.filter(({ count }) => count)
|
|
325
|
+
.sort(({ count: count1 }, { count: count2 }) => count2 - count1)
|
|
326
|
+
|
|
327
|
+
for (const { opcode, is_mem, fixed_g, count } of top_counts.slice(0, 200)) {
|
|
328
|
+
const opcode_description =
|
|
329
|
+
opcode.toString(16) + '_' + fixed_g + (is_mem ? '_m' : '_r')
|
|
330
|
+
text +=
|
|
331
|
+
opcode_description + ':' + ((count / total) * 100).toFixed(2) + ' '
|
|
332
|
+
}
|
|
333
|
+
text += '\n'
|
|
334
|
+
|
|
335
|
+
return text
|
|
336
|
+
}
|