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 | 8 |
9 #include "src/ast/ast-numbering.h" | 9 #include "src/ast/ast-numbering.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
524 } else { | 524 } else { |
525 Handle<Code> code = info->code(); | 525 Handle<Code> code = info->code(); |
526 size += code->CodeSize(); | 526 size += code->CodeSize(); |
527 size += code->relocation_info()->Size(); | 527 size += code->relocation_info()->Size(); |
528 size += code->deoptimization_data()->Size(); | 528 size += code->deoptimization_data()->Size(); |
529 size += code->handler_table()->Size(); | 529 size += code->handler_table()->Size(); |
530 } | 530 } |
531 return size; | 531 return size; |
532 } | 532 } |
533 | 533 |
534 bool GenerateBaselineCode(CompilationInfo* info) { | 534 bool GenerateUnoptimizedCode(CompilationInfo* info) { |
535 bool success; | 535 bool success; |
536 EnsureFeedbackVector(info); | 536 EnsureFeedbackVector(info); |
537 if (FLAG_ignition && UseIgnition(info)) { | 537 if (FLAG_ignition && UseIgnition(info)) { |
538 success = interpreter::Interpreter::MakeBytecode(info); | 538 success = interpreter::Interpreter::MakeBytecode(info); |
539 } else { | 539 } else { |
540 success = FullCodeGenerator::MakeCode(info); | 540 success = FullCodeGenerator::MakeCode(info); |
541 } | 541 } |
542 if (success) { | 542 if (success) { |
543 Isolate* isolate = info->isolate(); | 543 Isolate* isolate = info->isolate(); |
544 Counters* counters = isolate->counters(); | 544 Counters* counters = isolate->counters(); |
545 counters->total_baseline_code_size()->Increment(CodeAndMetadataSize(info)); | 545 counters->total_baseline_code_size()->Increment(CodeAndMetadataSize(info)); |
Michael Starzinger
2016/04/19 17:16:57
Please advise on whether renaming these counters t
rmcilroy
2016/04/20 11:01:53
They are used in the v8-perf repo in benchmarks/Lo
Michael Starzinger
2016/04/20 11:43:11
Done. Left a TODO as suggested. Not urgent at all,
| |
546 counters->total_baseline_compile_count()->Increment(1); | 546 counters->total_baseline_compile_count()->Increment(1); |
547 } | 547 } |
548 return success; | 548 return success; |
549 } | 549 } |
550 | 550 |
551 bool CompileBaselineCode(CompilationInfo* info) { | 551 bool CompileUnoptimizedCode(CompilationInfo* info) { |
552 DCHECK(AllowCompilation::IsAllowed(info->isolate())); | 552 DCHECK(AllowCompilation::IsAllowed(info->isolate())); |
553 if (!Compiler::Analyze(info->parse_info()) || !GenerateBaselineCode(info)) { | 553 if (!Compiler::Analyze(info->parse_info()) || |
554 !GenerateUnoptimizedCode(info)) { | |
554 Isolate* isolate = info->isolate(); | 555 Isolate* isolate = info->isolate(); |
555 if (!isolate->has_pending_exception()) isolate->StackOverflow(); | 556 if (!isolate->has_pending_exception()) isolate->StackOverflow(); |
556 return false; | 557 return false; |
557 } | 558 } |
558 return true; | 559 return true; |
559 } | 560 } |
560 | 561 |
561 void InstallSharedScopeInfo(CompilationInfo* info, | 562 void InstallSharedScopeInfo(CompilationInfo* info, |
562 Handle<SharedFunctionInfo> shared) { | 563 Handle<SharedFunctionInfo> shared) { |
563 Handle<ScopeInfo> scope_info = | 564 Handle<ScopeInfo> scope_info = |
(...skipping 16 matching lines...) Expand all Loading... | |
580 MUST_USE_RESULT MaybeHandle<Code> GetUnoptimizedCode(CompilationInfo* info) { | 581 MUST_USE_RESULT MaybeHandle<Code> GetUnoptimizedCode(CompilationInfo* info) { |
581 VMState<COMPILER> state(info->isolate()); | 582 VMState<COMPILER> state(info->isolate()); |
582 PostponeInterruptsScope postpone(info->isolate()); | 583 PostponeInterruptsScope postpone(info->isolate()); |
583 | 584 |
584 // Parse and update CompilationInfo with the results. | 585 // Parse and update CompilationInfo with the results. |
585 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); | 586 if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>(); |
586 Handle<SharedFunctionInfo> shared = info->shared_info(); | 587 Handle<SharedFunctionInfo> shared = info->shared_info(); |
587 DCHECK_EQ(shared->language_mode(), info->literal()->language_mode()); | 588 DCHECK_EQ(shared->language_mode(), info->literal()->language_mode()); |
588 | 589 |
589 // Compile either unoptimized code or bytecode for the interpreter. | 590 // Compile either unoptimized code or bytecode for the interpreter. |
590 if (!CompileBaselineCode(info)) return MaybeHandle<Code>(); | 591 if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>(); |
591 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); | 592 RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared); |
592 | 593 |
593 // Update the shared function info with the scope info. | 594 // Update the shared function info with the scope info. |
594 InstallSharedScopeInfo(info, shared); | 595 InstallSharedScopeInfo(info, shared); |
595 | 596 |
596 // Install compilation result on the shared function info | 597 // Install compilation result on the shared function info |
597 InstallSharedCompilationResult(info, shared); | 598 InstallSharedCompilationResult(info, shared); |
598 | 599 |
599 return info->code(); | 600 return info->code(); |
600 } | 601 } |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1010 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); | 1011 DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position()); |
1011 result = NewSharedFunctionInfoForLiteral(isolate, lit, script); | 1012 result = NewSharedFunctionInfoForLiteral(isolate, lit, script); |
1012 result->set_is_toplevel(true); | 1013 result->set_is_toplevel(true); |
1013 if (info->is_eval()) { | 1014 if (info->is_eval()) { |
1014 // Eval scripts cannot be (re-)compiled without context. | 1015 // Eval scripts cannot be (re-)compiled without context. |
1015 result->set_allows_lazy_compilation_without_context(false); | 1016 result->set_allows_lazy_compilation_without_context(false); |
1016 } | 1017 } |
1017 parse_info->set_shared_info(result); | 1018 parse_info->set_shared_info(result); |
1018 | 1019 |
1019 // Compile the code. | 1020 // Compile the code. |
1020 if (!CompileBaselineCode(info)) { | 1021 if (!CompileUnoptimizedCode(info)) { |
1021 return Handle<SharedFunctionInfo>::null(); | 1022 return Handle<SharedFunctionInfo>::null(); |
1022 } | 1023 } |
1023 | 1024 |
1024 // Update the shared function info with the scope info. | 1025 // Update the shared function info with the scope info. |
1025 InstallSharedScopeInfo(info, result); | 1026 InstallSharedScopeInfo(info, result); |
1026 | 1027 |
1027 // Install compilation result on the shared function info | 1028 // Install compilation result on the shared function info |
1028 InstallSharedCompilationResult(info, result); | 1029 InstallSharedCompilationResult(info, result); |
1029 | 1030 |
1030 Handle<String> script_name = | 1031 Handle<String> script_name = |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1529 | 1530 |
1530 // Consider compiling eagerly when compiling bytecode for Ignition. | 1531 // Consider compiling eagerly when compiling bytecode for Ignition. |
1531 lazy &= | 1532 lazy &= |
1532 !(FLAG_ignition && FLAG_ignition_eager && !isolate->serializer_enabled()); | 1533 !(FLAG_ignition && FLAG_ignition_eager && !isolate->serializer_enabled()); |
1533 | 1534 |
1534 // Generate code | 1535 // Generate code |
1535 TimerEventScope<TimerEventCompileCode> timer(isolate); | 1536 TimerEventScope<TimerEventCompileCode> timer(isolate); |
1536 TRACE_EVENT0("v8", "V8.CompileCode"); | 1537 TRACE_EVENT0("v8", "V8.CompileCode"); |
1537 if (lazy) { | 1538 if (lazy) { |
1538 info.SetCode(isolate->builtins()->CompileLazy()); | 1539 info.SetCode(isolate->builtins()->CompileLazy()); |
1539 } else if (Renumber(info.parse_info()) && GenerateBaselineCode(&info)) { | 1540 } else if (Renumber(info.parse_info()) && GenerateUnoptimizedCode(&info)) { |
1540 // Code generation will ensure that the feedback vector is present and | 1541 // Code generation will ensure that the feedback vector is present and |
1541 // appropriately sized. | 1542 // appropriately sized. |
1542 DCHECK(!info.code().is_null()); | 1543 DCHECK(!info.code().is_null()); |
1543 if (literal->should_eager_compile() && | 1544 if (literal->should_eager_compile() && |
1544 literal->should_be_used_once_hint()) { | 1545 literal->should_be_used_once_hint()) { |
1545 info.code()->MarkToBeExecutedOnce(isolate); | 1546 info.code()->MarkToBeExecutedOnce(isolate); |
1546 } | 1547 } |
1547 // Update the shared function info with the scope info. | 1548 // Update the shared function info with the scope info. |
1548 InstallSharedScopeInfo(&info, result); | 1549 InstallSharedScopeInfo(&info, result); |
1549 // Install compilation result on the shared function info. | 1550 // Install compilation result on the shared function info. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1682 MaybeHandle<Code> code; | 1683 MaybeHandle<Code> code; |
1683 if (cached.code != nullptr) code = handle(cached.code); | 1684 if (cached.code != nullptr) code = handle(cached.code); |
1684 Handle<Context> native_context(function->context()->native_context()); | 1685 Handle<Context> native_context(function->context()->native_context()); |
1685 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1686 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
1686 literals, BailoutId::None()); | 1687 literals, BailoutId::None()); |
1687 } | 1688 } |
1688 } | 1689 } |
1689 | 1690 |
1690 } // namespace internal | 1691 } // namespace internal |
1691 } // namespace v8 | 1692 } // namespace v8 |
OLD | NEW |