Skip to content

Commit e46be8e

Browse files
committed
src,test: support V8 6.1 postmortem data
1 parent f85f8fc commit e46be8e

File tree

6 files changed

+88
-24
lines changed

6 files changed

+88
-24
lines changed

src/llv8-constants.cc

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,13 @@ void Map::Load() {
212212

213213

214214
void JSObject::Load() {
215-
kPropertiesOffset = LoadConstant("class_JSReceiver__properties__FixedArray",
216-
"class_JSObject__properties__FixedArray");
215+
kPropertiesOffset =
216+
LoadConstant("class_JSReceiver__raw_properties_or_hash__Object",
217+
"class_JSReceiver__properties__FixedArray");
218+
219+
if (kPropertiesOffset == -1)
220+
kPropertiesOffset = LoadConstant("class_JSObject__properties__FixedArray");
221+
217222
kElementsOffset = LoadConstant("class_JSObject__elements__Object");
218223
kInternalFieldsOffset =
219224
LoadConstant("class_JSObject__internal_fields__uintptr_t");
@@ -262,19 +267,27 @@ void JSDate::Load() {
262267

263268

264269
void SharedInfo::Load() {
265-
kNameOffset = LoadConstant("class_SharedFunctionInfo__name__Object");
270+
kNameOffset = LoadConstant("class_SharedFunctionInfo__raw_name__Object",
271+
"class_SharedFunctionInfo__name__Object");
266272
kInferredNameOffset =
267273
LoadConstant("class_SharedFunctionInfo__inferred_name__String",
268274
"class_SharedFunctionInfo__function_identifier__Object");
269275
kScriptOffset = LoadConstant("class_SharedFunctionInfo__script__Object");
270276
kCodeOffset = LoadConstant("class_SharedFunctionInfo__code__Code");
271277
kStartPositionOffset =
272-
LoadConstant("class_SharedFunctionInfo__start_position_and_type__SMI");
278+
LoadConstant("class_SharedFunctionInfo__start_position_and_type__int",
279+
"class_SharedFunctionInfo__start_position_and_type__SMI");
273280
kEndPositionOffset =
274-
LoadConstant("class_SharedFunctionInfo__end_position__SMI");
281+
LoadConstant("class_SharedFunctionInfo__end_position__int",
282+
"class_SharedFunctionInfo__end_position__SMI");
275283
kParameterCountOffset = LoadConstant(
276-
"class_SharedFunctionInfo__internal_formal_parameter_count__SMI",
277-
"class_SharedFunctionInfo__formal_parameter_count__SMI");
284+
"class_SharedFunctionInfo__internal_formal_parameter_count__int",
285+
"class_SharedFunctionInfo__internal_formal_parameter_count__SMI");
286+
287+
if (kParameterCountOffset == -1) {
288+
kParameterCountOffset =
289+
LoadConstant("class_SharedFunctionInfo__formal_parameter_count__SMI");
290+
}
278291

279292
// NOTE: Could potentially be -1 on v4 and v5 node, should check in llv8
280293
kScopeInfoOffset =
@@ -288,6 +301,11 @@ void SharedInfo::Load() {
288301
kStartPositionShift = 2;
289302
kStartPositionMask = ~((1 << kStartPositionShift) - 1);
290303
}
304+
305+
if (LoadConstant("class_SharedFunctionInfo__compiler_hints__int") == -1)
306+
kEndPositionShift = 1;
307+
else
308+
kEndPositionShift = 0;
291309
}
292310

293311

@@ -301,7 +319,6 @@ void ScopeInfo::Load() {
301319
kParameterCountOffset = LoadConstant("scopeinfo_idx_nparams");
302320
kStackLocalCountOffset = LoadConstant("scopeinfo_idx_nstacklocals");
303321
kContextLocalCountOffset = LoadConstant("scopeinfo_idx_ncontextlocals");
304-
kContextGlobalCountOffset = LoadConstant("scopeinfo_idx_ncontextglobals");
305322
kVariablePartIndex = LoadConstant("scopeinfo_idx_first_vars");
306323
}
307324

@@ -377,6 +394,14 @@ void FixedArray::Load() {
377394
}
378395

379396

397+
void FixedTypedArrayBase::Load() {
398+
kBasePointerOffset =
399+
LoadConstant("class_FixedTypedArrayBase__base_pointer__Object");
400+
kExternalPointerOffset =
401+
LoadConstant("class_FixedTypedArrayBase__external_pointer__Object");
402+
}
403+
404+
380405
void Oddball::Load() {
381406
kKindOffset = LoadConstant("class_Oddball__kind_offset__int");
382407

@@ -516,7 +541,8 @@ void Frame::Load() {
516541

517542
kAdaptorFrame = LoadConstant("frametype_ArgumentsAdaptorFrame");
518543
kEntryFrame = LoadConstant("frametype_EntryFrame");
519-
kEntryConstructFrame = LoadConstant("frametype_EntryConstructFrame");
544+
kEntryConstructFrame = LoadConstant("frametype_ConstructEntryFrame",
545+
"frametype_EntryConstructFrame");
520546
kExitFrame = LoadConstant("frametype_ExitFrame");
521547
kInternalFrame = LoadConstant("frametype_InternalFrame");
522548
kConstructFrame = LoadConstant("frametype_ConstructFrame");
@@ -537,7 +563,8 @@ void Types::Load() {
537563
kOddballType = LoadConstant("type_Oddball__ODDBALL_TYPE");
538564
kJSObjectType = LoadConstant("type_JSObject__JS_OBJECT_TYPE");
539565
kJSAPIObjectType = LoadConstant("APIObjectType");
540-
kJSSpecialAPIObjectType = LoadConstant("APISpecialObjectType");
566+
kJSSpecialAPIObjectType = LoadConstant("SpecialAPIObjectType",
567+
"APISpecialObjectType");
541568
kJSArrayType = LoadConstant("type_JSArray__JS_ARRAY_TYPE");
542569
kCodeType = LoadConstant("type_Code__CODE_TYPE");
543570
kJSFunctionType = LoadConstant("type_JSFunction__JS_FUNCTION_TYPE");

src/llv8-constants.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class SharedInfo : public Module {
176176

177177
int64_t kStartPositionMask;
178178
int64_t kStartPositionShift;
179+
int64_t kEndPositionShift;
179180

180181
protected:
181182
void Load();
@@ -199,7 +200,6 @@ class ScopeInfo : public Module {
199200
int64_t kParameterCountOffset;
200201
int64_t kStackLocalCountOffset;
201202
int64_t kContextLocalCountOffset;
202-
int64_t kContextGlobalCountOffset;
203203
int64_t kVariablePartIndex;
204204

205205
protected:
@@ -328,6 +328,17 @@ class FixedArray : public Module {
328328
void Load();
329329
};
330330

331+
class FixedTypedArrayBase : public Module {
332+
public:
333+
MODULE_DEFAULT_METHODS(FixedTypedArrayBase);
334+
335+
int64_t kBasePointerOffset;
336+
int64_t kExternalPointerOffset;
337+
338+
protected:
339+
void Load();
340+
};
341+
331342
class Oddball : public Module {
332343
public:
333344
MODULE_DEFAULT_METHODS(Oddball);

src/llv8-inl.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ inline int64_t SharedFunctionInfo::EndPosition(Error& err) {
259259
if (err.Fail()) return -1;
260260

261261
field &= 0xffffffff;
262-
return field >> 1;
262+
field >>= v8()->shared_info()-> kEndPositionShift;
263+
return field;
263264
}
264265

265266
ACCESSOR(JSFunction, Info, js_function()->kSharedInfoOffset,
@@ -276,6 +277,14 @@ ACCESSOR(ThinString, Actual, thin_string()->kActualOffset, String);
276277

277278
ACCESSOR(FixedArrayBase, Length, fixed_array_base()->kLengthOffset, Smi);
278279

280+
inline int64_t FixedTypedArrayBase::GetBase(Error& err) {
281+
return LoadField(v8()->fixed_typed_array_base()->kBasePointerOffset, err);
282+
}
283+
284+
inline int64_t FixedTypedArrayBase::GetExternal(Error& err) {
285+
return LoadField(v8()->fixed_typed_array_base()->kExternalPointerOffset, err);
286+
}
287+
279288
inline std::string OneByteString::ToString(Error& err) {
280289
int64_t chars = LeaField(v8()->one_byte_string()->kCharsOffset);
281290
Smi len = Length(err);
@@ -452,11 +461,6 @@ inline Smi ScopeInfo::ContextLocalCount(Error& err) {
452461
err);
453462
}
454463

455-
inline Smi ScopeInfo::ContextGlobalCount(Error& err) {
456-
return FixedArray::Get<Smi>(v8()->scope_info()->kContextGlobalCountOffset,
457-
err);
458-
}
459-
460464
inline String ScopeInfo::ContextLocalName(int index, int param_count,
461465
int stack_count, Error& err) {
462466
int proper_index = index + stack_count + 1 + param_count;

src/llv8.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ void LLV8::Load(SBTarget target) {
4545
thin_string.Assign(target, &common);
4646
fixed_array_base.Assign(target, &common);
4747
fixed_array.Assign(target, &common);
48+
fixed_typed_array_base.Assign(target, &common);
4849
oddball.Assign(target, &common);
4950
js_array_buffer.Assign(target, &common);
5051
js_array_buffer_view.Assign(target, &common);
@@ -1152,6 +1153,18 @@ std::string JSArrayBufferView::Inspect(InspectOptions* options, Error& err) {
11521153
int64_t data = buf.BackingStore(err);
11531154
if (err.Fail()) return std::string();
11541155

1156+
if (data == 0) {
1157+
// The backing store has not been materialized yet.
1158+
HeapObject elements_obj = Elements(err);
1159+
if (err.Fail()) return std::string();
1160+
FixedTypedArrayBase elements(elements_obj);
1161+
int64_t base = elements.GetBase(err);
1162+
if (err.Fail()) return std::string();
1163+
int64_t external = elements.GetExternal(err);
1164+
if (err.Fail()) return std::string();
1165+
data = base + external;
1166+
}
1167+
11551168
Smi off = ByteOffset(err);
11561169
if (err.Fail()) return std::string();
11571170

src/llv8.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,14 @@ class FixedArray : public FixedArrayBase {
340340
std::string InspectContents(int length, Error& err);
341341
};
342342

343+
class FixedTypedArrayBase : public FixedArrayBase {
344+
public:
345+
V8_VALUE_DEFAULT_METHODS(FixedTypedArrayBase, FixedArrayBase)
346+
347+
inline int64_t GetBase(Error& err);
348+
inline int64_t GetExternal(Error& err);
349+
};
350+
343351
class DescriptorArray : public FixedArray {
344352
public:
345353
V8_VALUE_DEFAULT_METHODS(DescriptorArray, FixedArray)
@@ -383,7 +391,6 @@ class ScopeInfo : public FixedArray {
383391
inline Smi ParameterCount(Error& err);
384392
inline Smi StackLocalCount(Error& err);
385393
inline Smi ContextLocalCount(Error& err);
386-
inline Smi ContextGlobalCount(Error& err);
387394

388395
inline String ContextLocalName(int index, int param_count, int stack_count,
389396
Error& err);
@@ -400,9 +407,9 @@ class Oddball : public HeapObject {
400407
std::string Inspect(Error& err);
401408
};
402409

403-
class JSArrayBuffer : public HeapObject {
410+
class JSArrayBuffer : public JSObject {
404411
public:
405-
V8_VALUE_DEFAULT_METHODS(JSArrayBuffer, HeapObject)
412+
V8_VALUE_DEFAULT_METHODS(JSArrayBuffer, JSObject)
406413

407414
inline int64_t BackingStore(Error& err);
408415
inline int64_t BitField(Error& err);
@@ -413,9 +420,9 @@ class JSArrayBuffer : public HeapObject {
413420
std::string Inspect(InspectOptions* options, Error& err);
414421
};
415422

416-
class JSArrayBufferView : public HeapObject {
423+
class JSArrayBufferView : public JSObject {
417424
public:
418-
V8_VALUE_DEFAULT_METHODS(JSArrayBufferView, HeapObject)
425+
V8_VALUE_DEFAULT_METHODS(JSArrayBufferView, JSObject)
419426

420427
inline JSArrayBuffer Buffer(Error& err);
421428
inline Smi ByteOffset(Error& err);
@@ -484,6 +491,7 @@ class LLV8 {
484491
constants::SlicedString sliced_string;
485492
constants::ThinString thin_string;
486493
constants::FixedArrayBase fixed_array_base;
494+
constants::FixedTypedArrayBase fixed_typed_array_base;
487495
constants::FixedArray fixed_array;
488496
constants::Oddball oddball;
489497
constants::JSArrayBuffer js_array_buffer;
@@ -515,6 +523,7 @@ class LLV8 {
515523
friend class JSArray;
516524
friend class FixedArrayBase;
517525
friend class FixedArray;
526+
friend class FixedTypedArrayBase;
518527
friend class DescriptorArray;
519528
friend class NameDictionary;
520529
friend class Context;

test/inspect-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ tape('v8 inspect', (t) => {
7878
t.ok(/.other-key=[^\n]*<String: "ohai">/.test(lines),
7979
'.other-key property');
8080

81-
const arrayMatch =
81+
const arrayMatch =
8282
lines.match(/.array=(0x[0-9a-f]+):<Array: length=6>/);
8383
t.ok(arrayMatch, '.array JSArray property');
8484
array = arrayMatch[1];
8585

86-
const longArrayMatch =
86+
const longArrayMatch =
8787
lines.match(/.long-array=(0x[0-9a-f]+):<Array: length=20>/);
8888
t.ok(longArrayMatch, '.array JSArray property');
8989
longArray = longArrayMatch[1];

0 commit comments

Comments
 (0)