Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(970)

Unified Diff: runtime/vm/tags.cc

Issue 227433004: Add runtime and native entry tags (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/tags.cc
diff --git a/runtime/vm/tags.cc b/runtime/vm/tags.cc
index f05aa22cc77cf3b478de034d91fd3d78e946f146..e0711938915ed5e44073fe4fc4363e95dfa5fc20 100644
--- a/runtime/vm/tags.cc
+++ b/runtime/vm/tags.cc
@@ -6,10 +6,22 @@
#include "vm/isolate.h"
#include "vm/json_stream.h"
+#include "vm/native_entry.h"
namespace dart {
const char* VMTag::TagName(uword tag) {
+ if (IsNativeEntryTag(tag)) {
+ const uint8_t* native_reverse_lookup = NativeEntry::ResolveSymbol(tag);
+ if (native_reverse_lookup != NULL) {
+ return reinterpret_cast<const char*>(native_reverse_lookup);
+ }
+ return "Unknown native entry";
+ } else if (IsRuntimeEntryTag(tag)) {
+ const char* runtime_entry_name = RuntimeEntryTagName(tag);
+ ASSERT(runtime_entry_name != NULL);
+ return runtime_entry_name;
+ }
ASSERT(tag != kInvalidTagId);
ASSERT(tag < kNumVMTags);
const TagEntry& entry = entries_[tag];
@@ -18,6 +30,57 @@ const char* VMTag::TagName(uword tag) {
}
+bool VMTag::IsNativeEntryTag(uword tag) {
+ ASSERT(tag != kInvalidTagId);
+ ASSERT(tag != kNumVMTags);
+ return (tag > kNumVMTags) && !IsRuntimeEntryTag(tag);
+}
+
+
+struct RegisteredRuntimeEntry {
+ const char* name;
+ uword entry;
+ RegisteredRuntimeEntry* next;
+};
+
+static RegisteredRuntimeEntry* runtime_entry_list = NULL;
+
+
+bool VMTag::IsRuntimeEntryTag(uword id) {
+ RegisteredRuntimeEntry* current = runtime_entry_list;
+ while (current != NULL) {
+ if (current->entry == id) {
+ return true;
+ }
+ current = current->next;
+ }
+ return false;
+}
+
+
+const char* VMTag::RuntimeEntryTagName(uword id) {
+ RegisteredRuntimeEntry* current = runtime_entry_list;
+ while (current != NULL) {
+ if (current->entry == id) {
+ return current->name;
+ }
+ current = current->next;
+ }
+ return NULL;
+}
+
+
+void VMTag::RegisterRuntimeEntry(const RuntimeEntry* runtime_entry) {
+ RegisteredRuntimeEntry* entry =
+ reinterpret_cast<RegisteredRuntimeEntry*>(malloc(sizeof(*entry)));
siva 2014/04/10 17:58:22 Do we need a new type RegisteredRuntimeEntry here
Cutch 2014/04/10 20:17:32 Done.
+ ASSERT(entry != NULL);
+ entry->name = runtime_entry->name();
+ entry->entry = reinterpret_cast<uword>(runtime_entry->function());
+ entry->next = runtime_entry_list;
+ runtime_entry_list = entry;
+}
+
+
VMTag::TagEntry VMTag::entries_[] = {
{ "InvalidTag", kInvalidTagId, },
#define DEFINE_VM_TAG_ENTRY(tag) \
@@ -50,6 +113,14 @@ VMTagCounters::VMTagCounters() {
void VMTagCounters::Increment(uword tag) {
+ if (VMTag::IsRuntimeEntryTag(tag)) {
+ counters_[VMTag::kRuntimeTagId]++;
+ return;
+ } else if (tag > VMTag::kNumVMTags) {
+ // Assume native entry.
+ counters_[VMTag::kNativeTagId]++;
+ return;
+ }
ASSERT(tag != VMTag::kInvalidTagId);
ASSERT(tag < VMTag::kNumVMTags);
counters_[tag]++;
« runtime/vm/tags.h ('K') | « runtime/vm/tags.h ('k') | runtime/vm/unit_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698