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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 void AdvanceToOffsetForTracing( | 31 void AdvanceToOffsetForTracing( |
32 interpreter::BytecodeArrayIterator& bytecode_iterator, int offset) { | 32 interpreter::BytecodeArrayIterator& bytecode_iterator, int offset) { |
33 while (bytecode_iterator.current_offset() + | 33 while (bytecode_iterator.current_offset() + |
34 bytecode_iterator.current_bytecode_size() <= | 34 bytecode_iterator.current_bytecode_size() <= |
35 offset) { | 35 offset) { |
36 bytecode_iterator.Advance(); | 36 bytecode_iterator.Advance(); |
37 } | 37 } |
38 DCHECK_EQ(offset, bytecode_iterator.current_offset()); | 38 DCHECK(bytecode_iterator.current_offset() == offset || |
| 39 ((bytecode_iterator.current_offset() + 1) == offset && |
| 40 bytecode_iterator.current_operand_scale() > |
| 41 interpreter::OperandScale::kSingle)); |
39 } | 42 } |
40 | 43 |
41 void PrintRegisters(std::ostream& os, bool is_input, | 44 void PrintRegisters(std::ostream& os, bool is_input, |
42 interpreter::BytecodeArrayIterator& bytecode_iterator, | 45 interpreter::BytecodeArrayIterator& bytecode_iterator, |
43 Handle<Object> accumulator) { | 46 Handle<Object> accumulator) { |
44 static const int kRegFieldWidth = static_cast<int>(strlen("accumulator")); | 47 static const int kRegFieldWidth = static_cast<int>(strlen("accumulator")); |
45 static const char* kInputColourCode = "\033[0;36m"; | 48 static const char* kInputColourCode = "\033[0;36m"; |
46 static const char* kOutputColourCode = "\033[0;35m"; | 49 static const char* kOutputColourCode = "\033[0;35m"; |
47 static const char* kNormalColourCode = "\033[0;m"; | 50 static const char* kNormalColourCode = "\033[0;m"; |
48 const char* kArrowDirection = is_input ? " -> " : " <- "; | 51 const char* kArrowDirection = is_input ? " -> " : " <- "; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 CONVERT_ARG_HANDLE_CHECKED(Object, accumulator, 2); | 107 CONVERT_ARG_HANDLE_CHECKED(Object, accumulator, 2); |
105 OFStream os(stdout); | 108 OFStream os(stdout); |
106 | 109 |
107 int offset = bytecode_offset - BytecodeArray::kHeaderSize + kHeapObjectTag; | 110 int offset = bytecode_offset - BytecodeArray::kHeaderSize + kHeapObjectTag; |
108 interpreter::BytecodeArrayIterator bytecode_iterator(bytecode_array); | 111 interpreter::BytecodeArrayIterator bytecode_iterator(bytecode_array); |
109 AdvanceToOffsetForTracing(bytecode_iterator, offset); | 112 AdvanceToOffsetForTracing(bytecode_iterator, offset); |
110 if (offset == bytecode_iterator.current_offset()) { | 113 if (offset == bytecode_iterator.current_offset()) { |
111 // Print bytecode. | 114 // Print bytecode. |
112 const uint8_t* bytecode_address = | 115 const uint8_t* bytecode_address = |
113 reinterpret_cast<const uint8_t*>(*bytecode_array) + bytecode_offset; | 116 reinterpret_cast<const uint8_t*>(*bytecode_array) + bytecode_offset; |
114 Vector<char> buf = Vector<char>::New(50); | 117 os << " -> " << static_cast<const void*>(bytecode_address) |
115 SNPrintF(buf, "%p", bytecode_address); | 118 << " (" << bytecode_offset << ") : "; |
116 os << " -> " << buf.start() << " (" << bytecode_offset << ") : "; | |
117 interpreter::Bytecodes::Decode(os, bytecode_address, | 119 interpreter::Bytecodes::Decode(os, bytecode_address, |
118 bytecode_array->parameter_count()); | 120 bytecode_array->parameter_count()); |
119 os << std::endl; | 121 os << std::endl; |
120 // Print all input registers and accumulator. | 122 // Print all input registers and accumulator. |
121 PrintRegisters(os, true, bytecode_iterator, accumulator); | 123 PrintRegisters(os, true, bytecode_iterator, accumulator); |
122 | 124 |
123 os << std::flush; | 125 os << std::flush; |
124 } | 126 } |
125 return isolate->heap()->undefined_value(); | 127 return isolate->heap()->undefined_value(); |
126 } | 128 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 RUNTIME_FUNCTION(Runtime_InterpreterSetPendingMessage) { | 162 RUNTIME_FUNCTION(Runtime_InterpreterSetPendingMessage) { |
161 SealHandleScope shs(isolate); | 163 SealHandleScope shs(isolate); |
162 DCHECK_EQ(1, args.length()); | 164 DCHECK_EQ(1, args.length()); |
163 CONVERT_ARG_HANDLE_CHECKED(Object, message, 0); | 165 CONVERT_ARG_HANDLE_CHECKED(Object, message, 0); |
164 isolate->thread_local_top()->pending_message_obj_ = *message; | 166 isolate->thread_local_top()->pending_message_obj_ = *message; |
165 return isolate->heap()->undefined_value(); | 167 return isolate->heap()->undefined_value(); |
166 } | 168 } |
167 | 169 |
168 } // namespace internal | 170 } // namespace internal |
169 } // namespace v8 | 171 } // namespace v8 |
OLD | NEW |