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

Side by Side Diff: src/api.cc

Issue 2703563002: [ESNext] Implement DynamicImportCall (Closed)
Patch Set: fix build 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 2034 matching lines...) Expand 10 before | Expand all | Expand 10 after
2045 RETURN_TO_LOCAL_UNCHECKED(Run(context), Value); 2045 RETURN_TO_LOCAL_UNCHECKED(Run(context), Value);
2046 } 2046 }
2047 2047
2048 2048
2049 Local<UnboundScript> Script::GetUnboundScript() { 2049 Local<UnboundScript> Script::GetUnboundScript() {
2050 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2050 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2051 return ToApiHandle<UnboundScript>( 2051 return ToApiHandle<UnboundScript>(
2052 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); 2052 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared()));
2053 } 2053 }
2054 2054
2055 // static
2056 bool Module::FinishDynamicImportSuccess(Local<Context> context,
2057 Local<Promise> promise,
2058 Local<Module> module) {
2059 PREPARE_FOR_EXECUTION_BOOL(context, Module, FinishDynamicImportSuccess);
2060 i::Handle<i::Module> module_obj = Utils::OpenHandle(*module);
2061 i::Handle<i::JSModuleNamespace> module_namespace =
2062 i::Module::GetModuleNamespace(module_obj);
2063 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*promise), module_namespace};
2064 has_pending_exception =
2065 i::Execution::Call(isolate, isolate->promise_resolve(),
2066 isolate->factory()->undefined_value(), arraysize(argv),
2067 argv)
2068 .is_null();
2069 RETURN_ON_FAILED_EXECUTION_BOOL();
2070 return true;
2071 }
2072
2073 // static
2074 bool Module::FinishDynamicImportFailure(Local<Context> context,
2075 Local<Promise> promise,
2076 Local<Value> exception) {
2077 PREPARE_FOR_EXECUTION_BOOL(context, Module, FinishDynamicImportFailure);
2078 // We pass true to trigger the debugger's on exception handler.
2079 i::Handle<i::Object> argv[] = {Utils::OpenHandle(*promise),
2080 Utils::OpenHandle(*exception),
2081 isolate->factory()->ToBoolean(true)};
2082 has_pending_exception =
2083 i::Execution::Call(isolate, isolate->promise_internal_reject(),
2084 isolate->factory()->undefined_value(), arraysize(argv),
2085 argv)
2086 .is_null();
2087 RETURN_ON_FAILED_EXECUTION_BOOL();
2088 return true;
2089 }
2090
2055 int Module::GetModuleRequestsLength() const { 2091 int Module::GetModuleRequestsLength() const {
2056 i::Handle<i::Module> self = Utils::OpenHandle(this); 2092 i::Handle<i::Module> self = Utils::OpenHandle(this);
2057 return self->info()->module_requests()->length(); 2093 return self->info()->module_requests()->length();
2058 } 2094 }
2059 2095
2060 Local<String> Module::GetModuleRequest(int i) const { 2096 Local<String> Module::GetModuleRequest(int i) const {
2061 CHECK_GE(i, 0); 2097 CHECK_GE(i, 0);
2062 i::Handle<i::Module> self = Utils::OpenHandle(this); 2098 i::Handle<i::Module> self = Utils::OpenHandle(this);
2063 i::Isolate* isolate = self->GetIsolate(); 2099 i::Isolate* isolate = self->GetIsolate();
2064 i::Handle<i::FixedArray> module_requests(self->info()->module_requests(), 2100 i::Handle<i::FixedArray> module_requests(self->info()->module_requests(),
(...skipping 6113 matching lines...) Expand 10 before | Expand all | Expand 10 after
8178 v8_isolate->SetCreateHistogramFunction(params.create_histogram_callback); 8214 v8_isolate->SetCreateHistogramFunction(params.create_histogram_callback);
8179 } 8215 }
8180 8216
8181 if (params.add_histogram_sample_callback) { 8217 if (params.add_histogram_sample_callback) {
8182 v8_isolate->SetAddHistogramSampleFunction( 8218 v8_isolate->SetAddHistogramSampleFunction(
8183 params.add_histogram_sample_callback); 8219 params.add_histogram_sample_callback);
8184 } 8220 }
8185 8221
8186 isolate->set_api_external_references(params.external_references); 8222 isolate->set_api_external_references(params.external_references);
8187 isolate->set_allow_atomics_wait(params.allow_atomics_wait); 8223 isolate->set_allow_atomics_wait(params.allow_atomics_wait);
8224
8225 if (params.host_import_module_dynamically_callback_ != nullptr) {
8226 isolate->SetHostImportModuleDynamicallyCallback(
8227 params.host_import_module_dynamically_callback_);
8228 }
8229
8188 SetResourceConstraints(isolate, params.constraints); 8230 SetResourceConstraints(isolate, params.constraints);
8189 // TODO(jochen): Once we got rid of Isolate::Current(), we can remove this. 8231 // TODO(jochen): Once we got rid of Isolate::Current(), we can remove this.
8190 Isolate::Scope isolate_scope(v8_isolate); 8232 Isolate::Scope isolate_scope(v8_isolate);
8191 if (params.entry_hook || !i::Snapshot::Initialize(isolate)) { 8233 if (params.entry_hook || !i::Snapshot::Initialize(isolate)) {
8192 isolate->Init(NULL); 8234 isolate->Init(NULL);
8193 } 8235 }
8194 return v8_isolate; 8236 return v8_isolate;
8195 } 8237 }
8196 8238
8197 8239
(...skipping 2055 matching lines...) Expand 10 before | Expand all | Expand 10 after
10253 Address callback_address = 10295 Address callback_address =
10254 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 10296 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
10255 VMState<EXTERNAL> state(isolate); 10297 VMState<EXTERNAL> state(isolate);
10256 ExternalCallbackScope call_scope(isolate, callback_address); 10298 ExternalCallbackScope call_scope(isolate, callback_address);
10257 callback(info); 10299 callback(info);
10258 } 10300 }
10259 10301
10260 10302
10261 } // namespace internal 10303 } // namespace internal
10262 } // namespace v8 10304 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698