Skip to content

Commit

Permalink
src: fix backtrace for V8 6.8
Browse files Browse the repository at this point in the history
V8 6.8 replaces Closure inside Context with ScopeInfo. Those are minimal
changes to adopt llnode to the new behavior.

Ref: https://chromium-review.googlesource.com/#/c/785151/
Fixes: #193
  • Loading branch information
Matheus Marchini committed May 22, 2018
1 parent a68e089 commit 476afea
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/llv8-constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,9 @@ void ScopeInfo::Load() {


void Context::Load() {
kClosureIndex =
LoadConstant("class_Context__closure_index__int", "context_idx_closure");
kClosureIndex = LoadConstant("class_Context__closure_index__int",
"context_idx_closure", -1);
kScopeInfoIndex = LoadConstant("context_idx_scope_info", -1);
kPreviousIndex =
LoadConstant("class_Context__previous_index__int", "context_idx_prev");
kMinContextSlots = LoadConstant("class_Context__min_context_slots__int",
Expand Down
1 change: 1 addition & 0 deletions src/llv8-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class Context : public Module {
MODULE_DEFAULT_METHODS(Context);

int64_t kClosureIndex;
int64_t kScopeInfoIndex;
int64_t kGlobalObjectIndex;
int64_t kPreviousIndex;
int64_t kMinContextSlots;
Expand Down
26 changes: 18 additions & 8 deletions src/llv8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,18 @@ std::string FixedArray::InspectContents(int length, Error& err) {
return res;
}

HeapObject Context::GetScopeInfo(Error& err) {
if (v8()->context()->kScopeInfoIndex != -1) {
return FixedArray::Get<HeapObject>(v8()->context()->kScopeInfoIndex, err);
}
JSFunction closure = Closure(err);
if (err.Fail()) return HeapObject();

SharedFunctionInfo info = closure.Info(err);
if (err.Fail()) return HeapObject();

return info.GetScopeInfo(err);
}

std::string Context::Inspect(Error& err) {
std::string res;
Expand All @@ -1100,13 +1112,7 @@ std::string Context::Inspect(Error& err) {
Value previous = Previous(err);
if (err.Fail()) return std::string();

JSFunction closure = Closure(err);
if (err.Fail()) return std::string();

SharedFunctionInfo info = closure.Info(err);
if (err.Fail()) return std::string();

HeapObject scope_obj = info.GetScopeInfo(err);
HeapObject scope_obj = GetScopeInfo(err);
if (err.Fail()) return std::string();

ScopeInfo scope(scope_obj);
Expand All @@ -1128,7 +1134,11 @@ std::string Context::Inspect(Error& err) {
}

if (!res.empty()) res += "\n";
{

if (v8()->context()->kClosureIndex != -1) {
JSFunction closure;
closure = Closure(err);
if (err.Fail()) return std::string();
char tmp[128];
snprintf(tmp, sizeof(tmp), " (closure)=0x%016" PRIx64 " {",
closure.raw());
Expand Down
5 changes: 4 additions & 1 deletion src/llv8.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,14 @@ class Context : public FixedArray {
public:
V8_VALUE_DEFAULT_METHODS(Context, FixedArray)

inline JSFunction Closure(Error& err);
inline HeapObject GetScopeInfo(Error& err);
inline Value Previous(Error& err);
inline Value ContextSlot(int index, Error& err);

std::string Inspect(Error& err);

private:
inline JSFunction Closure(Error& err);
};

class ScopeInfo : public FixedArray {
Expand Down

0 comments on commit 476afea

Please sign in to comment.