Index: src/external-reference-table.cc |
diff --git a/src/external-reference-table.cc b/src/external-reference-table.cc |
index aa61117c97392b3593ac792bb99e37076480b0db..2e9fc465901c443e84d2411c344daa320441928d 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 (int i = 0; i < refs_.length(); i++) { |
+ v8::base::OS::Print("index=%5d count=%5d %-60s\n", i, refs_[i].count, |
+ refs_[i].name); |
+ } |
+} |
+#endif // DEBUG |
+ |
+// static |
+const char* ExternalReferenceTable::ResolveSymbol(void* address) { |
+#ifdef SYMBOLIZE_FUNCTION |
+ return backtrace_symbols(&address, 1)[0]; |
+#else |
+ return "<unresolved>"; |
+#endif // SYMBOLIZE_FUNCTION |
+} |
+ |
void ExternalReferenceTable::AddReferences(Isolate* isolate) { |
// Miscellaneous |
Add(ExternalReference::roots_array_start(isolate).address(), |
@@ -336,22 +363,24 @@ void ExternalReferenceTable::AddAccessors(Isolate* isolate) { |
}; |
static const AccessorRefTable getters[] = { |
-#define ACCESSOR_INFO_DECLARATION(name) \ |
- {FUNCTION_ADDR(&Accessors::name##Getter), "Accessors::" #name "Getter"}, |
+#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}, |
+ { 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); |
+ const char* name = getters[i].name + 12; // Skip "Redirect to " prefix. |
+ Add(getters[i].address, name); |
Add(AccessorInfo::redirect(isolate, getters[i].address, ACCESSOR_GETTER), |
- ""); |
+ getters[i].name); |
} |
for (unsigned i = 0; i < arraysize(setters); ++i) { |
@@ -412,7 +441,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++; |
} |
} |