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

Side by Side Diff: src/interpreter/bytecode-array-builder.cc

Issue 2038323002: [interpreter] Filter expression positions at source. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@oth-0060-source-position-testing
Patch Set: Fix expression positions on StackCheck that this CL broke. 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/interpreter/bytecode-array-builder.h" 5 #include "src/interpreter/bytecode-array-builder.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/interpreter/bytecode-array-writer.h" 8 #include "src/interpreter/bytecode-array-writer.h"
9 #include "src/interpreter/bytecode-label.h" 9 #include "src/interpreter/bytecode-label.h"
10 #include "src/interpreter/bytecode-peephole-optimizer.h" 10 #include "src/interpreter/bytecode-peephole-optimizer.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() { 72 Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() {
73 DCHECK(return_seen_in_block_); 73 DCHECK(return_seen_in_block_);
74 DCHECK(!bytecode_generated_); 74 DCHECK(!bytecode_generated_);
75 bytecode_generated_ = true; 75 bytecode_generated_ = true;
76 76
77 Handle<FixedArray> handler_table = handler_table_builder()->ToHandlerTable(); 77 Handle<FixedArray> handler_table = handler_table_builder()->ToHandlerTable();
78 return pipeline_->ToBytecodeArray(fixed_register_count(), parameter_count(), 78 return pipeline_->ToBytecodeArray(fixed_register_count(), parameter_count(),
79 handler_table); 79 handler_table);
80 } 80 }
81 81
82 // static
83 bool BytecodeArrayBuilder::NeedExpressionPosition(Bytecode bytecode) {
84 // Always need an expression position if filtering is turned
85 // off. Otherwise an expression is only needed if the bytecode has
86 // external side effects.
87 return !FLAG_ignition_filter_positions ||
88 !Bytecodes::IsWithoutExternalSideEffects(bytecode);
89 }
90
82 void BytecodeArrayBuilder::AttachSourceInfo(BytecodeNode* node) { 91 void BytecodeArrayBuilder::AttachSourceInfo(BytecodeNode* node) {
83 if (latest_source_info_.is_valid()) { 92 if (latest_source_info_.is_valid()) {
84 node->source_info().Update(latest_source_info_); 93 if (latest_source_info_.is_statement() ||
85 latest_source_info_.set_invalid(); 94 NeedExpressionPosition(node->bytecode())) {
95 node->source_info() = latest_source_info_;
96 latest_source_info_.set_invalid();
97 }
86 } 98 }
87 } 99 }
88 100
89 void BytecodeArrayBuilder::Output(Bytecode bytecode) { 101 void BytecodeArrayBuilder::Output(Bytecode bytecode) {
90 BytecodeNode node(bytecode); 102 BytecodeNode node(bytecode);
91 AttachSourceInfo(&node); 103 AttachSourceInfo(&node);
92 pipeline()->Write(&node); 104 pipeline()->Write(&node);
93 } 105 }
94 106
95 void BytecodeArrayBuilder::OutputScaled(Bytecode bytecode, 107 void BytecodeArrayBuilder::OutputScaled(Bytecode bytecode,
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 505
494 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotHole( 506 BytecodeArrayBuilder& BytecodeArrayBuilder::JumpIfNotHole(
495 BytecodeLabel* label) { 507 BytecodeLabel* label) {
496 return OutputJump(Bytecode::kJumpIfNotHole, label); 508 return OutputJump(Bytecode::kJumpIfNotHole, label);
497 } 509 }
498 510
499 BytecodeArrayBuilder& BytecodeArrayBuilder::StackCheck(int position) { 511 BytecodeArrayBuilder& BytecodeArrayBuilder::StackCheck(int position) {
500 if (position != RelocInfo::kNoPosition) { 512 if (position != RelocInfo::kNoPosition) {
501 // We need to attach a non-breakable source position to a stack check, 513 // We need to attach a non-breakable source position to a stack check,
502 // so we simply add it as expression position. 514 // so we simply add it as expression position.
503 latest_source_info_.Update({position, false}); 515 latest_source_info_ = {position, false};
504 } 516 }
505 Output(Bytecode::kStackCheck); 517 Output(Bytecode::kStackCheck);
506 return *this; 518 return *this;
507 } 519 }
508 520
509 BytecodeArrayBuilder& BytecodeArrayBuilder::Throw() { 521 BytecodeArrayBuilder& BytecodeArrayBuilder::Throw() {
510 Output(Bytecode::kThrow); 522 Output(Bytecode::kThrow);
511 return *this; 523 return *this;
512 } 524 }
513 525
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 latest_source_info_.Update({return_position_, true}); 727 latest_source_info_.Update({return_position_, true});
716 } 728 }
717 729
718 void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) { 730 void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) {
719 if (stmt->position() == RelocInfo::kNoPosition) return; 731 if (stmt->position() == RelocInfo::kNoPosition) return;
720 latest_source_info_.Update({stmt->position(), true}); 732 latest_source_info_.Update({stmt->position(), true});
721 } 733 }
722 734
723 void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) { 735 void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) {
724 if (expr->position() == RelocInfo::kNoPosition) return; 736 if (expr->position() == RelocInfo::kNoPosition) return;
737 if (latest_source_info_.is_expression()) {
738 latest_source_info_.set_invalid();
739 }
725 latest_source_info_.Update({expr->position(), false}); 740 latest_source_info_.Update({expr->position(), false});
726 } 741 }
727 742
728 void BytecodeArrayBuilder::SetExpressionAsStatementPosition(Expression* expr) { 743 void BytecodeArrayBuilder::SetExpressionAsStatementPosition(Expression* expr) {
729 if (expr->position() == RelocInfo::kNoPosition) return; 744 if (expr->position() == RelocInfo::kNoPosition) return;
730 latest_source_info_.Update({expr->position(), true}); 745 latest_source_info_.Update({expr->position(), true});
731 } 746 }
732 747
733 bool BytecodeArrayBuilder::TemporaryRegisterIsLive(Register reg) const { 748 bool BytecodeArrayBuilder::TemporaryRegisterIsLive(Register reg) const {
734 return temporary_register_allocator()->RegisterIsLive(reg); 749 return temporary_register_allocator()->RegisterIsLive(reg);
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 } 1033 }
1019 1034
1020 uint32_t BytecodeArrayBuilder::UnsignedOperand(size_t value) { 1035 uint32_t BytecodeArrayBuilder::UnsignedOperand(size_t value) {
1021 DCHECK_LE(value, kMaxUInt32); 1036 DCHECK_LE(value, kMaxUInt32);
1022 return static_cast<uint32_t>(value); 1037 return static_cast<uint32_t>(value);
1023 } 1038 }
1024 1039
1025 } // namespace interpreter 1040 } // namespace interpreter
1026 } // namespace internal 1041 } // namespace internal
1027 } // namespace v8 1042 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698