Skip to content

src: fix backtrace with v8 6.4 #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 17, 2018
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
37 changes: 25 additions & 12 deletions src/llv8-constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,35 +93,39 @@ int64_t Module::LoadRawConstant(const char* name, int64_t def) {
Error err;
int64_t v = LookupConstant(target_, name, def, err);
if (err.Fail()) {
Error::PrintInDebugMode("Failed to load raw constant %s", name);
Error::PrintInDebugMode(
"Failed to load raw constant %s, default to %" PRId64, name, def);
}

return v;
}

int64_t Module::LoadConstant(const char* name, Error& err, int64_t def) {
int64_t v =
LookupConstant(target_, (kConstantPrefix + name).c_str(), def, err);
return v;
}

int64_t Module::LoadConstant(const char* name, int64_t def) {
Error err;
int64_t v =
LookupConstant(target_, (kConstantPrefix + name).c_str(), def, err);
int64_t v = LoadConstant(name, err, def);
if (err.Fail()) {
Error::PrintInDebugMode("Failed to load constant %s", name);
Error::PrintInDebugMode("Failed to load constant %s, default to %" PRId64,
name, def);
}

return v;
}


int64_t Module::LoadConstant(const char* name, const char* fallback,
int64_t def) {
Error err;
int64_t v =
LookupConstant(target_, (kConstantPrefix + name).c_str(), def, err);
if (err.Fail())
v = LookupConstant(target_, (kConstantPrefix + fallback).c_str(), def, err);
int64_t v = LoadConstant(name, err, def);
if (err.Fail()) v = LoadConstant(fallback, err, def);
if (err.Fail()) {
Error::PrintInDebugMode("Failed to load constant %s, fallback %s", name,
fallback);
Error::PrintInDebugMode(
"Failed to load constant %s, fallback %s, default to %" PRId64, name,
fallback, def);
}

return v;
Expand Down Expand Up @@ -179,7 +183,16 @@ void HeapObject::Load() {


void Map::Load() {
kInstanceAttrsOffset = LoadConstant("class_Map__instance_attributes__int");
Error err;
kInstanceAttrsOffset =
LoadConstant("class_Map__instance_attributes__int", err);
if (err.Fail()) {
kInstanceAttrsOffset = LoadConstant("class_Map__instance_type__uint16_t");
kMapTypeMask = 0xffff;

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

} else {
kMapTypeMask = 0xff;
}

kMaybeConstructorOffset =
LoadConstant("class_Map__constructor_or_backpointer__Object",
"class_Map__constructor__Object");
Expand Down
6 changes: 6 additions & 0 deletions src/llv8-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@

namespace llnode {
namespace v8 {

class Error;

namespace constants {

// Forward declarations
class Common;


class Module {
public:
Module() : loaded_(false) {}
Expand All @@ -20,6 +24,7 @@ class Module {

protected:
int64_t LoadRawConstant(const char* name, int64_t def = -1);
int64_t LoadConstant(const char* name, Error& err, int64_t def = -1);
int64_t LoadConstant(const char* name, int64_t def = -1);
int64_t LoadConstant(const char* name, const char* fallback,
int64_t def = -1);
Expand Down Expand Up @@ -83,6 +88,7 @@ class Map : public Module {
public:
MODULE_DEFAULT_METHODS(Map);

int64_t kMapTypeMask;
int64_t kInstanceAttrsOffset;
int64_t kMaybeConstructorOffset;
int64_t kInstanceDescriptorsOffset;
Expand Down
2 changes: 1 addition & 1 deletion src/llv8-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ inline int64_t Map::GetType(Error& err) {
v8()->LoadUnsigned(LeaField(v8()->map()->kInstanceAttrsOffset), 2, err);
if (err.Fail()) return -1;

return type & 0xff;
return type & v8()->map()->kMapTypeMask;
}


Expand Down