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

Side by Side Diff: src/global-handles.cc

Issue 6696042: Adding 'isolates' argument to LOG to get rid of multiple TLS fetches in profiling. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/isolates
Patch Set: Created 9 years, 9 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
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 ASSERT(OFFSET_OF(Node, object_) == 0); 96 ASSERT(OFFSET_OF(Node, object_) == 0);
97 return reinterpret_cast<Node*>(location); 97 return reinterpret_cast<Node*>(location);
98 } 98 }
99 99
100 // Returns the handle. 100 // Returns the handle.
101 Handle<Object> handle() { return Handle<Object>(&object_); } 101 Handle<Object> handle() { return Handle<Object>(&object_); }
102 102
103 // Make this handle weak. 103 // Make this handle weak.
104 void MakeWeak(GlobalHandles* global_handles, void* parameter, 104 void MakeWeak(GlobalHandles* global_handles, void* parameter,
105 WeakReferenceCallback callback) { 105 WeakReferenceCallback callback) {
106 LOG(HandleEvent("GlobalHandle::MakeWeak", handle().location())); 106 LOG(global_handles->isolate(), HandleEvent("GlobalHandle::MakeWeak", handle( ).location()));
107 ASSERT(state_ != DESTROYED); 107 ASSERT(state_ != DESTROYED);
108 if (state_ != WEAK && !IsNearDeath()) { 108 if (state_ != WEAK && !IsNearDeath()) {
109 global_handles->number_of_weak_handles_++; 109 global_handles->number_of_weak_handles_++;
110 if (object_->IsJSGlobalObject()) { 110 if (object_->IsJSGlobalObject()) {
111 global_handles->number_of_global_object_weak_handles_++; 111 global_handles->number_of_global_object_weak_handles_++;
112 } 112 }
113 } 113 }
114 state_ = WEAK; 114 state_ = WEAK;
115 set_parameter(parameter); 115 set_parameter(parameter);
116 callback_ = callback; 116 callback_ = callback;
117 } 117 }
118 118
119 void ClearWeakness(GlobalHandles* global_handles) { 119 void ClearWeakness(GlobalHandles* global_handles) {
120 LOG(HandleEvent("GlobalHandle::ClearWeakness", handle().location())); 120 LOG(global_handles->isolate(), HandleEvent("GlobalHandle::ClearWeakness", ha ndle().location()));
121 ASSERT(state_ != DESTROYED); 121 ASSERT(state_ != DESTROYED);
122 if (state_ == WEAK || IsNearDeath()) { 122 if (state_ == WEAK || IsNearDeath()) {
123 global_handles->number_of_weak_handles_--; 123 global_handles->number_of_weak_handles_--;
124 if (object_->IsJSGlobalObject()) { 124 if (object_->IsJSGlobalObject()) {
125 global_handles->number_of_global_object_weak_handles_--; 125 global_handles->number_of_global_object_weak_handles_--;
126 } 126 }
127 } 127 }
128 state_ = NORMAL; 128 state_ = NORMAL;
129 set_parameter(NULL); 129 set_parameter(NULL);
130 } 130 }
(...skipping 16 matching lines...) Expand all
147 ASSERT(state_ != DESTROYED); 147 ASSERT(state_ != DESTROYED);
148 return parameter_or_next_free_.parameter; 148 return parameter_or_next_free_.parameter;
149 } 149 }
150 150
151 // Returns the callback for this weak handle. 151 // Returns the callback for this weak handle.
152 WeakReferenceCallback callback() { return callback_; } 152 WeakReferenceCallback callback() { return callback_; }
153 153
154 bool PostGarbageCollectionProcessing(Isolate* isolate, 154 bool PostGarbageCollectionProcessing(Isolate* isolate,
155 GlobalHandles* global_handles) { 155 GlobalHandles* global_handles) {
156 if (state_ != Node::PENDING) return false; 156 if (state_ != Node::PENDING) return false;
157 LOG(HandleEvent("GlobalHandle::Processing", handle().location())); 157 LOG(isolate, HandleEvent("GlobalHandle::Processing", handle().location()));
158 WeakReferenceCallback func = callback(); 158 WeakReferenceCallback func = callback();
159 if (func == NULL) { 159 if (func == NULL) {
160 Destroy(global_handles); 160 Destroy(global_handles);
161 return false; 161 return false;
162 } 162 }
163 void* par = parameter(); 163 void* par = parameter();
164 state_ = NEAR_DEATH; 164 state_ = NEAR_DEATH;
165 set_parameter(NULL); 165 set_parameter(NULL);
166 166
167 v8::Persistent<v8::Object> object = ToApi<v8::Object>(handle()); 167 v8::Persistent<v8::Object> object = ToApi<v8::Object>(handle());
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 376 }
377 } 377 }
378 } 378 }
379 379
380 380
381 void GlobalHandles::IdentifyWeakHandles(WeakSlotCallback f) { 381 void GlobalHandles::IdentifyWeakHandles(WeakSlotCallback f) {
382 for (Node* current = head_; current != NULL; current = current->next()) { 382 for (Node* current = head_; current != NULL; current = current->next()) {
383 if (current->state_ == Node::WEAK) { 383 if (current->state_ == Node::WEAK) {
384 if (f(&current->object_)) { 384 if (f(&current->object_)) {
385 current->state_ = Node::PENDING; 385 current->state_ = Node::PENDING;
386 LOG(HandleEvent("GlobalHandle::Pending", current->handle().location())); 386 LOG(isolate_, HandleEvent("GlobalHandle::Pending", current->handle().loc ation()));
387 } 387 }
388 } 388 }
389 } 389 }
390 } 390 }
391 391
392 392
393 bool GlobalHandles::PostGarbageCollectionProcessing() { 393 bool GlobalHandles::PostGarbageCollectionProcessing() {
394 // Process weak global handle callbacks. This must be done after the 394 // Process weak global handle callbacks. This must be done after the
395 // GC is completely done, because the callbacks may invoke arbitrary 395 // GC is completely done, because the callbacks may invoke arbitrary
396 // API functions. 396 // API functions.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 528
529 529
530 void GlobalHandles::RemoveObjectGroups() { 530 void GlobalHandles::RemoveObjectGroups() {
531 for (int i = 0; i< object_groups_.length(); i++) { 531 for (int i = 0; i< object_groups_.length(); i++) {
532 delete object_groups_.at(i); 532 delete object_groups_.at(i);
533 } 533 }
534 object_groups_.Clear(); 534 object_groups_.Clear();
535 } 535 }
536 536
537 } } // namespace v8::internal 537 } } // namespace v8::internal
OLDNEW
« src/compiler.cc ('K') | « src/global-handles.h ('k') | src/handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698