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 1931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1942 .ToLocal(&import)) { | 1942 .ToLocal(&import)) { |
1943 // TODO(adamk): Throw an exception. | 1943 // TODO(adamk): Throw an exception. |
1944 return false; | 1944 return false; |
1945 } | 1945 } |
1946 if (!import->Instantiate(v8_context, callback, callback_data)) { | 1946 if (!import->Instantiate(v8_context, callback, callback_data)) { |
1947 return false; | 1947 return false; |
1948 } | 1948 } |
1949 self->requested_modules()->set(i, *Utils::OpenHandle(*import)); | 1949 self->requested_modules()->set(i, *Utils::OpenHandle(*import)); |
1950 } | 1950 } |
1951 | 1951 |
1952 // TODO(neis): This will create multiple cells for the same local variable if | 1952 // Set up local exports. |
1953 // exported under multiple names, which is wrong but cannot be observed at the | |
1954 // moment. This will be fixed by doing the full-fledged linking here once we | |
1955 // get there. | |
1956 i::Handle<i::FixedArray> regular_exports = i::handle( | 1953 i::Handle<i::FixedArray> regular_exports = i::handle( |
1957 shared->scope_info()->ModuleDescriptorInfo()->regular_exports(), isolate); | 1954 shared->scope_info()->ModuleDescriptorInfo()->regular_exports(), isolate); |
1958 for (int i = 0, length = regular_exports->length(); i < length; ++i) { | 1955 for (int i = 0, n = regular_exports->length(); i < n; i += 2) { |
1959 i::Handle<i::ModuleInfoEntry> entry = | 1956 i::Handle<i::FixedArray> export_names( |
1960 i::handle(i::ModuleInfoEntry::cast(regular_exports->get(i)), isolate); | 1957 i::FixedArray::cast(regular_exports->get(i + 1)), isolate); |
1961 DCHECK(entry->import_name()->IsUndefined(isolate)); | 1958 i::Module::CreateExport(self, export_names); |
1962 i::Handle<i::String> export_name = | |
1963 handle(i::String::cast(entry->export_name()), isolate); | |
1964 i::Module::CreateExport(self, export_name); | |
1965 } | 1959 } |
1966 | 1960 |
1967 return true; | 1961 return true; |
1968 } | 1962 } |
1969 | 1963 |
1970 MaybeLocal<Value> Module::Evaluate(Local<Context> context) { | 1964 MaybeLocal<Value> Module::Evaluate(Local<Context> context) { |
1971 PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE( | 1965 PREPARE_FOR_EXECUTION_WITH_CONTEXT_IN_RUNTIME_CALL_STATS_SCOPE( |
1972 "v8", "V8.Execute", context, Script, Run, MaybeLocal<Value>(), | 1966 "v8", "V8.Execute", context, Script, Run, MaybeLocal<Value>(), |
1973 InternalEscapableScope, true); | 1967 InternalEscapableScope, true); |
1974 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); | 1968 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2117 | 2111 |
2118 MaybeLocal<Module> ScriptCompiler::CompileModule(Isolate* isolate, | 2112 MaybeLocal<Module> ScriptCompiler::CompileModule(Isolate* isolate, |
2119 Source* source) { | 2113 Source* source) { |
2120 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 2114 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
2121 | 2115 |
2122 auto maybe = CompileUnboundInternal(isolate, source, kNoCompileOptions, true); | 2116 auto maybe = CompileUnboundInternal(isolate, source, kNoCompileOptions, true); |
2123 Local<UnboundScript> unbound; | 2117 Local<UnboundScript> unbound; |
2124 if (!maybe.ToLocal(&unbound)) return MaybeLocal<Module>(); | 2118 if (!maybe.ToLocal(&unbound)) return MaybeLocal<Module>(); |
2125 | 2119 |
2126 i::Handle<i::SharedFunctionInfo> shared = Utils::OpenHandle(*unbound); | 2120 i::Handle<i::SharedFunctionInfo> shared = Utils::OpenHandle(*unbound); |
2127 i::Handle<i::Module> module = i_isolate->factory()->NewModule(shared); | 2121 return ToApiHandle<Module>(i_isolate->factory()->NewModule(shared)); |
2128 return ToApiHandle<Module>(module); | |
2129 } | 2122 } |
2130 | 2123 |
2131 | 2124 |
2132 class IsIdentifierHelper { | 2125 class IsIdentifierHelper { |
2133 public: | 2126 public: |
2134 IsIdentifierHelper() : is_identifier_(false), first_char_(true) {} | 2127 IsIdentifierHelper() : is_identifier_(false), first_char_(true) {} |
2135 | 2128 |
2136 bool Check(i::String* string) { | 2129 bool Check(i::String* string) { |
2137 i::ConsString* cons_string = i::String::VisitFlat(this, string, 0); | 2130 i::ConsString* cons_string = i::String::VisitFlat(this, string, 0); |
2138 if (cons_string == NULL) return is_identifier_; | 2131 if (cons_string == NULL) return is_identifier_; |
(...skipping 7288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9427 Address callback_address = | 9420 Address callback_address = |
9428 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9421 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
9429 VMState<EXTERNAL> state(isolate); | 9422 VMState<EXTERNAL> state(isolate); |
9430 ExternalCallbackScope call_scope(isolate, callback_address); | 9423 ExternalCallbackScope call_scope(isolate, callback_address); |
9431 callback(info); | 9424 callback(info); |
9432 } | 9425 } |
9433 | 9426 |
9434 | 9427 |
9435 } // namespace internal | 9428 } // namespace internal |
9436 } // namespace v8 | 9429 } // namespace v8 |
OLD | NEW |