| 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/scopeinfo.h" | 10 #include "src/ast/scopeinfo.h" |
| 11 #include "src/ast/scopes.h" | 11 #include "src/ast/scopes.h" |
| 12 #include "src/code-factory.h" | 12 #include "src/code-factory.h" |
| 13 #include "src/codegen.h" | 13 #include "src/codegen.h" |
| 14 #include "src/compiler.h" | 14 #include "src/compiler.h" |
| 15 #include "src/debug/debug.h" | 15 #include "src/debug/debug.h" |
| 16 #include "src/debug/liveedit.h" | 16 #include "src/debug/liveedit.h" |
| 17 #include "src/frames-inl.h" | 17 #include "src/frames-inl.h" |
| 18 #include "src/globals.h" |
| 18 #include "src/isolate-inl.h" | 19 #include "src/isolate-inl.h" |
| 19 #include "src/macro-assembler.h" | 20 #include "src/macro-assembler.h" |
| 20 #include "src/snapshot/snapshot.h" | 21 #include "src/snapshot/snapshot.h" |
| 21 #include "src/tracing/trace-event.h" | 22 #include "src/tracing/trace-event.h" |
| 22 | 23 |
| 23 namespace v8 { | 24 namespace v8 { |
| 24 namespace internal { | 25 namespace internal { |
| 25 | 26 |
| 26 #define __ ACCESS_MASM(masm()) | 27 #define __ ACCESS_MASM(masm()) |
| 27 | 28 |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 | 594 |
| 594 void FullCodeGenerator::EmitHasProperty() { | 595 void FullCodeGenerator::EmitHasProperty() { |
| 595 Callable callable = CodeFactory::HasProperty(isolate()); | 596 Callable callable = CodeFactory::HasProperty(isolate()); |
| 596 PopOperand(callable.descriptor().GetRegisterParameter(1)); | 597 PopOperand(callable.descriptor().GetRegisterParameter(1)); |
| 597 PopOperand(callable.descriptor().GetRegisterParameter(0)); | 598 PopOperand(callable.descriptor().GetRegisterParameter(0)); |
| 598 __ Call(callable.code(), RelocInfo::CODE_TARGET); | 599 __ Call(callable.code(), RelocInfo::CODE_TARGET); |
| 599 RestoreContext(); | 600 RestoreContext(); |
| 600 } | 601 } |
| 601 | 602 |
| 602 void FullCodeGenerator::RecordStatementPosition(int pos) { | 603 void FullCodeGenerator::RecordStatementPosition(int pos) { |
| 603 DCHECK_NE(RelocInfo::kNoPosition, pos); | 604 DCHECK_NE(kNoSourcePosition, pos); |
| 604 source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, true); | 605 source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, true); |
| 605 } | 606 } |
| 606 | 607 |
| 607 void FullCodeGenerator::RecordPosition(int pos) { | 608 void FullCodeGenerator::RecordPosition(int pos) { |
| 608 DCHECK_NE(RelocInfo::kNoPosition, pos); | 609 DCHECK_NE(kNoSourcePosition, pos); |
| 609 source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, false); | 610 source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, false); |
| 610 } | 611 } |
| 611 | 612 |
| 612 | 613 |
| 613 void FullCodeGenerator::SetFunctionPosition(FunctionLiteral* fun) { | 614 void FullCodeGenerator::SetFunctionPosition(FunctionLiteral* fun) { |
| 614 RecordPosition(fun->start_position()); | 615 RecordPosition(fun->start_position()); |
| 615 } | 616 } |
| 616 | 617 |
| 617 | 618 |
| 618 void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) { | 619 void FullCodeGenerator::SetReturnPosition(FunctionLiteral* fun) { |
| 619 // For default constructors, start position equals end position, and there | 620 // For default constructors, start position equals end position, and there |
| 620 // is no source code besides the class literal. | 621 // is no source code besides the class literal. |
| 621 int pos = std::max(fun->start_position(), fun->end_position() - 1); | 622 int pos = std::max(fun->start_position(), fun->end_position() - 1); |
| 622 RecordStatementPosition(pos); | 623 RecordStatementPosition(pos); |
| 623 if (info_->is_debug()) { | 624 if (info_->is_debug()) { |
| 624 // Always emit a debug break slot before a return. | 625 // Always emit a debug break slot before a return. |
| 625 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_RETURN); | 626 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_RETURN); |
| 626 } | 627 } |
| 627 } | 628 } |
| 628 | 629 |
| 629 | 630 |
| 630 void FullCodeGenerator::SetStatementPosition( | 631 void FullCodeGenerator::SetStatementPosition( |
| 631 Statement* stmt, FullCodeGenerator::InsertBreak insert_break) { | 632 Statement* stmt, FullCodeGenerator::InsertBreak insert_break) { |
| 632 if (stmt->position() == RelocInfo::kNoPosition) return; | 633 if (stmt->position() == kNoSourcePosition) return; |
| 633 RecordStatementPosition(stmt->position()); | 634 RecordStatementPosition(stmt->position()); |
| 634 if (insert_break == INSERT_BREAK && info_->is_debug() && | 635 if (insert_break == INSERT_BREAK && info_->is_debug() && |
| 635 !stmt->IsDebuggerStatement()) { | 636 !stmt->IsDebuggerStatement()) { |
| 636 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); | 637 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); |
| 637 } | 638 } |
| 638 } | 639 } |
| 639 | 640 |
| 640 void FullCodeGenerator::SetExpressionPosition(Expression* expr) { | 641 void FullCodeGenerator::SetExpressionPosition(Expression* expr) { |
| 641 if (expr->position() == RelocInfo::kNoPosition) return; | 642 if (expr->position() == kNoSourcePosition) return; |
| 642 RecordPosition(expr->position()); | 643 RecordPosition(expr->position()); |
| 643 } | 644 } |
| 644 | 645 |
| 645 | 646 |
| 646 void FullCodeGenerator::SetExpressionAsStatementPosition(Expression* expr) { | 647 void FullCodeGenerator::SetExpressionAsStatementPosition(Expression* expr) { |
| 647 if (expr->position() == RelocInfo::kNoPosition) return; | 648 if (expr->position() == kNoSourcePosition) return; |
| 648 RecordStatementPosition(expr->position()); | 649 RecordStatementPosition(expr->position()); |
| 649 if (info_->is_debug()) { | 650 if (info_->is_debug()) { |
| 650 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); | 651 DebugCodegen::GenerateSlot(masm_, RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION); |
| 651 } | 652 } |
| 652 } | 653 } |
| 653 | 654 |
| 654 void FullCodeGenerator::SetCallPosition(Expression* expr, | 655 void FullCodeGenerator::SetCallPosition(Expression* expr, |
| 655 TailCallMode tail_call_mode) { | 656 TailCallMode tail_call_mode) { |
| 656 if (expr->position() == RelocInfo::kNoPosition) return; | 657 if (expr->position() == kNoSourcePosition) return; |
| 657 RecordPosition(expr->position()); | 658 RecordPosition(expr->position()); |
| 658 if (info_->is_debug()) { | 659 if (info_->is_debug()) { |
| 659 RelocInfo::Mode mode = (tail_call_mode == TailCallMode::kAllow) | 660 RelocInfo::Mode mode = (tail_call_mode == TailCallMode::kAllow) |
| 660 ? RelocInfo::DEBUG_BREAK_SLOT_AT_TAIL_CALL | 661 ? RelocInfo::DEBUG_BREAK_SLOT_AT_TAIL_CALL |
| 661 : RelocInfo::DEBUG_BREAK_SLOT_AT_CALL; | 662 : RelocInfo::DEBUG_BREAK_SLOT_AT_CALL; |
| 662 // Always emit a debug break slot before a call. | 663 // Always emit a debug break slot before a call. |
| 663 DebugCodegen::GenerateSlot(masm_, mode); | 664 DebugCodegen::GenerateSlot(masm_, mode); |
| 664 } | 665 } |
| 665 } | 666 } |
| 666 | 667 |
| (...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 } | 1958 } |
| 1958 | 1959 |
| 1959 if (var->is_this()) { | 1960 if (var->is_this()) { |
| 1960 DCHECK(literal() != nullptr && | 1961 DCHECK(literal() != nullptr && |
| 1961 (literal()->kind() & kSubclassConstructor) != 0); | 1962 (literal()->kind() & kSubclassConstructor) != 0); |
| 1962 // TODO(littledan): implement 'this' hole check elimination. | 1963 // TODO(littledan): implement 'this' hole check elimination. |
| 1963 return true; | 1964 return true; |
| 1964 } | 1965 } |
| 1965 | 1966 |
| 1966 // Check that we always have valid source position. | 1967 // Check that we always have valid source position. |
| 1967 DCHECK(var->initializer_position() != RelocInfo::kNoPosition); | 1968 DCHECK(var->initializer_position() != kNoSourcePosition); |
| 1968 DCHECK(proxy->position() != RelocInfo::kNoPosition); | 1969 DCHECK(proxy->position() != kNoSourcePosition); |
| 1969 | 1970 |
| 1970 return var->scope()->is_nonlinear() || | 1971 return var->scope()->is_nonlinear() || |
| 1971 var->initializer_position() >= proxy->position(); | 1972 var->initializer_position() >= proxy->position(); |
| 1972 } | 1973 } |
| 1973 | 1974 |
| 1974 | 1975 |
| 1975 #undef __ | 1976 #undef __ |
| 1976 | 1977 |
| 1977 | 1978 |
| 1978 } // namespace internal | 1979 } // namespace internal |
| 1979 } // namespace v8 | 1980 } // namespace v8 |
| OLD | NEW |