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/base/utils/random-number-generator.h" | 9 #include "src/base/utils/random-number-generator.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 // environment has been at least partially initialized. Add a stack check | 1481 // environment has been at least partially initialized. Add a stack check |
1482 // before entering JS code to catch overflow early. | 1482 // before entering JS code to catch overflow early. |
1483 StackLimitCheck check(isolate); | 1483 StackLimitCheck check(isolate); |
1484 if (check.HasOverflowed()) return false; | 1484 if (check.HasOverflowed()) return false; |
1485 | 1485 |
1486 Handle<Context> context(isolate->context()); | 1486 Handle<Context> context(isolate->context()); |
1487 | 1487 |
1488 Handle<String> script_name = | 1488 Handle<String> script_name = |
1489 isolate->factory()->NewStringFromUtf8(name).ToHandleChecked(); | 1489 isolate->factory()->NewStringFromUtf8(name).ToHandleChecked(); |
1490 Handle<SharedFunctionInfo> function_info = Compiler::CompileScript( | 1490 Handle<SharedFunctionInfo> function_info = Compiler::CompileScript( |
1491 source, script_name, 0, 0, false, false, Handle<Object>(), context, NULL, | 1491 source, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(), |
1492 NULL, ScriptCompiler::kNoCompileOptions, NATIVES_CODE, false); | 1492 context, NULL, NULL, ScriptCompiler::kNoCompileOptions, NATIVES_CODE, |
| 1493 false); |
1493 | 1494 |
1494 DCHECK(context->IsNativeContext()); | 1495 DCHECK(context->IsNativeContext()); |
1495 | 1496 |
1496 Handle<Context> runtime_context(context->runtime_context()); | 1497 Handle<Context> runtime_context(context->runtime_context()); |
1497 Handle<JSBuiltinsObject> receiver(context->builtins()); | 1498 Handle<JSBuiltinsObject> receiver(context->builtins()); |
1498 Handle<JSFunction> fun = | 1499 Handle<JSFunction> fun = |
1499 isolate->factory()->NewFunctionFromSharedFunctionInfo(function_info, | 1500 isolate->factory()->NewFunctionFromSharedFunctionInfo(function_info, |
1500 runtime_context); | 1501 runtime_context); |
1501 | 1502 |
1502 // For non-extension scripts, run script to get the function wrapper. | 1503 // For non-extension scripts, run script to get the function wrapper. |
(...skipping 22 matching lines...) Expand all Loading... |
1525 // function and insert it into the cache. | 1526 // function and insert it into the cache. |
1526 Vector<const char> name = CStrVector(extension->name()); | 1527 Vector<const char> name = CStrVector(extension->name()); |
1527 SourceCodeCache* cache = isolate->bootstrapper()->extensions_cache(); | 1528 SourceCodeCache* cache = isolate->bootstrapper()->extensions_cache(); |
1528 Handle<Context> context(isolate->context()); | 1529 Handle<Context> context(isolate->context()); |
1529 DCHECK(context->IsNativeContext()); | 1530 DCHECK(context->IsNativeContext()); |
1530 | 1531 |
1531 if (!cache->Lookup(name, &function_info)) { | 1532 if (!cache->Lookup(name, &function_info)) { |
1532 Handle<String> script_name = | 1533 Handle<String> script_name = |
1533 factory->NewStringFromUtf8(name).ToHandleChecked(); | 1534 factory->NewStringFromUtf8(name).ToHandleChecked(); |
1534 function_info = Compiler::CompileScript( | 1535 function_info = Compiler::CompileScript( |
1535 source, script_name, 0, 0, false, false, Handle<Object>(), context, | 1536 source, script_name, 0, 0, ScriptOriginOptions(), Handle<Object>(), |
1536 extension, NULL, ScriptCompiler::kNoCompileOptions, NOT_NATIVES_CODE, | 1537 context, extension, NULL, ScriptCompiler::kNoCompileOptions, |
1537 false); | 1538 NOT_NATIVES_CODE, false); |
1538 if (function_info.is_null()) return false; | 1539 if (function_info.is_null()) return false; |
1539 cache->Add(name, function_info); | 1540 cache->Add(name, function_info); |
1540 } | 1541 } |
1541 | 1542 |
1542 // Set up the function context. Conceptually, we should clone the | 1543 // Set up the function context. Conceptually, we should clone the |
1543 // function before overwriting the context but since we're in a | 1544 // function before overwriting the context but since we're in a |
1544 // single-threaded environment it is not strictly necessary. | 1545 // single-threaded environment it is not strictly necessary. |
1545 Handle<JSFunction> fun = | 1546 Handle<JSFunction> fun = |
1546 factory->NewFunctionFromSharedFunctionInfo(function_info, context); | 1547 factory->NewFunctionFromSharedFunctionInfo(function_info, context); |
1547 | 1548 |
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3030 return from + sizeof(NestingCounterType); | 3031 return from + sizeof(NestingCounterType); |
3031 } | 3032 } |
3032 | 3033 |
3033 | 3034 |
3034 // Called when the top-level V8 mutex is destroyed. | 3035 // Called when the top-level V8 mutex is destroyed. |
3035 void Bootstrapper::FreeThreadResources() { | 3036 void Bootstrapper::FreeThreadResources() { |
3036 DCHECK(!IsActive()); | 3037 DCHECK(!IsActive()); |
3037 } | 3038 } |
3038 | 3039 |
3039 } } // namespace v8::internal | 3040 } } // namespace v8::internal |
OLD | NEW |