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

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

Issue 16153003: de-isolate remaining persistent calls (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 6 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') | no next file » | 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 ASSERT(state() == WEAK); 192 ASSERT(state() == WEAK);
193 set_state(PENDING); 193 set_state(PENDING);
194 } 194 }
195 195
196 // Independent flag accessors. 196 // Independent flag accessors.
197 void MarkIndependent() { 197 void MarkIndependent() {
198 ASSERT(state() != FREE); 198 ASSERT(state() != FREE);
199 set_independent(true); 199 set_independent(true);
200 } 200 }
201 201
202 void MarkPartiallyDependent(GlobalHandles* global_handles) { 202 void MarkPartiallyDependent() {
203 ASSERT(state() != FREE); 203 ASSERT(state() != FREE);
204 if (global_handles->isolate()->heap()->InNewSpace(object_)) { 204 if (GetGlobalHandles()->isolate()->heap()->InNewSpace(object_)) {
205 set_partially_dependent(true); 205 set_partially_dependent(true);
206 } 206 }
207 } 207 }
208 void clear_partially_dependent() { set_partially_dependent(false); } 208 void clear_partially_dependent() { set_partially_dependent(false); }
209 209
210 // Callback accessor. 210 // Callback accessor.
211 // TODO(svenpanne) Re-enable or nuke later. 211 // TODO(svenpanne) Re-enable or nuke later.
212 // WeakReferenceCallback callback() { return callback_; } 212 // WeakReferenceCallback callback() { return callback_; }
213 213
214 // Callback parameter accessors. 214 // Callback parameter accessors.
215 void set_parameter(void* parameter) { 215 void set_parameter(void* parameter) {
216 ASSERT(state() != FREE); 216 ASSERT(state() != FREE);
217 parameter_or_next_free_.parameter = parameter; 217 parameter_or_next_free_.parameter = parameter;
218 } 218 }
219 void* parameter() const { 219 void* parameter() const {
220 ASSERT(state() != FREE); 220 ASSERT(state() != FREE);
221 return parameter_or_next_free_.parameter; 221 return parameter_or_next_free_.parameter;
222 } 222 }
223 223
224 // Accessors for next free node in the free list. 224 // Accessors for next free node in the free list.
225 Node* next_free() { 225 Node* next_free() {
226 ASSERT(state() == FREE); 226 ASSERT(state() == FREE);
227 return parameter_or_next_free_.next_free; 227 return parameter_or_next_free_.next_free;
228 } 228 }
229 void set_next_free(Node* value) { 229 void set_next_free(Node* value) {
230 ASSERT(state() == FREE); 230 ASSERT(state() == FREE);
231 parameter_or_next_free_.next_free = value; 231 parameter_or_next_free_.next_free = value;
232 } 232 }
233 233
234 void MakeWeak(GlobalHandles* global_handles, 234 void MakeWeak(void* parameter,
235 void* parameter,
236 RevivableCallback weak_reference_callback, 235 RevivableCallback weak_reference_callback,
237 NearDeathCallback near_death_callback) { 236 NearDeathCallback near_death_callback) {
238 ASSERT(state() != FREE); 237 ASSERT(state() != FREE);
239 set_state(WEAK); 238 set_state(WEAK);
240 set_parameter(parameter); 239 set_parameter(parameter);
241 if (weak_reference_callback != NULL) { 240 if (weak_reference_callback != NULL) {
242 flags_ = IsWeakCallback::update(flags_, true); 241 flags_ = IsWeakCallback::update(flags_, true);
243 near_death_callback_ = 242 near_death_callback_ =
244 reinterpret_cast<NearDeathCallback>(weak_reference_callback); 243 reinterpret_cast<NearDeathCallback>(weak_reference_callback);
245 } else { 244 } else {
246 flags_ = IsWeakCallback::update(flags_, false); 245 flags_ = IsWeakCallback::update(flags_, false);
247 near_death_callback_ = near_death_callback; 246 near_death_callback_ = near_death_callback;
248 } 247 }
249 } 248 }
250 249
251 void ClearWeakness(GlobalHandles* global_handles) { 250 void ClearWeakness() {
252 ASSERT(state() != FREE); 251 ASSERT(state() != FREE);
253 set_state(NORMAL); 252 set_state(NORMAL);
254 set_parameter(NULL); 253 set_parameter(NULL);
255 } 254 }
256 255
257 bool PostGarbageCollectionProcessing(Isolate* isolate) { 256 bool PostGarbageCollectionProcessing(Isolate* isolate) {
258 if (state() != Node::PENDING) return false; 257 if (state() != Node::PENDING) return false;
259 if (near_death_callback_ == NULL) { 258 if (near_death_callback_ == NULL) {
260 Release(); 259 Release();
261 return false; 260 return false;
(...skipping 27 matching lines...) Expand all
289 } 288 }
290 } 289 }
291 // Absence of explicit cleanup or revival of weak handle 290 // Absence of explicit cleanup or revival of weak handle
292 // in most of the cases would lead to memory leak. 291 // in most of the cases would lead to memory leak.
293 ASSERT(state() != NEAR_DEATH); 292 ASSERT(state() != NEAR_DEATH);
294 return true; 293 return true;
295 } 294 }
296 295
297 private: 296 private:
298 inline NodeBlock* FindBlock(); 297 inline NodeBlock* FindBlock();
298 inline GlobalHandles* GetGlobalHandles();
299 inline void IncreaseBlockUses(); 299 inline void IncreaseBlockUses();
300 inline void DecreaseBlockUses(); 300 inline void DecreaseBlockUses();
301 301
302 // Storage for object pointer. 302 // Storage for object pointer.
303 // Placed first to avoid offset computation. 303 // Placed first to avoid offset computation.
304 Object* object_; 304 Object* object_;
305 305
306 // Next word stores class_id, index, state, and independent. 306 // Next word stores class_id, index, state, and independent.
307 // Note: the most aligned fields should go first. 307 // Note: the most aligned fields should go first.
308 308
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 private: 393 private:
394 Node nodes_[kSize]; 394 Node nodes_[kSize];
395 NodeBlock* const next_; 395 NodeBlock* const next_;
396 int used_nodes_; 396 int used_nodes_;
397 NodeBlock* next_used_; 397 NodeBlock* next_used_;
398 NodeBlock* prev_used_; 398 NodeBlock* prev_used_;
399 GlobalHandles* global_handles_; 399 GlobalHandles* global_handles_;
400 }; 400 };
401 401
402 402
403 GlobalHandles* GlobalHandles::Node::GetGlobalHandles() {
404 return FindBlock()->global_handles();
405 }
406
407
403 GlobalHandles::NodeBlock* GlobalHandles::Node::FindBlock() { 408 GlobalHandles::NodeBlock* GlobalHandles::Node::FindBlock() {
404 intptr_t ptr = reinterpret_cast<intptr_t>(this); 409 intptr_t ptr = reinterpret_cast<intptr_t>(this);
405 ptr = ptr - index_ * sizeof(Node); 410 ptr = ptr - index_ * sizeof(Node);
406 NodeBlock* block = reinterpret_cast<NodeBlock*>(ptr); 411 NodeBlock* block = reinterpret_cast<NodeBlock*>(ptr);
407 ASSERT(block->node_at(index_) == this); 412 ASSERT(block->node_at(index_) == this);
408 return block; 413 return block;
409 } 414 }
410 415
411 416
412 void GlobalHandles::Node::IncreaseBlockUses() { 417 void GlobalHandles::Node::IncreaseBlockUses() {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 void GlobalHandles::Destroy(Object** location) { 505 void GlobalHandles::Destroy(Object** location) {
501 if (location != NULL) Node::FromLocation(location)->Release(); 506 if (location != NULL) Node::FromLocation(location)->Release();
502 } 507 }
503 508
504 509
505 void GlobalHandles::MakeWeak(Object** location, 510 void GlobalHandles::MakeWeak(Object** location,
506 void* parameter, 511 void* parameter,
507 RevivableCallback weak_reference_callback, 512 RevivableCallback weak_reference_callback,
508 NearDeathCallback near_death_callback) { 513 NearDeathCallback near_death_callback) {
509 ASSERT((weak_reference_callback == NULL) != (near_death_callback == NULL)); 514 ASSERT((weak_reference_callback == NULL) != (near_death_callback == NULL));
510 Node::FromLocation(location)->MakeWeak(this, 515 Node::FromLocation(location)->MakeWeak(parameter,
511 parameter,
512 weak_reference_callback, 516 weak_reference_callback,
513 near_death_callback); 517 near_death_callback);
514 } 518 }
515 519
516 520
517 void GlobalHandles::ClearWeakness(Object** location) { 521 void GlobalHandles::ClearWeakness(Object** location) {
518 Node::FromLocation(location)->ClearWeakness(this); 522 Node::FromLocation(location)->ClearWeakness();
519 } 523 }
520 524
521 525
522 void GlobalHandles::MarkIndependent(Object** location) { 526 void GlobalHandles::MarkIndependent(Object** location) {
523 Node::FromLocation(location)->MarkIndependent(); 527 Node::FromLocation(location)->MarkIndependent();
524 } 528 }
525 529
526 530
527 void GlobalHandles::MarkPartiallyDependent(Object** location) { 531 void GlobalHandles::MarkPartiallyDependent(Object** location) {
528 Node::FromLocation(location)->MarkPartiallyDependent(this); 532 Node::FromLocation(location)->MarkPartiallyDependent();
529 } 533 }
530 534
531 535
532 bool GlobalHandles::IsIndependent(Object** location) { 536 bool GlobalHandles::IsIndependent(Object** location) {
533 return Node::FromLocation(location)->is_independent(); 537 return Node::FromLocation(location)->is_independent();
534 } 538 }
535 539
536 540
537 bool GlobalHandles::IsNearDeath(Object** location) { 541 bool GlobalHandles::IsNearDeath(Object** location) {
538 return Node::FromLocation(location)->IsNearDeath(); 542 return Node::FromLocation(location)->IsNearDeath();
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 } 1025 }
1022 } 1026 }
1023 object_group_connections_.Clear(); 1027 object_group_connections_.Clear();
1024 object_group_connections_.Initialize(kObjectGroupConnectionsCapacity); 1028 object_group_connections_.Initialize(kObjectGroupConnectionsCapacity);
1025 retainer_infos_.Clear(); 1029 retainer_infos_.Clear();
1026 implicit_ref_connections_.Clear(); 1030 implicit_ref_connections_.Clear();
1027 } 1031 }
1028 1032
1029 1033
1030 } } // namespace v8::internal 1034 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/global-handles.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698