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

Side by Side Diff: src/gdb-jit.cc

Issue 387533003: Remove AddCode and RemoveCode GDB JIT entry hooks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: One miro fix. Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gdb-jit.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifdef ENABLE_GDB_JIT_INTERFACE 5 #ifdef ENABLE_GDB_JIT_INTERFACE
6 #include "src/v8.h" 6 #include "src/v8.h"
7 7
8 #include "src/base/platform/platform.h" 8 #include "src/base/platform/platform.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/compiler.h" 10 #include "src/compiler.h"
(...skipping 2045 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 2056
2057 2057
2058 static base::LazyMutex mutex = LAZY_MUTEX_INITIALIZER; 2058 static base::LazyMutex mutex = LAZY_MUTEX_INITIALIZER;
2059 2059
2060 2060
2061 void GDBJITInterface::AddCode(const char* name, 2061 void GDBJITInterface::AddCode(const char* name,
2062 Code* code, 2062 Code* code,
2063 GDBJITInterface::CodeTag tag, 2063 GDBJITInterface::CodeTag tag,
2064 Script* script, 2064 Script* script,
2065 CompilationInfo* info) { 2065 CompilationInfo* info) {
2066 if (!FLAG_gdbjit) return;
2067
2068 base::LockGuard<base::Mutex> lock_guard(mutex.Pointer()); 2066 base::LockGuard<base::Mutex> lock_guard(mutex.Pointer());
2069 DisallowHeapAllocation no_gc; 2067 DisallowHeapAllocation no_gc;
2070 2068
2071 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); 2069 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true);
2072 if (e->value != NULL && !IsLineInfoTagged(e->value)) return; 2070 if (e->value != NULL && !IsLineInfoTagged(e->value)) return;
2073 2071
2074 LineInfo* lineinfo = UntagLineInfo(e->value); 2072 LineInfo* lineinfo = UntagLineInfo(e->value);
2075 CodeDescription code_desc(name, 2073 CodeDescription code_desc(name,
2076 code, 2074 code,
2077 script != NULL ? Handle<Script>(script) 2075 script != NULL ? Handle<Script>(script)
(...skipping 24 matching lines...) Expand all
2102 should_dump = true; 2100 should_dump = true;
2103 } else if (name != NULL) { 2101 } else if (name != NULL) {
2104 name_hint = strstr(name, FLAG_gdbjit_dump_filter); 2102 name_hint = strstr(name, FLAG_gdbjit_dump_filter);
2105 should_dump = (name_hint != NULL); 2103 should_dump = (name_hint != NULL);
2106 } 2104 }
2107 } 2105 }
2108 RegisterCodeEntry(entry, should_dump, name_hint); 2106 RegisterCodeEntry(entry, should_dump, name_hint);
2109 } 2107 }
2110 2108
2111 2109
2112 void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag,
2113 const char* name,
2114 Code* code) {
2115 if (!FLAG_gdbjit) return;
2116
2117 EmbeddedVector<char, 256> buffer;
2118 StringBuilder builder(buffer.start(), buffer.length());
2119
2120 builder.AddString(Tag2String(tag));
2121 if ((name != NULL) && (*name != '\0')) {
2122 builder.AddString(": ");
2123 builder.AddString(name);
2124 } else {
2125 builder.AddFormatted(": code object %p", static_cast<void*>(code));
2126 }
2127
2128 AddCode(builder.Finalize(), code, tag, NULL, NULL);
2129 }
2130
2131
2132 void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag,
2133 Name* name,
2134 Code* code) {
2135 if (!FLAG_gdbjit) return;
2136 if (name != NULL && name->IsString()) {
2137 AddCode(tag, String::cast(name)->ToCString(DISALLOW_NULLS).get(), code);
2138 } else {
2139 AddCode(tag, "", code);
2140 }
2141 }
2142
2143
2144 void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag, Code* code) {
2145 if (!FLAG_gdbjit) return;
2146
2147 AddCode(tag, "", code);
2148 }
2149
2150
2151 void GDBJITInterface::RemoveCode(Code* code) { 2110 void GDBJITInterface::RemoveCode(Code* code) {
2152 if (!FLAG_gdbjit) return; 2111 if (!FLAG_gdbjit) return;
2153 2112
2154 base::LockGuard<base::Mutex> lock_guard(mutex.Pointer()); 2113 base::LockGuard<base::Mutex> lock_guard(mutex.Pointer());
2155 HashMap::Entry* e = GetEntries()->Lookup(code, 2114 HashMap::Entry* e = GetEntries()->Lookup(code,
2156 HashForCodeObject(code), 2115 HashForCodeObject(code),
2157 false); 2116 false);
2158 if (e == NULL) return; 2117 if (e == NULL) return;
2159 2118
2160 if (IsLineInfoTagged(e->value)) { 2119 if (IsLineInfoTagged(e->value)) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2192 ASSERT(!IsLineInfoTagged(line_info)); 2151 ASSERT(!IsLineInfoTagged(line_info));
2193 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); 2152 HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true);
2194 ASSERT(e->value == NULL); 2153 ASSERT(e->value == NULL);
2195 e->value = TagLineInfo(line_info); 2154 e->value = TagLineInfo(line_info);
2196 } 2155 }
2197 2156
2198 2157
2199 void GDBJITInterface::EventHandler(const v8::JitCodeEvent* event) { 2158 void GDBJITInterface::EventHandler(const v8::JitCodeEvent* event) {
2200 if (!FLAG_gdbjit) return; 2159 if (!FLAG_gdbjit) return;
2201 switch (event->type) { 2160 switch (event->type) {
2202 case v8::JitCodeEvent::CODE_ADDED: 2161 case v8::JitCodeEvent::CODE_ADDED: {
2162 Code* code = Code::GetCodeFromTargetAddress(
2163 reinterpret_cast<Address>(event->code_start));
2164 if (code->kind() == Code::OPTIMIZED_FUNCTION ||
2165 code->kind() == Code::FUNCTION) {
2166 break;
2167 }
2168 EmbeddedVector<char, 256> buffer;
2169 StringBuilder builder(buffer.start(), buffer.length());
2170 builder.AddSubstring(event->name.str, static_cast<int>(event->name.len));
2171 AddCode(builder.Finalize(), code, NON_FUNCTION, NULL, NULL);
2172 break;
2173 }
2203 case v8::JitCodeEvent::CODE_MOVED: 2174 case v8::JitCodeEvent::CODE_MOVED:
2204 case v8::JitCodeEvent::CODE_REMOVED:
2205 break; 2175 break;
2176 case v8::JitCodeEvent::CODE_REMOVED: {
2177 Code* code = Code::GetCodeFromTargetAddress(
2178 reinterpret_cast<Address>(event->code_start));
2179 RemoveCode(code);
2180 break;
2181 }
2206 case v8::JitCodeEvent::CODE_ADD_LINE_POS_INFO: { 2182 case v8::JitCodeEvent::CODE_ADD_LINE_POS_INFO: {
2207 LineInfo* line_info = reinterpret_cast<LineInfo*>(event->user_data); 2183 LineInfo* line_info = reinterpret_cast<LineInfo*>(event->user_data);
2208 line_info->SetPosition(static_cast<intptr_t>(event->line_info.offset), 2184 line_info->SetPosition(static_cast<intptr_t>(event->line_info.offset),
2209 static_cast<int>(event->line_info.pos), 2185 static_cast<int>(event->line_info.pos),
2210 event->line_info.position_type == 2186 event->line_info.position_type ==
2211 v8::JitCodeEvent::STATEMENT_POSITION); 2187 v8::JitCodeEvent::STATEMENT_POSITION);
2212 break; 2188 break;
2213 } 2189 }
2214 case v8::JitCodeEvent::CODE_START_LINE_INFO_RECORDING: { 2190 case v8::JitCodeEvent::CODE_START_LINE_INFO_RECORDING: {
2215 v8::JitCodeEvent* mutable_event = const_cast<v8::JitCodeEvent*>(event); 2191 v8::JitCodeEvent* mutable_event = const_cast<v8::JitCodeEvent*>(event);
2216 mutable_event->user_data = new LineInfo(); 2192 mutable_event->user_data = new LineInfo();
2217 break; 2193 break;
2218 } 2194 }
2219 case v8::JitCodeEvent::CODE_END_LINE_INFO_RECORDING: { 2195 case v8::JitCodeEvent::CODE_END_LINE_INFO_RECORDING: {
2220 LineInfo* line_info = reinterpret_cast<LineInfo*>(event->user_data); 2196 LineInfo* line_info = reinterpret_cast<LineInfo*>(event->user_data);
2221 Code* code = Code::GetCodeFromTargetAddress( 2197 Code* code = Code::GetCodeFromTargetAddress(
2222 reinterpret_cast<Address>(event->code_start)); 2198 reinterpret_cast<Address>(event->code_start));
2223 RegisterDetailedLineInfo(code, line_info); 2199 RegisterDetailedLineInfo(code, line_info);
2224 break; 2200 break;
2225 } 2201 }
2226 } 2202 }
2227 } 2203 }
2228 2204
2229 2205
2230 } } // namespace v8::internal 2206 } } // namespace v8::internal
2231 #endif 2207 #endif
OLDNEW
« no previous file with comments | « src/gdb-jit.h ('k') | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698