Chromium Code Reviews| Index: test/cctest/interpreter/bytecode-expectations-printer.h |
| diff --git a/test/cctest/interpreter/bytecode-expectations-printer.h b/test/cctest/interpreter/bytecode-expectations-printer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7de7be78e70c5cc7b17d5e7250bcb7467552dd48 |
| --- /dev/null |
| +++ b/test/cctest/interpreter/bytecode-expectations-printer.h |
| @@ -0,0 +1,79 @@ |
| +// Copyright 2016 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef V8_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_ |
| +#define V8_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_ |
| + |
| +#include <iostream> |
| +#include <string> |
| + |
| +#include "src/interpreter/bytecodes.h" |
| +#include "src/objects.h" |
| + |
| +namespace v8 { |
| + |
| +class Isolate; |
| + |
| +namespace internal { |
| +namespace interpreter { |
| + |
| +class BytecodeArrayIterator; |
| + |
| +class BytecodeExpectationsPrinter final { |
| + public: |
| + enum class ConstantPoolType { |
| + kUnknown, |
| + kString, |
| + kInteger, |
| + kDouble, |
| + kMixed, |
| + }; |
| + |
| + BytecodeExpectationsPrinter(v8::Isolate* i, |
| + ConstantPoolType t = ConstantPoolType::kMixed) |
| + : isolate_(i), const_pool_type_(t) {} |
| + |
| + void PrintExpectation(std::ostream& stream, const std::string& snippet) const; |
| + |
| + void set_constant_pool_type(ConstantPoolType t) { const_pool_type_ = t; } |
| + ConstantPoolType constant_pool_type() const { return const_pool_type_; } |
| + |
| + private: |
| + i::Isolate* GetInternalIsolate() const; |
| + v8::Local<v8::String> V8StringFromUTF8(const char* data) const; |
| + std::string WrapCodeInFunction(const char* function_name, |
| + const std::string& function_body) const; |
| + |
| + v8::Local<v8::Value> CompileAndRun(const char* program) const; |
| + i::Handle<i::BytecodeArray> GetBytecodeArrayForGlobal( |
| + const char* global_name) const; |
|
rmcilroy
2016/02/15 11:15:19
nit - move these helpers between the PrintXX func
Stefano Sanfilippo
2016/02/15 13:26:33
Done.
|
| + |
| + void PrintEscapedString(std::ostream& stream, |
| + const std::string& string) const; |
| + void PrintBytecodeOperand(std::ostream& stream, |
| + const BytecodeArrayIterator& bytecode_iter, |
| + const Bytecode& bytecode, int op_index) const; |
| + void PrintBytecode(std::ostream& stream, |
| + const BytecodeArrayIterator& bytecode_iter) const; |
| + void PrintV8String(std::ostream& stream, i::String* string) const; |
| + void PrintConstant(std::ostream& stream, i::Handle<i::Object> constant) const; |
| + void PrintFrameSize(std::ostream& stream, |
| + i::Handle<i::BytecodeArray> bytecode_array) const; |
| + void PrintBytecodeSequence(std::ostream& stream, |
| + i::Handle<i::BytecodeArray> bytecode_array) const; |
| + void PrintConstantPool(std::ostream& stream, |
| + i::FixedArray* constant_pool) const; |
| + void PrintCodeSnippet(std::ostream& stream, const std::string& body) const; |
| + void PrintBytecodeArray(std::ostream& stream, const std::string& body, |
| + i::Handle<i::BytecodeArray> bytecode_array) const; |
| + |
| + v8::Isolate* isolate_; |
| + ConstantPoolType const_pool_type_; |
| +}; |
| + |
| +} // namespace interpreter |
| +} // namespace internal |
| +} // namespace v8 |
| + |
| +#endif // V8_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_ |