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

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: Addressing code review feedback + rebase 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
« no previous file with comments | « src/global-handles.h ('k') | src/handles.h » ('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 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ASSERT(OFFSET_OF(Node, object_) == 0); 103 ASSERT(OFFSET_OF(Node, object_) == 0);
104 return reinterpret_cast<Node*>(location); 104 return reinterpret_cast<Node*>(location);
105 } 105 }
106 106
107 // Returns the handle. 107 // Returns the handle.
108 Handle<Object> handle() { return Handle<Object>(&object_); } 108 Handle<Object> handle() { return Handle<Object>(&object_); }
109 109
110 // Make this handle weak. 110 // Make this handle weak.
111 void MakeWeak(GlobalHandles* global_handles, void* parameter, 111 void MakeWeak(GlobalHandles* global_handles, void* parameter,
112 WeakReferenceCallback callback) { 112 WeakReferenceCallback callback) {
113 LOG(HandleEvent("GlobalHandle::MakeWeak", handle().location())); 113 LOG(global_handles->isolate(),
114 HandleEvent("GlobalHandle::MakeWeak", handle().location()));
114 ASSERT(state_ != DESTROYED); 115 ASSERT(state_ != DESTROYED);
115 if (state_ != WEAK && !IsNearDeath()) { 116 if (state_ != WEAK && !IsNearDeath()) {
116 global_handles->number_of_weak_handles_++; 117 global_handles->number_of_weak_handles_++;
117 if (object_->IsJSGlobalObject()) { 118 if (object_->IsJSGlobalObject()) {
118 global_handles->number_of_global_object_weak_handles_++; 119 global_handles->number_of_global_object_weak_handles_++;
119 } 120 }
120 } 121 }
121 state_ = WEAK; 122 state_ = WEAK;
122 set_parameter(parameter); 123 set_parameter(parameter);
123 callback_ = callback; 124 callback_ = callback;
124 } 125 }
125 126
126 void ClearWeakness(GlobalHandles* global_handles) { 127 void ClearWeakness(GlobalHandles* global_handles) {
127 LOG(HandleEvent("GlobalHandle::ClearWeakness", handle().location())); 128 LOG(global_handles->isolate(),
129 HandleEvent("GlobalHandle::ClearWeakness", handle().location()));
128 ASSERT(state_ != DESTROYED); 130 ASSERT(state_ != DESTROYED);
129 if (state_ == WEAK || IsNearDeath()) { 131 if (state_ == WEAK || IsNearDeath()) {
130 global_handles->number_of_weak_handles_--; 132 global_handles->number_of_weak_handles_--;
131 if (object_->IsJSGlobalObject()) { 133 if (object_->IsJSGlobalObject()) {
132 global_handles->number_of_global_object_weak_handles_--; 134 global_handles->number_of_global_object_weak_handles_--;
133 } 135 }
134 } 136 }
135 state_ = NORMAL; 137 state_ = NORMAL;
136 set_parameter(NULL); 138 set_parameter(NULL);
137 } 139 }
(...skipping 24 matching lines...) Expand all
162 ASSERT(state_ != DESTROYED); 164 ASSERT(state_ != DESTROYED);
163 return parameter_or_next_free_.parameter; 165 return parameter_or_next_free_.parameter;
164 } 166 }
165 167
166 // Returns the callback for this weak handle. 168 // Returns the callback for this weak handle.
167 WeakReferenceCallback callback() { return callback_; } 169 WeakReferenceCallback callback() { return callback_; }
168 170
169 bool PostGarbageCollectionProcessing(Isolate* isolate, 171 bool PostGarbageCollectionProcessing(Isolate* isolate,
170 GlobalHandles* global_handles) { 172 GlobalHandles* global_handles) {
171 if (state_ != Node::PENDING) return false; 173 if (state_ != Node::PENDING) return false;
172 LOG(HandleEvent("GlobalHandle::Processing", handle().location())); 174 LOG(isolate, HandleEvent("GlobalHandle::Processing", handle().location()));
173 WeakReferenceCallback func = callback(); 175 WeakReferenceCallback func = callback();
174 if (func == NULL) { 176 if (func == NULL) {
175 Destroy(global_handles); 177 Destroy(global_handles);
176 return false; 178 return false;
177 } 179 }
178 void* par = parameter(); 180 void* par = parameter();
179 state_ = NEAR_DEATH; 181 state_ = NEAR_DEATH;
180 set_parameter(NULL); 182 set_parameter(NULL);
181 183
182 v8::Persistent<v8::Object> object = ToApi<v8::Object>(handle()); 184 v8::Persistent<v8::Object> object = ToApi<v8::Object>(handle());
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 400 }
399 } 401 }
400 } 402 }
401 403
402 404
403 void GlobalHandles::IdentifyWeakHandles(WeakSlotCallback f) { 405 void GlobalHandles::IdentifyWeakHandles(WeakSlotCallback f) {
404 for (Node* current = head_; current != NULL; current = current->next()) { 406 for (Node* current = head_; current != NULL; current = current->next()) {
405 if (current->state_ == Node::WEAK) { 407 if (current->state_ == Node::WEAK) {
406 if (f(&current->object_)) { 408 if (f(&current->object_)) {
407 current->state_ = Node::PENDING; 409 current->state_ = Node::PENDING;
408 LOG(HandleEvent("GlobalHandle::Pending", current->handle().location())); 410 LOG(isolate_,
411 HandleEvent("GlobalHandle::Pending", current->handle().location()));
409 } 412 }
410 } 413 }
411 } 414 }
412 } 415 }
413 416
414 417
415 bool GlobalHandles::PostGarbageCollectionProcessing() { 418 bool GlobalHandles::PostGarbageCollectionProcessing() {
416 // Process weak global handle callbacks. This must be done after the 419 // Process weak global handle callbacks. This must be done after the
417 // GC is completely done, because the callbacks may invoke arbitrary 420 // GC is completely done, because the callbacks may invoke arbitrary
418 // API functions. 421 // API functions.
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 565
563 566
564 void GlobalHandles::RemoveObjectGroups() { 567 void GlobalHandles::RemoveObjectGroups() {
565 for (int i = 0; i< object_groups_.length(); i++) { 568 for (int i = 0; i< object_groups_.length(); i++) {
566 delete object_groups_.at(i); 569 delete object_groups_.at(i);
567 } 570 }
568 object_groups_.Clear(); 571 object_groups_.Clear();
569 } 572 }
570 573
571 } } // namespace v8::internal 574 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/global-handles.h ('k') | src/handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698