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

Side by Side Diff: runtime/vm/object.cc

Issue 1541073002: Implement safepointing of threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address-code-review-comments Created 4 years, 11 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 2779 matching lines...) Expand 10 before | Expand all | Expand 10 after
2790 2790
2791 private: 2791 private:
2792 const Class& cls_; 2792 const Class& cls_;
2793 DISALLOW_COPY_AND_ASSIGN(CHACodeArray); 2793 DISALLOW_COPY_AND_ASSIGN(CHACodeArray);
2794 }; 2794 };
2795 2795
2796 2796
2797 #if defined(DEBUG) 2797 #if defined(DEBUG)
2798 static bool IsMutatorOrAtSafepoint() { 2798 static bool IsMutatorOrAtSafepoint() {
2799 Thread* thread = Thread::Current(); 2799 Thread* thread = Thread::Current();
2800 return thread->IsMutatorThread() || 2800 return thread->IsMutatorThread() || thread->IsAtSafepoint();
2801 thread->isolate()->thread_registry()->AtSafepoint();
2802 } 2801 }
2803 #endif 2802 #endif
2804 2803
2805 2804
2806 void Class::RegisterCHACode(const Code& code) { 2805 void Class::RegisterCHACode(const Code& code) {
2807 if (FLAG_trace_cha) { 2806 if (FLAG_trace_cha) {
2808 THR_Print("RegisterCHACode '%s' depends on class '%s'\n", 2807 THR_Print("RegisterCHACode '%s' depends on class '%s'\n",
2809 Function::Handle(code.function()).ToQualifiedCString(), ToCString()); 2808 Function::Handle(code.function()).ToQualifiedCString(), ToCString());
2810 } 2809 }
2811 DEBUG_ASSERT(IsMutatorOrAtSafepoint()); 2810 DEBUG_ASSERT(IsMutatorOrAtSafepoint());
(...skipping 7947 matching lines...) Expand 10 before | Expand all | Expand 10 after
10759 // - invalidate dependent code of this prefix; 10758 // - invalidate dependent code of this prefix;
10760 // - mark this prefixes as loaded; 10759 // - mark this prefixes as loaded;
10761 // - complete the future associated with this prefix. 10760 // - complete the future associated with this prefix.
10762 const Library& deferred_lib = Library::Handle(GetLibrary(0)); 10761 const Library& deferred_lib = Library::Handle(GetLibrary(0));
10763 if (deferred_lib.Loaded()) { 10762 if (deferred_lib.Loaded()) {
10764 this->set_is_loaded(); 10763 this->set_is_loaded();
10765 return true; 10764 return true;
10766 } else if (deferred_lib.LoadNotStarted()) { 10765 } else if (deferred_lib.LoadNotStarted()) {
10767 Thread* thread = Thread::Current(); 10766 Thread* thread = Thread::Current();
10768 Isolate* isolate = thread->isolate(); 10767 Isolate* isolate = thread->isolate();
10769 Api::Scope api_scope(thread);
10770 Zone* zone = thread->zone(); 10768 Zone* zone = thread->zone();
10771 deferred_lib.SetLoadRequested(); 10769 deferred_lib.SetLoadRequested();
10772 const GrowableObjectArray& pending_deferred_loads = 10770 const GrowableObjectArray& pending_deferred_loads =
10773 GrowableObjectArray::Handle( 10771 GrowableObjectArray::Handle(
10774 isolate->object_store()->pending_deferred_loads()); 10772 isolate->object_store()->pending_deferred_loads());
10775 pending_deferred_loads.Add(deferred_lib); 10773 pending_deferred_loads.Add(deferred_lib);
10776 const String& lib_url = String::Handle(zone, deferred_lib.url()); 10774 const String& lib_url = String::Handle(zone, deferred_lib.url());
10777 Dart_LibraryTagHandler handler = isolate->library_tag_handler(); 10775 Dart_LibraryTagHandler handler = isolate->library_tag_handler();
10778 handler(Dart_kImportTag, 10776 {
10779 Api::NewHandle(thread, importer()), 10777 TransitionVMToNative transition(thread);
10780 Api::NewHandle(thread, lib_url.raw())); 10778 Api::Scope api_scope(thread);
10779 handler(Dart_kImportTag,
10780 Api::NewHandle(thread, importer()),
10781 Api::NewHandle(thread, lib_url.raw()));
10782 }
10781 } else { 10783 } else {
10782 // Another load request is in flight. 10784 // Another load request is in flight.
10783 ASSERT(deferred_lib.LoadRequested()); 10785 ASSERT(deferred_lib.LoadRequested());
10784 } 10786 }
10785 return false; // Load request not yet completed. 10787 return false; // Load request not yet completed.
10786 } 10788 }
10787 10789
10788 10790
10789 RawArray* LibraryPrefix::dependent_code() const { 10791 RawArray* LibraryPrefix::dependent_code() const {
10790 return raw_ptr()->dependent_code_; 10792 return raw_ptr()->dependent_code_;
(...skipping 11242 matching lines...) Expand 10 before | Expand all | Expand 10 after
22033 return tag_label.ToCString(); 22035 return tag_label.ToCString();
22034 } 22036 }
22035 22037
22036 22038
22037 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 22039 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
22038 Instance::PrintJSONImpl(stream, ref); 22040 Instance::PrintJSONImpl(stream, ref);
22039 } 22041 }
22040 22042
22041 22043
22042 } // namespace dart 22044 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698