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

Side by Side Diff: src/api.cc

Issue 6993061: Clean up a few TODO(isolates). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 6 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 | « no previous file | src/heap-inl.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 (isolate)->is_out_of_memory()) { \ 90 (isolate)->is_out_of_memory()) { \
91 if (!handle_scope_implementer->ignore_out_of_memory()) \ 91 if (!handle_scope_implementer->ignore_out_of_memory()) \
92 i::V8::FatalProcessOutOfMemory(NULL); \ 92 i::V8::FatalProcessOutOfMemory(NULL); \
93 } \ 93 } \
94 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ 94 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \
95 (isolate)->OptionalRescheduleException(call_depth_is_zero); \ 95 (isolate)->OptionalRescheduleException(call_depth_is_zero); \
96 return value; \ 96 return value; \
97 } \ 97 } \
98 } while (false) 98 } while (false)
99 99
100 // TODO(isolates): Add a parameter to this macro for an isolate.
101 100
102 #define API_ENTRY_CHECK(msg) \ 101 #define API_ENTRY_CHECK(isolate, msg) \
103 do { \ 102 do { \
104 if (v8::Locker::IsActive()) { \ 103 if (v8::Locker::IsActive()) { \
105 ApiCheck(i::Isolate::Current()->thread_manager()-> \ 104 ApiCheck(isolate->thread_manager()-> IsLockedByCurrentThread(), \
106 IsLockedByCurrentThread(), \
107 msg, \ 105 msg, \
108 "Entering the V8 API without proper locking in place"); \ 106 "Entering the V8 API without proper locking in place"); \
109 } \ 107 } \
110 } while (false) 108 } while (false)
111 109
112 110
113 // --- E x c e p t i o n B e h a v i o r --- 111 // --- E x c e p t i o n B e h a v i o r ---
114 112
115 113
116 static void DefaultFatalErrorHandler(const char* location, 114 static void DefaultFatalErrorHandler(const char* location,
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 i::Isolate* isolate = i::Isolate::Current(); 564 i::Isolate* isolate = i::Isolate::Current();
567 LOG_API(isolate, "DisposeGlobal"); 565 LOG_API(isolate, "DisposeGlobal");
568 if (!isolate->IsInitialized()) return; 566 if (!isolate->IsInitialized()) return;
569 isolate->global_handles()->Destroy(obj); 567 isolate->global_handles()->Destroy(obj);
570 } 568 }
571 569
572 // --- H a n d l e s --- 570 // --- H a n d l e s ---
573 571
574 572
575 HandleScope::HandleScope() { 573 HandleScope::HandleScope() {
576 API_ENTRY_CHECK("HandleScope::HandleScope");
577 i::Isolate* isolate = i::Isolate::Current(); 574 i::Isolate* isolate = i::Isolate::Current();
575 API_ENTRY_CHECK(isolate, "HandleScope::HandleScope");
578 v8::ImplementationUtilities::HandleScopeData* current = 576 v8::ImplementationUtilities::HandleScopeData* current =
579 isolate->handle_scope_data(); 577 isolate->handle_scope_data();
580 isolate_ = isolate; 578 isolate_ = isolate;
581 prev_next_ = current->next; 579 prev_next_ = current->next;
582 prev_limit_ = current->limit; 580 prev_limit_ = current->limit;
583 is_closed_ = false; 581 is_closed_ = false;
584 current->level++; 582 current->level++;
585 } 583 }
586 584
587 585
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 621
624 622
625 i::Object** HandleScope::CreateHandle(i::HeapObject* value) { 623 i::Object** HandleScope::CreateHandle(i::HeapObject* value) {
626 ASSERT(value->IsHeapObject()); 624 ASSERT(value->IsHeapObject());
627 return reinterpret_cast<i::Object**>( 625 return reinterpret_cast<i::Object**>(
628 i::HandleScope::CreateHandle(value, value->GetIsolate())); 626 i::HandleScope::CreateHandle(value, value->GetIsolate()));
629 } 627 }
630 628
631 629
632 void Context::Enter() { 630 void Context::Enter() {
633 // TODO(isolates): Context should have a pointer to isolate. 631 i::Handle<i::Context> env = Utils::OpenHandle(this);
634 i::Isolate* isolate = i::Isolate::Current(); 632 i::Isolate* isolate = env->GetIsolate();
635 if (IsDeadCheck(isolate, "v8::Context::Enter()")) return; 633 if (IsDeadCheck(isolate, "v8::Context::Enter()")) return;
636 ENTER_V8(isolate); 634 ENTER_V8(isolate);
637 635
638 i::Handle<i::Context> env = Utils::OpenHandle(this);
639 isolate->handle_scope_implementer()->EnterContext(env); 636 isolate->handle_scope_implementer()->EnterContext(env);
640 637
641 isolate->handle_scope_implementer()->SaveContext(isolate->context()); 638 isolate->handle_scope_implementer()->SaveContext(isolate->context());
642 isolate->set_context(*env); 639 isolate->set_context(*env);
643 } 640 }
644 641
645 642
646 void Context::Exit() { 643 void Context::Exit() {
647 // TODO(isolates): Context should have a pointer to isolate. 644 i::Handle<i::Context> env = Utils::OpenHandle(this);
648 i::Isolate* isolate = i::Isolate::Current(); 645 i::Isolate* isolate = env->GetIsolate();
649 if (!isolate->IsInitialized()) return; 646 if (!isolate->IsInitialized()) return;
650 647
651 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveLastContext(), 648 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveLastContext(),
652 "v8::Context::Exit()", 649 "v8::Context::Exit()",
653 "Cannot exit non-entered context")) { 650 "Cannot exit non-entered context")) {
654 return; 651 return;
655 } 652 }
656 653
657 // Content of 'last_context' could be NULL. 654 // Content of 'last_context' could be NULL.
658 i::Context* last_context = 655 i::Context* last_context =
659 isolate->handle_scope_implementer()->RestoreContext(); 656 isolate->handle_scope_implementer()->RestoreContext();
660 isolate->set_context(last_context); 657 isolate->set_context(last_context);
661 } 658 }
662 659
663 660
664 void Context::SetData(v8::Handle<String> data) { 661 void Context::SetData(v8::Handle<String> data) {
665 // TODO(isolates): Context should have a pointer to isolate. 662 i::Handle<i::Context> env = Utils::OpenHandle(this);
666 i::Isolate* isolate = i::Isolate::Current(); 663 i::Isolate* isolate = env->GetIsolate();
667 if (IsDeadCheck(isolate, "v8::Context::SetData()")) return; 664 if (IsDeadCheck(isolate, "v8::Context::SetData()")) return;
668 ENTER_V8(isolate); 665 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
669 { 666 ASSERT(env->IsGlobalContext());
670 i::HandleScope scope(isolate); 667 if (env->IsGlobalContext()) {
671 i::Handle<i::Context> env = Utils::OpenHandle(this); 668 env->set_data(*raw_data);
672 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data);
673 ASSERT(env->IsGlobalContext());
674 if (env->IsGlobalContext()) {
675 env->set_data(*raw_data);
676 }
677 } 669 }
678 } 670 }
679 671
680 672
681 v8::Local<v8::Value> Context::GetData() { 673 v8::Local<v8::Value> Context::GetData() {
682 // TODO(isolates): Context should have a pointer to isolate. 674 i::Handle<i::Context> env = Utils::OpenHandle(this);
683 i::Isolate* isolate = i::Isolate::Current(); 675 i::Isolate* isolate = env->GetIsolate();
684 if (IsDeadCheck(isolate, "v8::Context::GetData()")) { 676 if (IsDeadCheck(isolate, "v8::Context::GetData()")) {
685 return v8::Local<Value>(); 677 return v8::Local<Value>();
686 } 678 }
687 ENTER_V8(isolate);
688 i::Object* raw_result = NULL; 679 i::Object* raw_result = NULL;
689 { 680 ASSERT(env->IsGlobalContext());
690 i::HandleScope scope(isolate); 681 if (env->IsGlobalContext()) {
691 i::Handle<i::Context> env = Utils::OpenHandle(this); 682 raw_result = env->data();
692 ASSERT(env->IsGlobalContext()); 683 } else {
693 if (env->IsGlobalContext()) { 684 return Local<Value>();
694 raw_result = env->data();
695 } else {
696 return Local<Value>();
697 }
698 } 685 }
699 i::Handle<i::Object> result(raw_result); 686 i::Handle<i::Object> result(raw_result, isolate);
700 return Utils::ToLocal(result); 687 return Utils::ToLocal(result);
701 } 688 }
702 689
703 690
704 i::Object** v8::HandleScope::RawClose(i::Object** value) { 691 i::Object** v8::HandleScope::RawClose(i::Object** value) {
705 if (!ApiCheck(!is_closed_, 692 if (!ApiCheck(!is_closed_,
706 "v8::HandleScope::Close()", 693 "v8::HandleScope::Close()",
707 "Local scope has already been closed")) { 694 "Local scope has already been closed")) {
708 return 0; 695 return 0;
709 } 696 }
(...skipping 4097 matching lines...) Expand 10 before | Expand all | Expand 10 after
4807 int V8::GetCurrentThreadId() { 4794 int V8::GetCurrentThreadId() {
4808 i::Isolate* isolate = i::Isolate::Current(); 4795 i::Isolate* isolate = i::Isolate::Current();
4809 EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()"); 4796 EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()");
4810 return isolate->thread_id().ToInteger(); 4797 return isolate->thread_id().ToInteger();
4811 } 4798 }
4812 4799
4813 4800
4814 void V8::TerminateExecution(int thread_id) { 4801 void V8::TerminateExecution(int thread_id) {
4815 i::Isolate* isolate = i::Isolate::Current(); 4802 i::Isolate* isolate = i::Isolate::Current();
4816 if (!isolate->IsInitialized()) return; 4803 if (!isolate->IsInitialized()) return;
4817 API_ENTRY_CHECK("V8::TerminateExecution()"); 4804 API_ENTRY_CHECK(isolate, "V8::TerminateExecution()");
4818 // If the thread_id identifies the current thread just terminate 4805 // If the thread_id identifies the current thread just terminate
4819 // execution right away. Otherwise, ask the thread manager to 4806 // execution right away. Otherwise, ask the thread manager to
4820 // terminate the thread with the given id if any. 4807 // terminate the thread with the given id if any.
4821 i::ThreadId internal_tid = i::ThreadId::FromInteger(thread_id); 4808 i::ThreadId internal_tid = i::ThreadId::FromInteger(thread_id);
4822 if (isolate->thread_id().Equals(internal_tid)) { 4809 if (isolate->thread_id().Equals(internal_tid)) {
4823 isolate->stack_guard()->TerminateExecution(); 4810 isolate->stack_guard()->TerminateExecution();
4824 } else { 4811 } else {
4825 isolate->thread_manager()->TerminateExecution(internal_tid); 4812 isolate->thread_manager()->TerminateExecution(internal_tid);
4826 } 4813 }
4827 } 4814 }
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
6028 6015
6029 6016
6030 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 6017 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
6031 HandleScopeImplementer* scope_implementer = 6018 HandleScopeImplementer* scope_implementer =
6032 reinterpret_cast<HandleScopeImplementer*>(storage); 6019 reinterpret_cast<HandleScopeImplementer*>(storage);
6033 scope_implementer->IterateThis(v); 6020 scope_implementer->IterateThis(v);
6034 return storage + ArchiveSpacePerThread(); 6021 return storage + ArchiveSpacePerThread();
6035 } 6022 }
6036 6023
6037 } } // namespace v8::internal 6024 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698