Index: test/cctest/interpreter/bytecode-expectations-printer.cc |
diff --git a/test/cctest/interpreter/bytecode-expectations-printer.cc b/test/cctest/interpreter/bytecode-expectations-printer.cc |
index 0094ed9cf81f3da9663c9dc1214eb9bb8943dbbe..44e71d4597d42fa3ae051044deb907828c5934fb 100644 |
--- a/test/cctest/interpreter/bytecode-expectations-printer.cc |
+++ b/test/cctest/interpreter/bytecode-expectations-printer.cc |
@@ -38,16 +38,17 @@ std::string BytecodeExpectationsPrinter::WrapCodeInFunction( |
return program_stream.str(); |
} |
-v8::Local<v8::Value> BytecodeExpectationsPrinter::CompileAndRun( |
+v8::Local<v8::Script> BytecodeExpectationsPrinter::Compile( |
const char* program) const { |
v8::Local<v8::String> source = V8StringFromUTF8(program); |
- v8::Local<v8::Script> script = |
- v8::Script::Compile(isolate_->GetCurrentContext(), source) |
- .ToLocalChecked(); |
+ return v8::Script::Compile(isolate_->GetCurrentContext(), source) |
+ .ToLocalChecked(); |
+} |
+v8::Local<v8::Value> BytecodeExpectationsPrinter::Run( |
+ v8::Local<v8::Script> script) const { |
v8::Local<v8::Value> result; |
CHECK(script->Run(isolate_->GetCurrentContext()).ToLocal(&result)); |
- |
return result; |
rmcilroy
2016/02/16 16:43:48
Not using the result? If not, just drop the return
Stefano Sanfilippo
2016/02/16 20:28:26
Done.
|
} |
@@ -107,7 +108,15 @@ void BytecodeExpectationsPrinter::PrintBytecodeOperand( |
Register register_value = bytecode_iter.GetRegisterOperand(op_index); |
stream << 'R'; |
if (op_size != OperandSize::kByte) stream << size_tag; |
- stream << '(' << register_value.index() << ')'; |
+ if (register_value.is_new_target()) { |
+ stream << "(new_target)"; |
+ } else if (register_value.is_current_context()) { |
+ stream << "(context)"; |
+ } else if (register_value.is_function_closure()) { |
+ stream << "(closure)"; |
+ } else { |
+ stream << '(' << register_value.index() << ')'; |
rmcilroy
2016/02/16 16:43:48
Just realized, could you also special case paramet
Stefano Sanfilippo
2016/02/16 20:28:26
Done.
If I understand correctly, the format you e
rmcilroy
2016/02/17 10:16:59
Yes. Could you also special-case <this> e.g., see
Stefano Sanfilippo
2016/02/17 14:32:28
Done.
|
+ } |
} else { |
stream << 'U' << size_tag << '('; |
@@ -232,6 +241,18 @@ void BytecodeExpectationsPrinter::PrintCodeSnippet( |
stream << "\"\n"; |
} |
+void BytecodeExpectationsPrinter::PrintHandlers( |
+ std::ostream& stream, i::Handle<i::BytecodeArray> bytecode_array) const { |
+ stream << "handlers: [\n"; |
+ HandlerTable* table = HandlerTable::cast(bytecode_array->handler_table()); |
+ for (int i = 0, num_entries = table->NumberOfRangeEntries(); i < num_entries; |
+ ++i) { |
+ stream << " [" << table->GetRangeStart(i) << ", " << table->GetRangeEnd(i) |
+ << ", " << table->GetRangeHandler(i) << "],\n"; |
+ } |
+ stream << "]\n"; |
+} |
+ |
void BytecodeExpectationsPrinter::PrintBytecodeArray( |
std::ostream& stream, const std::string& body, |
i::Handle<i::BytecodeArray> bytecode_array) const { |
@@ -240,22 +261,20 @@ void BytecodeExpectationsPrinter::PrintBytecodeArray( |
PrintFrameSize(stream, bytecode_array); |
PrintBytecodeSequence(stream, bytecode_array); |
PrintConstantPool(stream, bytecode_array->constant_pool()); |
- |
- // TODO(ssanfilippo) print handlers. |
- i::HandlerTable* handlers = |
- i::HandlerTable::cast(bytecode_array->handler_table()); |
- CHECK_EQ(handlers->NumberOfRangeEntries(), 0); |
+ PrintHandlers(stream, bytecode_array); |
} |
void BytecodeExpectationsPrinter::PrintExpectation( |
std::ostream& stream, const std::string& snippet) const { |
- const char* wrapper_function_name = "__genbckexp_wrapper__"; |
+ std::string source_code = |
+ wrap_ ? WrapCodeInFunction(top_function_name_.c_str(), snippet) : snippet; |
+ |
+ v8::Local<v8::Script> script = Compile(source_code.c_str()); |
- std::string source_code = WrapCodeInFunction(wrapper_function_name, snippet); |
- CompileAndRun(source_code.c_str()); |
+ if (execute_) Run(script); |
rmcilroy
2016/02/16 16:43:48
Out of interest, when do you not want to run the c
Stefano Sanfilippo
2016/02/16 20:28:26
Apparently, MakeTopLevelBytecode does not run the
rmcilroy
2016/02/17 10:16:59
Ahh I see, yeah you are right, top level code will
Stefano Sanfilippo
2016/02/17 14:32:28
Done.
|
i::Handle<i::BytecodeArray> bytecode_array = |
- GetBytecodeArrayForGlobal(wrapper_function_name); |
+ GetBytecodeArrayForGlobal(top_function_name_.c_str()); |
PrintBytecodeArray(stream, snippet, bytecode_array); |
stream << '\n'; |