| 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 | 8 |
| 9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
| 10 #include "src/frames-inl.h" | 10 #include "src/frames-inl.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 DCHECK(bytecode_iterator.current_offset() == offset || | 38 DCHECK(bytecode_iterator.current_offset() == offset || |
| 39 ((bytecode_iterator.current_offset() + 1) == offset && | 39 ((bytecode_iterator.current_offset() + 1) == offset && |
| 40 bytecode_iterator.current_operand_scale() > | 40 bytecode_iterator.current_operand_scale() > |
| 41 interpreter::OperandScale::kSingle)); | 41 interpreter::OperandScale::kSingle)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void PrintRegisters(std::ostream& os, bool is_input, | 44 void PrintRegisters(std::ostream& os, bool is_input, |
| 45 interpreter::BytecodeArrayIterator& bytecode_iterator, | 45 interpreter::BytecodeArrayIterator& bytecode_iterator, |
| 46 Handle<Object> accumulator) { | 46 Handle<Object> accumulator) { |
| 47 static const int kRegFieldWidth = static_cast<int>(strlen("accumulator")); | 47 static const char kAccumulator[] = "accumulator"; |
| 48 static const int kRegFieldWidth = static_cast<int>(sizeof(kAccumulator) - 1); |
| 48 static const char* kInputColourCode = "\033[0;36m"; | 49 static const char* kInputColourCode = "\033[0;36m"; |
| 49 static const char* kOutputColourCode = "\033[0;35m"; | 50 static const char* kOutputColourCode = "\033[0;35m"; |
| 50 static const char* kNormalColourCode = "\033[0;m"; | 51 static const char* kNormalColourCode = "\033[0;m"; |
| 51 const char* kArrowDirection = is_input ? " -> " : " <- "; | 52 const char* kArrowDirection = is_input ? " -> " : " <- "; |
| 52 if (FLAG_log_colour) { | 53 if (FLAG_log_colour) { |
| 53 os << (is_input ? kInputColourCode : kOutputColourCode); | 54 os << (is_input ? kInputColourCode : kOutputColourCode); |
| 54 } | 55 } |
| 55 | 56 |
| 57 interpreter::Bytecode bytecode = bytecode_iterator.current_bytecode(); |
| 58 |
| 56 // Print accumulator. | 59 // Print accumulator. |
| 57 os << " [ accumulator" << kArrowDirection; | 60 if ((is_input && interpreter::Bytecodes::ReadsAccumulator(bytecode)) || |
| 58 accumulator->ShortPrint(); | 61 (!is_input && interpreter::Bytecodes::WritesAccumulator(bytecode))) { |
| 59 os << " ]" << std::endl; | 62 os << " [ " << kAccumulator << kArrowDirection; |
| 63 accumulator->ShortPrint(); |
| 64 os << " ]" << std::endl; |
| 65 } |
| 60 | 66 |
| 61 // Find the location of the register file. | 67 // Find the location of the register file. |
| 62 JavaScriptFrameIterator frame_iterator( | 68 JavaScriptFrameIterator frame_iterator( |
| 63 bytecode_iterator.bytecode_array()->GetIsolate()); | 69 bytecode_iterator.bytecode_array()->GetIsolate()); |
| 64 JavaScriptFrame* frame = frame_iterator.frame(); | 70 JavaScriptFrame* frame = frame_iterator.frame(); |
| 65 Address register_file = | 71 Address register_file = |
| 66 frame->fp() + InterpreterFrameConstants::kRegisterFilePointerFromFp; | 72 frame->fp() + InterpreterFrameConstants::kRegisterFilePointerFromFp; |
| 67 | 73 |
| 68 // Print the registers. | 74 // Print the registers. |
| 69 interpreter::Bytecode bytecode = bytecode_iterator.current_bytecode(); | |
| 70 int operand_count = interpreter::Bytecodes::NumberOfOperands(bytecode); | 75 int operand_count = interpreter::Bytecodes::NumberOfOperands(bytecode); |
| 71 for (int operand_index = 0; operand_index < operand_count; operand_index++) { | 76 for (int operand_index = 0; operand_index < operand_count; operand_index++) { |
| 72 interpreter::OperandType operand_type = | 77 interpreter::OperandType operand_type = |
| 73 interpreter::Bytecodes::GetOperandType(bytecode, operand_index); | 78 interpreter::Bytecodes::GetOperandType(bytecode, operand_index); |
| 74 bool should_print = | 79 bool should_print = |
| 75 is_input | 80 is_input |
| 76 ? interpreter::Bytecodes::IsRegisterInputOperandType(operand_type) | 81 ? interpreter::Bytecodes::IsRegisterInputOperandType(operand_type) |
| 77 : interpreter::Bytecodes::IsRegisterOutputOperandType(operand_type); | 82 : interpreter::Bytecodes::IsRegisterOutputOperandType(operand_type); |
| 78 if (should_print) { | 83 if (should_print) { |
| 79 interpreter::Register first_reg = | 84 interpreter::Register first_reg = |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 RUNTIME_FUNCTION(Runtime_InterpreterSetPendingMessage) { | 167 RUNTIME_FUNCTION(Runtime_InterpreterSetPendingMessage) { |
| 163 SealHandleScope shs(isolate); | 168 SealHandleScope shs(isolate); |
| 164 DCHECK_EQ(1, args.length()); | 169 DCHECK_EQ(1, args.length()); |
| 165 CONVERT_ARG_HANDLE_CHECKED(Object, message, 0); | 170 CONVERT_ARG_HANDLE_CHECKED(Object, message, 0); |
| 166 isolate->thread_local_top()->pending_message_obj_ = *message; | 171 isolate->thread_local_top()->pending_message_obj_ = *message; |
| 167 return isolate->heap()->undefined_value(); | 172 return isolate->heap()->undefined_value(); |
| 168 } | 173 } |
| 169 | 174 |
| 170 } // namespace internal | 175 } // namespace internal |
| 171 } // namespace v8 | 176 } // namespace v8 |
| OLD | NEW |