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

Side by Side Diff: src/debug.cc

Issue 753553002: Phantom references support internal fields (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Delete allocated objects in test to make memory sanitizer happy Created 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 reinterpret_cast<ScriptCache*>(data.GetParameter()); 688 reinterpret_cast<ScriptCache*>(data.GetParameter());
689 HashMap::Entry* entry = script_cache->Lookup(key, hash, false); 689 HashMap::Entry* entry = script_cache->Lookup(key, hash, false);
690 Object** location = reinterpret_cast<Object**>(entry->value); 690 Object** location = reinterpret_cast<Object**>(entry->value);
691 script_cache->Remove(key, hash); 691 script_cache->Remove(key, hash);
692 692
693 // Clear the weak handle. 693 // Clear the weak handle.
694 GlobalHandles::Destroy(location); 694 GlobalHandles::Destroy(location);
695 } 695 }
696 696
697 697
698 void Debug::HandleWeakDebugInfo( 698 void Debug::HandlePhantomDebugInfo(
699 const v8::WeakCallbackData<v8::Value, void>& data) { 699 const v8::PhantomCallbackData<DebugInfoListNode>& data) {
700 Debug* debug = reinterpret_cast<Isolate*>(data.GetIsolate())->debug(); 700 Debug* debug = reinterpret_cast<Isolate*>(data.GetIsolate())->debug();
701 DebugInfoListNode* node = 701 DebugInfoListNode* node = data.GetParameter();
702 reinterpret_cast<DebugInfoListNode*>(data.GetParameter()); 702 debug->RemoveDebugInfo(node);
703 debug->RemoveDebugInfo(node->debug_info().location());
704 #ifdef DEBUG 703 #ifdef DEBUG
705 for (DebugInfoListNode* n = debug->debug_info_list_; 704 for (DebugInfoListNode* n = debug->debug_info_list_;
706 n != NULL; 705 n != NULL;
707 n = n->next()) { 706 n = n->next()) {
708 DCHECK(n != node); 707 DCHECK(n != node);
709 } 708 }
710 #endif 709 #endif
711 } 710 }
712 711
713 712
714 DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info): next_(NULL) { 713 DebugInfoListNode::DebugInfoListNode(DebugInfo* debug_info): next_(NULL) {
715 // Globalize the request debug info object and make it weak. 714 // Globalize the request debug info object and make it weak.
716 GlobalHandles* global_handles = debug_info->GetIsolate()->global_handles(); 715 GlobalHandles* global_handles = debug_info->GetIsolate()->global_handles();
717 debug_info_ = Handle<DebugInfo>::cast(global_handles->Create(debug_info)); 716 debug_info_ = Handle<DebugInfo>::cast(global_handles->Create(debug_info));
718 GlobalHandles::MakeWeak(reinterpret_cast<Object**>(debug_info_.location()), 717 typedef PhantomCallbackData<void>::Callback Callback;
719 this, Debug::HandleWeakDebugInfo, 718 GlobalHandles::MakePhantom(
720 GlobalHandles::Phantom); 719 reinterpret_cast<Object**>(debug_info_.location()), this,
720 reinterpret_cast<Callback>(Debug::HandlePhantomDebugInfo));
721 } 721 }
722 722
723 723
724 DebugInfoListNode::~DebugInfoListNode() { 724 DebugInfoListNode::~DebugInfoListNode() {
725 GlobalHandles::Destroy(reinterpret_cast<Object**>(debug_info_.location())); 725 GlobalHandles::Destroy(reinterpret_cast<Object**>(debug_info_.location()));
726 } 726 }
727 727
728 728
729 bool Debug::CompileDebuggerScript(Isolate* isolate, int index) { 729 bool Debug::CompileDebuggerScript(Isolate* isolate, int index) {
730 Factory* factory = isolate->factory(); 730 Factory* factory = isolate->factory();
(...skipping 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 2233
2234 // Add debug info to the list. 2234 // Add debug info to the list.
2235 DebugInfoListNode* node = new DebugInfoListNode(*debug_info); 2235 DebugInfoListNode* node = new DebugInfoListNode(*debug_info);
2236 node->set_next(debug_info_list_); 2236 node->set_next(debug_info_list_);
2237 debug_info_list_ = node; 2237 debug_info_list_ = node;
2238 2238
2239 return true; 2239 return true;
2240 } 2240 }
2241 2241
2242 2242
2243 // This uses the location of a handle to look up the debug info in the debug 2243 void Debug::RemoveDebugInfo(DebugInfoListNode* prev, DebugInfoListNode* node) {
2244 // info list, but it doesn't use the actual debug info for anything. Therefore 2244 // Unlink from list. If prev is NULL we are looking at the first element.
2245 // if the debug info has been collected by the GC, we can be sure that this 2245 if (prev == NULL) {
2246 // method will not attempt to resurrect it. 2246 debug_info_list_ = node->next();
2247 } else {
2248 prev->set_next(node->next());
2249 }
2250 delete node;
2251
2252 // If there are no more debug info objects there are not more break
2253 // points.
2254 has_break_points_ = debug_info_list_ != NULL;
2255 }
2256
2257
2247 void Debug::RemoveDebugInfo(DebugInfo** debug_info) { 2258 void Debug::RemoveDebugInfo(DebugInfo** debug_info) {
2248 DCHECK(debug_info_list_ != NULL); 2259 DCHECK(debug_info_list_ != NULL);
2249 // Run through the debug info objects to find this one and remove it. 2260 // Run through the debug info objects to find this one and remove it.
2250 DebugInfoListNode* prev = NULL; 2261 DebugInfoListNode* prev = NULL;
2251 DebugInfoListNode* current = debug_info_list_; 2262 DebugInfoListNode* current = debug_info_list_;
2252 while (current != NULL) { 2263 while (current != NULL) {
2253 if (current->debug_info().location() == debug_info) { 2264 if (current->debug_info().location() == debug_info) {
2254 // Unlink from list. If prev is NULL we are looking at the first element. 2265 RemoveDebugInfo(prev, current);
2255 if (prev == NULL) {
2256 debug_info_list_ = current->next();
2257 } else {
2258 prev->set_next(current->next());
2259 }
2260 delete current;
2261
2262 // If there are no more debug info objects there are not more break
2263 // points.
2264 has_break_points_ = debug_info_list_ != NULL;
2265
2266 return; 2266 return;
2267 } 2267 }
2268 // Move to next in list. 2268 // Move to next in list.
2269 prev = current;
2270 current = current->next();
2271 }
2272 UNREACHABLE();
2273 }
2274
2275
2276 void Debug::RemoveDebugInfo(DebugInfoListNode* node) {
2277 DCHECK(debug_info_list_ != NULL);
2278 // Run through the debug info objects to find this one and remove it.
2279 DebugInfoListNode* prev = NULL;
2280 DebugInfoListNode* current = debug_info_list_;
2281 while (current != NULL) {
2282 if (current == node) {
2283 RemoveDebugInfo(prev, node);
2284 return;
2285 }
2286 // Move to next in list.
2269 prev = current; 2287 prev = current;
2270 current = current->next(); 2288 current = current->next();
2271 } 2289 }
2272 UNREACHABLE(); 2290 UNREACHABLE();
2273 } 2291 }
2274 2292
2275 2293
2276 void Debug::RemoveDebugInfoAndClearFromShared(Handle<DebugInfo> debug_info) { 2294 void Debug::RemoveDebugInfoAndClearFromShared(Handle<DebugInfo> debug_info) {
2277 HandleScope scope(isolate_); 2295 HandleScope scope(isolate_);
2278 Handle<SharedFunctionInfo> shared(debug_info->shared()); 2296 Handle<SharedFunctionInfo> shared(debug_info->shared());
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3474 logger_->DebugEvent("Put", message.text()); 3492 logger_->DebugEvent("Put", message.text());
3475 } 3493 }
3476 3494
3477 3495
3478 void LockingCommandMessageQueue::Clear() { 3496 void LockingCommandMessageQueue::Clear() {
3479 base::LockGuard<base::Mutex> lock_guard(&mutex_); 3497 base::LockGuard<base::Mutex> lock_guard(&mutex_);
3480 queue_.Clear(); 3498 queue_.Clear();
3481 } 3499 }
3482 3500
3483 } } // namespace v8::internal 3501 } } // namespace v8::internal
OLDNEW
« include/v8.h ('K') | « src/debug.h ('k') | src/global-handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698