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

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

Issue 1769183003: Fix sticky error propagation from thread to isolate (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: g Created 4 years, 9 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
« no previous file with comments | « no previous file | runtime/vm/isolate.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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "lib/stacktrace.h" 10 #include "lib/stacktrace.h"
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1598 static void RunLoopDone(uword param) { 1598 static void RunLoopDone(uword param) {
1599 RunLoopData* data = reinterpret_cast<RunLoopData*>(param); 1599 RunLoopData* data = reinterpret_cast<RunLoopData*>(param);
1600 ASSERT(data->monitor != NULL); 1600 ASSERT(data->monitor != NULL);
1601 MonitorLocker ml(data->monitor); 1601 MonitorLocker ml(data->monitor);
1602 data->done = true; 1602 data->done = true;
1603 ml.Notify(); 1603 ml.Notify();
1604 } 1604 }
1605 1605
1606 1606
1607 DART_EXPORT Dart_Handle Dart_RunLoop() { 1607 DART_EXPORT Dart_Handle Dart_RunLoop() {
1608 Thread* T = Thread::Current(); 1608 Isolate* I;
1609 Isolate* I = T->isolate(); 1609 {
1610 CHECK_API_SCOPE(T); 1610 Thread* T = Thread::Current();
1611 CHECK_CALLBACK_STATE(T); 1611 I = T->isolate();
1612 CHECK_API_SCOPE(T);
1613 CHECK_CALLBACK_STATE(T);
1614 }
1612 API_TIMELINE_BEGIN_END; 1615 API_TIMELINE_BEGIN_END;
1613 // The message handler run loop does not expect to have a current isolate 1616 // The message handler run loop does not expect to have a current isolate
1614 // so we exit the isolate here and enter it again after the runloop is done. 1617 // so we exit the isolate here and enter it again after the runloop is done.
1615 ::Dart_ExitIsolate(); 1618 ::Dart_ExitIsolate();
1616 { 1619 {
1617 Monitor monitor; 1620 Monitor monitor;
1618 MonitorLocker ml(&monitor); 1621 MonitorLocker ml(&monitor);
1619 RunLoopData data; 1622 RunLoopData data;
1620 data.monitor = &monitor; 1623 data.monitor = &monitor;
1621 data.done = false; 1624 data.done = false;
1622 I->message_handler()->Run( 1625 I->message_handler()->Run(
1623 Dart::thread_pool(), 1626 Dart::thread_pool(),
1624 NULL, RunLoopDone, reinterpret_cast<uword>(&data)); 1627 NULL, RunLoopDone, reinterpret_cast<uword>(&data));
1625 while (!data.done) { 1628 while (!data.done) {
1626 ml.Wait(); 1629 ml.Wait();
1627 } 1630 }
1628 } 1631 }
1629 ::Dart_EnterIsolate(Api::CastIsolate(I)); 1632 ::Dart_EnterIsolate(Api::CastIsolate(I));
1630 if (T->sticky_error() != Object::null()) { 1633 if (I->sticky_error() != Object::null()) {
1631 Dart_Handle error = Api::NewHandle(T, T->sticky_error()); 1634 Dart_Handle error =
1632 T->clear_sticky_error(); 1635 Api::NewHandle(Thread::Current(), I->sticky_error());
1636 I->clear_sticky_error();
1633 return error; 1637 return error;
1634 } 1638 }
1635 if (FLAG_print_class_table) { 1639 if (FLAG_print_class_table) {
1636 HANDLESCOPE(T); 1640 HANDLESCOPE(Thread::Current());
1637 I->class_table()->Print(); 1641 I->class_table()->Print();
1638 } 1642 }
1639 return Api::Success(); 1643 return Api::Success();
1640 } 1644 }
1641 1645
1642 1646
1643 DART_EXPORT Dart_Handle Dart_HandleMessage() { 1647 DART_EXPORT Dart_Handle Dart_HandleMessage() {
1644 Thread* T = Thread::Current(); 1648 Thread* T = Thread::Current();
1645 Isolate* I = T->isolate(); 1649 Isolate* I = T->isolate();
1646 CHECK_API_SCOPE(T); 1650 CHECK_API_SCOPE(T);
(...skipping 4547 matching lines...) Expand 10 before | Expand all | Expand 10 after
6194 return Api::Success(); 6198 return Api::Success();
6195 } 6199 }
6196 #endif // DART_PRECOMPILER 6200 #endif // DART_PRECOMPILER
6197 6201
6198 6202
6199 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { 6203 DART_EXPORT bool Dart_IsRunningPrecompiledCode() {
6200 return Dart::IsRunningPrecompiledCode(); 6204 return Dart::IsRunningPrecompiledCode();
6201 } 6205 }
6202 6206
6203 } // namespace dart 6207 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698