Chromium Code Reviews| Index: src/external-reference-table.cc |
| diff --git a/src/external-reference-table.cc b/src/external-reference-table.cc |
| index aa61117c97392b3593ac792bb99e37076480b0db..a846e96bebf92534daf876189001851a143d7731 100644 |
| --- a/src/external-reference-table.cc |
| +++ b/src/external-reference-table.cc |
| @@ -11,6 +11,11 @@ |
| #include "src/deoptimizer.h" |
| #include "src/ic/stub-cache.h" |
| +#if defined(DEBUG) && defined(V8_OS_LINUX) && !defined(V8_OS_ANDROID) |
| +#define SYMBOLIZE_FUNCTION |
| +#include <execinfo.h> |
| +#endif // DEBUG && V8_OS_LINUX && !V8_OS_ANDROID |
| + |
| namespace v8 { |
| namespace internal { |
| @@ -43,6 +48,28 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { |
| AddApiReferences(isolate); |
| } |
| +#ifdef DEBUG |
| +void ExternalReferenceTable::ResetCount() { |
| + for (ExternalReferenceEntry& entry : refs_) entry.count = 0; |
| +} |
| + |
| +void ExternalReferenceTable::PrintCount() { |
| + for (uint32_t i = 0; i < refs_.length(); i++) { |
| + v8::base::OS::Print("index=%5d count=%5d %-60s\n", i, refs_[i].count, |
| + refs_[i].name); |
| + } |
| +} |
| + |
|
vogelheim
2016/11/14 11:09:36
super nitpick: No empty line here. :-)
Yang
2016/11/14 11:45:05
Done.
|
| +#endif // DEBUG |
| + |
| +// static |
| +const char* ExternalReferenceTable::ResolveSymbol(void* address) { |
| +#ifdef SYMBOLIZE_FUNCTION |
| + return backtrace_symbols(&address, 1)[0]; |
| +#endif // SYMBOLIZE_FUNCTION |
|
vogelheim
2016/11/14 11:09:36
Nitpick: Does this even compile if SYMBOLIZE_FUNCT
Yang
2016/11/14 11:45:05
Done.
|
| + return "<unresolved>"; |
| +} |
| + |
| void ExternalReferenceTable::AddReferences(Isolate* isolate) { |
| // Miscellaneous |
| Add(ExternalReference::roots_array_start(isolate).address(), |
| @@ -336,22 +363,23 @@ void ExternalReferenceTable::AddAccessors(Isolate* isolate) { |
| }; |
| static const AccessorRefTable getters[] = { |
| -#define ACCESSOR_INFO_DECLARATION(name) \ |
| - {FUNCTION_ADDR(&Accessors::name##Getter), "Accessors::" #name "Getter"}, |
| - ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION) |
| +#define ACCESSOR_INFO_DECLARATION(name) \ |
| + { FUNCTION_ADDR(&Accessors::name##Getter), \ |
| + "Redirect to Accessors::" #name "Getter"}, |
| + ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION) |
| #undef ACCESSOR_INFO_DECLARATION |
| }; |
| static const AccessorRefTable setters[] = { |
| #define ACCESSOR_SETTER_DECLARATION(name) \ |
| - {FUNCTION_ADDR(&Accessors::name), "Accessors::" #name}, |
| - ACCESSOR_SETTER_LIST(ACCESSOR_SETTER_DECLARATION) |
| + { FUNCTION_ADDR(&Accessors::name), "Accessors::" #name}, |
| + ACCESSOR_SETTER_LIST(ACCESSOR_SETTER_DECLARATION) |
| #undef ACCESSOR_INFO_DECLARATION |
| }; |
| for (unsigned i = 0; i < arraysize(getters); ++i) { |
| - Add(getters[i].address, getters[i].name); |
| + Add(getters[i].address, getters[i].name + 12); |
|
vogelheim
2016/11/14 11:09:36
Huh? Why .name + 12?
vogelheim
2016/11/14 11:09:36
Ah... the assert in serialize-common.cc explains i
Yang
2016/11/14 11:45:05
Added a comment.
|
| Add(AccessorInfo::redirect(isolate, getters[i].address, ACCESSOR_GETTER), |
| - ""); |
| + getters[i].name); |
| } |
| for (unsigned i = 0; i < arraysize(setters); ++i) { |
| @@ -412,7 +440,8 @@ void ExternalReferenceTable::AddApiReferences(Isolate* isolate) { |
| intptr_t* api_external_references = isolate->api_external_references(); |
| if (api_external_references != nullptr) { |
| while (*api_external_references != 0) { |
| - Add(reinterpret_cast<Address>(*api_external_references), "<embedder>"); |
| + Address address = reinterpret_cast<Address>(*api_external_references); |
| + Add(address, ResolveSymbol(address)); |
| api_external_references++; |
| } |
| } |