OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 6689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6700 return Just(true); | 6700 return Just(true); |
6701 } | 6701 } |
6702 | 6702 |
6703 | 6703 |
6704 void Promise::Resolver::Reject(Local<Value> value) { | 6704 void Promise::Resolver::Reject(Local<Value> value) { |
6705 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | 6705 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); |
6706 USE(Reject(context, value)); | 6706 USE(Reject(context, value)); |
6707 } | 6707 } |
6708 | 6708 |
6709 | 6709 |
6710 namespace { | |
6711 | |
6712 MaybeLocal<Promise> DoChain(Value* value, Local<Context> context, | |
6713 Local<Function> handler) { | |
6714 PREPARE_FOR_EXECUTION(context, Promise, Chain, Promise); | |
6715 auto self = Utils::OpenHandle(value); | |
6716 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*handler)}; | |
6717 i::Handle<i::Object> result; | |
6718 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_chain(), | |
6719 self, arraysize(argv), argv) | |
6720 .ToHandle(&result); | |
6721 RETURN_ON_FAILED_EXECUTION(Promise); | |
6722 RETURN_ESCAPED(Local<Promise>::Cast(Utils::ToLocal(result))); | |
6723 } | |
6724 | |
6725 } // namespace | |
6726 | |
6727 | |
6728 MaybeLocal<Promise> Promise::Chain(Local<Context> context, | |
6729 Local<Function> handler) { | |
6730 return DoChain(this, context, handler); | |
6731 } | |
6732 | |
6733 | |
6734 Local<Promise> Promise::Chain(Local<Function> handler) { | |
6735 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); | |
6736 RETURN_TO_LOCAL_UNCHECKED(DoChain(this, context, handler), Promise); | |
6737 } | |
6738 | |
6739 | |
6740 MaybeLocal<Promise> Promise::Catch(Local<Context> context, | 6710 MaybeLocal<Promise> Promise::Catch(Local<Context> context, |
6741 Local<Function> handler) { | 6711 Local<Function> handler) { |
6742 PREPARE_FOR_EXECUTION(context, Promise, Catch, Promise); | 6712 PREPARE_FOR_EXECUTION(context, Promise, Catch, Promise); |
6743 auto self = Utils::OpenHandle(this); | 6713 auto self = Utils::OpenHandle(this); |
6744 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; | 6714 i::Handle<i::Object> argv[] = { Utils::OpenHandle(*handler) }; |
6745 i::Handle<i::Object> result; | 6715 i::Handle<i::Object> result; |
6746 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_catch(), | 6716 has_pending_exception = !i::Execution::Call(isolate, isolate->promise_catch(), |
6747 self, arraysize(argv), argv) | 6717 self, arraysize(argv), argv) |
6748 .ToHandle(&result); | 6718 .ToHandle(&result); |
6749 RETURN_ON_FAILED_EXECUTION(Promise); | 6719 RETURN_ON_FAILED_EXECUTION(Promise); |
(...skipping 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9018 Address callback_address = | 8988 Address callback_address = |
9019 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8989 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
9020 VMState<EXTERNAL> state(isolate); | 8990 VMState<EXTERNAL> state(isolate); |
9021 ExternalCallbackScope call_scope(isolate, callback_address); | 8991 ExternalCallbackScope call_scope(isolate, callback_address); |
9022 callback(info); | 8992 callback(info); |
9023 } | 8993 } |
9024 | 8994 |
9025 | 8995 |
9026 } // namespace internal | 8996 } // namespace internal |
9027 } // namespace v8 | 8997 } // namespace v8 |
OLD | NEW |