| 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 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1930 "v8", "V8.Execute", context, Module, Evaluate, MaybeLocal<Value>(), | 1930 "v8", "V8.Execute", context, Module, Evaluate, MaybeLocal<Value>(), |
| 1931 InternalEscapableScope, true); | 1931 InternalEscapableScope, true); |
| 1932 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); | 1932 i::HistogramTimerScope execute_timer(isolate->counters()->execute(), true); |
| 1933 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); | 1933 i::AggregatingHistogramTimerScope timer(isolate->counters()->compile_lazy()); |
| 1934 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); | 1934 i::TimerEventScope<i::TimerEventExecute> timer_scope(isolate); |
| 1935 | 1935 |
| 1936 i::Handle<i::Module> self = Utils::OpenHandle(this); | 1936 i::Handle<i::Module> self = Utils::OpenHandle(this); |
| 1937 // It's an API error to call Evaluate before Instantiate. | 1937 // It's an API error to call Evaluate before Instantiate. |
| 1938 CHECK(self->code()->IsJSFunction()); | 1938 CHECK(self->code()->IsJSFunction()); |
| 1939 | 1939 |
| 1940 // Each module can only be evaluated once. | |
| 1941 if (self->evaluated()) return Undefined(reinterpret_cast<Isolate*>(isolate)); | |
| 1942 self->set_evaluated(true); | |
| 1943 | |
| 1944 i::Handle<i::FixedArray> requested_modules(self->requested_modules(), | |
| 1945 isolate); | |
| 1946 for (int i = 0, length = requested_modules->length(); i < length; ++i) { | |
| 1947 i::Handle<i::Module> import(i::Module::cast(requested_modules->get(i)), | |
| 1948 isolate); | |
| 1949 MaybeLocal<Value> maybe_result = Utils::ToLocal(import)->Evaluate(context); | |
| 1950 if (maybe_result.IsEmpty()) return maybe_result; | |
| 1951 } | |
| 1952 | |
| 1953 i::Handle<i::JSFunction> function(i::JSFunction::cast(self->code()), isolate); | |
| 1954 DCHECK_EQ(i::MODULE_SCOPE, function->shared()->scope_info()->scope_type()); | |
| 1955 i::Handle<i::Object> receiver = isolate->factory()->undefined_value(); | |
| 1956 | |
| 1957 Local<Value> result; | 1940 Local<Value> result; |
| 1958 i::Handle<i::Object> argv[] = {self}; | 1941 has_pending_exception = !ToLocal(i::Module::Evaluate(self), &result); |
| 1959 has_pending_exception = !ToLocal<Value>( | |
| 1960 i::Execution::Call(isolate, function, receiver, arraysize(argv), argv), | |
| 1961 &result); | |
| 1962 | |
| 1963 RETURN_ON_FAILED_EXECUTION(Value); | 1942 RETURN_ON_FAILED_EXECUTION(Value); |
| 1964 RETURN_ESCAPED(result); | 1943 RETURN_ESCAPED(result); |
| 1965 } | 1944 } |
| 1966 | 1945 |
| 1967 MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal( | 1946 MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal( |
| 1968 Isolate* v8_isolate, Source* source, CompileOptions options, | 1947 Isolate* v8_isolate, Source* source, CompileOptions options, |
| 1969 bool is_module) { | 1948 bool is_module) { |
| 1970 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 1949 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 1971 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, ScriptCompiler, CompileUnbound, | 1950 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, ScriptCompiler, CompileUnbound, |
| 1972 UnboundScript); | 1951 UnboundScript); |
| (...skipping 7417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9390 Address callback_address = | 9369 Address callback_address = |
| 9391 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 9370 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 9392 VMState<EXTERNAL> state(isolate); | 9371 VMState<EXTERNAL> state(isolate); |
| 9393 ExternalCallbackScope call_scope(isolate, callback_address); | 9372 ExternalCallbackScope call_scope(isolate, callback_address); |
| 9394 callback(info); | 9373 callback(info); |
| 9395 } | 9374 } |
| 9396 | 9375 |
| 9397 | 9376 |
| 9398 } // namespace internal | 9377 } // namespace internal |
| 9399 } // namespace v8 | 9378 } // namespace v8 |
| OLD | NEW |