Skip to content

Commit

Permalink
src: make Symbol more resilient
Browse files Browse the repository at this point in the history
Instead of crashing if llnode fails to parse a Symbol, just return  a
??? token.

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 5a94ecf commit 1b8f143
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/llv8-constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ void Frame::Load() {


void Symbol::Load() {
kNameOffset = LoadConstant("class_Symbol__name__Object");
kNameOffset = LoadConstant({"class_Symbol__name__Object"});
}


Expand Down
2 changes: 1 addition & 1 deletion src/llv8-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ class Symbol : public Module {
public:
CONSTANTS_DEFAULT_METHODS(Symbol);

int64_t kNameOffset;
Constant<int64_t> kNameOffset;

protected:
void Load();
Expand Down
2 changes: 1 addition & 1 deletion src/llv8-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ ACCESSOR(Map, MaybeConstructor, map()->kMaybeConstructorOffset, HeapObject)
SAFE_ACCESSOR(Map, InstanceDescriptors, map()->kInstanceDescriptorsOffset,
HeapObject)

ACCESSOR(Symbol, Name, symbol()->kNameOffset, HeapObject)
SAFE_ACCESSOR(Symbol, Name, symbol()->kNameOffset, HeapObject)

inline int64_t Map::BitField3(Error& err) {
return v8()->LoadUnsigned(LeaField(v8()->map()->kBitField3Offset), 4, err);
Expand Down
1 change: 1 addition & 0 deletions src/llv8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ std::string Symbol::ToString(Error& err) {
return "Symbol()";
}
HeapObject name = Name(err);
RETURN_IF_INVALID(name, "Symbol(???)");
return "Symbol('" + String(name).ToString(err) + "')";
}

Expand Down

0 comments on commit 1b8f143

Please sign in to comment.