| 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 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1911 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); | 1911 i::Handle<i::SharedFunctionInfo>(i::JSFunction::cast(*obj)->shared())); |
| 1912 } | 1912 } |
| 1913 | 1913 |
| 1914 | 1914 |
| 1915 MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal( | 1915 MaybeLocal<UnboundScript> ScriptCompiler::CompileUnboundInternal( |
| 1916 Isolate* v8_isolate, Source* source, CompileOptions options, | 1916 Isolate* v8_isolate, Source* source, CompileOptions options, |
| 1917 bool is_module) { | 1917 bool is_module) { |
| 1918 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | 1918 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| 1919 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, ScriptCompiler, CompileUnbound, | 1919 PREPARE_FOR_EXECUTION_WITH_ISOLATE(isolate, ScriptCompiler, CompileUnbound, |
| 1920 UnboundScript); | 1920 UnboundScript); |
| 1921 TRACE_EVENT0("v8", "V8.ScriptCompiler"); |
| 1921 | 1922 |
| 1922 // Don't try to produce any kind of cache when the debugger is loaded. | 1923 // Don't try to produce any kind of cache when the debugger is loaded. |
| 1923 if (isolate->debug()->is_loaded() && | 1924 if (isolate->debug()->is_loaded() && |
| 1924 (options == kProduceParserCache || options == kProduceCodeCache)) { | 1925 (options == kProduceParserCache || options == kProduceCodeCache)) { |
| 1925 options = kNoCompileOptions; | 1926 options = kNoCompileOptions; |
| 1926 } | 1927 } |
| 1927 | 1928 |
| 1928 i::ScriptData* script_data = NULL; | 1929 i::ScriptData* script_data = NULL; |
| 1929 if (options == kConsumeParserCache || options == kConsumeCodeCache) { | 1930 if (options == kConsumeParserCache || options == kConsumeCodeCache) { |
| 1930 DCHECK(source->cached_data); | 1931 DCHECK(source->cached_data); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2071 DISALLOW_COPY_AND_ASSIGN(IsIdentifierHelper); | 2072 DISALLOW_COPY_AND_ASSIGN(IsIdentifierHelper); |
| 2072 }; | 2073 }; |
| 2073 | 2074 |
| 2074 | 2075 |
| 2075 MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext( | 2076 MaybeLocal<Function> ScriptCompiler::CompileFunctionInContext( |
| 2076 Local<Context> v8_context, Source* source, size_t arguments_count, | 2077 Local<Context> v8_context, Source* source, size_t arguments_count, |
| 2077 Local<String> arguments[], size_t context_extension_count, | 2078 Local<String> arguments[], size_t context_extension_count, |
| 2078 Local<Object> context_extensions[]) { | 2079 Local<Object> context_extensions[]) { |
| 2079 PREPARE_FOR_EXECUTION(v8_context, ScriptCompiler, CompileFunctionInContext, | 2080 PREPARE_FOR_EXECUTION(v8_context, ScriptCompiler, CompileFunctionInContext, |
| 2080 Function); | 2081 Function); |
| 2082 TRACE_EVENT0("v8", "V8.ScriptCompiler"); |
| 2081 i::Handle<i::String> source_string; | 2083 i::Handle<i::String> source_string; |
| 2082 auto factory = isolate->factory(); | 2084 auto factory = isolate->factory(); |
| 2083 if (arguments_count) { | 2085 if (arguments_count) { |
| 2084 source_string = factory->NewStringFromStaticChars("(function("); | 2086 source_string = factory->NewStringFromStaticChars("(function("); |
| 2085 for (size_t i = 0; i < arguments_count; ++i) { | 2087 for (size_t i = 0; i < arguments_count; ++i) { |
| 2086 IsIdentifierHelper helper; | 2088 IsIdentifierHelper helper; |
| 2087 if (!helper.Check(*Utils::OpenHandle(*arguments[i]))) { | 2089 if (!helper.Check(*Utils::OpenHandle(*arguments[i]))) { |
| 2088 return Local<Function>(); | 2090 return Local<Function>(); |
| 2089 } | 2091 } |
| 2090 has_pending_exception = | 2092 has_pending_exception = |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2185 return new i::BackgroundParsingTask(source->impl(), options, | 2187 return new i::BackgroundParsingTask(source->impl(), options, |
| 2186 i::FLAG_stack_size, isolate); | 2188 i::FLAG_stack_size, isolate); |
| 2187 } | 2189 } |
| 2188 | 2190 |
| 2189 | 2191 |
| 2190 MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context, | 2192 MaybeLocal<Script> ScriptCompiler::Compile(Local<Context> context, |
| 2191 StreamedSource* v8_source, | 2193 StreamedSource* v8_source, |
| 2192 Local<String> full_source_string, | 2194 Local<String> full_source_string, |
| 2193 const ScriptOrigin& origin) { | 2195 const ScriptOrigin& origin) { |
| 2194 PREPARE_FOR_EXECUTION(context, ScriptCompiler, Compile, Script); | 2196 PREPARE_FOR_EXECUTION(context, ScriptCompiler, Compile, Script); |
| 2197 TRACE_EVENT0("v8", "V8.ScriptCompiler"); |
| 2195 i::StreamedSource* source = v8_source->impl(); | 2198 i::StreamedSource* source = v8_source->impl(); |
| 2196 i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string)); | 2199 i::Handle<i::String> str = Utils::OpenHandle(*(full_source_string)); |
| 2197 i::Handle<i::Script> script = isolate->factory()->NewScript(str); | 2200 i::Handle<i::Script> script = isolate->factory()->NewScript(str); |
| 2198 if (!origin.ResourceName().IsEmpty()) { | 2201 if (!origin.ResourceName().IsEmpty()) { |
| 2199 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); | 2202 script->set_name(*Utils::OpenHandle(*(origin.ResourceName()))); |
| 2200 } | 2203 } |
| 2201 if (!origin.ResourceLineOffset().IsEmpty()) { | 2204 if (!origin.ResourceLineOffset().IsEmpty()) { |
| 2202 script->set_line_offset( | 2205 script->set_line_offset( |
| 2203 static_cast<int>(origin.ResourceLineOffset()->Value())); | 2206 static_cast<int>(origin.ResourceLineOffset()->Value())); |
| 2204 } | 2207 } |
| (...skipping 6742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8947 Address callback_address = | 8950 Address callback_address = |
| 8948 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8951 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8949 VMState<EXTERNAL> state(isolate); | 8952 VMState<EXTERNAL> state(isolate); |
| 8950 ExternalCallbackScope call_scope(isolate, callback_address); | 8953 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8951 callback(info); | 8954 callback(info); |
| 8952 } | 8955 } |
| 8953 | 8956 |
| 8954 | 8957 |
| 8955 } // namespace internal | 8958 } // namespace internal |
| 8956 } // namespace v8 | 8959 } // namespace v8 |
| OLD | NEW |