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

Side by Side Diff: src/api.cc

Issue 2366063002: [modules] Initialize requested_modules before recursing in Module::Instantiate (Closed)
Patch Set: Make test more robust Created 4 years, 2 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
« no previous file with comments | « no previous file | test/mjsunit/modules-circular-valid.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 // persist a module_map across multiple top-level module loads, as 1969 // persist a module_map across multiple top-level module loads, as
1970 // the current module is left in a "half-instantiated" state. 1970 // the current module is left in a "half-instantiated" state.
1971 if (!callback(v8_context, v8_module->GetModuleRequest(i), v8_module, 1971 if (!callback(v8_context, v8_module->GetModuleRequest(i), v8_module,
1972 callback_data) 1972 callback_data)
1973 .ToLocal(&requested_module)) { 1973 .ToLocal(&requested_module)) {
1974 // TODO(adamk): Give this a better error message. But this is a 1974 // TODO(adamk): Give this a better error message. But this is a
1975 // misuse of the API anyway. 1975 // misuse of the API anyway.
1976 isolate->ThrowIllegalOperation(); 1976 isolate->ThrowIllegalOperation();
1977 return false; 1977 return false;
1978 } 1978 }
1979 if (!requested_module->Instantiate(v8_context, callback, callback_data)) { 1979 module->requested_modules()->set(i, *Utils::OpenHandle(*requested_module));
1980 if (!InstantiateModule(requested_module, v8_context, callback,
1981 callback_data)) {
1980 return false; 1982 return false;
1981 } 1983 }
1982 module->requested_modules()->set(i, *Utils::OpenHandle(*requested_module));
1983 } 1984 }
1984 1985
1985 // Resolve imports. 1986 // Resolve imports.
1986 for (int i = 0, n = regular_imports->length(); i < n; ++i) { 1987 for (int i = 0, n = regular_imports->length(); i < n; ++i) {
1987 i::Handle<i::ModuleInfoEntry> entry( 1988 i::Handle<i::ModuleInfoEntry> entry(
1988 i::ModuleInfoEntry::cast(regular_imports->get(i)), isolate); 1989 i::ModuleInfoEntry::cast(regular_imports->get(i)), isolate);
1989 i::Handle<i::String> name(i::String::cast(entry->import_name()), isolate); 1990 i::Handle<i::String> name(i::String::cast(entry->import_name()), isolate);
1990 int module_request = i::Smi::cast(entry->module_request())->value(); 1991 int module_request = i::Smi::cast(entry->module_request())->value();
1991 if (i::Module::ResolveImport(module, name, module_request).is_null()) { 1992 if (i::Module::ResolveImport(module, name, module_request).is_null()) {
1992 return false; 1993 return false;
(...skipping 7489 matching lines...) Expand 10 before | Expand all | Expand 10 after
9482 Address callback_address = 9483 Address callback_address =
9483 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9484 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9484 VMState<EXTERNAL> state(isolate); 9485 VMState<EXTERNAL> state(isolate);
9485 ExternalCallbackScope call_scope(isolate, callback_address); 9486 ExternalCallbackScope call_scope(isolate, callback_address);
9486 callback(info); 9487 callback(info);
9487 } 9488 }
9488 9489
9489 9490
9490 } // namespace internal 9491 } // namespace internal
9491 } // namespace v8 9492 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/modules-circular-valid.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698