Skip to content

Commit 5cf29dd

Browse files
Fix a few more v8 issues (#448)
Co-authored-by: Tim Rühsen <tim.ruehsen@gmx.de>
1 parent 8c700b5 commit 5cf29dd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

interpreter/nodev8/v8.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ type v8Data struct {
352352
WeakFixedArray uint16 `name:"WeakFixedArray__WEAK_FIXED_ARRAY_TYPE"`
353353
TrustedByteArray uint16 `name:"TrustedByteArray__TRUSTED_BYTE_ARRAY_TYPE" zero:""`
354354
TrustedFixedArray uint16 `name:"TrustedFixedArray__TRUSTED_FIXED_ARRAY_TYPE" zero:""`
355+
TrustedWeakFixedArray uint16 `name:"TrustedFixedArray__TRUSTED_WEAK_FIXED_ARRAY_TYPE" zero:""`
355356
ProtectedFixedArray uint16 `name:"ProtectedFixedArray__PROTECTED_FIXED_ARRAY_TYPE" zero:""`
356357
JSFunction uint16 `name:"JSFunction__JS_FUNCTION_TYPE"`
357358
Map uint16 `name:"Map__MAP_TYPE"`
@@ -468,7 +469,8 @@ type v8Data struct {
468469
// class DeoptimizationLiteralArray introduced in V8 9.8.23
469470
// https://chromium.googlesource.com/v8/v8.git/+/refs/tags/10.2.154.1/src/objects/code.h#1090
470471
DeoptimizationLiteralArray struct {
471-
WeakFixedArray bool
472+
WeakFixedArray bool
473+
TrustedWeakFixedArray bool
472474
}
473475

474476
// https://chromium.googlesource.com/v8/v8.git/+/refs/tags/9.2.230.1/src/objects/script.tq#18
@@ -1292,7 +1294,9 @@ func (i *v8Instance) readCode(taggedPtr libpf.Address, cookie uint32, sfi *v8SFI
12921294
// The first numSFI entries of literal array are the pointers for
12931295
// inlined function's SFI structures
12941296
expectedTag := vms.Type.FixedArray
1295-
if vms.DeoptimizationLiteralArray.WeakFixedArray {
1297+
if vms.DeoptimizationLiteralArray.TrustedWeakFixedArray {
1298+
expectedTag = vms.Type.TrustedWeakFixedArray
1299+
} else if vms.DeoptimizationLiteralArray.WeakFixedArray {
12961300
expectedTag = vms.Type.WeakFixedArray
12971301
}
12981302
literalArrayPtr := npsr.Ptr(deoptimizationData,
@@ -2101,6 +2105,14 @@ func (d *v8Data) readIntrospectionData(ef *pfelf.File, syms libpf.SymbolFinder)
21012105
// so we can probably get away with just hardcoding it for now.
21022106
vms.SharedFunctionInfo.FunctionData = 8
21032107
}
2108+
if d.version >= v8Ver(12, 5, 0) {
2109+
// This changed in f6c936e836b4d8ffafe790bcc3586f2ba5ffcf74
2110+
vms.DeoptimizationLiteralArray.TrustedWeakFixedArray = true
2111+
} else if d.version >= v8Ver(11, 9, 0) {
2112+
// This had been WeakFixedArray for a very long time,
2113+
// but we lost the metadata in 0698c376801dcde939850b7ad0b55c7459c83f4d.
2114+
vms.DeoptimizationLiteralArray.WeakFixedArray = true
2115+
}
21042116

21052117
for i := 0; i < vmVal.NumField(); i++ {
21062118
classVal := vmVal.Field(i)

0 commit comments

Comments
 (0)