Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: src/full-codegen/full-codegen.cc

Issue 2095893002: Use source position table for unoptimized code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/full-codegen/full-codegen.h" 5 #include "src/full-codegen/full-codegen.h"
6 6
7 #include "src/ast/ast-numbering.h" 7 #include "src/ast/ast-numbering.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/prettyprinter.h" 9 #include "src/ast/prettyprinter.h"
10 #include "src/ast/scopeinfo.h" 10 #include "src/ast/scopeinfo.h"
(...skipping 27 matching lines...) Expand all
38 !script->source()->IsUndefined(isolate)) { 38 !script->source()->IsUndefined(isolate)) {
39 int len = String::cast(script->source())->length(); 39 int len = String::cast(script->source())->length();
40 isolate->counters()->total_full_codegen_source_size()->Increment(len); 40 isolate->counters()->total_full_codegen_source_size()->Increment(len);
41 } 41 }
42 CodeGenerator::MakeCodePrologue(info, "full"); 42 CodeGenerator::MakeCodePrologue(info, "full");
43 const int kInitialBufferSize = 4 * KB; 43 const int kInitialBufferSize = 4 * KB;
44 MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize, 44 MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize,
45 CodeObjectRequired::kYes); 45 CodeObjectRequired::kYes);
46 if (info->will_serialize()) masm.enable_serializer(); 46 if (info->will_serialize()) masm.enable_serializer();
47 47
48 LOG_CODE_EVENT(isolate,
49 CodeStartLinePosInfoRecordEvent(masm.positions_recorder()));
50
51 FullCodeGenerator cgen(&masm, info); 48 FullCodeGenerator cgen(&masm, info);
49 LOG_CODE_EVENT(isolate, CodeStartLinePosInfoRecordEvent(
50 &cgen.source_position_table_builder_));
52 cgen.Generate(); 51 cgen.Generate();
53 if (cgen.HasStackOverflow()) { 52 if (cgen.HasStackOverflow()) {
54 DCHECK(!isolate->has_pending_exception()); 53 DCHECK(!isolate->has_pending_exception());
55 return false; 54 return false;
56 } 55 }
57 unsigned table_offset = cgen.EmitBackEdgeTable(); 56 unsigned table_offset = cgen.EmitBackEdgeTable();
58 57
59 Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&masm, info); 58 Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&masm, info);
60 cgen.PopulateDeoptimizationData(code); 59 cgen.PopulateDeoptimizationData(code);
61 cgen.PopulateTypeFeedbackInfo(code); 60 cgen.PopulateTypeFeedbackInfo(code);
62 cgen.PopulateHandlerTable(code); 61 cgen.PopulateHandlerTable(code);
63 code->set_has_deoptimization_support(info->HasDeoptimizationSupport()); 62 code->set_has_deoptimization_support(info->HasDeoptimizationSupport());
64 code->set_has_reloc_info_for_serialization(info->will_serialize()); 63 code->set_has_reloc_info_for_serialization(info->will_serialize());
65 code->set_allow_osr_at_loop_nesting_level(0); 64 code->set_allow_osr_at_loop_nesting_level(0);
66 code->set_profiler_ticks(0); 65 code->set_profiler_ticks(0);
67 code->set_back_edge_table_offset(table_offset); 66 code->set_back_edge_table_offset(table_offset);
67 code->set_source_position_table(
68 *cgen.source_position_table_builder_.ToSourcePositionTable());
68 CodeGenerator::PrintCode(code, info); 69 CodeGenerator::PrintCode(code, info);
69 info->SetCode(code); 70 info->SetCode(code);
70 void* line_info = masm.positions_recorder()->DetachJITHandlerData(); 71 void* line_info = cgen.source_position_table_builder_.DetachJITHandlerData();
71 LOG_CODE_EVENT(isolate, CodeEndLinePosInfoRecordEvent( 72 LOG_CODE_EVENT(isolate, CodeEndLinePosInfoRecordEvent(
72 AbstractCode::cast(*code), line_info)); 73 AbstractCode::cast(*code), line_info));
73 74
74 #ifdef DEBUG 75 #ifdef DEBUG
75 // Check that no context-specific object has been embedded. 76 // Check that no context-specific object has been embedded.
76 code->VerifyEmbeddedObjects(Code::kNoContextSpecificPointers); 77 code->VerifyEmbeddedObjects(Code::kNoContextSpecificPointers);
77 #endif // DEBUG 78 #endif // DEBUG
78 return true; 79 return true;
79 } 80 }
80 81
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 } 609 }
609 610
610 void FullCodeGenerator::EmitHasProperty() { 611 void FullCodeGenerator::EmitHasProperty() {
611 Callable callable = CodeFactory::HasProperty(isolate()); 612 Callable callable = CodeFactory::HasProperty(isolate());
612 PopOperand(callable.descriptor().GetRegisterParameter(1)); 613 PopOperand(callable.descriptor().GetRegisterParameter(1));
613 PopOperand(callable.descriptor().GetRegisterParameter(0)); 614 PopOperand(callable.descriptor().GetRegisterParameter(0));
614 __ Call(callable.code(), RelocInfo::CODE_TARGET); 615 __ Call(callable.code(), RelocInfo::CODE_TARGET);
615 RestoreContext(); 616 RestoreContext();
616 } 617 }
617 618
618 void RecordStatementPosition(MacroAssembler* masm, int pos) { 619 void FullCodeGenerator::RecordStatementPosition(int pos) {
619 if (pos == RelocInfo::kNoPosition) return; 620 DCHECK_NE(RelocInfo::kNoPosition, pos);
620 masm->positions_recorder()->RecordStatementPosition(pos); 621 source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, true);
621 } 622 }
622 623
623 void RecordPosition(MacroAssembler* masm, int pos) { 624 void FullCodeGenerator::RecordPosition(int pos) {
624 if (pos == RelocInfo::kNoPosition) return; 625 DCHECK_NE(RelocInfo::kNoPosition, pos);
625 masm->positions_recorder()->RecordPosition(pos); 626 source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, false);
626 } 627 }
627 628
628 629
629 void FullCodeGenerator::SetFunctionPosition(FunctionLiteral* fun) { 630 void FullCodeGenerator::SetFunctionPosition(FunctionLiteral* fun) {
630 RecordPosition(masm_, fun->start_position()); 631 RecordPosition(fun->start_position());
631 } 632 }
632 633
633 634
634 void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) { 635 void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) {
635 // For default constructors, start position equals end position, and there 636 // For default constructors, start position equals end position, and there
636 // is no source code besides the class literal. 637 // is no source code besides the class literal.
637 int pos = std::max(fun->start_position(), fun->end_position() - 1); 638 int pos = std::max(fun->start_position(), fun->end_position() - 1);
638 RecordStatementPosition(masm_, pos); 639 RecordStatementPosition(pos);
639 if (info_->is_debug()) { 640 if (info_->is_debug()) {
640 // Always emit a debug break slot before a return. 641 // Always emit a debug break slot before a return.
641 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_RETURN); 642 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_RETURN);
642 } 643 }
643 } 644 }
644 645
645 646
646 void FullCodeGenerator::SetStatementPosition( 647 void FullCodeGenerator::SetStatementPosition(
647 Statement* stmt, FullCodeGenerator::InsertBreak insert_break) { 648 Statement* stmt, FullCodeGenerator::InsertBreak insert_break) {
648 if (stmt->position() == RelocInfo::kNoPosition) return; 649 if (stmt->position() == RelocInfo::kNoPosition) return;
649 RecordStatementPosition(masm_, stmt->position()); 650 RecordStatementPosition(stmt->position());
650 if (insert_break == INSERT_BREAK && info_->is_debug() && 651 if (insert_break == INSERT_BREAK && info_->is_debug() &&
651 !stmt->IsDebuggerStatement()) { 652 !stmt->IsDebuggerStatement()) {
652 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); 653 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION);
653 } 654 }
654 } 655 }
655 656
656 void FullCodeGenerator::SetExpressionPosition(Expression* expr) { 657 void FullCodeGenerator::SetExpressionPosition(Expression* expr) {
657 if (expr->position() == RelocInfo::kNoPosition) return; 658 if (expr->position() == RelocInfo::kNoPosition) return;
658 RecordPosition(masm_, expr->position()); 659 RecordPosition(expr->position());
659 } 660 }
660 661
661 662
662 void FullCodeGenerator::SetExpressionAsStatementPosition(Expression* expr) { 663 void FullCodeGenerator::SetExpressionAsStatementPosition(Expression* expr) {
663 if (expr->position() == RelocInfo::kNoPosition) return; 664 if (expr->position() == RelocInfo::kNoPosition) return;
664 RecordStatementPosition(masm_, expr->position()); 665 RecordStatementPosition(expr->position());
665 if (info_->is_debug()) { 666 if (info_->is_debug()) {
666 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); 667 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION);
667 } 668 }
668 } 669 }
669 670
670 void FullCodeGenerator::SetCallPosition(Expression* expr, 671 void FullCodeGenerator::SetCallPosition(Expression* expr,
671 TailCallMode tail_call_mode) { 672 TailCallMode tail_call_mode) {
672 if (expr->position() == RelocInfo::kNoPosition) return; 673 if (expr->position() == RelocInfo::kNoPosition) return;
673 RecordPosition(masm_, expr->position()); 674 RecordPosition(expr->position());
674 if (info_->is_debug()) { 675 if (info_->is_debug()) {
675 RelocInfo::Mode mode = (tail_call_mode == TailCallMode::kAllow) 676 RelocInfo::Mode mode = (tail_call_mode == TailCallMode::kAllow)
676 ? RelocInfo::DEBUG_BREAK_SLOT_AT_TAIL_CALL 677 ? RelocInfo::DEBUG_BREAK_SLOT_AT_TAIL_CALL
677 : RelocInfo::DEBUG_BREAK_SLOT_AT_CALL; 678 : RelocInfo::DEBUG_BREAK_SLOT_AT_CALL;
678 // Always emit a debug break slot before a call. 679 // Always emit a debug break slot before a call.
679 DebugCodegen::GenerateSlot(masm_, mode); 680 DebugCodegen::GenerateSlot(masm_, mode);
680 } 681 }
681 } 682 }
682 683
683 684
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 return var->scope()->is_nonlinear() || 1987 return var->scope()->is_nonlinear() ||
1987 var->initializer_position() >= proxy->position(); 1988 var->initializer_position() >= proxy->position();
1988 } 1989 }
1989 1990
1990 1991
1991 #undef __ 1992 #undef __
1992 1993
1993 1994
1994 } // namespace internal 1995 } // namespace internal
1995 } // namespace v8 1996 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698