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 6355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6366 } | 6366 } |
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 template<bool HasCompilationBlock> | |
Erik Corry
2012/06/22 11:08:36
This should be named_like_this, but I wonder wheth
sanjoy
2012/06/22 20:08:10
Reverted.
| |
6376 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) { | 6377 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) { |
6377 // Iterate over all handles in the blocks except for the last. | 6378 // Iterate over all handles in the blocks except for the last. |
6378 for (int i = blocks()->length() - 2; i >= 0; --i) { | 6379 for (int i = blocks()->length() - 2; i >= 0; --i) { |
6379 Object** block = blocks()->at(i); | 6380 Object** block = blocks()->at(i); |
6380 v->VisitPointers(block, &block[kHandleBlockSize]); | 6381 if (HasCompilationBlock && block == last_block_before_compilation_) { |
6382 ASSERT(last_valid_handle_before_compilation_ >= block && | |
6383 last_valid_handle_before_compilation_ < | |
6384 (&block[kHandleBlockSize])); | |
6385 v->VisitPointers(block, last_valid_handle_before_compilation_); | |
6386 } else { | |
6387 v->VisitPointers(block, &block[kHandleBlockSize]); | |
6388 } | |
6381 } | 6389 } |
6382 | 6390 |
6383 // Iterate over live handles in the last block (if any). | 6391 // Iterate over live handles in the last block (if any). |
6384 if (!blocks()->is_empty()) { | 6392 if (!blocks()->is_empty()) { |
6385 v->VisitPointers(blocks()->last(), handle_scope_data_.next); | 6393 v->VisitPointers(blocks()->last(), handle_scope_data_.next); |
6394 ASSERT(!HasCompilationBlock || | |
6395 blocks()->last() != last_block_before_compilation_); | |
6386 } | 6396 } |
6387 | 6397 |
6388 if (!saved_contexts_.is_empty()) { | 6398 if (!saved_contexts_.is_empty()) { |
6389 Object** start = reinterpret_cast<Object**>(&saved_contexts_.first()); | 6399 Object** start = reinterpret_cast<Object**>(&saved_contexts_.first()); |
6390 v->VisitPointers(start, start + saved_contexts_.length()); | 6400 v->VisitPointers(start, start + saved_contexts_.length()); |
6391 } | 6401 } |
6402 | |
6403 // Iterate over the extensions hidden by the compiler. | |
6404 for (HiddenExtensions* extension = hidden_extensions_head_; extension; | |
6405 extension = extension->next) { | |
6406 if (!extension->blocks.is_empty()) { | |
6407 for (int i = 0; i < extension->blocks.length() - 1; i++) { | |
6408 v->VisitPointers(extension->blocks[i], | |
6409 &(extension->blocks[i][kHandleBlockSize])); | |
6410 } | |
6411 } | |
6412 ASSERT(extension->last_block_end < | |
6413 &extension->blocks.last()[kHandleBlockSize]); | |
6414 ASSERT(extension->last_block_end >= extension->blocks.last()); | |
6415 v->VisitPointers(extension->blocks.last(), extension->last_block_end); | |
6416 } | |
6392 } | 6417 } |
6393 | 6418 |
6394 | 6419 |
6395 void HandleScopeImplementer::Iterate(ObjectVisitor* v) { | 6420 void HandleScopeImplementer::Iterate(ObjectVisitor* v) { |
6396 v8::ImplementationUtilities::HandleScopeData* current = | 6421 v8::ImplementationUtilities::HandleScopeData* current = |
6397 isolate_->handle_scope_data(); | 6422 isolate_->handle_scope_data(); |
6398 handle_scope_data_ = *current; | 6423 handle_scope_data_ = *current; |
6399 IterateThis(v); | 6424 if (last_block_before_compilation_ == NULL) { |
6425 IterateThis<false>(v); | |
6426 } else { | |
6427 IterateThis<true>(v); | |
6428 } | |
6400 } | 6429 } |
6401 | 6430 |
6402 | 6431 |
6403 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6432 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
6404 HandleScopeImplementer* scope_implementer = | 6433 HandleScopeImplementer* scope_implementer = |
6405 reinterpret_cast<HandleScopeImplementer*>(storage); | 6434 reinterpret_cast<HandleScopeImplementer*>(storage); |
6406 scope_implementer->IterateThis(v); | 6435 |
6436 if (scope_implementer->last_block_before_compilation_ == NULL) { | |
6437 scope_implementer->IterateThis<false>(v); | |
6438 } else { | |
6439 scope_implementer->IterateThis<true>(v); | |
6440 } | |
6407 return storage + ArchiveSpacePerThread(); | 6441 return storage + ArchiveSpacePerThread(); |
6408 } | 6442 } |
6409 | 6443 |
6444 | |
6445 HandleScopeImplementer::HiddenExtensions* | |
6446 HandleScopeImplementer::HideExtensions(Object** prev_limit) { | |
6447 HiddenExtensions* extension = new HiddenExtensions; | |
6448 while (!blocks_.is_empty()) { | |
6449 internal::Object** block_start = blocks_.last(); | |
6450 internal::Object** block_limit = block_start + kHandleBlockSize; | |
6451 | |
6452 // We should not need to check for NoHandleAllocation here. | |
6453 // ASSERT this. | |
Erik Corry
2012/06/22 11:08:36
ASSERT -> Assert
(in the comment)
sanjoy
2012/06/22 20:08:10
Fixed.
| |
6454 ASSERT(prev_limit == block_limit || | |
6455 !(block_start <= prev_limit && prev_limit <= block_limit)); | |
6456 if (prev_limit == block_limit) break; | |
6457 extension->blocks.Add(blocks_.last()); | |
6458 blocks_.RemoveLast(); | |
6459 } | |
6460 | |
6461 ASSERT(!blocks_.is_empty() && prev_limit != NULL); | |
6462 | |
6463 extension->next = hidden_extensions_head_; | |
6464 extension->previous = NULL; | |
6465 extension->last_block_end = isolate_->handle_scope_data()->next; | |
6466 hidden_extensions_head_ = extension; | |
6467 return extension; | |
6468 } | |
6469 | |
6470 | |
6471 void HandleScopeImplementer::DeleteHiddenExtensions( | |
6472 HiddenExtensions* extension) { | |
6473 if (hidden_extensions_head_ == extension) { | |
6474 hidden_extensions_head_ = extension->next; | |
6475 } | |
6476 if (extension->next) { | |
Erik Corry
2012/06/22 11:08:36
We don't allow implicit conversions to bool.
sanjoy
2012/06/22 20:08:10
Fixed.
| |
6477 extension->next->previous = extension->previous; | |
6478 } | |
6479 if (extension->previous) { | |
Erik Corry
2012/06/22 11:08:36
and here
sanjoy
2012/06/22 20:08:10
Fixed.
| |
6480 extension->previous->next = extension->next; | |
6481 } | |
6482 | |
6483 for (int i = 0; i < extension->blocks.length(); i++) { | |
6484 #ifdef DEBUG | |
6485 HandleScope::ZapRange(extension->blocks[i], | |
6486 &extension->blocks[i][kHandleBlockSize]); | |
6487 #endif | |
6488 if (spare_ != NULL) DeleteArray(spare_); | |
6489 spare_ = extension->blocks[i]; | |
6490 } | |
6491 delete extension; | |
6492 } | |
6493 | |
6410 } } // namespace v8::internal | 6494 } } // namespace v8::internal |
OLD | NEW |