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

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

Issue 2350633003: Add Dart_GetStickyError (Closed)
Patch Set: turnidge review Created 4 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
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 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 } 1460 }
1461 } 1461 }
1462 1462
1463 1463
1464 DART_EXPORT void Dart_SetStickyError(Dart_Handle error) { 1464 DART_EXPORT void Dart_SetStickyError(Dart_Handle error) {
1465 Thread* thread = Thread::Current(); 1465 Thread* thread = Thread::Current();
1466 DARTSCOPE(thread); 1466 DARTSCOPE(thread);
1467 Isolate* isolate = thread->isolate(); 1467 Isolate* isolate = thread->isolate();
1468 CHECK_ISOLATE(isolate); 1468 CHECK_ISOLATE(isolate);
1469 NoSafepointScope no_safepoint_scope; 1469 NoSafepointScope no_safepoint_scope;
1470 if (isolate->sticky_error() != Error::null()) { 1470 if ((isolate->sticky_error() != Error::null()) && !::Dart_IsNull(error)) {
1471 FATAL1("%s expects there to be no sticky error.", CURRENT_FUNC); 1471 FATAL1("%s expects there to be no sticky error.", CURRENT_FUNC);
1472 } 1472 }
1473 if (!::Dart_IsUnhandledExceptionError(error)) { 1473 if (!::Dart_IsUnhandledExceptionError(error) && !::Dart_IsNull(error)) {
1474 FATAL1("%s expects the error to be an unhandled exception error.", 1474 FATAL1("%s expects the error to be an unhandled exception error or null.",
1475 CURRENT_FUNC); 1475 CURRENT_FUNC);
1476 } 1476 }
1477 isolate->SetStickyError( 1477 isolate->SetStickyError(
1478 Api::UnwrapErrorHandle(Z, error).raw()); 1478 Api::UnwrapErrorHandle(Z, error).raw());
1479 } 1479 }
1480 1480
1481 1481
1482 DART_EXPORT bool Dart_HasStickyError() { 1482 DART_EXPORT bool Dart_HasStickyError() {
1483 Isolate* isolate = Isolate::Current(); 1483 Isolate* isolate = Isolate::Current();
1484 CHECK_ISOLATE(isolate); 1484 CHECK_ISOLATE(isolate);
1485 NoSafepointScope no_safepoint_scope; 1485 NoSafepointScope no_safepoint_scope;
1486 return isolate->sticky_error() != Error::null(); 1486 return isolate->sticky_error() != Error::null();
1487 } 1487 }
1488 1488
1489 1489
1490 DART_EXPORT Dart_Handle Dart_GetStickyError() {
1491 Isolate* I = Isolate::Current();
1492 CHECK_ISOLATE(I);
siva 2016/09/22 19:43:54 Other places we use the pattern Thread* T = Thre
1493 NoSafepointScope no_safepoint_scope;
1494 if (I->sticky_error() != Object::null()) {
siva 2016/09/22 19:43:54 if (I->sticky_error() != Error::null()) {
1495 Dart_Handle error =
1496 Api::NewHandle(Thread::Current(), I->sticky_error());
siva 2016/09/22 19:43:54 NewHandle(T, ...);
1497 return error;
1498 }
1499 return Dart_Null();
1500 }
1501
1502
1490 DART_EXPORT void Dart_ExitIsolate() { 1503 DART_EXPORT void Dart_ExitIsolate() {
1491 Thread* T = Thread::Current(); 1504 Thread* T = Thread::Current();
1492 CHECK_ISOLATE(T->isolate()); 1505 CHECK_ISOLATE(T->isolate());
1493 // The Thread structure is disassociated from the isolate, we do the 1506 // The Thread structure is disassociated from the isolate, we do the
1494 // safepoint transition explicity here instead of using the TransitionXXX 1507 // safepoint transition explicity here instead of using the TransitionXXX
1495 // scope objects as the original transition happened outside this scope in 1508 // scope objects as the original transition happened outside this scope in
1496 // Dart_EnterIsolate/Dart_CreateIsolate. 1509 // Dart_EnterIsolate/Dart_CreateIsolate.
1497 ASSERT(T->execution_state() == Thread::kThreadInNative); 1510 ASSERT(T->execution_state() == Thread::kThreadInNative);
1498 T->ExitSafepoint(); 1511 T->ExitSafepoint();
1499 T->set_execution_state(Thread::kThreadInVM); 1512 T->set_execution_state(Thread::kThreadInVM);
(...skipping 5100 matching lines...) Expand 10 before | Expand all | Expand 10 after
6600 6613
6601 DART_EXPORT bool Dart_IsPrecompiledRuntime() { 6614 DART_EXPORT bool Dart_IsPrecompiledRuntime() {
6602 #if defined(DART_PRECOMPILED_RUNTIME) 6615 #if defined(DART_PRECOMPILED_RUNTIME)
6603 return true; 6616 return true;
6604 #else 6617 #else
6605 return false; 6618 return false;
6606 #endif 6619 #endif
6607 } 6620 }
6608 6621
6609 } // namespace dart 6622 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698