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

Side by Side Diff: src/api.cc

Issue 2367623004: [modules] Detect and throw exceptions for cyclic dependencies (Closed)
Patch Set: Update golden files 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 | « BUILD.gn ('k') | src/factory.cc » ('j') | src/objects.h » ('J')
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 28 matching lines...) Expand all
39 #include "src/execution.h" 39 #include "src/execution.h"
40 #include "src/frames-inl.h" 40 #include "src/frames-inl.h"
41 #include "src/gdb-jit.h" 41 #include "src/gdb-jit.h"
42 #include "src/global-handles.h" 42 #include "src/global-handles.h"
43 #include "src/globals.h" 43 #include "src/globals.h"
44 #include "src/icu_util.h" 44 #include "src/icu_util.h"
45 #include "src/isolate-inl.h" 45 #include "src/isolate-inl.h"
46 #include "src/json-parser.h" 46 #include "src/json-parser.h"
47 #include "src/json-stringifier.h" 47 #include "src/json-stringifier.h"
48 #include "src/messages.h" 48 #include "src/messages.h"
49 #include "src/module-resolve-set-inl.h"
49 #include "src/parsing/parser.h" 50 #include "src/parsing/parser.h"
50 #include "src/parsing/scanner-character-streams.h" 51 #include "src/parsing/scanner-character-streams.h"
51 #include "src/pending-compilation-error-handler.h" 52 #include "src/pending-compilation-error-handler.h"
52 #include "src/profiler/cpu-profiler.h" 53 #include "src/profiler/cpu-profiler.h"
53 #include "src/profiler/heap-profiler.h" 54 #include "src/profiler/heap-profiler.h"
54 #include "src/profiler/heap-snapshot-generator-inl.h" 55 #include "src/profiler/heap-snapshot-generator-inl.h"
55 #include "src/profiler/profile-generator-inl.h" 56 #include "src/profiler/profile-generator-inl.h"
56 #include "src/profiler/tick-sample.h" 57 #include "src/profiler/tick-sample.h"
57 #include "src/property-descriptor.h" 58 #include "src/property-descriptor.h"
58 #include "src/property-details.h" 59 #include "src/property-details.h"
59 #include "src/property.h" 60 #include "src/property.h"
60 #include "src/prototype.h" 61 #include "src/prototype.h"
61 #include "src/runtime-profiler.h" 62 #include "src/runtime-profiler.h"
62 #include "src/runtime/runtime.h" 63 #include "src/runtime/runtime.h"
63 #include "src/simulator.h" 64 #include "src/simulator.h"
64 #include "src/snapshot/code-serializer.h" 65 #include "src/snapshot/code-serializer.h"
65 #include "src/snapshot/natives.h" 66 #include "src/snapshot/natives.h"
66 #include "src/snapshot/snapshot.h" 67 #include "src/snapshot/snapshot.h"
67 #include "src/startup-data-util.h" 68 #include "src/startup-data-util.h"
68 #include "src/tracing/trace-event.h" 69 #include "src/tracing/trace-event.h"
69 #include "src/unicode-inl.h" 70 #include "src/unicode-inl.h"
70 #include "src/v8.h" 71 #include "src/v8.h"
71 #include "src/v8threads.h" 72 #include "src/v8threads.h"
72 #include "src/value-serializer.h" 73 #include "src/value-serializer.h"
73 #include "src/version.h" 74 #include "src/version.h"
74 #include "src/vm-state-inl.h" 75 #include "src/vm-state-inl.h"
75 #include "src/wasm/wasm-module.h" 76 #include "src/wasm/wasm-module.h"
77 #include "src/zone/zone.h"
76 78
77 namespace v8 { 79 namespace v8 {
78 80
79 #define LOG_API(isolate, class_name, function_name) \ 81 #define LOG_API(isolate, class_name, function_name) \
80 i::RuntimeCallTimerScope _runtime_timer( \ 82 i::RuntimeCallTimerScope _runtime_timer( \
81 isolate, &i::RuntimeCallStats::API_##class_name##_##function_name); \ 83 isolate, &i::RuntimeCallStats::API_##class_name##_##function_name); \
82 LOG(isolate, ApiEntryCall("v8::" #class_name "::" #function_name)) 84 LOG(isolate, ApiEntryCall("v8::" #class_name "::" #function_name))
83 85
84 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate)) 86 #define ENTER_V8(isolate) i::VMState<v8::OTHER> __state__((isolate))
85 87
(...skipping 1883 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 // persist a module_map across multiple top-level module loads, as 1971 // persist a module_map across multiple top-level module loads, as
1970 // the current module is left in a "half-instantiated" state. 1972 // the current module is left in a "half-instantiated" state.
1971 if (!callback(v8_context, v8_module->GetModuleRequest(i), v8_module, 1973 if (!callback(v8_context, v8_module->GetModuleRequest(i), v8_module,
1972 callback_data) 1974 callback_data)
1973 .ToLocal(&requested_module)) { 1975 .ToLocal(&requested_module)) {
1974 // TODO(adamk): Give this a better error message. But this is a 1976 // TODO(adamk): Give this a better error message. But this is a
1975 // misuse of the API anyway. 1977 // misuse of the API anyway.
1976 isolate->ThrowIllegalOperation(); 1978 isolate->ThrowIllegalOperation();
1977 return false; 1979 return false;
1978 } 1980 }
1979 if (!requested_module->Instantiate(v8_context, callback, callback_data)) { 1981 module->requested_modules()->set(i, *Utils::OpenHandle(*requested_module));
1982 if (!InstantiateModule(requested_module, v8_context, callback,
1983 callback_data)) {
1980 return false; 1984 return false;
1981 } 1985 }
1982 module->requested_modules()->set(i, *Utils::OpenHandle(*requested_module));
1983 } 1986 }
1984 1987
1988 i::Zone zone(isolate->allocator());
1989
1985 // Resolve imports. 1990 // Resolve imports.
1986 for (int i = 0, n = regular_imports->length(); i < n; ++i) { 1991 for (int i = 0, n = regular_imports->length(); i < n; ++i) {
1987 i::Handle<i::ModuleInfoEntry> entry( 1992 i::Handle<i::ModuleInfoEntry> entry(
1988 i::ModuleInfoEntry::cast(regular_imports->get(i)), isolate); 1993 i::ModuleInfoEntry::cast(regular_imports->get(i)), isolate);
1989 i::Handle<i::String> name(i::String::cast(entry->import_name()), isolate); 1994 i::Handle<i::String> name(i::String::cast(entry->import_name()), isolate);
1990 int module_request = i::Smi::cast(entry->module_request())->value(); 1995 int module_request = i::Smi::cast(entry->module_request())->value();
1991 if (i::Module::ResolveImport(module, name, module_request).is_null()) { 1996 i::Module::ResolveSet resolve_set(&zone);
1997 if (i::Module::ResolveImport(module, name, module_request, &resolve_set,
1998 &zone)
1999 .is_null()) {
1992 return false; 2000 return false;
1993 } 2001 }
1994 } 2002 }
1995 2003
1996 // Resolve indirect exports. 2004 // Resolve indirect exports.
1997 for (int i = 0, n = special_exports->length(); i < n; ++i) { 2005 for (int i = 0, n = special_exports->length(); i < n; ++i) {
1998 i::Handle<i::ModuleInfoEntry> entry( 2006 i::Handle<i::ModuleInfoEntry> entry(
1999 i::ModuleInfoEntry::cast(special_exports->get(i)), isolate); 2007 i::ModuleInfoEntry::cast(special_exports->get(i)), isolate);
2000 i::Handle<i::String> name(i::String::cast(entry->export_name()), isolate); 2008 i::Handle<i::String> name(i::String::cast(entry->export_name()), isolate);
2001 if (i::Module::ResolveExport(module, name).is_null()) { 2009 i::Module::ResolveSet resolve_set(&zone);
2010 if (i::Module::ResolveExport(module, name, &resolve_set, &zone).is_null()) {
2002 return false; 2011 return false;
2003 } 2012 }
2004 } 2013 }
2005 2014
2006 return true; 2015 return true;
2007 } 2016 }
2008 2017
2009 bool Module::Instantiate(Local<Context> context, 2018 bool Module::Instantiate(Local<Context> context,
2010 Module::ResolveCallback callback, 2019 Module::ResolveCallback callback,
2011 Local<Value> callback_data) { 2020 Local<Value> callback_data) {
(...skipping 7470 matching lines...) Expand 10 before | Expand all | Expand 10 after
9482 Address callback_address = 9491 Address callback_address =
9483 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9492 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9484 VMState<EXTERNAL> state(isolate); 9493 VMState<EXTERNAL> state(isolate);
9485 ExternalCallbackScope call_scope(isolate, callback_address); 9494 ExternalCallbackScope call_scope(isolate, callback_address);
9486 callback(info); 9495 callback(info);
9487 } 9496 }
9488 9497
9489 9498
9490 } // namespace internal 9499 } // namespace internal
9491 } // namespace v8 9500 } // namespace v8
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/factory.cc » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698