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 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2038 RETURN_TO_LOCAL_UNCHECKED(Run(context), Value); | 2038 RETURN_TO_LOCAL_UNCHECKED(Run(context), Value); |
2039 } | 2039 } |
2040 | 2040 |
2041 | 2041 |
2042 Local<UnboundScript> Script::GetUnboundScript() { | 2042 Local<UnboundScript> Script::GetUnboundScript() { |
2043 i::Handle<i::Object> obj = Utils::OpenHandle(this); | 2043 i::Handle<i::Object> obj = Utils::OpenHandle(this); |
2044 return ToApiHandle<UnboundScript>( | 2044 return ToApiHandle<UnboundScript>( |
2045 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); | 2045 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); |
2046 } | 2046 } |
2047 | 2047 |
| 2048 // static |
| 2049 bool Module::FinishDynamicImportSuccess(Local<Context> context, |
| 2050 Local<Promise> promise, |
| 2051 Local<Module> module) { |
| 2052 PREPARE_FOR_EXECUTION_BOOL(context, Module, FinishDynamicImportSuccess); |
| 2053 i::Handle<i::Module> module_obj = Utils::OpenHandle(*module); |
| 2054 i::Handle<i::JSModuleNamespace> module_namespace = |
| 2055 i::Module::GetModuleNamespace(module_obj); |
| 2056 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*promise), module_namespace}; |
| 2057 has_pending_exception = |
| 2058 i::Execution::Call(isolate, isolate->promise_resolve(), |
| 2059 isolate->factory()->undefined_value(), arraysize(argv), |
| 2060 argv) |
| 2061 .is_null(); |
| 2062 RETURN_ON_FAILED_EXECUTION_BOOL(); |
| 2063 return true; |
| 2064 } |
| 2065 |
| 2066 // static |
| 2067 bool Module::FinishDynamicImportFailure(Local<Context> context, |
| 2068 Local<Promise> promise, |
| 2069 Local<Value> exception) { |
| 2070 PREPARE_FOR_EXECUTION_BOOL(context, Module, FinishDynamicImportFailure); |
| 2071 // We pass true to trigger the debugger's on exception handler. |
| 2072 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*promise), |
| 2073 Utils::OpenHandle(*exception), |
| 2074 isolate->factory()->ToBoolean(true)}; |
| 2075 has_pending_exception = |
| 2076 i::Execution::Call(isolate, isolate->promise_internal_reject(), |
| 2077 isolate->factory()->undefined_value(), arraysize(argv), |
| 2078 argv) |
| 2079 .is_null(); |
| 2080 RETURN_ON_FAILED_EXECUTION_BOOL(); |
| 2081 return true; |
| 2082 } |
| 2083 |
2048 int Module::GetModuleRequestsLength() const { | 2084 int Module::GetModuleRequestsLength() const { |
2049 i::Handle<i::Module> self = Utils::OpenHandle(this); | 2085 i::Handle<i::Module> self = Utils::OpenHandle(this); |
2050 return self->info()->module_requests()->length(); | 2086 return self->info()->module_requests()->length(); |
2051 } | 2087 } |
2052 | 2088 |
2053 Local<String> Module::GetModuleRequest(int i) const { | 2089 Local<String> Module::GetModuleRequest(int i) const { |
2054 CHECK_GE(i, 0); | 2090 CHECK_GE(i, 0); |
2055 i::Handle<i::Module> self = Utils::OpenHandle(this); | 2091 i::Handle<i::Module> self = Utils::OpenHandle(this); |
2056 i::Isolate* isolate = self->GetIsolate(); | 2092 i::Isolate* isolate = self->GetIsolate(); |
2057 i::Handle<i::FixedArray> module_requests(self->info()->module_requests(), | 2093 i::Handle<i::FixedArray> module_requests(self->info()->module_requests(), |
(...skipping 6157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8215 v8_isolate->SetCreateHistogramFunction(params.create_histogram_callback); | 8251 v8_isolate->SetCreateHistogramFunction(params.create_histogram_callback); |
8216 } | 8252 } |
8217 | 8253 |
8218 if (params.add_histogram_sample_callback) { | 8254 if (params.add_histogram_sample_callback) { |
8219 v8_isolate->SetAddHistogramSampleFunction( | 8255 v8_isolate->SetAddHistogramSampleFunction( |
8220 params.add_histogram_sample_callback); | 8256 params.add_histogram_sample_callback); |
8221 } | 8257 } |
8222 | 8258 |
8223 isolate->set_api_external_references(params.external_references); | 8259 isolate->set_api_external_references(params.external_references); |
8224 isolate->set_allow_atomics_wait(params.allow_atomics_wait); | 8260 isolate->set_allow_atomics_wait(params.allow_atomics_wait); |
| 8261 |
| 8262 if (params.host_import_module_dynamically_callback_ != nullptr) { |
| 8263 isolate->SetHostImportModuleDynamicallyCallback( |
| 8264 params.host_import_module_dynamically_callback_); |
| 8265 } |
| 8266 |
8225 SetResourceConstraints(isolate, params.constraints); | 8267 SetResourceConstraints(isolate, params.constraints); |
8226 // TODO(jochen): Once we got rid of Isolate::Current(), we can remove this. | 8268 // TODO(jochen): Once we got rid of Isolate::Current(), we can remove this. |
8227 Isolate::Scope isolate_scope(v8_isolate); | 8269 Isolate::Scope isolate_scope(v8_isolate); |
8228 if (params.entry_hook || !i::Snapshot::Initialize(isolate)) { | 8270 if (params.entry_hook || !i::Snapshot::Initialize(isolate)) { |
8229 isolate->Init(NULL); | 8271 isolate->Init(NULL); |
8230 } | 8272 } |
8231 return v8_isolate; | 8273 return v8_isolate; |
8232 } | 8274 } |
8233 | 8275 |
8234 | 8276 |
(...skipping 2055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10290 Address callback_address = | 10332 Address callback_address = |
10291 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 10333 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
10292 VMState<EXTERNAL> state(isolate); | 10334 VMState<EXTERNAL> state(isolate); |
10293 ExternalCallbackScope call_scope(isolate, callback_address); | 10335 ExternalCallbackScope call_scope(isolate, callback_address); |
10294 callback(info); | 10336 callback(info); |
10295 } | 10337 } |
10296 | 10338 |
10297 | 10339 |
10298 } // namespace internal | 10340 } // namespace internal |
10299 } // namespace v8 | 10341 } // namespace v8 |
OLD | NEW |