OLD | NEW |
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 #include "src/interpreter/interpreter-intrinsics.h" | 7 #include "src/interpreter/interpreter-intrinsics.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 DCHECK_GE(parameter_count_, 0); | 114 DCHECK_GE(parameter_count_, 0); |
115 DCHECK_GE(context_register_count_, 0); | 115 DCHECK_GE(context_register_count_, 0); |
116 DCHECK_GE(local_register_count_, 0); | 116 DCHECK_GE(local_register_count_, 0); |
117 return_position_ = | 117 return_position_ = |
118 literal ? std::max(literal->start_position(), literal->end_position() - 1) | 118 literal ? std::max(literal->start_position(), literal->end_position() - 1) |
119 : RelocInfo::kNoPosition; | 119 : RelocInfo::kNoPosition; |
120 LOG_CODE_EVENT(isolate_, CodeStartLinePosInfoRecordEvent( | 120 LOG_CODE_EVENT(isolate_, CodeStartLinePosInfoRecordEvent( |
121 source_position_table_builder())); | 121 source_position_table_builder())); |
122 } | 122 } |
123 | 123 |
124 BytecodeArrayBuilder::~BytecodeArrayBuilder() { DCHECK_EQ(0, unbound_jumps_); } | |
125 | |
126 Register BytecodeArrayBuilder::first_context_register() const { | 124 Register BytecodeArrayBuilder::first_context_register() const { |
127 DCHECK_GT(context_register_count_, 0); | 125 DCHECK_GT(context_register_count_, 0); |
128 return Register(local_register_count_); | 126 return Register(local_register_count_); |
129 } | 127 } |
130 | 128 |
131 | 129 |
132 Register BytecodeArrayBuilder::last_context_register() const { | 130 Register BytecodeArrayBuilder::last_context_register() const { |
133 DCHECK_GT(context_register_count_, 0); | 131 DCHECK_GT(context_register_count_, 0); |
134 return Register(local_register_count_ + context_register_count_ - 1); | 132 return Register(local_register_count_ + context_register_count_ - 1); |
135 } | 133 } |
136 | 134 |
137 | 135 |
138 Register BytecodeArrayBuilder::Parameter(int parameter_index) const { | 136 Register BytecodeArrayBuilder::Parameter(int parameter_index) const { |
139 DCHECK_GE(parameter_index, 0); | 137 DCHECK_GE(parameter_index, 0); |
140 return Register::FromParameterIndex(parameter_index, parameter_count()); | 138 return Register::FromParameterIndex(parameter_index, parameter_count()); |
141 } | 139 } |
142 | 140 |
143 | 141 |
144 bool BytecodeArrayBuilder::RegisterIsParameterOrLocal(Register reg) const { | 142 bool BytecodeArrayBuilder::RegisterIsParameterOrLocal(Register reg) const { |
145 return reg.is_parameter() || reg.index() < locals_count(); | 143 return reg.is_parameter() || reg.index() < locals_count(); |
146 } | 144 } |
147 | 145 |
148 | 146 |
149 Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() { | 147 Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() { |
| 148 DCHECK_EQ(0, unbound_jumps_); |
150 DCHECK_EQ(bytecode_generated_, false); | 149 DCHECK_EQ(bytecode_generated_, false); |
151 DCHECK(exit_seen_in_block_); | 150 DCHECK(exit_seen_in_block_); |
152 | 151 |
153 int bytecode_size = static_cast<int>(bytecodes_.size()); | 152 int bytecode_size = static_cast<int>(bytecodes_.size()); |
154 int register_count = fixed_and_temporary_register_count(); | 153 int register_count = fixed_and_temporary_register_count(); |
155 int frame_size = register_count * kPointerSize; | 154 int frame_size = register_count * kPointerSize; |
156 Handle<FixedArray> constant_pool = constant_array_builder()->ToFixedArray(); | 155 Handle<FixedArray> constant_pool = constant_array_builder()->ToFixedArray(); |
157 Handle<FixedArray> handler_table = handler_table_builder()->ToHandlerTable(); | 156 Handle<FixedArray> handler_table = handler_table_builder()->ToHandlerTable(); |
158 Handle<ByteArray> source_position_table = | 157 Handle<ByteArray> source_position_table = |
159 source_position_table_builder()->ToSourcePositionTable(); | 158 source_position_table_builder()->ToSourcePositionTable(); |
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 } | 1488 } |
1490 | 1489 |
1491 uint32_t BytecodeArrayBuilder::UnsignedOperand(size_t value) { | 1490 uint32_t BytecodeArrayBuilder::UnsignedOperand(size_t value) { |
1492 DCHECK_LE(value, kMaxUInt32); | 1491 DCHECK_LE(value, kMaxUInt32); |
1493 return static_cast<uint32_t>(value); | 1492 return static_cast<uint32_t>(value); |
1494 } | 1493 } |
1495 | 1494 |
1496 } // namespace interpreter | 1495 } // namespace interpreter |
1497 } // namespace internal | 1496 } // namespace internal |
1498 } // namespace v8 | 1497 } // namespace v8 |
OLD | NEW |