| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/extensions/externalize-string-extension.h" | 10 #include "src/extensions/externalize-string-extension.h" |
| (...skipping 1867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 StackLimitCheck check(isolate); | 1878 StackLimitCheck check(isolate); |
| 1879 if (check.JsHasOverflowed(1 * KB)) { | 1879 if (check.JsHasOverflowed(1 * KB)) { |
| 1880 isolate->StackOverflow(); | 1880 isolate->StackOverflow(); |
| 1881 return false; | 1881 return false; |
| 1882 } | 1882 } |
| 1883 | 1883 |
| 1884 Handle<Context> context(isolate->context()); | 1884 Handle<Context> context(isolate->context()); |
| 1885 | 1885 |
| 1886 Handle<String> script_name = | 1886 Handle<String> script_name = |
| 1887 isolate->factory()->NewStringFromUtf8(name).ToHandleChecked(); | 1887 isolate->factory()->NewStringFromUtf8(name).ToHandleChecked(); |
| 1888 Handle<SharedFunctionInfo> function_info = Compiler::CompileScript( | 1888 Handle<SharedFunctionInfo> function_info = |
| 1889 source, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(), | 1889 Compiler::GetSharedFunctionInfoForScript( |
| 1890 context, NULL, NULL, ScriptCompiler::kNoCompileOptions, natives_flag, | 1890 source, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(), |
| 1891 false); | 1891 context, NULL, NULL, ScriptCompiler::kNoCompileOptions, natives_flag, |
| 1892 false); |
| 1892 if (function_info.is_null()) return false; | 1893 if (function_info.is_null()) return false; |
| 1893 | 1894 |
| 1894 DCHECK(context->IsNativeContext()); | 1895 DCHECK(context->IsNativeContext()); |
| 1895 | 1896 |
| 1896 Handle<JSFunction> fun = | 1897 Handle<JSFunction> fun = |
| 1897 isolate->factory()->NewFunctionFromSharedFunctionInfo(function_info, | 1898 isolate->factory()->NewFunctionFromSharedFunctionInfo(function_info, |
| 1898 context); | 1899 context); |
| 1899 Handle<Object> receiver = isolate->factory()->undefined_value(); | 1900 Handle<Object> receiver = isolate->factory()->undefined_value(); |
| 1900 | 1901 |
| 1901 // For non-extension scripts, run script to get the function wrapper. | 1902 // For non-extension scripts, run script to get the function wrapper. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 // If we can't find the function in the cache, we compile a new | 1936 // If we can't find the function in the cache, we compile a new |
| 1936 // function and insert it into the cache. | 1937 // function and insert it into the cache. |
| 1937 Vector<const char> name = CStrVector(extension->name()); | 1938 Vector<const char> name = CStrVector(extension->name()); |
| 1938 SourceCodeCache* cache = isolate->bootstrapper()->extensions_cache(); | 1939 SourceCodeCache* cache = isolate->bootstrapper()->extensions_cache(); |
| 1939 Handle<Context> context(isolate->context()); | 1940 Handle<Context> context(isolate->context()); |
| 1940 DCHECK(context->IsNativeContext()); | 1941 DCHECK(context->IsNativeContext()); |
| 1941 | 1942 |
| 1942 if (!cache->Lookup(name, &function_info)) { | 1943 if (!cache->Lookup(name, &function_info)) { |
| 1943 Handle<String> script_name = | 1944 Handle<String> script_name = |
| 1944 factory->NewStringFromUtf8(name).ToHandleChecked(); | 1945 factory->NewStringFromUtf8(name).ToHandleChecked(); |
| 1945 function_info = Compiler::CompileScript( | 1946 function_info = Compiler::GetSharedFunctionInfoForScript( |
| 1946 source, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(), | 1947 source, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(), |
| 1947 context, extension, NULL, ScriptCompiler::kNoCompileOptions, | 1948 context, extension, NULL, ScriptCompiler::kNoCompileOptions, |
| 1948 EXTENSION_CODE, false); | 1949 EXTENSION_CODE, false); |
| 1949 if (function_info.is_null()) return false; | 1950 if (function_info.is_null()) return false; |
| 1950 cache->Add(name, function_info); | 1951 cache->Add(name, function_info); |
| 1951 } | 1952 } |
| 1952 | 1953 |
| 1953 // Set up the function context. Conceptually, we should clone the | 1954 // Set up the function context. Conceptually, we should clone the |
| 1954 // function before overwriting the context but since we're in a | 1955 // function before overwriting the context but since we're in a |
| 1955 // single-threaded environment it is not strictly necessary. | 1956 // single-threaded environment it is not strictly necessary. |
| (...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3632 } | 3633 } |
| 3633 | 3634 |
| 3634 | 3635 |
| 3635 // Called when the top-level V8 mutex is destroyed. | 3636 // Called when the top-level V8 mutex is destroyed. |
| 3636 void Bootstrapper::FreeThreadResources() { | 3637 void Bootstrapper::FreeThreadResources() { |
| 3637 DCHECK(!IsActive()); | 3638 DCHECK(!IsActive()); |
| 3638 } | 3639 } |
| 3639 | 3640 |
| 3640 } // namespace internal | 3641 } // namespace internal |
| 3641 } // namespace v8 | 3642 } // namespace v8 |
| OLD | NEW |