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/compiler.h" | 5 #include "src/compiler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/asmjs/asm-js.h" | 10 #include "src/asmjs/asm-js.h" |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 return info->code(); | 624 return info->code(); |
625 } | 625 } |
626 | 626 |
627 MUST_USE_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeMap( | 627 MUST_USE_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeMap( |
628 Handle<JSFunction> function, BailoutId osr_ast_id) { | 628 Handle<JSFunction> function, BailoutId osr_ast_id) { |
629 RuntimeCallTimerScope runtimeTimer( | 629 RuntimeCallTimerScope runtimeTimer( |
630 function->GetIsolate(), | 630 function->GetIsolate(), |
631 &RuntimeCallStats::CompileGetFromOptimizedCodeMap); | 631 &RuntimeCallStats::CompileGetFromOptimizedCodeMap); |
632 Handle<SharedFunctionInfo> shared(function->shared()); | 632 Handle<SharedFunctionInfo> shared(function->shared()); |
633 DisallowHeapAllocation no_gc; | 633 DisallowHeapAllocation no_gc; |
634 CodeAndVector cached = shared->SearchOptimizedCodeMap( | 634 Code* code = shared->SearchOptimizedCodeMap( |
635 function->context()->native_context(), osr_ast_id); | 635 function->context()->native_context(), osr_ast_id); |
636 if (cached.code != nullptr) { | 636 if (code != nullptr) { |
637 // Caching of optimized code enabled and optimized code found. | 637 // Caching of optimized code enabled and optimized code found. |
638 if (cached.vector != nullptr) function->set_feedback_vector(cached.vector); | 638 DCHECK(!code->marked_for_deoptimization()); |
639 DCHECK(!cached.code->marked_for_deoptimization()); | |
640 DCHECK(function->shared()->is_compiled()); | 639 DCHECK(function->shared()->is_compiled()); |
641 return Handle<Code>(cached.code); | 640 return Handle<Code>(code); |
642 } | 641 } |
643 return MaybeHandle<Code>(); | 642 return MaybeHandle<Code>(); |
644 } | 643 } |
645 | 644 |
646 void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { | 645 void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) { |
647 Handle<Code> code = info->code(); | 646 Handle<Code> code = info->code(); |
648 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. | 647 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do. |
649 | 648 |
650 // Function context specialization folds-in the function context, | 649 // Function context specialization folds-in the function context, |
651 // so no sharing can occur. | 650 // so no sharing can occur. |
652 if (info->is_function_context_specializing()) return; | 651 if (info->is_function_context_specializing()) return; |
653 // Frame specialization implies function context specialization. | 652 // Frame specialization implies function context specialization. |
654 DCHECK(!info->is_frame_specializing()); | 653 DCHECK(!info->is_frame_specializing()); |
655 | 654 |
656 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive | 655 // TODO(4764): When compiling for OSR from bytecode, BailoutId might derive |
657 // from bytecode offset and overlap with actual BailoutId. No caching! | 656 // from bytecode offset and overlap with actual BailoutId. No caching! |
658 if (info->is_osr() && info->is_optimizing_from_bytecode()) return; | 657 if (info->is_osr() && info->is_optimizing_from_bytecode()) return; |
659 | 658 |
660 // Cache optimized context-specific code. | 659 // Cache optimized context-specific code. |
661 Handle<JSFunction> function = info->closure(); | 660 Handle<JSFunction> function = info->closure(); |
662 Handle<SharedFunctionInfo> shared(function->shared()); | 661 Handle<SharedFunctionInfo> shared(function->shared()); |
663 Handle<TypeFeedbackVector> vector(function->feedback_vector()); | |
664 Handle<Context> native_context(function->context()->native_context()); | 662 Handle<Context> native_context(function->context()->native_context()); |
665 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 663 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
666 vector, info->osr_ast_id()); | 664 info->osr_ast_id()); |
667 } | 665 } |
668 | 666 |
669 bool GetOptimizedCodeNow(CompilationJob* job) { | 667 bool GetOptimizedCodeNow(CompilationJob* job) { |
670 CompilationInfo* info = job->info(); | 668 CompilationInfo* info = job->info(); |
671 Isolate* isolate = info->isolate(); | 669 Isolate* isolate = info->isolate(); |
672 | 670 |
673 // Parsing is not required when optimizing from existing bytecode. | 671 // Parsing is not required when optimizing from existing bytecode. |
674 if (!info->is_optimizing_from_bytecode()) { | 672 if (!info->is_optimizing_from_bytecode()) { |
675 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; | 673 if (!Compiler::ParseAndAnalyze(info->parse_info())) return false; |
676 EnsureFeedbackMetadata(info); | 674 EnsureFeedbackMetadata(info); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 // 3) The code may have already been invalidated due to dependency change. | 890 // 3) The code may have already been invalidated due to dependency change. |
893 // 4) Code generation may have failed. | 891 // 4) Code generation may have failed. |
894 if (job->state() == CompilationJob::State::kReadyToFinalize) { | 892 if (job->state() == CompilationJob::State::kReadyToFinalize) { |
895 if (shared->optimization_disabled()) { | 893 if (shared->optimization_disabled()) { |
896 job->RetryOptimization(kOptimizationDisabled); | 894 job->RetryOptimization(kOptimizationDisabled); |
897 } else if (info->dependencies()->HasAborted()) { | 895 } else if (info->dependencies()->HasAborted()) { |
898 job->RetryOptimization(kBailedOutDueToDependencyChange); | 896 job->RetryOptimization(kBailedOutDueToDependencyChange); |
899 } else if (job->FinalizeJob() == CompilationJob::SUCCEEDED) { | 897 } else if (job->FinalizeJob() == CompilationJob::SUCCEEDED) { |
900 job->RecordOptimizedCompilationStats(); | 898 job->RecordOptimizedCompilationStats(); |
901 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info); | 899 RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info); |
902 if (shared | 900 if (shared->SearchOptimizedCodeMap(info->context()->native_context(), |
903 ->SearchOptimizedCodeMap(info->context()->native_context(), | 901 info->osr_ast_id()) == nullptr) { |
904 info->osr_ast_id()) | |
905 .code == nullptr) { | |
906 InsertCodeIntoOptimizedCodeMap(info); | 902 InsertCodeIntoOptimizedCodeMap(info); |
907 } | 903 } |
908 if (FLAG_trace_opt) { | 904 if (FLAG_trace_opt) { |
909 PrintF("[completed optimizing "); | 905 PrintF("[completed optimizing "); |
910 info->closure()->ShortPrint(); | 906 info->closure()->ShortPrint(); |
911 PrintF("]\n"); | 907 PrintF("]\n"); |
912 } | 908 } |
913 info->closure()->ReplaceCode(*info->code()); | 909 info->closure()->ReplaceCode(*info->code()); |
914 return CompilationJob::SUCCEEDED; | 910 return CompilationJob::SUCCEEDED; |
915 } | 911 } |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 Handle<Context> context, LanguageMode language_mode, | 1403 Handle<Context> context, LanguageMode language_mode, |
1408 ParseRestriction restriction, int eval_scope_position, int eval_position, | 1404 ParseRestriction restriction, int eval_scope_position, int eval_position, |
1409 int line_offset, int column_offset, Handle<Object> script_name, | 1405 int line_offset, int column_offset, Handle<Object> script_name, |
1410 ScriptOriginOptions options) { | 1406 ScriptOriginOptions options) { |
1411 Isolate* isolate = source->GetIsolate(); | 1407 Isolate* isolate = source->GetIsolate(); |
1412 int source_length = source->length(); | 1408 int source_length = source->length(); |
1413 isolate->counters()->total_eval_size()->Increment(source_length); | 1409 isolate->counters()->total_eval_size()->Increment(source_length); |
1414 isolate->counters()->total_compile_size()->Increment(source_length); | 1410 isolate->counters()->total_compile_size()->Increment(source_length); |
1415 | 1411 |
1416 CompilationCache* compilation_cache = isolate->compilation_cache(); | 1412 CompilationCache* compilation_cache = isolate->compilation_cache(); |
1417 MaybeHandle<SharedFunctionInfo> maybe_shared_info = | 1413 InfoVectorPair eval_result = compilation_cache->LookupEval( |
1418 compilation_cache->LookupEval(source, outer_info, context, language_mode, | 1414 source, outer_info, context, language_mode, eval_scope_position); |
1419 eval_scope_position); | |
1420 Handle<SharedFunctionInfo> shared_info; | 1415 Handle<SharedFunctionInfo> shared_info; |
| 1416 if (eval_result.has_shared()) { |
| 1417 shared_info = Handle<SharedFunctionInfo>(eval_result.shared(), isolate); |
| 1418 } |
| 1419 Handle<Cell> vector; |
| 1420 if (eval_result.has_vector()) { |
| 1421 vector = Handle<Cell>(eval_result.vector(), isolate); |
| 1422 } |
1421 | 1423 |
1422 Handle<Script> script; | 1424 Handle<Script> script; |
1423 if (!maybe_shared_info.ToHandle(&shared_info)) { | 1425 if (!eval_result.has_shared()) { |
1424 script = isolate->factory()->NewScript(source); | 1426 script = isolate->factory()->NewScript(source); |
1425 if (isolate->NeedsSourcePositionsForProfiling()) { | 1427 if (isolate->NeedsSourcePositionsForProfiling()) { |
1426 Script::InitLineEnds(script); | 1428 Script::InitLineEnds(script); |
1427 } | 1429 } |
1428 if (!script_name.is_null()) { | 1430 if (!script_name.is_null()) { |
1429 script->set_name(*script_name); | 1431 script->set_name(*script_name); |
1430 script->set_line_offset(line_offset); | 1432 script->set_line_offset(line_offset); |
1431 script->set_column_offset(column_offset); | 1433 script->set_column_offset(column_offset); |
1432 } | 1434 } |
1433 script->set_origin_options(options); | 1435 script->set_origin_options(options); |
1434 script->set_compilation_type(Script::COMPILATION_TYPE_EVAL); | 1436 script->set_compilation_type(Script::COMPILATION_TYPE_EVAL); |
1435 Script::SetEvalOrigin(script, outer_info, eval_position); | 1437 Script::SetEvalOrigin(script, outer_info, eval_position); |
1436 | 1438 |
1437 Zone zone(isolate->allocator(), ZONE_NAME); | 1439 Zone zone(isolate->allocator(), ZONE_NAME); |
1438 ParseInfo parse_info(&zone, script); | 1440 ParseInfo parse_info(&zone, script); |
1439 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); | 1441 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); |
1440 parse_info.set_eval(); | 1442 parse_info.set_eval(); |
1441 parse_info.set_language_mode(language_mode); | 1443 parse_info.set_language_mode(language_mode); |
1442 parse_info.set_parse_restriction(restriction); | 1444 parse_info.set_parse_restriction(restriction); |
1443 if (!context->IsNativeContext()) { | 1445 if (!context->IsNativeContext()) { |
1444 parse_info.set_outer_scope_info(handle(context->scope_info())); | 1446 parse_info.set_outer_scope_info(handle(context->scope_info())); |
1445 } | 1447 } |
1446 | 1448 |
1447 shared_info = CompileToplevel(&info); | 1449 shared_info = CompileToplevel(&info); |
1448 | |
1449 if (shared_info.is_null()) { | 1450 if (shared_info.is_null()) { |
1450 return MaybeHandle<JSFunction>(); | 1451 return MaybeHandle<JSFunction>(); |
1451 } else { | |
1452 // If caller is strict mode, the result must be in strict mode as well. | |
1453 DCHECK(is_sloppy(language_mode) || | |
1454 is_strict(shared_info->language_mode())); | |
1455 compilation_cache->PutEval(source, outer_info, context, shared_info, | |
1456 eval_scope_position); | |
1457 } | 1452 } |
1458 } | 1453 } |
1459 | 1454 |
1460 Handle<JSFunction> result = | 1455 // If caller is strict mode, the result must be in strict mode as well. |
1461 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 1456 DCHECK(is_sloppy(language_mode) || is_strict(shared_info->language_mode())); |
1462 shared_info, context, NOT_TENURED); | 1457 |
| 1458 Handle<JSFunction> result; |
| 1459 if (eval_result.has_shared()) { |
| 1460 if (eval_result.has_vector()) { |
| 1461 result = isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 1462 shared_info, context, vector, NOT_TENURED); |
| 1463 } else { |
| 1464 result = isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 1465 shared_info, context, isolate->factory()->undefined_cell(), |
| 1466 NOT_TENURED); |
| 1467 JSFunction::EnsureLiterals(result); |
| 1468 // Make sure to cache this result. |
| 1469 Handle<Cell> new_vector(result->feedback_vector_cell(), isolate); |
| 1470 compilation_cache->PutEval(source, outer_info, context, shared_info, |
| 1471 new_vector, eval_scope_position); |
| 1472 } |
| 1473 } else { |
| 1474 result = isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 1475 shared_info, context, NOT_TENURED); |
| 1476 JSFunction::EnsureLiterals(result); |
| 1477 // Add the SharedFunctionInfo and the LiteralsArray to the eval cache if |
| 1478 // we didn't retrieve from there. |
| 1479 Handle<Cell> vector(result->feedback_vector_cell(), isolate); |
| 1480 compilation_cache->PutEval(source, outer_info, context, shared_info, vector, |
| 1481 eval_scope_position); |
| 1482 } |
1463 | 1483 |
1464 // OnAfterCompile has to be called after we create the JSFunction, which we | 1484 // OnAfterCompile has to be called after we create the JSFunction, which we |
1465 // may require to recompile the eval for debugging, if we find a function | 1485 // may require to recompile the eval for debugging, if we find a function |
1466 // that contains break points in the eval script. | 1486 // that contains break points in the eval script. |
1467 isolate->debug()->OnAfterCompile(script); | 1487 isolate->debug()->OnAfterCompile(script); |
1468 | 1488 |
1469 return result; | 1489 return result; |
1470 } | 1490 } |
1471 | 1491 |
1472 namespace { | 1492 namespace { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 DCHECK(extension == NULL); | 1565 DCHECK(extension == NULL); |
1546 } | 1566 } |
1547 int source_length = source->length(); | 1567 int source_length = source->length(); |
1548 isolate->counters()->total_load_size()->Increment(source_length); | 1568 isolate->counters()->total_load_size()->Increment(source_length); |
1549 isolate->counters()->total_compile_size()->Increment(source_length); | 1569 isolate->counters()->total_compile_size()->Increment(source_length); |
1550 | 1570 |
1551 LanguageMode language_mode = construct_language_mode(FLAG_use_strict); | 1571 LanguageMode language_mode = construct_language_mode(FLAG_use_strict); |
1552 CompilationCache* compilation_cache = isolate->compilation_cache(); | 1572 CompilationCache* compilation_cache = isolate->compilation_cache(); |
1553 | 1573 |
1554 // Do a lookup in the compilation cache but not for extensions. | 1574 // Do a lookup in the compilation cache but not for extensions. |
1555 MaybeHandle<SharedFunctionInfo> maybe_result; | |
1556 Handle<SharedFunctionInfo> result; | 1575 Handle<SharedFunctionInfo> result; |
| 1576 Handle<Cell> vector; |
1557 if (extension == NULL) { | 1577 if (extension == NULL) { |
1558 // First check per-isolate compilation cache. | 1578 // First check per-isolate compilation cache. |
1559 maybe_result = compilation_cache->LookupScript( | 1579 InfoVectorPair pair = compilation_cache->LookupScript( |
1560 source, script_name, line_offset, column_offset, resource_options, | 1580 source, script_name, line_offset, column_offset, resource_options, |
1561 context, language_mode); | 1581 context, language_mode); |
1562 if (maybe_result.is_null() && FLAG_serialize_toplevel && | 1582 if (!pair.has_shared() && FLAG_serialize_toplevel && |
1563 compile_options == ScriptCompiler::kConsumeCodeCache && | 1583 compile_options == ScriptCompiler::kConsumeCodeCache && |
1564 !isolate->debug()->is_loaded()) { | 1584 !isolate->debug()->is_loaded()) { |
1565 // Then check cached code provided by embedder. | 1585 // Then check cached code provided by embedder. |
1566 HistogramTimerScope timer(isolate->counters()->compile_deserialize()); | 1586 HistogramTimerScope timer(isolate->counters()->compile_deserialize()); |
1567 RuntimeCallTimerScope runtimeTimer(isolate, | 1587 RuntimeCallTimerScope runtimeTimer(isolate, |
1568 &RuntimeCallStats::CompileDeserialize); | 1588 &RuntimeCallStats::CompileDeserialize); |
1569 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), | 1589 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), |
1570 "V8.CompileDeserialize"); | 1590 "V8.CompileDeserialize"); |
1571 Handle<SharedFunctionInfo> result; | 1591 Handle<SharedFunctionInfo> inner_result; |
1572 if (CodeSerializer::Deserialize(isolate, *cached_data, source) | 1592 if (CodeSerializer::Deserialize(isolate, *cached_data, source) |
1573 .ToHandle(&result)) { | 1593 .ToHandle(&inner_result)) { |
1574 // Promote to per-isolate compilation cache. | 1594 // Promote to per-isolate compilation cache. |
1575 compilation_cache->PutScript(source, context, language_mode, result); | 1595 // TODO(mvstanton): create a feedback vector array here. |
1576 return result; | 1596 DCHECK(inner_result->is_compiled()); |
| 1597 Handle<TypeFeedbackVector> feedback_vector = TypeFeedbackVector::New( |
| 1598 isolate, handle(inner_result->feedback_metadata())); |
| 1599 vector = isolate->factory()->NewCell(feedback_vector); |
| 1600 compilation_cache->PutScript(source, context, language_mode, |
| 1601 inner_result, vector); |
| 1602 return inner_result; |
1577 } | 1603 } |
1578 // Deserializer failed. Fall through to compile. | 1604 // Deserializer failed. Fall through to compile. |
| 1605 } else { |
| 1606 if (pair.has_shared()) { |
| 1607 result = Handle<SharedFunctionInfo>(pair.shared(), isolate); |
| 1608 } |
| 1609 if (pair.has_vector()) { |
| 1610 vector = Handle<Cell>(pair.vector(), isolate); |
| 1611 } |
1579 } | 1612 } |
1580 } | 1613 } |
1581 | 1614 |
1582 base::ElapsedTimer timer; | 1615 base::ElapsedTimer timer; |
1583 if (FLAG_profile_deserialization && FLAG_serialize_toplevel && | 1616 if (FLAG_profile_deserialization && FLAG_serialize_toplevel && |
1584 compile_options == ScriptCompiler::kProduceCodeCache) { | 1617 compile_options == ScriptCompiler::kProduceCodeCache) { |
1585 timer.Start(); | 1618 timer.Start(); |
1586 } | 1619 } |
1587 | 1620 |
1588 if (!maybe_result.ToHandle(&result) || | 1621 if (result.is_null() || |
1589 (FLAG_serialize_toplevel && | 1622 (FLAG_serialize_toplevel && |
1590 compile_options == ScriptCompiler::kProduceCodeCache)) { | 1623 compile_options == ScriptCompiler::kProduceCodeCache)) { |
1591 // No cache entry found, or embedder wants a code cache. Compile the script. | 1624 // No cache entry found, or embedder wants a code cache. Compile the script. |
1592 | 1625 |
1593 // Create a script object describing the script to be compiled. | 1626 // Create a script object describing the script to be compiled. |
1594 Handle<Script> script = isolate->factory()->NewScript(source); | 1627 Handle<Script> script = isolate->factory()->NewScript(source); |
1595 if (isolate->NeedsSourcePositionsForProfiling()) { | 1628 if (isolate->NeedsSourcePositionsForProfiling()) { |
1596 Script::InitLineEnds(script); | 1629 Script::InitLineEnds(script); |
1597 } | 1630 } |
1598 if (natives == NATIVES_CODE) { | 1631 if (natives == NATIVES_CODE) { |
(...skipping 28 matching lines...) Expand all Loading... |
1627 } | 1660 } |
1628 if (FLAG_serialize_toplevel && | 1661 if (FLAG_serialize_toplevel && |
1629 compile_options == ScriptCompiler::kProduceCodeCache) { | 1662 compile_options == ScriptCompiler::kProduceCodeCache) { |
1630 info.PrepareForSerializing(); | 1663 info.PrepareForSerializing(); |
1631 } | 1664 } |
1632 | 1665 |
1633 parse_info.set_language_mode( | 1666 parse_info.set_language_mode( |
1634 static_cast<LanguageMode>(parse_info.language_mode() | language_mode)); | 1667 static_cast<LanguageMode>(parse_info.language_mode() | language_mode)); |
1635 result = CompileToplevel(&info); | 1668 result = CompileToplevel(&info); |
1636 if (extension == NULL && !result.is_null()) { | 1669 if (extension == NULL && !result.is_null()) { |
1637 compilation_cache->PutScript(source, context, language_mode, result); | 1670 // We need a feedback vector. |
| 1671 DCHECK(result->is_compiled()); |
| 1672 Handle<TypeFeedbackVector> feedback_vector = |
| 1673 TypeFeedbackVector::New(isolate, handle(result->feedback_metadata())); |
| 1674 vector = isolate->factory()->NewCell(feedback_vector); |
| 1675 compilation_cache->PutScript(source, context, language_mode, result, |
| 1676 vector); |
1638 if (FLAG_serialize_toplevel && | 1677 if (FLAG_serialize_toplevel && |
1639 compile_options == ScriptCompiler::kProduceCodeCache && | 1678 compile_options == ScriptCompiler::kProduceCodeCache && |
1640 !ContainsAsmModule(script)) { | 1679 !ContainsAsmModule(script)) { |
1641 HistogramTimerScope histogram_timer( | 1680 HistogramTimerScope histogram_timer( |
1642 isolate->counters()->compile_serialize()); | 1681 isolate->counters()->compile_serialize()); |
1643 RuntimeCallTimerScope runtimeTimer(isolate, | 1682 RuntimeCallTimerScope runtimeTimer(isolate, |
1644 &RuntimeCallStats::CompileSerialize); | 1683 &RuntimeCallStats::CompileSerialize); |
1645 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), | 1684 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), |
1646 "V8.CompileSerialize"); | 1685 "V8.CompileSerialize"); |
1647 *cached_data = CodeSerializer::Serialize(isolate, result, source); | 1686 *cached_data = CodeSerializer::Serialize(isolate, result, source); |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1781 void Compiler::PostInstantiation(Handle<JSFunction> function, | 1820 void Compiler::PostInstantiation(Handle<JSFunction> function, |
1782 PretenureFlag pretenure) { | 1821 PretenureFlag pretenure) { |
1783 Handle<SharedFunctionInfo> shared(function->shared()); | 1822 Handle<SharedFunctionInfo> shared(function->shared()); |
1784 | 1823 |
1785 if (FLAG_always_opt && shared->allows_lazy_compilation() && | 1824 if (FLAG_always_opt && shared->allows_lazy_compilation() && |
1786 !function->shared()->HasAsmWasmData() && | 1825 !function->shared()->HasAsmWasmData() && |
1787 function->shared()->is_compiled()) { | 1826 function->shared()->is_compiled()) { |
1788 function->MarkForOptimization(); | 1827 function->MarkForOptimization(); |
1789 } | 1828 } |
1790 | 1829 |
1791 CodeAndVector cached = shared->SearchOptimizedCodeMap( | 1830 Code* code = shared->SearchOptimizedCodeMap( |
1792 function->context()->native_context(), BailoutId::None()); | 1831 function->context()->native_context(), BailoutId::None()); |
1793 if (cached.code != nullptr) { | 1832 if (code != nullptr) { |
1794 // Caching of optimized code enabled and optimized code found. | 1833 // Caching of optimized code enabled and optimized code found. |
1795 DCHECK(!cached.code->marked_for_deoptimization()); | 1834 DCHECK(!code->marked_for_deoptimization()); |
1796 DCHECK(function->shared()->is_compiled()); | 1835 DCHECK(function->shared()->is_compiled()); |
1797 function->ReplaceCode(cached.code); | 1836 function->ReplaceCode(code); |
1798 } | 1837 } |
1799 | 1838 |
1800 if (cached.vector != nullptr) { | 1839 if (shared->is_compiled()) { |
1801 DCHECK(shared->is_compiled()); | |
1802 function->set_feedback_vector(cached.vector); | |
1803 } else if (shared->is_compiled()) { | |
1804 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1840 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
1805 JSFunction::EnsureLiterals(function); | 1841 JSFunction::EnsureLiterals(function); |
1806 } | 1842 } |
1807 } | 1843 } |
1808 | 1844 |
1809 } // namespace internal | 1845 } // namespace internal |
1810 } // namespace v8 | 1846 } // namespace v8 |
OLD | NEW |