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

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

Issue 1744123003: [debugger] fix break locations for assignments and return. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixes and addressed comments Created 4 years, 9 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
« no previous file with comments | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "src/compiler.h" 6 #include "src/compiler.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 namespace interpreter { 10 namespace interpreter {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 private: 61 private:
62 const BytecodeArrayBuilder& array_builder_; 62 const BytecodeArrayBuilder& array_builder_;
63 size_t previous_bytecode_start_; 63 size_t previous_bytecode_start_;
64 64
65 DISALLOW_COPY_AND_ASSIGN(PreviousBytecodeHelper); 65 DISALLOW_COPY_AND_ASSIGN(PreviousBytecodeHelper);
66 }; 66 };
67 67
68 BytecodeArrayBuilder::BytecodeArrayBuilder(Isolate* isolate, Zone* zone, 68 BytecodeArrayBuilder::BytecodeArrayBuilder(Isolate* isolate, Zone* zone,
69 int parameter_count, 69 int parameter_count,
70 int context_count, int locals_count) 70 int context_count, int locals_count,
71 FunctionLiteral* literal)
71 : isolate_(isolate), 72 : isolate_(isolate),
72 zone_(zone), 73 zone_(zone),
73 bytecodes_(zone), 74 bytecodes_(zone),
74 bytecode_generated_(false), 75 bytecode_generated_(false),
75 constant_array_builder_(isolate, zone), 76 constant_array_builder_(isolate, zone),
76 handler_table_builder_(isolate, zone), 77 handler_table_builder_(isolate, zone),
77 source_position_table_builder_(isolate, zone), 78 source_position_table_builder_(isolate, zone),
78 last_block_end_(0), 79 last_block_end_(0),
79 last_bytecode_start_(~0), 80 last_bytecode_start_(~0),
80 exit_seen_in_block_(false), 81 exit_seen_in_block_(false),
81 unbound_jumps_(0), 82 unbound_jumps_(0),
82 parameter_count_(parameter_count), 83 parameter_count_(parameter_count),
83 local_register_count_(locals_count), 84 local_register_count_(locals_count),
84 context_register_count_(context_count), 85 context_register_count_(context_count),
85 temporary_allocator_(zone, fixed_register_count()), 86 temporary_allocator_(zone, fixed_register_count()),
86 register_translator_(this) { 87 register_translator_(this) {
87 DCHECK_GE(parameter_count_, 0); 88 DCHECK_GE(parameter_count_, 0);
88 DCHECK_GE(context_register_count_, 0); 89 DCHECK_GE(context_register_count_, 0);
89 DCHECK_GE(local_register_count_, 0); 90 DCHECK_GE(local_register_count_, 0);
91 return_position_ =
92 literal ? std::max(literal->start_position(), literal->end_position() - 1)
93 : RelocInfo::kNoPosition;
90 } 94 }
91 95
92 BytecodeArrayBuilder::~BytecodeArrayBuilder() { DCHECK_EQ(0, unbound_jumps_); } 96 BytecodeArrayBuilder::~BytecodeArrayBuilder() { DCHECK_EQ(0, unbound_jumps_); }
93 97
94 Register BytecodeArrayBuilder::first_context_register() const { 98 Register BytecodeArrayBuilder::first_context_register() const {
95 DCHECK_GT(context_register_count_, 0); 99 DCHECK_GT(context_register_count_, 0);
96 return Register(local_register_count_); 100 return Register(local_register_count_);
97 } 101 }
98 102
99 103
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 958
955 959
956 BytecodeArrayBuilder& BytecodeArrayBuilder::ReThrow() { 960 BytecodeArrayBuilder& BytecodeArrayBuilder::ReThrow() {
957 Output(Bytecode::kReThrow); 961 Output(Bytecode::kReThrow);
958 exit_seen_in_block_ = true; 962 exit_seen_in_block_ = true;
959 return *this; 963 return *this;
960 } 964 }
961 965
962 966
963 BytecodeArrayBuilder& BytecodeArrayBuilder::Return() { 967 BytecodeArrayBuilder& BytecodeArrayBuilder::Return() {
968 SetReturnPosition();
964 Output(Bytecode::kReturn); 969 Output(Bytecode::kReturn);
965 exit_seen_in_block_ = true; 970 exit_seen_in_block_ = true;
966 return *this; 971 return *this;
967 } 972 }
968 973
969 BytecodeArrayBuilder& BytecodeArrayBuilder::Debugger() { 974 BytecodeArrayBuilder& BytecodeArrayBuilder::Debugger() {
970 Output(Bytecode::kDebugger); 975 Output(Bytecode::kDebugger);
971 return *this; 976 return *this;
972 } 977 }
973 978
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 handler_table_builder()->SetTryRegionEnd(handler_id, bytecodes()->size()); 1040 handler_table_builder()->SetTryRegionEnd(handler_id, bytecodes()->size());
1036 return *this; 1041 return *this;
1037 } 1042 }
1038 1043
1039 1044
1040 void BytecodeArrayBuilder::LeaveBasicBlock() { 1045 void BytecodeArrayBuilder::LeaveBasicBlock() {
1041 last_block_end_ = bytecodes()->size(); 1046 last_block_end_ = bytecodes()->size();
1042 exit_seen_in_block_ = false; 1047 exit_seen_in_block_ = false;
1043 } 1048 }
1044 1049
1045 void BytecodeArrayBuilder::EnsureReturn(FunctionLiteral* literal) { 1050 void BytecodeArrayBuilder::EnsureReturn() {
1046 if (!exit_seen_in_block_) { 1051 if (!exit_seen_in_block_) {
1047 LoadUndefined(); 1052 LoadUndefined();
1048 SetReturnPosition(literal);
1049 Return(); 1053 Return();
1050 } 1054 }
1051 DCHECK(exit_seen_in_block_); 1055 DCHECK(exit_seen_in_block_);
1052 } 1056 }
1053 1057
1054 BytecodeArrayBuilder& BytecodeArrayBuilder::Call(Register callable, 1058 BytecodeArrayBuilder& BytecodeArrayBuilder::Call(Register callable,
1055 Register receiver_args, 1059 Register receiver_args,
1056 size_t receiver_args_count, 1060 size_t receiver_args_count,
1057 int feedback_slot, 1061 int feedback_slot,
1058 TailCallMode tail_call_mode) { 1062 TailCallMode tail_call_mode) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 LanguageMode language_mode) { 1173 LanguageMode language_mode) {
1170 Output(BytecodeForDelete(language_mode), object.ToRawOperand()); 1174 Output(BytecodeForDelete(language_mode), object.ToRawOperand());
1171 return *this; 1175 return *this;
1172 } 1176 }
1173 1177
1174 1178
1175 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { 1179 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) {
1176 return constant_array_builder()->Insert(object); 1180 return constant_array_builder()->Insert(object);
1177 } 1181 }
1178 1182
1179 void BytecodeArrayBuilder::SetReturnPosition(FunctionLiteral* fun) { 1183 void BytecodeArrayBuilder::SetReturnPosition() {
1180 // Don't emit dead code. 1184 if (return_position_ == RelocInfo::kNoPosition) return;
1181 if (exit_seen_in_block_) return; 1185 if (exit_seen_in_block_) return;
1182 1186 source_position_table_builder_.AddStatementPosition(bytecodes_.size(),
1183 int pos = std::max(fun->start_position(), fun->end_position() - 1); 1187 return_position_);
1184 source_position_table_builder_.AddStatementPosition(bytecodes_.size(), pos);
1185 } 1188 }
1186 1189
1187 void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) { 1190 void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) {
1188 if (stmt->position() == RelocInfo::kNoPosition) return; 1191 if (stmt->position() == RelocInfo::kNoPosition) return;
1189 if (exit_seen_in_block_) return; 1192 if (exit_seen_in_block_) return;
1190 source_position_table_builder_.AddStatementPosition(bytecodes_.size(), 1193 source_position_table_builder_.AddStatementPosition(bytecodes_.size(),
1191 stmt->position()); 1194 stmt->position());
1192 } 1195 }
1193 1196
1194 void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) { 1197 void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) {
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 } 1627 }
1625 1628
1626 // static 1629 // static
1627 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { 1630 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) {
1628 return value.is_short_operand(); 1631 return value.is_short_operand();
1629 } 1632 }
1630 1633
1631 } // namespace interpreter 1634 } // namespace interpreter
1632 } // namespace internal 1635 } // namespace internal
1633 } // namespace v8 1636 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.h ('k') | src/interpreter/bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698