Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(120)

Side by Side Diff: src/api.cc

Issue 2703563002: [ESNext] Implement DynamicImportCall (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 6109 matching lines...) Expand 10 before | Expand all | Expand 10 after
8167 v8_isolate->SetCreateHistogramFunction(params.create_histogram_callback); 8203 v8_isolate->SetCreateHistogramFunction(params.create_histogram_callback);
8168 } 8204 }
8169 8205
8170 if (params.add_histogram_sample_callback) { 8206 if (params.add_histogram_sample_callback) {
8171 v8_isolate->SetAddHistogramSampleFunction( 8207 v8_isolate->SetAddHistogramSampleFunction(
8172 params.add_histogram_sample_callback); 8208 params.add_histogram_sample_callback);
8173 } 8209 }
8174 8210
8175 isolate->set_api_external_references(params.external_references); 8211 isolate->set_api_external_references(params.external_references);
8176 isolate->set_allow_atomics_wait(params.allow_atomics_wait); 8212 isolate->set_allow_atomics_wait(params.allow_atomics_wait);
8213
8214 if (params.host_import_module_dynamically_callback_ != nullptr) {
8215 isolate->SetHostImportModuleDynamicallyCallback(
8216 params.host_import_module_dynamically_callback_);
8217 }
8218
8177 SetResourceConstraints(isolate, params.constraints); 8219 SetResourceConstraints(isolate, params.constraints);
8178 // TODO(jochen): Once we got rid of Isolate::Current(), we can remove this. 8220 // TODO(jochen): Once we got rid of Isolate::Current(), we can remove this.
8179 Isolate::Scope isolate_scope(v8_isolate); 8221 Isolate::Scope isolate_scope(v8_isolate);
8180 if (params.entry_hook || !i::Snapshot::Initialize(isolate)) { 8222 if (params.entry_hook || !i::Snapshot::Initialize(isolate)) {
8181 isolate->Init(NULL); 8223 isolate->Init(NULL);
8182 } 8224 }
8183 return v8_isolate; 8225 return v8_isolate;
8184 } 8226 }
8185 8227
8186 8228
(...skipping 2055 matching lines...) Expand 10 before | Expand all | Expand 10 after
10242 Address callback_address = 10284 Address callback_address =
10243 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10285 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10244 VMState<EXTERNAL> state(isolate); 10286 VMState<EXTERNAL> state(isolate);
10245 ExternalCallbackScope call_scope(isolate, callback_address); 10287 ExternalCallbackScope call_scope(isolate, callback_address);
10246 callback(info); 10288 callback(info);
10247 } 10289 }
10248 10290
10249 10291
10250 } // namespace internal 10292 } // namespace internal
10251 } // namespace v8 10293 } // namespace v8
OLDNEW
« include/v8.h ('K') | « include/v8.h ('k') | src/asmjs/asm-wasm-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698