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

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
« no previous file with comments | « runtime/vm/tags.h ('k') | runtime/vm/unit_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/tags.cc
diff --git a/runtime/vm/tags.cc b/runtime/vm/tags.cc
index f05aa22cc77cf3b478de034d91fd3d78e946f146..68f9c51c0deebf39451d744b05f6cd31af837a8b 100644
--- a/runtime/vm/tags.cc
+++ b/runtime/vm/tags.cc
@@ -6,10 +6,23 @@
#include "vm/isolate.h"
#include "vm/json_stream.h"
+#include "vm/native_entry.h"
+#include "vm/runtime_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 +31,45 @@ const char* VMTag::TagName(uword tag) {
}
+bool VMTag::IsNativeEntryTag(uword tag) {
+ ASSERT(tag != kInvalidTagId);
+ ASSERT(tag != kNumVMTags);
+ return (tag > kNumVMTags) && !IsRuntimeEntryTag(tag);
+}
+
+static RuntimeEntry* runtime_entry_list = NULL;
+
+bool VMTag::IsRuntimeEntryTag(uword id) {
+ const RuntimeEntry* current = runtime_entry_list;
+ while (current != NULL) {
+ if (reinterpret_cast<uword>(current->function()) == id) {
+ return true;
+ }
+ current = current->next();
+ }
+ return false;
+}
+
+
+const char* VMTag::RuntimeEntryTagName(uword id) {
+ const RuntimeEntry* current = runtime_entry_list;
+ while (current != NULL) {
+ if (reinterpret_cast<uword>(current->function()) == id) {
+ return current->name();
+ }
+ current = current->next();
+ }
+ return NULL;
+}
+
+
+void VMTag::RegisterRuntimeEntry(RuntimeEntry* runtime_entry) {
+ ASSERT(runtime_entry != NULL);
+ runtime_entry->set_next(runtime_entry_list);
+ runtime_entry_list = runtime_entry;
+}
+
+
VMTag::TagEntry VMTag::entries_[] = {
{ "InvalidTag", kInvalidTagId, },
#define DEFINE_VM_TAG_ENTRY(tag) \
@@ -50,6 +102,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]++;
« no previous file with comments | « 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