Skip to content

Commit

Permalink
src: handle String__FIELD_offset__int
Browse files Browse the repository at this point in the history
Some Node.js v12 versions will have String postmortem metadata as
`String__FIELD_offset__int` instead of `String__FIELD_offset__TYPE`.
Handle both cases so llnode can work on more versions.

PR-URL: #330
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
mmarchini committed Jan 21, 2020
1 parent f8eebcc commit 5a94ecf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
12 changes: 8 additions & 4 deletions src/llv8-constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -323,18 +323,22 @@ void TwoByteString::Load() {


void ConsString::Load() {
kFirstOffset = LoadConstant("class_ConsString__first__String");
kSecondOffset = LoadConstant("class_ConsString__second__String");
kFirstOffset = LoadConstant({"class_ConsString__first__String",
"class_ConsString__first_offset__int"});
kSecondOffset = LoadConstant({"class_ConsString__second__String",
"class_ConsString__second_offset__int"});
}


void SlicedString::Load() {
kParentOffset = LoadConstant("class_SlicedString__parent__String");
kOffsetOffset = LoadConstant("class_SlicedString__offset__SMI");
kOffsetOffset = LoadConstant({"class_SlicedString__offset__SMI",
"class_SlicedString__offset_offset__int"});
}

void ThinString::Load() {
kActualOffset = LoadConstant("class_ThinString__actual__String");
kActualOffset = LoadConstant({"class_ThinString__actual__String",
"class_ThinString__actual_offset__int"});
}

void FixedArrayBase::Load() {
Expand Down
8 changes: 4 additions & 4 deletions src/llv8-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ class ConsString : public Module {
public:
CONSTANTS_DEFAULT_METHODS(ConsString);

int64_t kFirstOffset;
int64_t kSecondOffset;
Constant<int64_t> kFirstOffset;
Constant<int64_t> kSecondOffset;

protected:
void Load();
Expand All @@ -308,7 +308,7 @@ class SlicedString : public Module {
CONSTANTS_DEFAULT_METHODS(SlicedString);

int64_t kParentOffset;
int64_t kOffsetOffset;
Constant<int64_t> kOffsetOffset;

protected:
void Load();
Expand All @@ -318,7 +318,7 @@ class ThinString : public Module {
public:
CONSTANTS_DEFAULT_METHODS(ThinString);

int64_t kActualOffset;
Constant<int64_t> kActualOffset;

protected:
void Load();
Expand Down
8 changes: 4 additions & 4 deletions src/llv8-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -774,13 +774,13 @@ ACCESSOR(JSFunction, Info, js_function()->kSharedInfoOffset,
SharedFunctionInfo);
ACCESSOR(JSFunction, GetContext, js_function()->kContextOffset, HeapObject);

ACCESSOR(ConsString, First, cons_string()->kFirstOffset, String);
ACCESSOR(ConsString, Second, cons_string()->kSecondOffset, String);
SAFE_ACCESSOR(ConsString, First, cons_string()->kFirstOffset, String);
SAFE_ACCESSOR(ConsString, Second, cons_string()->kSecondOffset, String);

ACCESSOR(SlicedString, Parent, sliced_string()->kParentOffset, String);
ACCESSOR(SlicedString, Offset, sliced_string()->kOffsetOffset, Smi);
SAFE_ACCESSOR(SlicedString, Offset, sliced_string()->kOffsetOffset, Smi);

ACCESSOR(ThinString, Actual, thin_string()->kActualOffset, String);
SAFE_ACCESSOR(ThinString, Actual, thin_string()->kActualOffset, String);

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

Expand Down

0 comments on commit 5a94ecf

Please sign in to comment.