Skip to content

Commit 295a084

Browse files
author
Matheus Marchini
committed
src: inspect properties with descriptor details
When the PropertyLocation of the details of a JSObject property is kDescriptor, we can just get the descriptor from the descriptors array and inspect it. This solves several fields being resolved as `<unknown field type>`. Fixes: #198 Ref: #209 PR-URL: #221 Refs: #209 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 65debbd commit 295a084

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/llv8-inl.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,18 @@ inline Value DescriptorArray::GetValue(int index, Error& err) {
476476
err);
477477
}
478478

479+
inline bool DescriptorArray::IsDescriptorDetails(Smi details) {
480+
// node.js <= 7
481+
if (v8()->descriptor_array()->kPropertyTypeMask != -1) {
482+
return false;
483+
}
484+
485+
// node.js >= 8
486+
return (details.GetValue() &
487+
v8()->descriptor_array()->kPropertyLocationMask) ==
488+
(v8()->descriptor_array()->kPropertyLocationEnum_kDescriptor
489+
<< v8()->descriptor_array()->kPropertyLocationShift);
490+
}
479491
inline bool DescriptorArray::IsFieldDetails(Smi details) {
480492
// node.js <= 7
481493
if (v8()->descriptor_array()->kPropertyTypeMask != -1) {

src/llv8.cc

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ std::string JSObject::InspectDescriptors(Map map, Error& err) {
15161516
res += " ." + key.ToString(err) + "=";
15171517
if (err.Fail()) return std::string();
15181518

1519-
if (descriptors.IsConstFieldDetails(details)) {
1519+
if (descriptors.IsConstFieldDetails(details) || descriptors.IsDescriptorDetails(details)) {
15201520
Value value;
15211521

15221522
value = descriptors.GetValue(i, err);
@@ -1527,14 +1527,6 @@ std::string JSObject::InspectDescriptors(Map map, Error& err) {
15271527
continue;
15281528
}
15291529

1530-
// Skip non-fields for now
1531-
if (!descriptors.IsFieldDetails(details)) {
1532-
Error::PrintInDebugMode("Unknown field Type %" PRId64,
1533-
details.GetValue());
1534-
res += "<unknown field type>";
1535-
continue;
1536-
}
1537-
15381530
int64_t index = descriptors.FieldIndex(details) - in_object_count;
15391531

15401532
if (descriptors.IsDoubleField(details)) {

src/llv8.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ class DescriptorArray : public FixedArray {
363363
inline Value GetValue(int index, Error& err);
364364

365365
inline bool IsFieldDetails(Smi details);
366+
inline bool IsDescriptorDetails(Smi details);
366367
inline bool IsConstFieldDetails(Smi details);
367368
inline bool IsDoubleField(Smi details);
368369
inline int64_t FieldIndex(Smi details);

0 commit comments

Comments
 (0)