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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 15045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15056 const uint8_t* first_bytecode_address = GetFirstBytecodeAddress(); | 15056 const uint8_t* first_bytecode_address = GetFirstBytecodeAddress(); |
15057 int bytecode_size = 0; | 15057 int bytecode_size = 0; |
15058 | 15058 |
15059 interpreter::SourcePositionTableIterator source_positions( | 15059 interpreter::SourcePositionTableIterator source_positions( |
15060 source_position_table()); | 15060 source_position_table()); |
15061 | 15061 |
15062 for (int i = 0; i < this->length(); i += bytecode_size) { | 15062 for (int i = 0; i < this->length(); i += bytecode_size) { |
15063 const uint8_t* bytecode_start = &first_bytecode_address[i]; | 15063 const uint8_t* bytecode_start = &first_bytecode_address[i]; |
15064 interpreter::Bytecode bytecode = | 15064 interpreter::Bytecode bytecode = |
15065 interpreter::Bytecodes::FromByte(bytecode_start[0]); | 15065 interpreter::Bytecodes::FromByte(bytecode_start[0]); |
15066 bytecode_size = interpreter::Bytecodes::Size(bytecode); | 15066 int prefix_offset = 0; |
rmcilroy
2016/03/10 16:45:38
It might be time to rework this so that it uses th
oth
2016/03/11 16:26:13
Ack.
| |
15067 int operand_scale = | |
15068 interpreter::Bytecodes::GetPrefixBytecodeScale(bytecode); | |
15069 if (operand_scale > 1) { | |
15070 // Bytecode is a prefix for wider operands in the next bytecode. | |
15071 prefix_offset += 1; | |
15072 bytecode = interpreter::Bytecodes::FromByte(bytecode_start[1]); | |
15073 } | |
15074 bytecode_size = | |
15075 prefix_offset + interpreter::Bytecodes::Size(bytecode, operand_scale); | |
15067 | 15076 |
15068 if (!source_positions.done() && i == source_positions.bytecode_offset()) { | 15077 if (!source_positions.done() && i == source_positions.bytecode_offset()) { |
15069 os << std::setw(5) << source_positions.source_position(); | 15078 os << std::setw(5) << source_positions.source_position(); |
15070 os << (source_positions.is_statement() ? " S> " : " E> "); | 15079 os << (source_positions.is_statement() ? " S> " : " E> "); |
15071 source_positions.Advance(); | 15080 source_positions.Advance(); |
15072 } else { | 15081 } else { |
15073 os << " "; | 15082 os << " "; |
15074 } | 15083 } |
15075 | 15084 |
15076 SNPrintF(buf, "%p", bytecode_start); | 15085 SNPrintF(buf, "%p", bytecode_start); |
15077 os << buf.start() << " : "; | 15086 os << buf.start() << " : "; |
15078 interpreter::Bytecodes::Decode(os, bytecode_start, parameter_count()); | 15087 interpreter::Bytecodes::Decode(os, bytecode_start, parameter_count()); |
15079 | 15088 |
15080 if (interpreter::Bytecodes::IsJumpConstantWide(bytecode)) { | 15089 if (interpreter::Bytecodes::IsJump(bytecode)) { |
15081 DCHECK_EQ(bytecode_size, 3); | 15090 static const int operand_offset = 1; |
15082 int index = static_cast<int>(ReadUnalignedUInt16(bytecode_start + 1)); | 15091 int operand; |
15083 int offset = Smi::cast(constant_pool()->get(index))->value(); | 15092 switch (operand_scale) { |
15093 case 1: | |
15094 operand = static_cast<int8_t>(bytecode_start[operand_offset]); | |
15095 break; | |
15096 case 2: | |
15097 operand = static_cast<int16_t>(ReadUnalignedUInt16( | |
15098 bytecode_start + prefix_offset + operand_offset)); | |
15099 break; | |
15100 case 4: | |
15101 operand = static_cast<int>(ReadUnalignedUInt32( | |
15102 bytecode_start + prefix_offset + operand_offset)); | |
15103 break; | |
15104 default: | |
15105 UNREACHABLE(); | |
15106 } | |
15107 int offset; | |
15108 if (interpreter::Bytecodes::IsJumpConstant(bytecode)) { | |
15109 offset = Smi::cast(constant_pool()->get(operand))->value(); | |
15110 } else { | |
15111 offset = operand; | |
15112 } | |
15113 offset += prefix_offset; | |
15084 SNPrintF(buf, " (%p)", bytecode_start + offset); | 15114 SNPrintF(buf, " (%p)", bytecode_start + offset); |
15085 os << buf.start(); | 15115 DCHECK_GE(i + offset, 0); |
15086 } else if (interpreter::Bytecodes::IsJumpConstant(bytecode)) { | 15116 DCHECK_LT(i + offset, length()); |
15087 DCHECK_EQ(bytecode_size, 2); | |
15088 int index = static_cast<int>(bytecode_start[1]); | |
15089 int offset = Smi::cast(constant_pool()->get(index))->value(); | |
15090 SNPrintF(buf, " (%p)", bytecode_start + offset); | |
15091 os << buf.start(); | |
15092 } else if (interpreter::Bytecodes::IsJump(bytecode)) { | |
15093 DCHECK_EQ(bytecode_size, 2); | |
15094 int offset = static_cast<int8_t>(bytecode_start[1]); | |
15095 SNPrintF(buf, " (%p)", bytecode_start + offset); | |
15096 os << buf.start(); | 15117 os << buf.start(); |
15097 } | 15118 } |
15098 | |
15099 os << std::endl; | 15119 os << std::endl; |
15100 } | 15120 } |
15101 | 15121 |
15102 if (constant_pool()->length() > 0) { | 15122 if (constant_pool()->length() > 0) { |
15103 os << "Constant pool (size = " << constant_pool()->length() << ")\n"; | 15123 os << "Constant pool (size = " << constant_pool()->length() << ")\n"; |
15104 constant_pool()->Print(); | 15124 constant_pool()->Print(); |
15105 } | 15125 } |
15106 | 15126 |
15107 #ifdef ENABLE_DISASSEMBLER | 15127 #ifdef ENABLE_DISASSEMBLER |
15108 if (handler_table()->length() > 0) { | 15128 if (handler_table()->length() > 0) { |
(...skipping 4727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19836 if (cell->value() != *new_value) { | 19856 if (cell->value() != *new_value) { |
19837 cell->set_value(*new_value); | 19857 cell->set_value(*new_value); |
19838 Isolate* isolate = cell->GetIsolate(); | 19858 Isolate* isolate = cell->GetIsolate(); |
19839 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19859 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19840 isolate, DependentCode::kPropertyCellChangedGroup); | 19860 isolate, DependentCode::kPropertyCellChangedGroup); |
19841 } | 19861 } |
19842 } | 19862 } |
19843 | 19863 |
19844 } // namespace internal | 19864 } // namespace internal |
19845 } // namespace v8 | 19865 } // namespace v8 |
OLD | NEW |