summaryrefslogtreecommitdiff
path: root/deps/v8/src/runtime/runtime-interpreter.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/runtime/runtime-interpreter.cc')
-rw-r--r--deps/v8/src/runtime/runtime-interpreter.cc111
1 files changed, 58 insertions, 53 deletions
diff --git a/deps/v8/src/runtime/runtime-interpreter.cc b/deps/v8/src/runtime/runtime-interpreter.cc
index 7150a8b287..22ae9113d8 100644
--- a/deps/v8/src/runtime/runtime-interpreter.cc
+++ b/deps/v8/src/runtime/runtime-interpreter.cc
@@ -16,30 +16,6 @@
namespace v8 {
namespace internal {
-RUNTIME_FUNCTION(Runtime_InterpreterToBoolean) {
- SealHandleScope shs(isolate);
- DCHECK_EQ(1, args.length());
- CONVERT_ARG_CHECKED(Object, x, 0);
- return isolate->heap()->ToBoolean(x->BooleanValue());
-}
-
-
-RUNTIME_FUNCTION(Runtime_InterpreterLogicalNot) {
- SealHandleScope shs(isolate);
- DCHECK_EQ(1, args.length());
- CONVERT_ARG_CHECKED(Object, x, 0);
- return isolate->heap()->ToBoolean(!x->BooleanValue());
-}
-
-
-RUNTIME_FUNCTION(Runtime_InterpreterTypeOf) {
- HandleScope shs(isolate);
- DCHECK_EQ(1, args.length());
- CONVERT_ARG_HANDLE_CHECKED(Object, x, 0);
- return Object::cast(*Object::TypeOf(isolate, x));
-}
-
-
RUNTIME_FUNCTION(Runtime_InterpreterNewClosure) {
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
@@ -52,10 +28,24 @@ RUNTIME_FUNCTION(Runtime_InterpreterNewClosure) {
namespace {
+void AdvanceToOffsetForTracing(
+ interpreter::BytecodeArrayIterator& bytecode_iterator, int offset) {
+ while (bytecode_iterator.current_offset() +
+ bytecode_iterator.current_bytecode_size() <=
+ offset) {
+ bytecode_iterator.Advance();
+ }
+ DCHECK(bytecode_iterator.current_offset() == offset ||
+ ((bytecode_iterator.current_offset() + 1) == offset &&
+ bytecode_iterator.current_operand_scale() >
+ interpreter::OperandScale::kSingle));
+}
+
void PrintRegisters(std::ostream& os, bool is_input,
- Handle<BytecodeArray> bytecode_array, int bytecode_offset,
+ interpreter::BytecodeArrayIterator& bytecode_iterator,
Handle<Object> accumulator) {
- static const int kRegFieldWidth = static_cast<int>(strlen("accumulator"));
+ static const char kAccumulator[] = "accumulator";
+ static const int kRegFieldWidth = static_cast<int>(sizeof(kAccumulator) - 1);
static const char* kInputColourCode = "\033[0;36m";
static const char* kOutputColourCode = "\033[0;35m";
static const char* kNormalColourCode = "\033[0;m";
@@ -64,22 +54,24 @@ void PrintRegisters(std::ostream& os, bool is_input,
os << (is_input ? kInputColourCode : kOutputColourCode);
}
+ interpreter::Bytecode bytecode = bytecode_iterator.current_bytecode();
+
// Print accumulator.
- os << " [ accumulator" << kArrowDirection;
- accumulator->ShortPrint();
- os << " ]" << std::endl;
+ if ((is_input && interpreter::Bytecodes::ReadsAccumulator(bytecode)) ||
+ (!is_input && interpreter::Bytecodes::WritesAccumulator(bytecode))) {
+ os << " [ " << kAccumulator << kArrowDirection;
+ accumulator->ShortPrint();
+ os << " ]" << std::endl;
+ }
// Find the location of the register file.
- JavaScriptFrameIterator frame_iterator(bytecode_array->GetIsolate());
+ JavaScriptFrameIterator frame_iterator(
+ bytecode_iterator.bytecode_array()->GetIsolate());
JavaScriptFrame* frame = frame_iterator.frame();
Address register_file =
frame->fp() + InterpreterFrameConstants::kRegisterFilePointerFromFp;
// Print the registers.
- interpreter::BytecodeArrayIterator bytecode_iterator(bytecode_array);
- bytecode_iterator.set_current_offset(
- bytecode_offset - BytecodeArray::kHeaderSize + kHeapObjectTag);
- interpreter::Bytecode bytecode = bytecode_iterator.current_bytecode();
int operand_count = interpreter::Bytecodes::NumberOfOperands(bytecode);
for (int operand_index = 0; operand_index < operand_count; operand_index++) {
interpreter::OperandType operand_type =
@@ -98,7 +90,7 @@ void PrintRegisters(std::ostream& os, bool is_input,
Object* reg_object = Memory::Object_at(reg_location);
os << " [ " << std::setw(kRegFieldWidth)
<< interpreter::Register(reg_index).ToString(
- bytecode_array->parameter_count())
+ bytecode_iterator.bytecode_array()->parameter_count())
<< kArrowDirection;
reg_object->ShortPrint(os);
os << " ]" << std::endl;
@@ -120,20 +112,23 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeEntry) {
CONVERT_ARG_HANDLE_CHECKED(Object, accumulator, 2);
OFStream os(stdout);
- // Print bytecode.
- const uint8_t* bytecode_address =
- reinterpret_cast<const uint8_t*>(*bytecode_array) + bytecode_offset;
- Vector<char> buf = Vector<char>::New(50);
- SNPrintF(buf, "%p", bytecode_address);
- os << " -> " << buf.start() << " (" << bytecode_offset << ") : ";
- interpreter::Bytecodes::Decode(os, bytecode_address,
- bytecode_array->parameter_count());
- os << std::endl;
-
- // Print all input registers and accumulator.
- PrintRegisters(os, true, bytecode_array, bytecode_offset, accumulator);
-
- os << std::flush;
+ int offset = bytecode_offset - BytecodeArray::kHeaderSize + kHeapObjectTag;
+ interpreter::BytecodeArrayIterator bytecode_iterator(bytecode_array);
+ AdvanceToOffsetForTracing(bytecode_iterator, offset);
+ if (offset == bytecode_iterator.current_offset()) {
+ // Print bytecode.
+ const uint8_t* bytecode_address =
+ reinterpret_cast<const uint8_t*>(*bytecode_array) + bytecode_offset;
+ os << " -> " << static_cast<const void*>(bytecode_address)
+ << " (" << bytecode_offset << ") : ";
+ interpreter::Bytecodes::Decode(os, bytecode_address,
+ bytecode_array->parameter_count());
+ os << std::endl;
+ // Print all input registers and accumulator.
+ PrintRegisters(os, true, bytecode_iterator, accumulator);
+
+ os << std::flush;
+ }
return isolate->heap()->undefined_value();
}
@@ -143,11 +138,21 @@ RUNTIME_FUNCTION(Runtime_InterpreterTraceBytecodeExit) {
CONVERT_ARG_HANDLE_CHECKED(BytecodeArray, bytecode_array, 0);
CONVERT_SMI_ARG_CHECKED(bytecode_offset, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, accumulator, 2);
- OFStream os(stdout);
- // Print all output registers and accumulator.
- PrintRegisters(os, false, bytecode_array, bytecode_offset, accumulator);
- os << std::flush;
+ int offset = bytecode_offset - BytecodeArray::kHeaderSize + kHeapObjectTag;
+ interpreter::BytecodeArrayIterator bytecode_iterator(bytecode_array);
+ AdvanceToOffsetForTracing(bytecode_iterator, offset);
+ // The offset comparison here ensures registers only printed when the
+ // (potentially) widened bytecode has completed. The iterator reports
+ // the offset as the offset of the prefix bytecode.
+ if (bytecode_iterator.current_operand_scale() ==
+ interpreter::OperandScale::kSingle ||
+ offset > bytecode_iterator.current_offset()) {
+ OFStream os(stdout);
+ // Print all output registers and accumulator.
+ PrintRegisters(os, false, bytecode_iterator, accumulator);
+ os << std::flush;
+ }
return isolate->heap()->undefined_value();
}