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 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2061 ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>()); | 2061 ON_BAILOUT(isolate, "v8::Message::Get()", return Local<String>()); |
2062 ENTER_V8(isolate); | 2062 ENTER_V8(isolate); |
2063 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 2063 EscapableHandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
2064 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2064 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2065 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj); | 2065 i::Handle<i::String> raw_result = i::MessageHandler::GetMessage(isolate, obj); |
2066 Local<String> result = Utils::ToLocal(raw_result); | 2066 Local<String> result = Utils::ToLocal(raw_result); |
2067 return scope.Escape(result); | 2067 return scope.Escape(result); |
2068 } | 2068 } |
2069 | 2069 |
2070 | 2070 |
| 2071 v8::Handle<v8::Promise> Message::GetPromise() const { |
| 2072 i::Handle<i::JSMessageObject> message = |
| 2073 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
| 2074 i::Object* promise = message->promise(); |
| 2075 if (promise->IsUndefined()) return v8::Handle<v8::Promise>(); |
| 2076 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2077 i::Handle<i::JSObject> promise_handle(i::JSObject::cast(promise), isolate); |
| 2078 return Utils::PromiseToLocal(promise_handle); |
| 2079 } |
| 2080 |
| 2081 |
2071 ScriptOrigin Message::GetScriptOrigin() const { | 2082 ScriptOrigin Message::GetScriptOrigin() const { |
2072 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2083 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
2073 i::Handle<i::JSMessageObject> message = | 2084 i::Handle<i::JSMessageObject> message = |
2074 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); | 2085 i::Handle<i::JSMessageObject>::cast(Utils::OpenHandle(this)); |
2075 i::Handle<i::Object> script_wraper = | 2086 i::Handle<i::Object> script_wraper = |
2076 i::Handle<i::Object>(message->script(), isolate); | 2087 i::Handle<i::Object>(message->script(), isolate); |
2077 i::Handle<i::JSValue> script_value = | 2088 i::Handle<i::JSValue> script_value = |
2078 i::Handle<i::JSValue>::cast(script_wraper); | 2089 i::Handle<i::JSValue>::cast(script_wraper); |
2079 i::Handle<i::Script> script(i::Script::cast(script_value->value())); | 2090 i::Handle<i::Script> script(i::Script::cast(script_value->value())); |
2080 i::Handle<i::Object> scriptName(i::Script::GetNameOrSourceURL(script)); | 2091 i::Handle<i::Object> scriptName(i::Script::GetNameOrSourceURL(script)); |
(...skipping 3883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5964 isolate, | 5975 isolate, |
5965 isolate->promise_then(), | 5976 isolate->promise_then(), |
5966 promise, | 5977 promise, |
5967 arraysize(argv), argv, | 5978 arraysize(argv), argv, |
5968 false).ToHandle(&result); | 5979 false).ToHandle(&result); |
5969 EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>()); | 5980 EXCEPTION_BAILOUT_CHECK(isolate, Local<Promise>()); |
5970 return Local<Promise>::Cast(Utils::ToLocal(result)); | 5981 return Local<Promise>::Cast(Utils::ToLocal(result)); |
5971 } | 5982 } |
5972 | 5983 |
5973 | 5984 |
| 5985 bool Promise::HasRejectHandler() { |
| 5986 i::Handle<i::JSObject> promise = Utils::OpenHandle(this); |
| 5987 i::Isolate* isolate = promise->GetIsolate(); |
| 5988 LOG_API(isolate, "Promise::HasRejectHandler"); |
| 5989 ENTER_V8(isolate); |
| 5990 EXCEPTION_PREAMBLE(isolate); |
| 5991 i::Handle<i::Object> result; |
| 5992 has_pending_exception = !i::Execution::PromiseHasRejectHandler( |
| 5993 isolate, promise).ToHandle(&result); |
| 5994 EXCEPTION_BAILOUT_CHECK(isolate, false); |
| 5995 return result->BooleanValue(); |
| 5996 } |
| 5997 |
| 5998 |
5974 bool v8::ArrayBuffer::IsExternal() const { | 5999 bool v8::ArrayBuffer::IsExternal() const { |
5975 return Utils::OpenHandle(this)->is_external(); | 6000 return Utils::OpenHandle(this)->is_external(); |
5976 } | 6001 } |
5977 | 6002 |
5978 | 6003 |
5979 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { | 6004 v8::ArrayBuffer::Contents v8::ArrayBuffer::Externalize() { |
5980 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 6005 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |
5981 Utils::ApiCheck(!obj->is_external(), | 6006 Utils::ApiCheck(!obj->is_external(), |
5982 "v8::ArrayBuffer::Externalize", | 6007 "v8::ArrayBuffer::Externalize", |
5983 "ArrayBuffer already externalized"); | 6008 "ArrayBuffer already externalized"); |
(...skipping 1672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7656 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7681 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7657 Address callback_address = | 7682 Address callback_address = |
7658 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7683 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7659 VMState<EXTERNAL> state(isolate); | 7684 VMState<EXTERNAL> state(isolate); |
7660 ExternalCallbackScope call_scope(isolate, callback_address); | 7685 ExternalCallbackScope call_scope(isolate, callback_address); |
7661 callback(info); | 7686 callback(info); |
7662 } | 7687 } |
7663 | 7688 |
7664 | 7689 |
7665 } } // namespace v8::internal | 7690 } } // namespace v8::internal |
OLD | NEW |