Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 831 obj = Api::UnwrapInstanceHandle(Z, exception).raw(); | 831 obj = Api::UnwrapInstanceHandle(Z, exception).raw(); |
| 832 if (obj.IsNull()) { | 832 if (obj.IsNull()) { |
| 833 RETURN_TYPE_ERROR(Z, exception, Instance); | 833 RETURN_TYPE_ERROR(Z, exception, Instance); |
| 834 } | 834 } |
| 835 } | 835 } |
| 836 const Stacktrace& stacktrace = Stacktrace::Handle(Z); | 836 const Stacktrace& stacktrace = Stacktrace::Handle(Z); |
| 837 return Api::NewHandle(T, UnhandledException::New(obj, stacktrace)); | 837 return Api::NewHandle(T, UnhandledException::New(obj, stacktrace)); |
| 838 } | 838 } |
| 839 | 839 |
| 840 | 840 |
| 841 DART_EXPORT Dart_Handle Dart_PropagateError(Dart_Handle handle) { | 841 DART_EXPORT Dart_Handle Dart_PropagateError(Dart_Handle handle) { |
|
rmacnak
2016/02/01 23:38:00
Here too.
| |
| 842 Thread* thread = Thread::Current(); | 842 Thread* thread = Thread::Current(); |
| 843 { | 843 { |
| 844 const Object& obj = Object::Handle(thread->zone(), | 844 const Object& obj = Object::Handle(thread->zone(), |
| 845 Api::UnwrapHandle(handle)); | 845 Api::UnwrapHandle(handle)); |
| 846 if (!obj.IsError()) { | 846 if (!obj.IsError()) { |
| 847 return Api::NewError( | 847 return Api::NewError( |
| 848 "%s expects argument 'handle' to be an error handle. " | 848 "%s expects argument 'handle' to be an error handle. " |
| 849 "Did you forget to check Dart_IsError first?", | 849 "Did you forget to check Dart_IsError first?", |
| 850 CURRENT_FUNC); | 850 CURRENT_FUNC); |
| 851 } | 851 } |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1561 return Api::Success(); | 1561 return Api::Success(); |
| 1562 } | 1562 } |
| 1563 | 1563 |
| 1564 | 1564 |
| 1565 DART_EXPORT Dart_Handle Dart_HandleMessage() { | 1565 DART_EXPORT Dart_Handle Dart_HandleMessage() { |
| 1566 Thread* T = Thread::Current(); | 1566 Thread* T = Thread::Current(); |
| 1567 Isolate* I = T->isolate(); | 1567 Isolate* I = T->isolate(); |
| 1568 CHECK_API_SCOPE(T); | 1568 CHECK_API_SCOPE(T); |
| 1569 CHECK_CALLBACK_STATE(T); | 1569 CHECK_CALLBACK_STATE(T); |
| 1570 API_TIMELINE_BEGIN_END; | 1570 API_TIMELINE_BEGIN_END; |
| 1571 TransitionNativeToVM trainsition(T); | 1571 TransitionNativeToVM transition(T); |
| 1572 if (I->message_handler()->HandleNextMessage() != MessageHandler::kOK) { | 1572 if (I->message_handler()->HandleNextMessage() != MessageHandler::kOK) { |
| 1573 Dart_Handle error = Api::NewHandle(T, I->object_store()->sticky_error()); | 1573 Dart_Handle error = Api::NewHandle(T, I->object_store()->sticky_error()); |
| 1574 I->object_store()->clear_sticky_error(); | 1574 I->object_store()->clear_sticky_error(); |
| 1575 return error; | 1575 return error; |
| 1576 } | 1576 } |
| 1577 return Api::Success(); | 1577 return Api::Success(); |
| 1578 } | 1578 } |
| 1579 | 1579 |
| 1580 | 1580 |
| 1581 DART_EXPORT bool Dart_HandleServiceMessages() { | 1581 DART_EXPORT bool Dart_HandleServiceMessages() { |
| 1582 Thread* T = Thread::Current(); | 1582 Thread* T = Thread::Current(); |
| 1583 Isolate* I = T->isolate(); | 1583 Isolate* I = T->isolate(); |
| 1584 CHECK_API_SCOPE(T); | 1584 CHECK_API_SCOPE(T); |
| 1585 CHECK_CALLBACK_STATE(T); | 1585 CHECK_CALLBACK_STATE(T); |
| 1586 API_TIMELINE_DURATION; | 1586 API_TIMELINE_DURATION; |
| 1587 TransitionNativeToVM trainsition(T); | 1587 TransitionNativeToVM transition(T); |
| 1588 ASSERT(I->GetAndClearResumeRequest() == false); | 1588 ASSERT(I->GetAndClearResumeRequest() == false); |
| 1589 MessageHandler::MessageStatus status = | 1589 MessageHandler::MessageStatus status = |
| 1590 I->message_handler()->HandleOOBMessages(); | 1590 I->message_handler()->HandleOOBMessages(); |
| 1591 bool resume = I->GetAndClearResumeRequest(); | 1591 bool resume = I->GetAndClearResumeRequest(); |
| 1592 return (status != MessageHandler::kOK) || resume; | 1592 return (status != MessageHandler::kOK) || resume; |
| 1593 } | 1593 } |
| 1594 | 1594 |
| 1595 | 1595 |
| 1596 DART_EXPORT bool Dart_HasServiceMessages() { | 1596 DART_EXPORT bool Dart_HasServiceMessages() { |
| 1597 Isolate* isolate = Isolate::Current(); | 1597 Isolate* isolate = Isolate::Current(); |
| (...skipping 2816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4414 if (excp.IsNull()) { | 4414 if (excp.IsNull()) { |
| 4415 RETURN_TYPE_ERROR(zone, exception, Instance); | 4415 RETURN_TYPE_ERROR(zone, exception, Instance); |
| 4416 } | 4416 } |
| 4417 } | 4417 } |
| 4418 if (thread->top_exit_frame_info() == 0) { | 4418 if (thread->top_exit_frame_info() == 0) { |
| 4419 // There are no dart frames on the stack so it would be illegal to | 4419 // There are no dart frames on the stack so it would be illegal to |
| 4420 // throw an exception here. | 4420 // throw an exception here. |
| 4421 return Api::NewError("No Dart frames on stack, cannot throw exception"); | 4421 return Api::NewError("No Dart frames on stack, cannot throw exception"); |
| 4422 } | 4422 } |
| 4423 | 4423 |
| 4424 TransitionNativeToVM transition(thread); | |
| 4424 // Unwind all the API scopes till the exit frame before throwing an | 4425 // Unwind all the API scopes till the exit frame before throwing an |
| 4425 // exception. | 4426 // exception. |
| 4426 const Instance* saved_exception; | 4427 const Instance* saved_exception; |
| 4427 { | 4428 { |
| 4428 NoSafepointScope no_safepoint; | 4429 NoSafepointScope no_safepoint; |
| 4429 RawInstance* raw_exception = | 4430 RawInstance* raw_exception = |
| 4430 Api::UnwrapInstanceHandle(zone, exception).raw(); | 4431 Api::UnwrapInstanceHandle(zone, exception).raw(); |
| 4431 thread->UnwindScopes(thread->top_exit_frame_info()); | 4432 thread->UnwindScopes(thread->top_exit_frame_info()); |
| 4432 saved_exception = &Instance::Handle(raw_exception); | 4433 saved_exception = &Instance::Handle(raw_exception); |
| 4433 } | 4434 } |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 4452 if (stk.IsNull()) { | 4453 if (stk.IsNull()) { |
| 4453 RETURN_TYPE_ERROR(zone, stacktrace, Instance); | 4454 RETURN_TYPE_ERROR(zone, stacktrace, Instance); |
| 4454 } | 4455 } |
| 4455 } | 4456 } |
| 4456 if (thread->top_exit_frame_info() == 0) { | 4457 if (thread->top_exit_frame_info() == 0) { |
| 4457 // There are no dart frames on the stack so it would be illegal to | 4458 // There are no dart frames on the stack so it would be illegal to |
| 4458 // throw an exception here. | 4459 // throw an exception here. |
| 4459 return Api::NewError("No Dart frames on stack, cannot throw exception"); | 4460 return Api::NewError("No Dart frames on stack, cannot throw exception"); |
| 4460 } | 4461 } |
| 4461 | 4462 |
| 4463 TransitionNativeToVM transition(thread); | |
| 4462 // Unwind all the API scopes till the exit frame before throwing an | 4464 // Unwind all the API scopes till the exit frame before throwing an |
| 4463 // exception. | 4465 // exception. |
| 4464 const Instance* saved_exception; | 4466 const Instance* saved_exception; |
| 4465 const Stacktrace* saved_stacktrace; | 4467 const Stacktrace* saved_stacktrace; |
| 4466 { | 4468 { |
| 4467 NoSafepointScope no_safepoint; | 4469 NoSafepointScope no_safepoint; |
| 4468 RawInstance* raw_exception = | 4470 RawInstance* raw_exception = |
| 4469 Api::UnwrapInstanceHandle(zone, exception).raw(); | 4471 Api::UnwrapInstanceHandle(zone, exception).raw(); |
| 4470 RawStacktrace* raw_stacktrace = | 4472 RawStacktrace* raw_stacktrace = |
| 4471 Api::UnwrapStacktraceHandle(zone, stacktrace).raw(); | 4473 Api::UnwrapStacktraceHandle(zone, stacktrace).raw(); |
| (...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6012 return Api::Success(); | 6014 return Api::Success(); |
| 6013 } | 6015 } |
| 6014 #endif // DART_PRECOMPILED_RUNTIME | 6016 #endif // DART_PRECOMPILED_RUNTIME |
| 6015 | 6017 |
| 6016 | 6018 |
| 6017 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { | 6019 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { |
| 6018 return Dart::IsRunningPrecompiledCode(); | 6020 return Dart::IsRunningPrecompiledCode(); |
| 6019 } | 6021 } |
| 6020 | 6022 |
| 6021 } // namespace dart | 6023 } // namespace dart |
| OLD | NEW |