Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/llnode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ bool PluginInitialize(SBDebugger d) {
"There are scripts for generating this file on Linux and Mac "
"in the scripts directory of the llnode repository."
#endif // LLDB_SBMemoryRegionInfoList_h_
);
);

interpreter.AddCommand("findjsobjects", new llnode::FindObjectsCmd(),
"Alias for `v8 findjsobjects`");
Expand Down
48 changes: 37 additions & 11 deletions src/llv8-constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,13 @@ void Map::Load() {


void JSObject::Load() {
kPropertiesOffset = LoadConstant("class_JSReceiver__properties__FixedArray",
"class_JSObject__properties__FixedArray");
kPropertiesOffset =
LoadConstant("class_JSReceiver__raw_properties_or_hash__Object",
"class_JSReceiver__properties__FixedArray");

if (kPropertiesOffset == -1)
kPropertiesOffset = LoadConstant("class_JSObject__properties__FixedArray");

kElementsOffset = LoadConstant("class_JSObject__elements__Object");
kInternalFieldsOffset =
LoadConstant("class_JSObject__internal_fields__uintptr_t");
Expand Down Expand Up @@ -262,19 +267,27 @@ void JSDate::Load() {


void SharedInfo::Load() {
kNameOffset = LoadConstant("class_SharedFunctionInfo__name__Object");
kNameOffset = LoadConstant("class_SharedFunctionInfo__raw_name__Object",
"class_SharedFunctionInfo__name__Object");
kInferredNameOffset =
LoadConstant("class_SharedFunctionInfo__inferred_name__String",
"class_SharedFunctionInfo__function_identifier__Object");
kScriptOffset = LoadConstant("class_SharedFunctionInfo__script__Object");
kCodeOffset = LoadConstant("class_SharedFunctionInfo__code__Code");
kStartPositionOffset =
LoadConstant("class_SharedFunctionInfo__start_position_and_type__SMI");
LoadConstant("class_SharedFunctionInfo__start_position_and_type__int",
"class_SharedFunctionInfo__start_position_and_type__SMI");

This comment was marked as off-topic.

This comment was marked as off-topic.

kEndPositionOffset =
LoadConstant("class_SharedFunctionInfo__end_position__SMI");
LoadConstant("class_SharedFunctionInfo__end_position__int",
"class_SharedFunctionInfo__end_position__SMI");
kParameterCountOffset = LoadConstant(
"class_SharedFunctionInfo__internal_formal_parameter_count__SMI",
"class_SharedFunctionInfo__formal_parameter_count__SMI");
"class_SharedFunctionInfo__internal_formal_parameter_count__int",
"class_SharedFunctionInfo__internal_formal_parameter_count__SMI");

if (kParameterCountOffset == -1) {
kParameterCountOffset =
LoadConstant("class_SharedFunctionInfo__formal_parameter_count__SMI");
}

// NOTE: Could potentially be -1 on v4 and v5 node, should check in llv8
kScopeInfoOffset =
Expand All @@ -288,6 +301,11 @@ void SharedInfo::Load() {
kStartPositionShift = 2;
kStartPositionMask = ~((1 << kStartPositionShift) - 1);
}

if (LoadConstant("class_SharedFunctionInfo__compiler_hints__int") == -1)
kEndPositionShift = 1;
else
kEndPositionShift = 0;
}


Expand All @@ -301,7 +319,6 @@ void ScopeInfo::Load() {
kParameterCountOffset = LoadConstant("scopeinfo_idx_nparams");
kStackLocalCountOffset = LoadConstant("scopeinfo_idx_nstacklocals");
kContextLocalCountOffset = LoadConstant("scopeinfo_idx_ncontextlocals");
kContextGlobalCountOffset = LoadConstant("scopeinfo_idx_ncontextglobals");
kVariablePartIndex = LoadConstant("scopeinfo_idx_first_vars");
}

Expand Down Expand Up @@ -377,6 +394,14 @@ void FixedArray::Load() {
}


void FixedTypedArrayBase::Load() {
kBasePointerOffset =
LoadConstant("class_FixedTypedArrayBase__base_pointer__Object");
kExternalPointerOffset =
LoadConstant("class_FixedTypedArrayBase__external_pointer__Object");
}


void Oddball::Load() {
kKindOffset = LoadConstant("class_Oddball__kind_offset__int");

Expand Down Expand Up @@ -446,7 +471,6 @@ void DescriptorArray::Load() {
LoadConstant("prop_attributes_DONT_ENUM");

kPropertyKindMask = LoadConstant("prop_kind_mask");
kPropertyKindShift = LoadConstant("prop_kind_shift", int64_t(0));
kPropertyKindEnum_kAccessor = LoadConstant("prop_kind_Accessor");
kPropertyKindEnum_kData = LoadConstant("prop_kind_Data");

Expand Down Expand Up @@ -516,7 +540,8 @@ void Frame::Load() {

kAdaptorFrame = LoadConstant("frametype_ArgumentsAdaptorFrame");
kEntryFrame = LoadConstant("frametype_EntryFrame");
kEntryConstructFrame = LoadConstant("frametype_EntryConstructFrame");
kEntryConstructFrame = LoadConstant("frametype_ConstructEntryFrame",
"frametype_EntryConstructFrame");
kExitFrame = LoadConstant("frametype_ExitFrame");
kInternalFrame = LoadConstant("frametype_InternalFrame");
kConstructFrame = LoadConstant("frametype_ConstructFrame");
Expand All @@ -537,7 +562,8 @@ void Types::Load() {
kOddballType = LoadConstant("type_Oddball__ODDBALL_TYPE");
kJSObjectType = LoadConstant("type_JSObject__JS_OBJECT_TYPE");
kJSAPIObjectType = LoadConstant("APIObjectType");
kJSSpecialAPIObjectType = LoadConstant("APISpecialObjectType");
kJSSpecialAPIObjectType =
LoadConstant("SpecialAPIObjectType", "APISpecialObjectType");
kJSArrayType = LoadConstant("type_JSArray__JS_ARRAY_TYPE");
kCodeType = LoadConstant("type_Code__CODE_TYPE");
kJSFunctionType = LoadConstant("type_JSFunction__JS_FUNCTION_TYPE");
Expand Down
14 changes: 12 additions & 2 deletions src/llv8-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class SharedInfo : public Module {

int64_t kStartPositionMask;
int64_t kStartPositionShift;
int64_t kEndPositionShift;

protected:
void Load();
Expand All @@ -199,7 +200,6 @@ class ScopeInfo : public Module {
int64_t kParameterCountOffset;
int64_t kStackLocalCountOffset;
int64_t kContextLocalCountOffset;
int64_t kContextGlobalCountOffset;
int64_t kVariablePartIndex;

protected:
Expand Down Expand Up @@ -328,6 +328,17 @@ class FixedArray : public Module {
void Load();
};

class FixedTypedArrayBase : public Module {
public:
MODULE_DEFAULT_METHODS(FixedTypedArrayBase);

int64_t kBasePointerOffset;
int64_t kExternalPointerOffset;

protected:
void Load();
};

class Oddball : public Module {
public:
MODULE_DEFAULT_METHODS(Oddball);
Expand Down Expand Up @@ -407,7 +418,6 @@ class DescriptorArray : public Module {
int64_t kPropertyAttributesEnum_DONT_DELETE = -1;

int64_t kPropertyKindMask = -1;
int64_t kPropertyKindShift = -1;
int64_t kPropertyKindEnum_kAccessor = -1;
int64_t kPropertyKindEnum_kData = -1;

Expand Down
16 changes: 10 additions & 6 deletions src/llv8-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ inline int64_t SharedFunctionInfo::EndPosition(Error& err) {
if (err.Fail()) return -1;

field &= 0xffffffff;
return field >> 1;
field >>= v8()->shared_info()->kEndPositionShift;
return field;
}

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

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

inline int64_t FixedTypedArrayBase::GetBase(Error& err) {
return LoadField(v8()->fixed_typed_array_base()->kBasePointerOffset, err);
}

inline int64_t FixedTypedArrayBase::GetExternal(Error& err) {
return LoadField(v8()->fixed_typed_array_base()->kExternalPointerOffset, err);
}

inline std::string OneByteString::ToString(Error& err) {
int64_t chars = LeaField(v8()->one_byte_string()->kCharsOffset);
Smi len = Length(err);
Expand Down Expand Up @@ -452,11 +461,6 @@ inline Smi ScopeInfo::ContextLocalCount(Error& err) {
err);
}

inline Smi ScopeInfo::ContextGlobalCount(Error& err) {
return FixedArray::Get<Smi>(v8()->scope_info()->kContextGlobalCountOffset,
err);
}

inline String ScopeInfo::ContextLocalName(int index, int param_count,
int stack_count, Error& err) {
int proper_index = index + stack_count + 1 + param_count;
Expand Down
13 changes: 13 additions & 0 deletions src/llv8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void LLV8::Load(SBTarget target) {
thin_string.Assign(target, &common);
fixed_array_base.Assign(target, &common);
fixed_array.Assign(target, &common);
fixed_typed_array_base.Assign(target, &common);
oddball.Assign(target, &common);
js_array_buffer.Assign(target, &common);
js_array_buffer_view.Assign(target, &common);
Expand Down Expand Up @@ -1152,6 +1153,18 @@ std::string JSArrayBufferView::Inspect(InspectOptions* options, Error& err) {
int64_t data = buf.BackingStore(err);
if (err.Fail()) return std::string();

if (data == 0) {
// The backing store has not been materialized yet.
HeapObject elements_obj = Elements(err);
if (err.Fail()) return std::string();
FixedTypedArrayBase elements(elements_obj);
int64_t base = elements.GetBase(err);
if (err.Fail()) return std::string();
int64_t external = elements.GetExternal(err);
if (err.Fail()) return std::string();
data = base + external;
}

Smi off = ByteOffset(err);
if (err.Fail()) return std::string();

Expand Down
19 changes: 14 additions & 5 deletions src/llv8.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,14 @@ class FixedArray : public FixedArrayBase {
std::string InspectContents(int length, Error& err);
};

class FixedTypedArrayBase : public FixedArrayBase {
public:
V8_VALUE_DEFAULT_METHODS(FixedTypedArrayBase, FixedArrayBase)

inline int64_t GetBase(Error& err);
inline int64_t GetExternal(Error& err);
};

class DescriptorArray : public FixedArray {
public:
V8_VALUE_DEFAULT_METHODS(DescriptorArray, FixedArray)
Expand Down Expand Up @@ -383,7 +391,6 @@ class ScopeInfo : public FixedArray {
inline Smi ParameterCount(Error& err);
inline Smi StackLocalCount(Error& err);
inline Smi ContextLocalCount(Error& err);
inline Smi ContextGlobalCount(Error& err);

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

class JSArrayBuffer : public HeapObject {
class JSArrayBuffer : public JSObject {
public:
V8_VALUE_DEFAULT_METHODS(JSArrayBuffer, HeapObject)
V8_VALUE_DEFAULT_METHODS(JSArrayBuffer, JSObject)

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

class JSArrayBufferView : public HeapObject {
class JSArrayBufferView : public JSObject {
public:
V8_VALUE_DEFAULT_METHODS(JSArrayBufferView, HeapObject)
V8_VALUE_DEFAULT_METHODS(JSArrayBufferView, JSObject)

inline JSArrayBuffer Buffer(Error& err);
inline Smi ByteOffset(Error& err);
Expand Down Expand Up @@ -484,6 +491,7 @@ class LLV8 {
constants::SlicedString sliced_string;
constants::ThinString thin_string;
constants::FixedArrayBase fixed_array_base;
constants::FixedTypedArrayBase fixed_typed_array_base;
constants::FixedArray fixed_array;
constants::Oddball oddball;
constants::JSArrayBuffer js_array_buffer;
Expand Down Expand Up @@ -515,6 +523,7 @@ class LLV8 {
friend class JSArray;
friend class FixedArrayBase;
friend class FixedArray;
friend class FixedTypedArrayBase;
friend class DescriptorArray;
friend class NameDictionary;
friend class Context;
Expand Down
4 changes: 2 additions & 2 deletions test/inspect-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ tape('v8 inspect', (t) => {
t.ok(/.other-key=[^\n]*<String: "ohai">/.test(lines),
'.other-key property');

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

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