react-native-update-cli 2.26.0 → 2.26.1
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.
|
@@ -194,8 +194,8 @@ export interface HermesEquivalenceResult {
|
|
|
194
194
|
functions: number;
|
|
195
195
|
/**
|
|
196
196
|
* `instruction`: literals decoded from the binary buffers at each
|
|
197
|
-
* New*WithBuffer instruction (HBC v87–96); `buffer`: the dumped
|
|
198
|
-
* compared as a whole (unknown layout
|
|
197
|
+
* New*WithBuffer instruction (HBC v87–96 and v98); `buffer`: the dumped
|
|
198
|
+
* buffers compared as a whole (unknown layout)
|
|
199
199
|
*/
|
|
200
200
|
literals?: 'instruction' | 'buffer';
|
|
201
201
|
}
|
package/lib/utils/hermes-base.js
CHANGED
|
@@ -837,21 +837,37 @@ const STRING_TABLE_LINE = /^\s*[is](\d+)\[[^\]]*\](?: #[0-9A-F]+)?: (.*)$/;
|
|
|
837
837
|
exports.LITERAL_SEPARATOR = '\u001f';
|
|
838
838
|
/**
|
|
839
839
|
* `NewArrayWithBuffer rX, sizeHint, count, offset` and
|
|
840
|
-
* `NewObjectWithBuffer rX, sizeHint, count, keyOffset, valueOffset`
|
|
841
|
-
*
|
|
842
|
-
*
|
|
843
|
-
*
|
|
844
|
-
*
|
|
840
|
+
* `NewObjectWithBuffer rX, sizeHint, count, keyOffset, valueOffset` (HBC
|
|
841
|
+
* v87–96) or `NewObjectWithBuffer[AndParent] rX, [rP,] shapeIndex,
|
|
842
|
+
* valueOffset` (v98) with the literals decoded from the binary buffers at
|
|
843
|
+
* those offsets, so two builds that lay their buffers out differently still
|
|
844
|
+
* compare by what each instruction builds. The shape index is dropped like an
|
|
845
|
+
* offset: it only locates the keys. Null when the operands do not fit the
|
|
846
|
+
* layout; an offset that cannot be decoded is spelled out (and so never
|
|
847
|
+
* equals a decoded one).
|
|
845
848
|
*/
|
|
846
849
|
function renderBufferInstruction(opcode, operands, literals) {
|
|
847
850
|
const [sizeHint, count] = operands;
|
|
848
851
|
if (opcode.startsWith('NewArray')) {
|
|
849
|
-
if (operands.length
|
|
852
|
+
if (operands.length !== 3)
|
|
850
853
|
return null;
|
|
851
854
|
const entries = literals.array(operands[2], count);
|
|
852
855
|
return `size=${sizeHint} n=${count} [${entries ? entries.join(exports.LITERAL_SEPARATOR) : `<undecodable@${operands[2]}>`}]`;
|
|
853
856
|
}
|
|
854
|
-
if (
|
|
857
|
+
if (literals.layout === 'shaped') {
|
|
858
|
+
if (operands.length !== 2)
|
|
859
|
+
return null;
|
|
860
|
+
const [shapeIndex, valueOffset] = operands;
|
|
861
|
+
const shape = literals.shape(shapeIndex);
|
|
862
|
+
const keys = shape && literals.objectKeys(shape.keyOffset, shape.count);
|
|
863
|
+
const values = shape && literals.objectValues(valueOffset, shape.count);
|
|
864
|
+
if (!shape || !keys || !values) {
|
|
865
|
+
return `n=${shape?.count ?? '?'} {<undecodable@shape${shapeIndex}/${valueOffset}>}`;
|
|
866
|
+
}
|
|
867
|
+
const pairs = keys.map((k, i) => `${k}: ${values[i]}`);
|
|
868
|
+
return `n=${shape.count} {${pairs.join(exports.LITERAL_SEPARATOR)}}`;
|
|
869
|
+
}
|
|
870
|
+
if (operands.length !== 4)
|
|
855
871
|
return null;
|
|
856
872
|
const keys = literals.objectKeys(operands[2], count);
|
|
857
873
|
const values = literals.objectValues(operands[3], count);
|
|
@@ -876,18 +892,22 @@ function normalizeDisassemblyLine(line, strings, literals) {
|
|
|
876
892
|
}
|
|
877
893
|
let m;
|
|
878
894
|
if (opcode.startsWith('New') && opcode.includes('WithBuffer')) {
|
|
895
|
+
// v98's AndParent form takes the parent object in a second register,
|
|
896
|
+
// which is compared as is (it is not a buffer operand)
|
|
879
897
|
m =
|
|
880
|
-
/^(\s*New(?:Array|Object)WithBuffer)(?:Long)?(
|
|
898
|
+
/^(\s*New(?:Array|Object)WithBuffer)(?:Long)?(AndParent)?\s+(r\d+)(?:, (r\d+))?(.*)$/.exec(line);
|
|
881
899
|
if (m) {
|
|
882
|
-
const
|
|
900
|
+
const op = `${m[1]}${m[2] ?? ''}`;
|
|
901
|
+
const regs = m[4] ? `${m[3]} ${m[4]}` : m[3];
|
|
902
|
+
const nums = m[5].match(/\d+/g) ?? [];
|
|
883
903
|
if (literals) {
|
|
884
904
|
const rendered = renderBufferInstruction(m[1].trim(), nums.map(Number), literals);
|
|
885
905
|
if (rendered)
|
|
886
|
-
return `${
|
|
906
|
+
return `${op} ${regs} ${rendered}`;
|
|
887
907
|
}
|
|
888
908
|
// no binary buffers: only the size hint survives; the buffer content
|
|
889
909
|
// is compared as a whole instead (compareBuffers)
|
|
890
|
-
return `${
|
|
910
|
+
return `${op} ${regs} sizes=${nums.slice(0, 1).join(',')}`;
|
|
891
911
|
}
|
|
892
912
|
}
|
|
893
913
|
if (opcode.charCodeAt(0) === 0x4a /* J */) {
|
|
@@ -1120,7 +1140,7 @@ function clip(line) {
|
|
|
1120
1140
|
* (the whole line would be clipped before the difference for long literals).
|
|
1121
1141
|
*/
|
|
1122
1142
|
function literalDifference(a, b) {
|
|
1123
|
-
const open = /^(\s*New\w+WithBuffer r\d+ size=\d+ n=\d+ [[{])/;
|
|
1143
|
+
const open = /^(\s*New\w+WithBuffer(?:AndParent)? r\d+(?: r\d+)?(?: size=\d+)? n=\d+ [[{])/;
|
|
1124
1144
|
const ma = open.exec(a);
|
|
1125
1145
|
const mb = open.exec(b);
|
|
1126
1146
|
if (!ma || !mb)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type LiteralValue = {
|
|
2
|
-
kind: 'null' | 'true' | 'false';
|
|
2
|
+
kind: 'null' | 'true' | 'false' | 'undefined';
|
|
3
3
|
} | {
|
|
4
4
|
kind: 'number';
|
|
5
5
|
value: number;
|
|
@@ -10,26 +10,33 @@ export type LiteralValue = {
|
|
|
10
10
|
kind: 'string';
|
|
11
11
|
id: number;
|
|
12
12
|
};
|
|
13
|
-
/** The
|
|
14
|
-
export
|
|
13
|
+
/** The literal buffers of an HBC file, in one of the two layouts. */
|
|
14
|
+
export type LiteralBuffers = {
|
|
15
|
+
layout: 'split';
|
|
15
16
|
version: number;
|
|
16
17
|
array: Buffer;
|
|
17
18
|
objectKeys: Buffer;
|
|
18
19
|
objectValues: Buffer;
|
|
19
|
-
}
|
|
20
|
+
} | {
|
|
21
|
+
layout: 'shaped';
|
|
22
|
+
version: number;
|
|
23
|
+
values: Buffer;
|
|
24
|
+
objectKeys: Buffer;
|
|
25
|
+
shapes: Buffer;
|
|
26
|
+
};
|
|
20
27
|
/**
|
|
21
28
|
* Read only the literal buffers of an HBC file (header + three byte ranges,
|
|
22
|
-
* never the whole file). Null for a file whose layout is unknown
|
|
23
|
-
* HBC v98 (literalValueBuffer + objShapeTable, not decoded yet): the caller
|
|
29
|
+
* never the whole file). Null for a file whose layout is unknown: the caller
|
|
24
30
|
* then falls back to comparing the dumped buffers as a whole.
|
|
25
31
|
*/
|
|
26
32
|
export declare function readLiteralBuffers(file: string): Promise<LiteralBuffers | null>;
|
|
27
33
|
/**
|
|
28
34
|
* Decode `count` literal values starting at byte `offset`. Null when the
|
|
29
35
|
* offset or a run reaches outside the buffer or a tag type is unknown; the
|
|
30
|
-
* caller reports that as a difference rather than guessing.
|
|
36
|
+
* caller reports that as a difference rather than guessing. `layout` decides
|
|
37
|
+
* what type 6 means (see the file comment).
|
|
31
38
|
*/
|
|
32
|
-
export declare function decodeSerializedLiterals(buffer: Buffer, offset: number, count: number): LiteralValue[] | null;
|
|
39
|
+
export declare function decodeSerializedLiterals(buffer: Buffer, offset: number, count: number, layout?: LiteralBuffers['layout']): LiteralValue[] | null;
|
|
33
40
|
/**
|
|
34
41
|
* One literal as text, string ids resolved through the dump's string table
|
|
35
42
|
* (an unknown id stays visible as `?id`). Doubles keep their exact bits in
|
|
@@ -45,7 +52,13 @@ export declare class LiteralResolver {
|
|
|
45
52
|
private readonly strings;
|
|
46
53
|
constructor(buffers: LiteralBuffers, strings: Map<number, string>);
|
|
47
54
|
private decode;
|
|
55
|
+
get layout(): LiteralBuffers['layout'];
|
|
48
56
|
array(offset: number, count: number): string[] | null;
|
|
49
57
|
objectKeys(offset: number, count: number): string[] | null;
|
|
50
58
|
objectValues(offset: number, count: number): string[] | null;
|
|
59
|
+
/** Shape table entry (HBC v98); null out of range or in the split layout. */
|
|
60
|
+
shape(index: number): {
|
|
61
|
+
keyOffset: number;
|
|
62
|
+
count: number;
|
|
63
|
+
} | null;
|
|
51
64
|
}
|
|
@@ -22,7 +22,19 @@ exports.renderLiteral = renderLiteral;
|
|
|
22
22
|
* the next byte", bits 3..0 = low 4 bits of the run length (high 8 bits in
|
|
23
23
|
* the next byte when bit 7 is set). Values follow the tag, fixed width per
|
|
24
24
|
* type: none (null/true/false), 8-byte little-endian double, 4/2/1-byte
|
|
25
|
-
* string id, 4-byte little-endian int32.
|
|
25
|
+
* string id, 4-byte little-endian int32. HBC v98 reuses type 6 (the 1-byte
|
|
26
|
+
* string id before) for `undefined`, which takes no value bytes; string ids
|
|
27
|
+
* there are always 2 or 4 bytes wide.
|
|
28
|
+
*
|
|
29
|
+
* Two file layouts use that format:
|
|
30
|
+
* - HBC v87–96 (`split`): arrayBuffer, objKeyBuffer, objValueBuffer.
|
|
31
|
+
* `NewArrayWithBuffer dst, sizeHint, count, arrayOffset`;
|
|
32
|
+
* `NewObjectWithBuffer dst, sizeHint, count, keyOffset, valueOffset`.
|
|
33
|
+
* - HBC v98 (`shaped`): literalValueBuffer (array elements and object values
|
|
34
|
+
* alike), objKeyBuffer, objShapeTable (8-byte entries: keyOffset u32,
|
|
35
|
+
* numProps u32). `NewArrayWithBuffer dst, sizeHint, count, valueOffset`;
|
|
36
|
+
* `NewObjectWithBuffer dst, shapeIndex, valueOffset` and
|
|
37
|
+
* `NewObjectWithBufferAndParent dst, parent, shapeIndex, valueOffset`.
|
|
26
38
|
*/
|
|
27
39
|
const promises_1 = require("node:fs/promises");
|
|
28
40
|
const hbcTransform_1 = require("./hbcTransform");
|
|
@@ -38,13 +50,14 @@ var Tag;
|
|
|
38
50
|
Tag[Tag["Number"] = 48] = "Number";
|
|
39
51
|
Tag[Tag["LongString"] = 64] = "LongString";
|
|
40
52
|
Tag[Tag["ShortString"] = 80] = "ShortString";
|
|
41
|
-
|
|
53
|
+
/** HBC ≤96: 1-byte string id; HBC v98: `undefined` */
|
|
54
|
+
Tag[Tag["ByteStringOrUndefined"] = 96] = "ByteStringOrUndefined";
|
|
42
55
|
Tag[Tag["Integer"] = 112] = "Integer";
|
|
43
56
|
})(Tag || (Tag = {}));
|
|
57
|
+
const SHAPE_ENTRY_SIZE = 8;
|
|
44
58
|
/**
|
|
45
59
|
* Read only the literal buffers of an HBC file (header + three byte ranges,
|
|
46
|
-
* never the whole file). Null for a file whose layout is unknown
|
|
47
|
-
* HBC v98 (literalValueBuffer + objShapeTable, not decoded yet): the caller
|
|
60
|
+
* never the whole file). Null for a file whose layout is unknown: the caller
|
|
48
61
|
* then falls back to comparing the dumped buffers as a whole.
|
|
49
62
|
*/
|
|
50
63
|
async function readLiteralBuffers(file) {
|
|
@@ -60,32 +73,40 @@ async function readLiteralBuffers(file) {
|
|
|
60
73
|
const resolved = (0, hbcTransform_1.resolveHbcSections)(header, size);
|
|
61
74
|
if (!resolved)
|
|
62
75
|
return null;
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return buf;
|
|
73
|
-
|
|
74
|
-
return
|
|
76
|
+
const readRanges = async (names) => {
|
|
77
|
+
const ranges = names.map((name) => resolved.sections.get(name));
|
|
78
|
+
if (ranges.some((r) => !r))
|
|
79
|
+
return null;
|
|
80
|
+
const bufs = await Promise.all(ranges.map(async (r) => {
|
|
81
|
+
const buf = Buffer.alloc(r.size);
|
|
82
|
+
if (r.size === 0)
|
|
83
|
+
return buf;
|
|
84
|
+
const { bytesRead } = await handle.read(buf, 0, r.size, r.start);
|
|
85
|
+
return bytesRead === r.size ? buf : null;
|
|
86
|
+
}));
|
|
87
|
+
return bufs.some((b) => !b) ? null : bufs;
|
|
75
88
|
};
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
89
|
+
const { version } = resolved;
|
|
90
|
+
if (resolved.sections.has('objShapeTable')) {
|
|
91
|
+
const bufs = await readRanges([
|
|
92
|
+
'literalValueBuffer',
|
|
93
|
+
'objKeyBuffer',
|
|
94
|
+
'objShapeTable',
|
|
95
|
+
]);
|
|
96
|
+
if (!bufs)
|
|
97
|
+
return null;
|
|
98
|
+
const [values, objectKeys, shapes] = bufs;
|
|
99
|
+
return { layout: 'shaped', version, values, objectKeys, shapes };
|
|
100
|
+
}
|
|
101
|
+
const bufs = await readRanges([
|
|
102
|
+
'arrayBuffer',
|
|
103
|
+
'objKeyBuffer',
|
|
104
|
+
'objValueBuffer',
|
|
80
105
|
]);
|
|
81
|
-
if (!
|
|
106
|
+
if (!bufs)
|
|
82
107
|
return null;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
array: a,
|
|
86
|
-
objectKeys: k,
|
|
87
|
-
objectValues: v,
|
|
88
|
-
};
|
|
108
|
+
const [array, objectKeys, objectValues] = bufs;
|
|
109
|
+
return { layout: 'split', version, array, objectKeys, objectValues };
|
|
89
110
|
}
|
|
90
111
|
finally {
|
|
91
112
|
await handle.close();
|
|
@@ -94,9 +115,10 @@ async function readLiteralBuffers(file) {
|
|
|
94
115
|
/**
|
|
95
116
|
* Decode `count` literal values starting at byte `offset`. Null when the
|
|
96
117
|
* offset or a run reaches outside the buffer or a tag type is unknown; the
|
|
97
|
-
* caller reports that as a difference rather than guessing.
|
|
118
|
+
* caller reports that as a difference rather than guessing. `layout` decides
|
|
119
|
+
* what type 6 means (see the file comment).
|
|
98
120
|
*/
|
|
99
|
-
function decodeSerializedLiterals(buffer, offset, count) {
|
|
121
|
+
function decodeSerializedLiterals(buffer, offset, count, layout = 'split') {
|
|
100
122
|
const values = [];
|
|
101
123
|
let pos = offset;
|
|
102
124
|
while (values.length < count) {
|
|
@@ -139,7 +161,11 @@ function decodeSerializedLiterals(buffer, offset, count) {
|
|
|
139
161
|
values.push({ kind: 'string', id: buffer.readUInt16LE(pos) });
|
|
140
162
|
pos += 2;
|
|
141
163
|
break;
|
|
142
|
-
case Tag.
|
|
164
|
+
case Tag.ByteStringOrUndefined:
|
|
165
|
+
if (layout === 'shaped') {
|
|
166
|
+
values.push({ kind: 'undefined' });
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
143
169
|
if (pos + 1 > buffer.length)
|
|
144
170
|
return null;
|
|
145
171
|
values.push({ kind: 'string', id: buffer[pos] });
|
|
@@ -168,6 +194,7 @@ function renderLiteral(value, strings) {
|
|
|
168
194
|
case 'null':
|
|
169
195
|
case 'true':
|
|
170
196
|
case 'false':
|
|
197
|
+
case 'undefined':
|
|
171
198
|
return value.kind;
|
|
172
199
|
case 'int':
|
|
173
200
|
return `[int ${value.value}]`;
|
|
@@ -194,17 +221,35 @@ class LiteralResolver {
|
|
|
194
221
|
this.strings = strings;
|
|
195
222
|
}
|
|
196
223
|
decode(buffer, offset, count) {
|
|
197
|
-
const values = decodeSerializedLiterals(buffer, offset, count);
|
|
224
|
+
const values = decodeSerializedLiterals(buffer, offset, count, this.buffers.layout);
|
|
198
225
|
return values ? values.map((v) => renderLiteral(v, this.strings)) : null;
|
|
199
226
|
}
|
|
227
|
+
get layout() {
|
|
228
|
+
return this.buffers.layout;
|
|
229
|
+
}
|
|
200
230
|
array(offset, count) {
|
|
201
|
-
|
|
231
|
+
const b = this.buffers;
|
|
232
|
+
return this.decode(b.layout === 'split' ? b.array : b.values, offset, count);
|
|
202
233
|
}
|
|
203
234
|
objectKeys(offset, count) {
|
|
204
235
|
return this.decode(this.buffers.objectKeys, offset, count);
|
|
205
236
|
}
|
|
206
237
|
objectValues(offset, count) {
|
|
207
|
-
|
|
238
|
+
const b = this.buffers;
|
|
239
|
+
return this.decode(b.layout === 'split' ? b.objectValues : b.values, offset, count);
|
|
240
|
+
}
|
|
241
|
+
/** Shape table entry (HBC v98); null out of range or in the split layout. */
|
|
242
|
+
shape(index) {
|
|
243
|
+
const b = this.buffers;
|
|
244
|
+
if (b.layout !== 'shaped' || index < 0)
|
|
245
|
+
return null;
|
|
246
|
+
const at = index * SHAPE_ENTRY_SIZE;
|
|
247
|
+
if (at + SHAPE_ENTRY_SIZE > b.shapes.length)
|
|
248
|
+
return null;
|
|
249
|
+
return {
|
|
250
|
+
keyOffset: b.shapes.readUInt32LE(at),
|
|
251
|
+
count: b.shapes.readUInt32LE(at + 4),
|
|
252
|
+
};
|
|
208
253
|
}
|
|
209
254
|
}
|
|
210
255
|
exports.LiteralResolver = LiteralResolver;
|
package/package.json
CHANGED