| 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 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| 852 } | 852 } |
| 853 if (thread->top_exit_frame_info() == 0) { | 853 if (thread->top_exit_frame_info() == 0) { |
| 854 // There are no dart frames on the stack so it would be illegal to | 854 // There are no dart frames on the stack so it would be illegal to |
| 855 // propagate an error here. | 855 // propagate an error here. |
| 856 return Api::NewError("No Dart frames on stack, cannot propagate error."); | 856 return Api::NewError("No Dart frames on stack, cannot propagate error."); |
| 857 } | 857 } |
| 858 | 858 |
| 859 TransitionNativeToVM transition(thread); |
| 859 // Unwind all the API scopes till the exit frame before propagating. | 860 // Unwind all the API scopes till the exit frame before propagating. |
| 860 const Error* error; | 861 const Error* error; |
| 861 { | 862 { |
| 862 // We need to preserve the error object across the destruction of zones | 863 // We need to preserve the error object across the destruction of zones |
| 863 // when the ApiScopes are unwound. By using NoSafepointScope, we can ensure | 864 // when the ApiScopes are unwound. By using NoSafepointScope, we can ensure |
| 864 // that GC won't touch the raw error object before creating a valid | 865 // that GC won't touch the raw error object before creating a valid |
| 865 // handle for it in the surviving zone. | 866 // handle for it in the surviving zone. |
| 866 NoSafepointScope no_safepoint; | 867 NoSafepointScope no_safepoint; |
| 867 RawError* raw_error = Api::UnwrapErrorHandle(thread->zone(), handle).raw(); | 868 RawError* raw_error = Api::UnwrapErrorHandle(thread->zone(), handle).raw(); |
| 868 thread->UnwindScopes(thread->top_exit_frame_info()); | 869 thread->UnwindScopes(thread->top_exit_frame_info()); |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 return Api::Success(); | 1562 return Api::Success(); |
| 1562 } | 1563 } |
| 1563 | 1564 |
| 1564 | 1565 |
| 1565 DART_EXPORT Dart_Handle Dart_HandleMessage() { | 1566 DART_EXPORT Dart_Handle Dart_HandleMessage() { |
| 1566 Thread* T = Thread::Current(); | 1567 Thread* T = Thread::Current(); |
| 1567 Isolate* I = T->isolate(); | 1568 Isolate* I = T->isolate(); |
| 1568 CHECK_API_SCOPE(T); | 1569 CHECK_API_SCOPE(T); |
| 1569 CHECK_CALLBACK_STATE(T); | 1570 CHECK_CALLBACK_STATE(T); |
| 1570 API_TIMELINE_BEGIN_END; | 1571 API_TIMELINE_BEGIN_END; |
| 1571 TransitionNativeToVM trainsition(T); | 1572 TransitionNativeToVM transition(T); |
| 1572 if (I->message_handler()->HandleNextMessage() != MessageHandler::kOK) { | 1573 if (I->message_handler()->HandleNextMessage() != MessageHandler::kOK) { |
| 1573 Dart_Handle error = Api::NewHandle(T, I->object_store()->sticky_error()); | 1574 Dart_Handle error = Api::NewHandle(T, I->object_store()->sticky_error()); |
| 1574 I->object_store()->clear_sticky_error(); | 1575 I->object_store()->clear_sticky_error(); |
| 1575 return error; | 1576 return error; |
| 1576 } | 1577 } |
| 1577 return Api::Success(); | 1578 return Api::Success(); |
| 1578 } | 1579 } |
| 1579 | 1580 |
| 1580 | 1581 |
| 1581 DART_EXPORT bool Dart_HandleServiceMessages() { | 1582 DART_EXPORT bool Dart_HandleServiceMessages() { |
| 1582 Thread* T = Thread::Current(); | 1583 Thread* T = Thread::Current(); |
| 1583 Isolate* I = T->isolate(); | 1584 Isolate* I = T->isolate(); |
| 1584 CHECK_API_SCOPE(T); | 1585 CHECK_API_SCOPE(T); |
| 1585 CHECK_CALLBACK_STATE(T); | 1586 CHECK_CALLBACK_STATE(T); |
| 1586 API_TIMELINE_DURATION; | 1587 API_TIMELINE_DURATION; |
| 1587 TransitionNativeToVM trainsition(T); | 1588 TransitionNativeToVM transition(T); |
| 1588 ASSERT(I->GetAndClearResumeRequest() == false); | 1589 ASSERT(I->GetAndClearResumeRequest() == false); |
| 1589 MessageHandler::MessageStatus status = | 1590 MessageHandler::MessageStatus status = |
| 1590 I->message_handler()->HandleOOBMessages(); | 1591 I->message_handler()->HandleOOBMessages(); |
| 1591 bool resume = I->GetAndClearResumeRequest(); | 1592 bool resume = I->GetAndClearResumeRequest(); |
| 1592 return (status != MessageHandler::kOK) || resume; | 1593 return (status != MessageHandler::kOK) || resume; |
| 1593 } | 1594 } |
| 1594 | 1595 |
| 1595 | 1596 |
| 1596 DART_EXPORT bool Dart_HasServiceMessages() { | 1597 DART_EXPORT bool Dart_HasServiceMessages() { |
| 1597 Isolate* isolate = Isolate::Current(); | 1598 Isolate* isolate = Isolate::Current(); |
| (...skipping 2816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4414 if (excp.IsNull()) { | 4415 if (excp.IsNull()) { |
| 4415 RETURN_TYPE_ERROR(zone, exception, Instance); | 4416 RETURN_TYPE_ERROR(zone, exception, Instance); |
| 4416 } | 4417 } |
| 4417 } | 4418 } |
| 4418 if (thread->top_exit_frame_info() == 0) { | 4419 if (thread->top_exit_frame_info() == 0) { |
| 4419 // There are no dart frames on the stack so it would be illegal to | 4420 // There are no dart frames on the stack so it would be illegal to |
| 4420 // throw an exception here. | 4421 // throw an exception here. |
| 4421 return Api::NewError("No Dart frames on stack, cannot throw exception"); | 4422 return Api::NewError("No Dart frames on stack, cannot throw exception"); |
| 4422 } | 4423 } |
| 4423 | 4424 |
| 4425 TransitionNativeToVM transition(thread); |
| 4424 // Unwind all the API scopes till the exit frame before throwing an | 4426 // Unwind all the API scopes till the exit frame before throwing an |
| 4425 // exception. | 4427 // exception. |
| 4426 const Instance* saved_exception; | 4428 const Instance* saved_exception; |
| 4427 { | 4429 { |
| 4428 NoSafepointScope no_safepoint; | 4430 NoSafepointScope no_safepoint; |
| 4429 RawInstance* raw_exception = | 4431 RawInstance* raw_exception = |
| 4430 Api::UnwrapInstanceHandle(zone, exception).raw(); | 4432 Api::UnwrapInstanceHandle(zone, exception).raw(); |
| 4431 thread->UnwindScopes(thread->top_exit_frame_info()); | 4433 thread->UnwindScopes(thread->top_exit_frame_info()); |
| 4432 saved_exception = &Instance::Handle(raw_exception); | 4434 saved_exception = &Instance::Handle(raw_exception); |
| 4433 } | 4435 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4452 if (stk.IsNull()) { | 4454 if (stk.IsNull()) { |
| 4453 RETURN_TYPE_ERROR(zone, stacktrace, Instance); | 4455 RETURN_TYPE_ERROR(zone, stacktrace, Instance); |
| 4454 } | 4456 } |
| 4455 } | 4457 } |
| 4456 if (thread->top_exit_frame_info() == 0) { | 4458 if (thread->top_exit_frame_info() == 0) { |
| 4457 // There are no dart frames on the stack so it would be illegal to | 4459 // There are no dart frames on the stack so it would be illegal to |
| 4458 // throw an exception here. | 4460 // throw an exception here. |
| 4459 return Api::NewError("No Dart frames on stack, cannot throw exception"); | 4461 return Api::NewError("No Dart frames on stack, cannot throw exception"); |
| 4460 } | 4462 } |
| 4461 | 4463 |
| 4464 TransitionNativeToVM transition(thread); |
| 4462 // Unwind all the API scopes till the exit frame before throwing an | 4465 // Unwind all the API scopes till the exit frame before throwing an |
| 4463 // exception. | 4466 // exception. |
| 4464 const Instance* saved_exception; | 4467 const Instance* saved_exception; |
| 4465 const Stacktrace* saved_stacktrace; | 4468 const Stacktrace* saved_stacktrace; |
| 4466 { | 4469 { |
| 4467 NoSafepointScope no_safepoint; | 4470 NoSafepointScope no_safepoint; |
| 4468 RawInstance* raw_exception = | 4471 RawInstance* raw_exception = |
| 4469 Api::UnwrapInstanceHandle(zone, exception).raw(); | 4472 Api::UnwrapInstanceHandle(zone, exception).raw(); |
| 4470 RawStacktrace* raw_stacktrace = | 4473 RawStacktrace* raw_stacktrace = |
| 4471 Api::UnwrapStacktraceHandle(zone, stacktrace).raw(); | 4474 Api::UnwrapStacktraceHandle(zone, stacktrace).raw(); |
| (...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6012 return Api::Success(); | 6015 return Api::Success(); |
| 6013 } | 6016 } |
| 6014 #endif // DART_PRECOMPILED_RUNTIME | 6017 #endif // DART_PRECOMPILED_RUNTIME |
| 6015 | 6018 |
| 6016 | 6019 |
| 6017 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { | 6020 DART_EXPORT bool Dart_IsRunningPrecompiledCode() { |
| 6018 return Dart::IsRunningPrecompiledCode(); | 6021 return Dart::IsRunningPrecompiledCode(); |
| 6019 } | 6022 } |
| 6020 | 6023 |
| 6021 } // namespace dart | 6024 } // namespace dart |
| OLD | NEW |