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

Side by Side Diff: src/api.cc

Issue 10778036: The deferred handes list belongs to the Isolate and not to the (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review. Created 8 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/api.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 6404 matching lines...) Expand 10 before | Expand all | Expand 10 after
6415 6415
6416 // Iterate over live handles in the last block (if any). 6416 // Iterate over live handles in the last block (if any).
6417 if (!blocks()->is_empty()) { 6417 if (!blocks()->is_empty()) {
6418 v->VisitPointers(blocks()->last(), handle_scope_data_.next); 6418 v->VisitPointers(blocks()->last(), handle_scope_data_.next);
6419 } 6419 }
6420 6420
6421 if (!saved_contexts_.is_empty()) { 6421 if (!saved_contexts_.is_empty()) {
6422 Object** start = reinterpret_cast<Object**>(&saved_contexts_.first()); 6422 Object** start = reinterpret_cast<Object**>(&saved_contexts_.first());
6423 v->VisitPointers(start, start + saved_contexts_.length()); 6423 v->VisitPointers(start, start + saved_contexts_.length());
6424 } 6424 }
6425
6426 for (DeferredHandles* deferred = deferred_handles_head_;
6427 deferred != NULL;
6428 deferred = deferred->next_) {
6429 deferred->Iterate(v);
6430 }
6431 } 6425 }
6432 6426
6433 6427
6434 void HandleScopeImplementer::Iterate(ObjectVisitor* v) { 6428 void HandleScopeImplementer::Iterate(ObjectVisitor* v) {
6435 v8::ImplementationUtilities::HandleScopeData* current = 6429 v8::ImplementationUtilities::HandleScopeData* current =
6436 isolate_->handle_scope_data(); 6430 isolate_->handle_scope_data();
6437 handle_scope_data_ = *current; 6431 handle_scope_data_ = *current;
6438 IterateThis(v); 6432 IterateThis(v);
6439 } 6433 }
6440 6434
6441 6435
6442 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 6436 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
6443 HandleScopeImplementer* scope_implementer = 6437 HandleScopeImplementer* scope_implementer =
6444 reinterpret_cast<HandleScopeImplementer*>(storage); 6438 reinterpret_cast<HandleScopeImplementer*>(storage);
6445 scope_implementer->IterateThis(v); 6439 scope_implementer->IterateThis(v);
6446 return storage + ArchiveSpacePerThread(); 6440 return storage + ArchiveSpacePerThread();
6447 } 6441 }
6448 6442
6449 6443
6450 DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) { 6444 DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) {
6451 DeferredHandles* deferred = new DeferredHandles( 6445 DeferredHandles* deferred =
6452 deferred_handles_head_, isolate()->handle_scope_data()->next, this); 6446 new DeferredHandles(isolate()->handle_scope_data()->next, isolate());
6453 6447
6454 while (!blocks_.is_empty()) { 6448 while (!blocks_.is_empty()) {
6455 Object** block_start = blocks_.last(); 6449 Object** block_start = blocks_.last();
6456 Object** block_limit = &block_start[kHandleBlockSize]; 6450 Object** block_limit = &block_start[kHandleBlockSize];
6457 // We should not need to check for NoHandleAllocation here. Assert 6451 // We should not need to check for NoHandleAllocation here. Assert
6458 // this. 6452 // this.
6459 ASSERT(prev_limit == block_limit || 6453 ASSERT(prev_limit == block_limit ||
6460 !(block_start <= prev_limit && prev_limit <= block_limit)); 6454 !(block_start <= prev_limit && prev_limit <= block_limit));
6461 if (prev_limit == block_limit) break; 6455 if (prev_limit == block_limit) break;
6462 deferred->blocks_.Add(blocks_.last()); 6456 deferred->blocks_.Add(blocks_.last());
6463 blocks_.RemoveLast(); 6457 blocks_.RemoveLast();
6464 } 6458 }
6465 6459
6466 // deferred->blocks_ now contains the blocks installed on the 6460 // deferred->blocks_ now contains the blocks installed on the
6467 // HandleScope stack since BeginDeferredScope was called, but in 6461 // HandleScope stack since BeginDeferredScope was called, but in
6468 // reverse order. 6462 // reverse order.
6469 6463
6470 ASSERT(prev_limit == NULL || !blocks_.is_empty()); 6464 ASSERT(prev_limit == NULL || !blocks_.is_empty());
6471 6465
6472 ASSERT(!blocks_.is_empty() && prev_limit != NULL); 6466 ASSERT(!blocks_.is_empty() && prev_limit != NULL);
6473 deferred_handles_head_ = deferred;
6474 ASSERT(last_handle_before_deferred_block_ != NULL); 6467 ASSERT(last_handle_before_deferred_block_ != NULL);
6475 last_handle_before_deferred_block_ = NULL; 6468 last_handle_before_deferred_block_ = NULL;
6476 return deferred; 6469 return deferred;
6477 } 6470 }
6478 6471
6479 6472
6480 void HandleScopeImplementer::DestroyDeferredHandles(DeferredHandles* deferred) {
6481 #ifdef DEBUG
6482 DeferredHandles* deferred_iterator = deferred;
6483 while (deferred_iterator->previous_ != NULL) {
6484 deferred_iterator = deferred_iterator->previous_;
6485 }
6486 ASSERT(deferred_handles_head_ == deferred_iterator);
6487 #endif
6488 if (deferred_handles_head_ == deferred) {
6489 deferred_handles_head_ = deferred_handles_head_->next_;
6490 }
6491 if (deferred->next_ != NULL) {
6492 deferred->next_->previous_ = deferred->previous_;
6493 }
6494 if (deferred->previous_ != NULL) {
6495 deferred->previous_->next_ = deferred->next_;
6496 }
6497 for (int i = 0; i < deferred->blocks_.length(); i++) {
6498 #ifdef DEBUG
6499 HandleScope::ZapRange(deferred->blocks_[i],
6500 &deferred->blocks_[i][kHandleBlockSize]);
6501 #endif
6502 if (spare_ != NULL) DeleteArray(spare_);
6503 spare_ = deferred->blocks_[i];
6504 }
6505 }
6506
6507
6508 void HandleScopeImplementer::BeginDeferredScope() { 6473 void HandleScopeImplementer::BeginDeferredScope() {
6509 ASSERT(last_handle_before_deferred_block_ == NULL); 6474 ASSERT(last_handle_before_deferred_block_ == NULL);
6510 last_handle_before_deferred_block_ = isolate()->handle_scope_data()->next; 6475 last_handle_before_deferred_block_ = isolate()->handle_scope_data()->next;
6511 } 6476 }
6512 6477
6513 6478
6514 DeferredHandles::~DeferredHandles() { 6479 DeferredHandles::~DeferredHandles() {
6515 impl_->DestroyDeferredHandles(this); 6480 isolate_->UnlinkDeferredHandles(this);
6481
6482 for (int i = 0; i < blocks_.length(); i++) {
6483 #ifdef DEBUG
6484 HandleScope::ZapRange(blocks_[i], &blocks_[i][kHandleBlockSize]);
6485 #endif
6486 isolate_->handle_scope_implementer()->ReturnBlock(blocks_[i]);
6487 }
6516 } 6488 }
6517 6489
6518 6490
6519 void DeferredHandles::Iterate(ObjectVisitor* v) { 6491 void DeferredHandles::Iterate(ObjectVisitor* v) {
6520 ASSERT(!blocks_.is_empty()); 6492 ASSERT(!blocks_.is_empty());
6521 6493
6522 ASSERT((first_block_limit_ >= blocks_.first()) && 6494 ASSERT((first_block_limit_ >= blocks_.first()) &&
6523 (first_block_limit_ <= &(blocks_.first())[kHandleBlockSize])); 6495 (first_block_limit_ <= &(blocks_.first())[kHandleBlockSize]));
6524 6496
6525 v->VisitPointers(blocks_.first(), first_block_limit_); 6497 v->VisitPointers(blocks_.first(), first_block_limit_);
6526 6498
6527 for (int i = 1; i < blocks_.length(); i++) { 6499 for (int i = 1; i < blocks_.length(); i++) {
6528 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 6500 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6529 } 6501 }
6530 } 6502 }
6531 6503
6532 6504
6533 } } // namespace v8::internal 6505 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698