| 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 | 7 |
| 8 namespace v8 { | 8 namespace v8 { |
| 9 namespace internal { | 9 namespace internal { |
| 10 namespace interpreter { | 10 namespace interpreter { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 local_register_count_(locals_count), | 84 local_register_count_(locals_count), |
| 85 context_register_count_(context_count), | 85 context_register_count_(context_count), |
| 86 temporary_allocator_(zone, fixed_register_count()), | 86 temporary_allocator_(zone, fixed_register_count()), |
| 87 register_translator_(this) { | 87 register_translator_(this) { |
| 88 DCHECK_GE(parameter_count_, 0); | 88 DCHECK_GE(parameter_count_, 0); |
| 89 DCHECK_GE(context_register_count_, 0); | 89 DCHECK_GE(context_register_count_, 0); |
| 90 DCHECK_GE(local_register_count_, 0); | 90 DCHECK_GE(local_register_count_, 0); |
| 91 return_position_ = | 91 return_position_ = |
| 92 literal ? std::max(literal->start_position(), literal->end_position() - 1) | 92 literal ? std::max(literal->start_position(), literal->end_position() - 1) |
| 93 : RelocInfo::kNoPosition; | 93 : RelocInfo::kNoPosition; |
| 94 LOG_CODE_EVENT(isolate_, CodeStartLinePosInfoRecordEvent( |
| 95 source_position_table_builder())); |
| 94 } | 96 } |
| 95 | 97 |
| 96 BytecodeArrayBuilder::~BytecodeArrayBuilder() { DCHECK_EQ(0, unbound_jumps_); } | 98 BytecodeArrayBuilder::~BytecodeArrayBuilder() { DCHECK_EQ(0, unbound_jumps_); } |
| 97 | 99 |
| 98 Register BytecodeArrayBuilder::first_context_register() const { | 100 Register BytecodeArrayBuilder::first_context_register() const { |
| 99 DCHECK_GT(context_register_count_, 0); | 101 DCHECK_GT(context_register_count_, 0); |
| 100 return Register(local_register_count_); | 102 return Register(local_register_count_); |
| 101 } | 103 } |
| 102 | 104 |
| 103 | 105 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 123 DCHECK(exit_seen_in_block_); | 125 DCHECK(exit_seen_in_block_); |
| 124 | 126 |
| 125 int bytecode_size = static_cast<int>(bytecodes_.size()); | 127 int bytecode_size = static_cast<int>(bytecodes_.size()); |
| 126 int register_count = | 128 int register_count = |
| 127 fixed_and_temporary_register_count() + translation_register_count(); | 129 fixed_and_temporary_register_count() + translation_register_count(); |
| 128 int frame_size = register_count * kPointerSize; | 130 int frame_size = register_count * kPointerSize; |
| 129 Handle<FixedArray> constant_pool = constant_array_builder()->ToFixedArray(); | 131 Handle<FixedArray> constant_pool = constant_array_builder()->ToFixedArray(); |
| 130 Handle<FixedArray> handler_table = handler_table_builder()->ToHandlerTable(); | 132 Handle<FixedArray> handler_table = handler_table_builder()->ToHandlerTable(); |
| 131 Handle<ByteArray> source_position_table = | 133 Handle<ByteArray> source_position_table = |
| 132 source_position_table_builder()->ToSourcePositionTable(); | 134 source_position_table_builder()->ToSourcePositionTable(); |
| 133 Handle<BytecodeArray> output = isolate_->factory()->NewBytecodeArray( | 135 Handle<BytecodeArray> bytecode_array = isolate_->factory()->NewBytecodeArray( |
| 134 bytecode_size, &bytecodes_.front(), frame_size, parameter_count(), | 136 bytecode_size, &bytecodes_.front(), frame_size, parameter_count(), |
| 135 constant_pool); | 137 constant_pool); |
| 136 output->set_handler_table(*handler_table); | 138 bytecode_array->set_handler_table(*handler_table); |
| 137 output->set_source_position_table(*source_position_table); | 139 bytecode_array->set_source_position_table(*source_position_table); |
| 140 |
| 141 void* line_info = source_position_table_builder()->DetachJITHandlerData(); |
| 142 LOG_CODE_EVENT(isolate_, CodeEndLinePosInfoRecordEvent( |
| 143 AbstractCode::cast(*bytecode_array), line_info)); |
| 144 |
| 138 bytecode_generated_ = true; | 145 bytecode_generated_ = true; |
| 139 return output; | 146 return bytecode_array; |
| 140 } | 147 } |
| 141 | 148 |
| 142 | 149 |
| 143 template <size_t N> | 150 template <size_t N> |
| 144 void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t(&operands)[N]) { | 151 void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t(&operands)[N]) { |
| 145 // Don't output dead code. | 152 // Don't output dead code. |
| 146 if (exit_seen_in_block_) return; | 153 if (exit_seen_in_block_) return; |
| 147 | 154 |
| 148 int operand_count = static_cast<int>(N); | 155 int operand_count = static_cast<int>(N); |
| 149 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count); | 156 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count); |
| (...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 } | 1638 } |
| 1632 | 1639 |
| 1633 // static | 1640 // static |
| 1634 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { | 1641 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { |
| 1635 return value.is_short_operand(); | 1642 return value.is_short_operand(); |
| 1636 } | 1643 } |
| 1637 | 1644 |
| 1638 } // namespace interpreter | 1645 } // namespace interpreter |
| 1639 } // namespace internal | 1646 } // namespace internal |
| 1640 } // namespace v8 | 1647 } // namespace v8 |
| OLD | NEW |