| 123456789101112131415161718192021222324252627282930313233 |
- // 生成当前 V8 的 dummy 字节码,对比 996box .jsc 头部
- const vm = require('vm');
- const v8 = require('v8');
- v8.setFlagsFromString('--no-lazy');
- v8.setFlagsFromString('--no-flush-bytecode');
- const script = new vm.Script('"\u200b"', { produceCachedData: true });
- const cached = script.cachedData;
- console.log('Current V8 version:', process.versions.v8);
- console.log('Dummy cachedData size:', cached.length);
- console.log('Dummy header (first 32 bytes):', cached.subarray(0, 32).toString('hex'));
- console.log('\n996box urlCreator.jsc:');
- const raw = require('fs').readFileSync(process.argv[2]);
- console.log(' header:', raw.subarray(0, 32).toString('hex'));
- // 字段对比
- function fields(buf, off) {
- return {
- magic: buf.subarray(off+0, off+2).toString('hex'),
- versionHash: '0x' + buf.readUInt32LE(off+4).toString(16),
- sourceHash: '0x' + buf.readUInt32LE(off+8).toString(16),
- flagHash: '0x' + buf.readUInt32LE(off+12).toString(16),
- roChecksum: '0x' + buf.readUInt32LE(off+16).toString(16),
- payloadLen: '0x' + buf.readUInt32LE(off+20).toString(16),
- checksum: '0x' + buf.readUInt32LE(off+24).toString(16),
- };
- }
- console.log('\nDummy:', fields(cached, 0));
- console.log('996box (off 0, bytenode wrapper included):', fields(raw, 0));
- console.log('996box (off 2, bytenode wrapper stripped):', fields(raw, 2));
|