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 2026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 RETURN_TO_LOCAL_UNCHECKED(Run(context), Value); | 2037 RETURN_TO_LOCAL_UNCHECKED(Run(context), Value); |
2038 } | 2038 } |
2039 | 2039 |
2040 | 2040 |
2041 Local<UnboundScript> Script::GetUnboundScript() { | 2041 Local<UnboundScript> Script::GetUnboundScript() { |
2042 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2042 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2043 return ToApiHandle<UnboundScript>( | 2043 return ToApiHandle<UnboundScript>( |
2044 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); | 2044 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); |
2045 } | 2045 } |
2046 | 2046 |
| 2047 bool DynamicImportResult::FinishDynamicImportSuccess(Local<Context> context, |
| 2048 Local<Module> module) { |
| 2049 PREPARE_FOR_EXECUTION_BOOL(context, Module, FinishDynamicImportSuccess); |
| 2050 auto promise = Utils::OpenHandle(this); |
| 2051 i::Handle<i::Module> module_obj = Utils::OpenHandle(*module); |
| 2052 i::Handle<i::JSModuleNamespace> module_namespace = |
| 2053 i::Module::GetModuleNamespace(module_obj); |
| 2054 i::Handle<i::Object> argv[] = {promise, module_namespace}; |
| 2055 has_pending_exception = |
| 2056 i::Execution::Call(isolate, isolate->promise_resolve(), |
| 2057 isolate->factory()->undefined_value(), arraysize(argv), |
| 2058 argv) |
| 2059 .is_null(); |
| 2060 RETURN_ON_FAILED_EXECUTION_BOOL(); |
| 2061 return true; |
| 2062 } |
| 2063 |
| 2064 bool DynamicImportResult::FinishDynamicImportFailure(Local<Context> context, |
| 2065 Local<Value> exception) { |
| 2066 PREPARE_FOR_EXECUTION_BOOL(context, Module, FinishDynamicImportFailure); |
| 2067 auto promise = Utils::OpenHandle(this); |
| 2068 // We pass true to trigger the debugger's on exception handler. |
| 2069 i::Handle<i::Object> argv[] = {promise, Utils::OpenHandle(*exception), |
| 2070 isolate->factory()->ToBoolean(true)}; |
| 2071 has_pending_exception = |
| 2072 i::Execution::Call(isolate, isolate->promise_internal_reject(), |
| 2073 isolate->factory()->undefined_value(), arraysize(argv), |
| 2074 argv) |
| 2075 .is_null(); |
| 2076 RETURN_ON_FAILED_EXECUTION_BOOL(); |
| 2077 return true; |
| 2078 } |
| 2079 |
2047 int Module::GetModuleRequestsLength() const { | 2080 int Module::GetModuleRequestsLength() const { |
2048 i::Handle<i::Module> self = Utils::OpenHandle(this); | 2081 i::Handle<i::Module> self = Utils::OpenHandle(this); |
2049 return self->info()->module_requests()->length(); | 2082 return self->info()->module_requests()->length(); |
2050 } | 2083 } |
2051 | 2084 |
2052 Local<String> Module::GetModuleRequest(int i) const { | 2085 Local<String> Module::GetModuleRequest(int i) const { |
2053 CHECK_GE(i, 0); | 2086 CHECK_GE(i, 0); |
2054 i::Handle<i::Module> self = Utils::OpenHandle(this); | 2087 i::Handle<i::Module> self = Utils::OpenHandle(this); |
2055 i::Isolate* isolate = self->GetIsolate(); | 2088 i::Isolate* isolate = self->GetIsolate(); |
2056 i::Handle<i::FixedArray> module_requests(self->info()->module_requests(), | 2089 i::Handle<i::FixedArray> module_requests(self->info()->module_requests(), |
(...skipping 6167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8224 v8_isolate->SetCreateHistogramFunction(params.create_histogram_callback); | 8257 v8_isolate->SetCreateHistogramFunction(params.create_histogram_callback); |
8225 } | 8258 } |
8226 | 8259 |
8227 if (params.add_histogram_sample_callback) { | 8260 if (params.add_histogram_sample_callback) { |
8228 v8_isolate->SetAddHistogramSampleFunction( | 8261 v8_isolate->SetAddHistogramSampleFunction( |
8229 params.add_histogram_sample_callback); | 8262 params.add_histogram_sample_callback); |
8230 } | 8263 } |
8231 | 8264 |
8232 isolate->set_api_external_references(params.external_references); | 8265 isolate->set_api_external_references(params.external_references); |
8233 isolate->set_allow_atomics_wait(params.allow_atomics_wait); | 8266 isolate->set_allow_atomics_wait(params.allow_atomics_wait); |
| 8267 |
| 8268 if (params.host_import_module_dynamically_callback_ != nullptr) { |
| 8269 isolate->SetHostImportModuleDynamicallyCallback( |
| 8270 params.host_import_module_dynamically_callback_); |
| 8271 } |
| 8272 |
8234 SetResourceConstraints(isolate, params.constraints); | 8273 SetResourceConstraints(isolate, params.constraints); |
8235 // TODO(jochen): Once we got rid of Isolate::Current(), we can remove this. | 8274 // TODO(jochen): Once we got rid of Isolate::Current(), we can remove this. |
8236 Isolate::Scope isolate_scope(v8_isolate); | 8275 Isolate::Scope isolate_scope(v8_isolate); |
8237 if (params.entry_hook || !i::Snapshot::Initialize(isolate)) { | 8276 if (params.entry_hook || !i::Snapshot::Initialize(isolate)) { |
8238 isolate->Init(NULL); | 8277 isolate->Init(NULL); |
8239 } | 8278 } |
8240 return v8_isolate; | 8279 return v8_isolate; |
8241 } | 8280 } |
8242 | 8281 |
8243 | 8282 |
(...skipping 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10317 Address callback_address = | 10356 Address callback_address = |
10318 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10357 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10319 VMState<EXTERNAL> state(isolate); | 10358 VMState<EXTERNAL> state(isolate); |
10320 ExternalCallbackScope call_scope(isolate, callback_address); | 10359 ExternalCallbackScope call_scope(isolate, callback_address); |
10321 callback(info); | 10360 callback(info); |
10322 } | 10361 } |
10323 | 10362 |
10324 | 10363 |
10325 } // namespace internal | 10364 } // namespace internal |
10326 } // namespace v8 | 10365 } // namespace v8 |
OLD | NEW |