@@ -427,7 +427,7 @@ void Context::Enter() {
427427 i::Handle<i::Context> env = Utils::OpenHandle (this );
428428 thread_local .EnterContext (env);
429429
430- thread_local .SaveContext (i::GlobalHandles::Create ( i:: Top::context () ));
430+ thread_local .SaveContext (i::Top::context ());
431431 i::Top::set_context (*env);
432432}
433433
@@ -441,9 +441,8 @@ void Context::Exit() {
441441 }
442442
443443 // Content of 'last_context' could be NULL.
444- i::Handle<i::Object> last_context = thread_local .RestoreContext ();
445- i::Top::set_context (static_cast <i::Context*>(*last_context));
446- i::GlobalHandles::Destroy (last_context.location ());
444+ i::Context* last_context = thread_local .RestoreContext ();
445+ i::Top::set_context (last_context);
447446}
448447
449448
@@ -3700,38 +3699,37 @@ char* HandleScopeImplementer::RestoreThreadHelper(char* storage) {
37003699}
37013700
37023701
3703- void HandleScopeImplementer::Iterate (
3704- ObjectVisitor* v,
3705- List<i::Object**>* blocks,
3706- v8::ImplementationUtilities::HandleScopeData* handle_data) {
3702+ void HandleScopeImplementer::IterateThis (ObjectVisitor* v) {
37073703 // Iterate over all handles in the blocks except for the last.
3708- for (int i = blocks ->length () - 2 ; i >= 0 ; --i) {
3709- Object** block = blocks ->at (i);
3704+ for (int i = Blocks () ->length () - 2 ; i >= 0 ; --i) {
3705+ Object** block = Blocks () ->at (i);
37103706 v->VisitPointers (block, &block[kHandleBlockSize ]);
37113707 }
37123708
37133709 // Iterate over live handles in the last block (if any).
3714- if (!blocks->is_empty ()) {
3715- v->VisitPointers (blocks->last (), handle_data->next );
3710+ if (!Blocks ()->is_empty ()) {
3711+ v->VisitPointers (Blocks ()->last (), handle_scope_data_.next );
3712+ }
3713+
3714+ if (!saved_contexts_.is_empty ()) {
3715+ Object** start = reinterpret_cast <Object**>(&saved_contexts_.first ());
3716+ v->VisitPointers (start, start + saved_contexts_.length ());
37163717 }
37173718}
37183719
37193720
37203721void HandleScopeImplementer::Iterate (ObjectVisitor* v) {
37213722 v8::ImplementationUtilities::HandleScopeData* current =
37223723 v8::ImplementationUtilities::CurrentHandleScope ();
3723- Iterate (v, thread_local .Blocks (), current);
3724+ thread_local .handle_scope_data_ = *current;
3725+ thread_local .IterateThis (v);
37243726}
37253727
37263728
37273729char * HandleScopeImplementer::Iterate (ObjectVisitor* v, char * storage) {
37283730 HandleScopeImplementer* thread_local =
37293731 reinterpret_cast <HandleScopeImplementer*>(storage);
3730- List<internal::Object**>* blocks_of_archived_thread = thread_local ->Blocks ();
3731- v8::ImplementationUtilities::HandleScopeData* handle_data_of_archived_thread =
3732- &thread_local ->handle_scope_data_ ;
3733- Iterate (v, blocks_of_archived_thread, handle_data_of_archived_thread);
3734-
3732+ thread_local ->IterateThis (v);
37353733 return storage + ArchiveSpacePerThread ();
37363734}
37373735
0 commit comments