OLD | NEW |
---|---|
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 6359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // Iterate over all handles in the blocks except for the last. | 6377 // Iterate over all handles in the blocks except for the last. |
6378 for (int i = blocks()->length() - 2; i >= 0; --i) { | 6378 for (int i = blocks()->length() - 2; i >= 0; --i) { |
6379 Object** block = blocks()->at(i); | 6379 Object** block = blocks()->at(i); |
6380 v->VisitPointers(block, &block[kHandleBlockSize]); | 6380 if (block == last_non_persistent_block_) { |
6381 ASSERT(last_non_persistent_handle_ >= block && | |
6382 last_non_persistent_handle_ < | |
6383 (&block[kHandleBlockSize])); | |
6384 v->VisitPointers(block, last_non_persistent_handle_); | |
6385 } else { | |
6386 v->VisitPointers(block, &block[kHandleBlockSize]); | |
6387 } | |
6381 } | 6388 } |
6382 | 6389 |
6383 // Iterate over live handles in the last block (if any). | 6390 // Iterate over live handles in the last block (if any). |
6384 if (!blocks()->is_empty()) { | 6391 if (!blocks()->is_empty()) { |
6385 v->VisitPointers(blocks()->last(), handle_scope_data_.next); | 6392 v->VisitPointers(blocks()->last(), handle_scope_data_.next); |
6393 ASSERT(!has_compilation_block_ || | |
danno
2012/06/24 11:07:03
I can't find has_compilation_block_ anywhere else.
| |
6394 blocks()->last() != last_non_persistent_block_); | |
6386 } | 6395 } |
6387 | 6396 |
6388 if (!saved_contexts_.is_empty()) { | 6397 if (!saved_contexts_.is_empty()) { |
6389 Object** start = reinterpret_cast<Object**>(&saved_contexts_.first()); | 6398 Object** start = reinterpret_cast<Object**>(&saved_contexts_.first()); |
6390 v->VisitPointers(start, start + saved_contexts_.length()); | 6399 v->VisitPointers(start, start + saved_contexts_.length()); |
6391 } | 6400 } |
6401 | |
6402 for (PersistentExtensions* extension = persistent_extensions_head_; extension; | |
6403 extension = extension->next) { | |
6404 if (!extension->blocks.is_empty()) { | |
6405 for (int i = 0; i < extension->blocks.length() - 1; i++) { | |
6406 v->VisitPointers(extension->blocks[i], | |
6407 &(extension->blocks[i][kHandleBlockSize])); | |
6408 } | |
6409 } | |
6410 ASSERT(extension->last_block_end < | |
6411 &extension->blocks.last()[kHandleBlockSize]); | |
6412 ASSERT(extension->last_block_end >= extension->blocks.last()); | |
6413 v->VisitPointers(extension->blocks.last(), extension->last_block_end); | |
6414 } | |
6392 } | 6415 } |
6393 | 6416 |
6394 | 6417 |
6395 void HandleScopeImplementer::Iterate(ObjectVisitor* v) { | 6418 void HandleScopeImplementer::Iterate(ObjectVisitor* v) { |
6396 v8::ImplementationUtilities::HandleScopeData* current = | 6419 v8::ImplementationUtilities::HandleScopeData* current = |
6397 isolate_->handle_scope_data(); | 6420 isolate_->handle_scope_data(); |
6398 handle_scope_data_ = *current; | 6421 handle_scope_data_ = *current; |
6399 IterateThis(v); | 6422 IterateThis(v); |
6400 } | 6423 } |
6401 | 6424 |
6402 | 6425 |
6403 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6426 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
6404 HandleScopeImplementer* scope_implementer = | 6427 HandleScopeImplementer* scope_implementer = |
6405 reinterpret_cast<HandleScopeImplementer*>(storage); | 6428 reinterpret_cast<HandleScopeImplementer*>(storage); |
6406 scope_implementer->IterateThis(v); | 6429 scope_implementer->IterateThis(v); |
6407 return storage + ArchiveSpacePerThread(); | 6430 return storage + ArchiveSpacePerThread(); |
6408 } | 6431 } |
6409 | 6432 |
6433 | |
6434 HandleScopeImplementer::PersistentExtensions* | |
6435 HandleScopeImplementer::PersistExtensions(Object** prev_limit) { | |
6436 PersistentExtensions* extension = new PersistentExtensions; | |
6437 while (!blocks_.is_empty()) { | |
6438 internal::Object** block_start = blocks_.last(); | |
6439 internal::Object** block_limit = block_start + kHandleBlockSize; | |
6440 | |
6441 // We should not need to check for NoHandleAllocation here. | |
6442 // Assert this. | |
6443 ASSERT(prev_limit == block_limit || | |
6444 !(block_start <= prev_limit && prev_limit <= block_limit)); | |
6445 if (prev_limit == block_limit) break; | |
6446 extension->blocks.Add(blocks_.last()); | |
6447 blocks_.RemoveLast(); | |
6448 } | |
6449 | |
6450 ASSERT(!blocks_.is_empty() && prev_limit != NULL); | |
6451 | |
6452 extension->next = persistent_extensions_head_; | |
6453 extension->previous = NULL; | |
6454 extension->last_block_end = isolate_->handle_scope_data()->next; | |
6455 persistent_extensions_head_ = extension; | |
6456 return extension; | |
6457 } | |
6458 | |
6459 | |
6460 void HandleScopeImplementer::ReleaseExtensions( | |
6461 PersistentExtensions* extension) { | |
6462 if (persistent_extensions_head_ == extension) { | |
6463 persistent_extensions_head_ = extension->next; | |
6464 } | |
6465 if (extension->next != NULL) { | |
6466 extension->next->previous = extension->previous; | |
6467 } | |
6468 if (extension->previous != NULL) { | |
6469 extension->previous->next = extension->next; | |
6470 } | |
6471 | |
6472 for (int i = 0; i < extension->blocks.length(); i++) { | |
6473 #ifdef DEBUG | |
6474 HandleScope::ZapRange(extension->blocks[i], | |
6475 &extension->blocks[i][kHandleBlockSize]); | |
6476 #endif | |
6477 if (spare_ != NULL) DeleteArray(spare_); | |
6478 spare_ = extension->blocks[i]; | |
6479 } | |
6480 delete extension; | |
6481 } | |
6482 | |
6410 } } // namespace v8::internal | 6483 } } // namespace v8::internal |
OLD | NEW |