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/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/scopes.h" | 10 #include "src/ast/scopes.h" |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
672 DCHECK_NE(kNoSourcePosition, pos); | 672 DCHECK_NE(kNoSourcePosition, pos); |
673 source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, false); | 673 source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, false); |
674 } | 674 } |
675 | 675 |
676 | 676 |
677 void FullCodeGenerator::SetFunctionPosition(FunctionLiteral* fun) { | 677 void FullCodeGenerator::SetFunctionPosition(FunctionLiteral* fun) { |
678 RecordPosition(fun->start_position()); | 678 RecordPosition(fun->start_position()); |
679 } | 679 } |
680 | 680 |
681 | 681 |
682 void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) { | 682 void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) { |
dgozman
2016/11/08 01:37:13
Do we have similar problem in other code generatio
Yang
2016/11/08 12:23:33
Yes, we need this logic in BytecodeArrayBuilder::B
kozy
2016/11/08 16:28:45
Done.
| |
683 // For default constructors, start position equals end position, and there | 683 // For default constructors, start position equals end position, and there |
684 // is no source code besides the class literal. | 684 // is no source code besides the class literal. |
685 int pos = std::max(fun->start_position(), fun->end_position() - 1); | 685 bool doesnt_contain_close_brace = |
686 IsArrowFunction(fun->kind()) && fun->HasSingleReturnBody(); | |
687 int pos = | |
688 std::max(fun->start_position(), | |
689 fun->end_position() - (doesnt_contain_close_brace ? 0 : 1)); | |
686 RecordStatementPosition(pos); | 690 RecordStatementPosition(pos); |
687 if (info_->is_debug()) { | 691 if (info_->is_debug()) { |
688 // Always emit a debug break slot before a return. | 692 // Always emit a debug break slot before a return. |
689 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_RETURN); | 693 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_RETURN); |
690 } | 694 } |
691 } | 695 } |
692 | 696 |
693 | 697 |
694 void FullCodeGenerator::SetStatementPosition( | 698 void FullCodeGenerator::SetStatementPosition( |
695 Statement* stmt, FullCodeGenerator::InsertBreak insert_break) { | 699 Statement* stmt, FullCodeGenerator::InsertBreak insert_break) { |
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1991 return info_->has_simple_parameters(); | 1995 return info_->has_simple_parameters(); |
1992 } | 1996 } |
1993 | 1997 |
1994 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } | 1998 FunctionLiteral* FullCodeGenerator::literal() const { return info_->literal(); } |
1995 | 1999 |
1996 #undef __ | 2000 #undef __ |
1997 | 2001 |
1998 | 2002 |
1999 } // namespace internal | 2003 } // namespace internal |
2000 } // namespace v8 | 2004 } // namespace v8 |
OLD | NEW |