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

Side by Side Diff: src/api.cc

Issue 199021: Changed saved context stack to using direct pointers. Before we would... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 3 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/list.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 return i::HandleScope::CreateHandle(value); 420 return i::HandleScope::CreateHandle(value);
421 } 421 }
422 422
423 423
424 void Context::Enter() { 424 void Context::Enter() {
425 if (IsDeadCheck("v8::Context::Enter()")) return; 425 if (IsDeadCheck("v8::Context::Enter()")) return;
426 ENTER_V8; 426 ENTER_V8;
427 i::Handle<i::Context> env = Utils::OpenHandle(this); 427 i::Handle<i::Context> env = Utils::OpenHandle(this);
428 thread_local.EnterContext(env); 428 thread_local.EnterContext(env);
429 429
430 thread_local.SaveContext(i::GlobalHandles::Create(i::Top::context())); 430 thread_local.SaveContext(i::Top::context());
431 i::Top::set_context(*env); 431 i::Top::set_context(*env);
432 } 432 }
433 433
434 434
435 void Context::Exit() { 435 void Context::Exit() {
436 if (!i::V8::IsRunning()) return; 436 if (!i::V8::IsRunning()) return;
437 if (!ApiCheck(thread_local.LeaveLastContext(), 437 if (!ApiCheck(thread_local.LeaveLastContext(),
438 "v8::Context::Exit()", 438 "v8::Context::Exit()",
439 "Cannot exit non-entered context")) { 439 "Cannot exit non-entered context")) {
440 return; 440 return;
441 } 441 }
442 442
443 // Content of 'last_context' could be NULL. 443 // Content of 'last_context' could be NULL.
444 i::Handle<i::Object> last_context = thread_local.RestoreContext(); 444 i::Context* last_context = thread_local.RestoreContext();
445 i::Top::set_context(static_cast<i::Context*>(*last_context)); 445 i::Top::set_context(last_context);
446 i::GlobalHandles::Destroy(last_context.location());
447 } 446 }
448 447
449 448
450 void Context::SetData(v8::Handle<Value> data) { 449 void Context::SetData(v8::Handle<Value> data) {
451 if (IsDeadCheck("v8::Context::SetData()")) return; 450 if (IsDeadCheck("v8::Context::SetData()")) return;
452 ENTER_V8; 451 ENTER_V8;
453 { 452 {
454 HandleScope scope; 453 HandleScope scope;
455 i::Handle<i::Context> env = Utils::OpenHandle(this); 454 i::Handle<i::Context> env = Utils::OpenHandle(this);
456 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data); 455 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
(...skipping 3236 matching lines...) Expand 10 before | Expand all | Expand 10 after
3693 } 3692 }
3694 3693
3695 3694
3696 char* HandleScopeImplementer::RestoreThreadHelper(char* storage) { 3695 char* HandleScopeImplementer::RestoreThreadHelper(char* storage) {
3697 memcpy(this, storage, sizeof(*this)); 3696 memcpy(this, storage, sizeof(*this));
3698 *v8::ImplementationUtilities::CurrentHandleScope() = handle_scope_data_; 3697 *v8::ImplementationUtilities::CurrentHandleScope() = handle_scope_data_;
3699 return storage + ArchiveSpacePerThread(); 3698 return storage + ArchiveSpacePerThread();
3700 } 3699 }
3701 3700
3702 3701
3703 void HandleScopeImplementer::Iterate( 3702 void HandleScopeImplementer::IterateThis(ObjectVisitor* v) {
3704 ObjectVisitor* v,
3705 List<i::Object**>* blocks,
3706 v8::ImplementationUtilities::HandleScopeData* handle_data) {
3707 // Iterate over all handles in the blocks except for the last. 3703 // Iterate over all handles in the blocks except for the last.
3708 for (int i = blocks->length() - 2; i >= 0; --i) { 3704 for (int i = Blocks()->length() - 2; i >= 0; --i) {
3709 Object** block = blocks->at(i); 3705 Object** block = Blocks()->at(i);
3710 v->VisitPointers(block, &block[kHandleBlockSize]); 3706 v->VisitPointers(block, &block[kHandleBlockSize]);
3711 } 3707 }
3712 3708
3713 // Iterate over live handles in the last block (if any). 3709 // Iterate over live handles in the last block (if any).
3714 if (!blocks->is_empty()) { 3710 if (!Blocks()->is_empty()) {
3715 v->VisitPointers(blocks->last(), handle_data->next); 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());
3716 } 3717 }
3717 } 3718 }
3718 3719
3719 3720
3720 void HandleScopeImplementer::Iterate(ObjectVisitor* v) { 3721 void HandleScopeImplementer::Iterate(ObjectVisitor* v) {
3721 v8::ImplementationUtilities::HandleScopeData* current = 3722 v8::ImplementationUtilities::HandleScopeData* current =
3722 v8::ImplementationUtilities::CurrentHandleScope(); 3723 v8::ImplementationUtilities::CurrentHandleScope();
3723 Iterate(v, thread_local.Blocks(), current); 3724 thread_local.handle_scope_data_ = *current;
3725 thread_local.IterateThis(v);
3724 } 3726 }
3725 3727
3726 3728
3727 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 3729 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
3728 HandleScopeImplementer* thread_local = 3730 HandleScopeImplementer* thread_local =
3729 reinterpret_cast<HandleScopeImplementer*>(storage); 3731 reinterpret_cast<HandleScopeImplementer*>(storage);
3730 List<internal::Object**>* blocks_of_archived_thread = thread_local->Blocks(); 3732 thread_local->IterateThis(v);
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
3735 return storage + ArchiveSpacePerThread(); 3733 return storage + ArchiveSpacePerThread();
3736 } 3734 }
3737 3735
3738 } } // namespace v8::internal 3736 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698