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

Unified Diff: src/gdbjit.h

Issue 5965011: Basic GDB JIT Interface integration. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: minor formatting cleanup Created 10 years 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: src/gdbjit.h
diff --git a/src/gdbjit.h b/src/gdbjit.h
new file mode 100644
index 0000000000000000000000000000000000000000..98f886f62c4a44a920ab4d4ccc7d6d95fd37fbb5
--- /dev/null
+++ b/src/gdbjit.h
@@ -0,0 +1,137 @@
+// Copyright 2010 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef V8_GDBJIT_H_
+#define V8_GDBJIT_H_
+
+#ifdef ENABLE_GDBJIT_INTERFACE
Erik Corry 2011/01/04 14:21:48 A few lines here on which gdb versions, OSs etc. t
Vyacheslav Egorov (Chromium) 2011/01/18 16:10:42 Done.
+#include "v8.h"
+#include "factory.h"
+
+namespace v8 {
+namespace internal {
+
+#define CODE_TAGS_LIST(V) \
+ V(LOAD_IC) \
+ V(KEYED_LOAD_IC) \
+ V(STORE_IC) \
+ V(KEYED_STORE_IC) \
+ V(CALL_IC) \
+ V(CALL_INITIALIZE) \
+ V(CALL_PRE_MONOMORPHIC) \
+ V(CALL_NORMAL) \
+ V(CALL_MEGAMORPHIC) \
+ V(CALL_MISS) \
+ V(STUB) \
+ V(BUILTIN) \
+ V(SCRIPT) \
+ V(EVAL)
+
+class GDBJITLineInfo : public Malloced {
+ public:
+ GDBJITLineInfo()
+ : pc_info_(10) { }
+
+ void SetPosition(intptr_t pc, int pos, bool is_statement) {
Erik Corry 2011/01/04 14:21:48 What is pos, a line number? The names of the func
Vyacheslav Egorov (Chromium) 2011/01/18 16:10:42 pos is used in common V8 sense --- position in str
+ AddPCInfo(PCInfo(pc, pos, is_statement));
+ }
+
+ struct PCInfo {
+ PCInfo(intptr_t pc, int pos, bool is_statement)
+ : pc_(pc), pos_(pos), is_statement_(is_statement) { }
+
+ intptr_t pc_;
+ int pos_;
+ bool is_statement_;
+ };
+
+ List<PCInfo>* pc_info() {
Erik Corry 2011/01/04 14:21:48 Lower case names are reserved for getters. Doing
Vyacheslav Egorov (Chromium) 2011/01/18 16:10:42 Done.
+ pc_info_.Sort(ComparePCInfo);
+ return &pc_info_;
+ }
+
+ private:
+ static int ComparePCInfo(const PCInfo* a, const PCInfo* b) {
+ if (a->pc_ == b->pc_ && a->is_statement_ != b->is_statement_) {
+ return b->is_statement_ ? +1 : -1;
+ }
+ return a->pc_ - b->pc_;
Erik Corry 2011/01/04 14:21:48 Subtracting two 64 bit values and returning the an
Vyacheslav Egorov (Chromium) 2011/01/18 16:10:42 Done.
+ }
+
+ void AddPCInfo(const PCInfo& pc_info) {
+ pc_info_.Add(pc_info);
+ }
+
+ List<PCInfo> pc_info_;
+};
+
Erik Corry 2011/01/04 14:21:48 There should be two blank lines here.
Vyacheslav Egorov (Chromium) 2011/01/18 16:10:42 Done.
+class GDBJITInterface: public AllStatic {
+ public:
+ enum CodeTag {
+#define V(x) x,
+ CODE_TAGS_LIST(V)
+#undef V
+ TAG_COUNT
+ };
+
+ static const char* Tag2String(CodeTag tag) {
+ switch (tag) {
+#define V(x) case x: return #x;
+ CODE_TAGS_LIST(V)
+#undef V
+ default:
+ return NULL;
+ }
+ }
+
+ static void AddCode(const char* name,
+ Code* code,
+ Script* script = NULL);
+
+ static void AddCode(Handle<String> name,
+ Handle<Script> script,
+ Handle<Code> code);
+
+ static void AddCode(CodeTag tag, String* name, Code* code);
+
+ static void AddCode(CodeTag tag, const char* name, Code* code);
+
+ static void AddCode(CodeTag tag, Code* code);
+
+ static void RemoveCode(Code* code);
+
+ static void RegisterDetailedLineInfo(Code* code, GDBJITLineInfo* line_info);
+};
+
+#define GDBJIT(action) GDBJITInterface::action
+
+} } // namespace v8::internal
+#else
+#define GDBJIT(action) ((void) 0)
+#endif
+
+#endif

Powered by Google App Engine
This is Rietveld 408576698