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

Side by Side Diff: src/api.cc

Issue 10698031: Revert the change adding CompilationHandleScope. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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/compiler.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 6356 matching lines...) Expand 10 before | Expand all | Expand 10 after
6367 6367
6368 6368
6369 char* HandleScopeImplementer::RestoreThread(char* storage) { 6369 char* HandleScopeImplementer::RestoreThread(char* storage) {
6370 memcpy(this, storage, sizeof(*this)); 6370 memcpy(this, storage, sizeof(*this));
6371 *isolate_->handle_scope_data() = handle_scope_data_; 6371 *isolate_->handle_scope_data() = handle_scope_data_;
6372 return storage + ArchiveSpacePerThread(); 6372 return storage + ArchiveSpacePerThread();
6373 } 6373 }
6374 6374
6375 6375
6376 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) { 6376 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) {
6377 #ifdef DEBUG
6378 bool found_block_before_deferred = false;
6379 #endif
6380 // Iterate over all handles in the blocks except for the last. 6377 // Iterate over all handles in the blocks except for the last.
6381 for (int i = blocks()->length() - 2; i >= 0; --i) { 6378 for (int i = blocks()->length() - 2; i >= 0; --i) {
6382 Object** block = blocks()->at(i); 6379 Object** block = blocks()->at(i);
6383 if (last_handle_before_deferred_block_ != NULL && 6380 v->VisitPointers(block, &block[kHandleBlockSize]);
6384 (last_handle_before_deferred_block_ < &block[kHandleBlockSize]) &&
6385 (last_handle_before_deferred_block_ >= block)) {
6386 v->VisitPointers(block, last_handle_before_deferred_block_);
6387 ASSERT(!found_block_before_deferred);
6388 #ifdef DEBUG
6389 found_block_before_deferred = true;
6390 #endif
6391 } else {
6392 v->VisitPointers(block, &block[kHandleBlockSize]);
6393 }
6394 } 6381 }
6395 6382
6396 ASSERT(last_handle_before_deferred_block_ == NULL ||
6397 found_block_before_deferred);
6398
6399 // Iterate over live handles in the last block (if any). 6383 // Iterate over live handles in the last block (if any).
6400 if (!blocks()->is_empty()) { 6384 if (!blocks()->is_empty()) {
6401 v->VisitPointers(blocks()->last(), handle_scope_data_.next); 6385 v->VisitPointers(blocks()->last(), handle_scope_data_.next);
6402 } 6386 }
6403 6387
6404 if (!saved_contexts_.is_empty()) { 6388 if (!saved_contexts_.is_empty()) {
6405 Object** start = reinterpret_cast<Object**>(&saved_contexts_.first()); 6389 Object** start = reinterpret_cast<Object**>(&saved_contexts_.first());
6406 v->VisitPointers(start, start + saved_contexts_.length()); 6390 v->VisitPointers(start, start + saved_contexts_.length());
6407 } 6391 }
6408
6409 for (DeferredHandles* deferred = deferred_handles_head_;
6410 deferred != NULL;
6411 deferred = deferred->next_) {
6412 deferred->Iterate(v);
6413 }
6414 } 6392 }
6415 6393
6416 6394
6417 void HandleScopeImplementer::Iterate(ObjectVisitor* v) { 6395 void HandleScopeImplementer::Iterate(ObjectVisitor* v) {
6418 v8::ImplementationUtilities::HandleScopeData* current = 6396 v8::ImplementationUtilities::HandleScopeData* current =
6419 isolate_->handle_scope_data(); 6397 isolate_->handle_scope_data();
6420 handle_scope_data_ = *current; 6398 handle_scope_data_ = *current;
6421 IterateThis(v); 6399 IterateThis(v);
6422 } 6400 }
6423 6401
6424 6402
6425 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 6403 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
6426 HandleScopeImplementer* scope_implementer = 6404 HandleScopeImplementer* scope_implementer =
6427 reinterpret_cast<HandleScopeImplementer*>(storage); 6405 reinterpret_cast<HandleScopeImplementer*>(storage);
6428 scope_implementer->IterateThis(v); 6406 scope_implementer->IterateThis(v);
6429 return storage + ArchiveSpacePerThread(); 6407 return storage + ArchiveSpacePerThread();
6430 } 6408 }
6431 6409
6432
6433 DeferredHandles* HandleScopeImplementer::Detach(Object** prev_limit) {
6434 DeferredHandles* deferred = new DeferredHandles(
6435 deferred_handles_head_, isolate()->handle_scope_data()->next, this);
6436
6437 while (!blocks_.is_empty()) {
6438 Object** block_start = blocks_.last();
6439 Object** block_limit = &block_start[kHandleBlockSize];
6440 // We should not need to check for NoHandleAllocation here. Assert
6441 // this.
6442 ASSERT(prev_limit == block_limit ||
6443 !(block_start <= prev_limit && prev_limit <= block_limit));
6444 if (prev_limit == block_limit) break;
6445 deferred->blocks_.Add(blocks_.last());
6446 blocks_.RemoveLast();
6447 }
6448
6449 ASSERT(!blocks_.is_empty() && prev_limit != NULL);
6450 deferred_handles_head_ = deferred;
6451 ASSERT(last_handle_before_deferred_block_ != NULL);
6452 last_handle_before_deferred_block_ = NULL;
6453 return deferred;
6454 }
6455
6456
6457 void HandleScopeImplementer::DestroyDeferredHandles(DeferredHandles* deferred) {
6458 if (deferred_handles_head_ == deferred) {
6459 deferred_handles_head_ = deferred_handles_head_->next_;
6460 }
6461 if (deferred->next_ != NULL) {
6462 deferred->next_->previous_ = deferred->previous_;
6463 }
6464 if (deferred->previous_ != NULL) {
6465 deferred->previous_->next_ = deferred->next_;
6466 }
6467 for (int i = 0; i < deferred->blocks_.length(); i++) {
6468 #ifdef DEBUG
6469 HandleScope::ZapRange(deferred->blocks_[i],
6470 &deferred->blocks_[i][kHandleBlockSize]);
6471 #endif
6472 if (spare_ != NULL) DeleteArray(spare_);
6473 spare_ = deferred->blocks_[i];
6474 }
6475 }
6476
6477
6478 void HandleScopeImplementer::BeginDeferredScope() {
6479 ASSERT(last_handle_before_deferred_block_ == NULL);
6480 last_handle_before_deferred_block_ = isolate()->handle_scope_data()->next;
6481 }
6482
6483
6484 DeferredHandles::~DeferredHandles() {
6485 impl_->DestroyDeferredHandles(this);
6486 }
6487
6488
6489 void DeferredHandles::Iterate(ObjectVisitor* v) {
6490 ASSERT(!blocks_.is_empty());
6491
6492 for (int i = 0; i < (blocks_.length() - 1); i++) {
6493 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6494 }
6495
6496 ASSERT((last_block_limit_ >= blocks_.last()) &&
6497 (last_block_limit_ < &(blocks_.last())[kHandleBlockSize]));
6498
6499 v->VisitPointers(blocks_.last(), last_block_limit_);
6500 }
6501
6502
6503 } } // namespace v8::internal 6410 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698