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

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..dd9bdb1a393659c6852ce7315fe4fd3f9b908c34 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 char* native_reverse_lookup = NativeEntry::ReverseLookup(tag);
+ if (native_reverse_lookup != NULL) {
+ return 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,50 @@ const char* VMTag::TagName(uword tag) {
}
+bool VMTag::IsNativeEntryTag(uword tag) {
+ ASSERT(tag != kInvalidTagId);
+ ASSERT(tag != kNumVMTags);
+ return (tag > kNumVMTags) && !IsRuntimeEntryTag(tag);
+}
+
+#define DECLARE_RUNTIME_ENTRY_POINT(name) \
+ extern void DRT_##name(NativeArguments arguments);
+RUNTIME_ENTRY_TAG_LIST(DECLARE_RUNTIME_ENTRY_POINT);
+#undef DECLARE_RUNTIME_ENTRY_POINT
+
+#define REGISTER_RUNTIME_ENTRY(name) \
+ { ""#name, reinterpret_cast<uword>(&DRT_##name) },
+
+static struct RuntimeEntries {
+ const char* name;
+ uword entry;
+} RuntimeTagEntries[] = {
+ RUNTIME_ENTRY_TAG_LIST(REGISTER_RUNTIME_ENTRY)
+};
+
+
+bool VMTag::IsRuntimeEntryTag(uword id) {
+ int num_entries = sizeof(RuntimeTagEntries) / sizeof(struct RuntimeEntries);
+ for (int i = 0; i < num_entries; i++) {
+ if (RuntimeTagEntries[i].entry == id) {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+const char* VMTag::RuntimeEntryTagName(uword id) {
+ int num_entries = sizeof(RuntimeTagEntries) / sizeof(struct RuntimeEntries);
+ for (int i = 0; i < num_entries; i++) {
+ if (RuntimeTagEntries[i].entry == id) {
+ return RuntimeTagEntries[i].name;
+ }
+ }
+ return NULL;
+}
+
+
VMTag::TagEntry VMTag::entries_[] = {
{ "InvalidTag", kInvalidTagId, },
#define DEFINE_VM_TAG_ENTRY(tag) \
@@ -50,6 +106,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