OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef V8_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_ | |
6 #define V8_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_ | |
7 | |
8 #include <iostream> | |
9 #include <string> | |
10 | |
11 #include "src/interpreter/bytecodes.h" | |
12 #include "src/objects.h" | |
13 | |
14 namespace v8 { | |
15 | |
16 class Isolate; | |
17 | |
18 namespace internal { | |
19 namespace interpreter { | |
20 | |
21 class BytecodeArrayIterator; | |
22 | |
23 class BytecodeExpectationsPrinter final { | |
24 public: | |
25 enum class ConstantPoolType { | |
26 kUnknown, | |
27 kString, | |
28 kInteger, | |
29 kDouble, | |
30 kMixed, | |
31 }; | |
32 | |
33 BytecodeExpectationsPrinter(v8::Isolate* i, | |
34 ConstantPoolType t = ConstantPoolType::kMixed) | |
35 : isolate_(i), const_pool_type_(t) {} | |
36 | |
37 void PrintExpectation(std::ostream& stream, const std::string& snippet) const; | |
38 | |
39 void set_constant_pool_type(ConstantPoolType t) { const_pool_type_ = t; } | |
40 ConstantPoolType constant_pool_type() const { return const_pool_type_; } | |
41 | |
42 private: | |
43 i::Isolate* GetInternalIsolate() const; | |
44 v8::Local<v8::String> V8StringFromUTF8(const char* data) const; | |
45 std::string WrapCodeInFunction(const char* function_name, | |
46 const std::string& function_body) const; | |
47 | |
48 v8::Local<v8::Value> CompileAndRun(const char* program) const; | |
49 i::Handle<i::BytecodeArray> GetBytecodeArrayForGlobal( | |
50 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.
| |
51 | |
52 void PrintEscapedString(std::ostream& stream, | |
53 const std::string& string) const; | |
54 void PrintBytecodeOperand(std::ostream& stream, | |
55 const BytecodeArrayIterator& bytecode_iter, | |
56 const Bytecode& bytecode, int op_index) const; | |
57 void PrintBytecode(std::ostream& stream, | |
58 const BytecodeArrayIterator& bytecode_iter) const; | |
59 void PrintV8String(std::ostream& stream, i::String* string) const; | |
60 void PrintConstant(std::ostream& stream, i::Handle<i::Object> constant) const; | |
61 void PrintFrameSize(std::ostream& stream, | |
62 i::Handle<i::BytecodeArray> bytecode_array) const; | |
63 void PrintBytecodeSequence(std::ostream& stream, | |
64 i::Handle<i::BytecodeArray> bytecode_array) const; | |
65 void PrintConstantPool(std::ostream& stream, | |
66 i::FixedArray* constant_pool) const; | |
67 void PrintCodeSnippet(std::ostream& stream, const std::string& body) const; | |
68 void PrintBytecodeArray(std::ostream& stream, const std::string& body, | |
69 i::Handle<i::BytecodeArray> bytecode_array) const; | |
70 | |
71 v8::Isolate* isolate_; | |
72 ConstantPoolType const_pool_type_; | |
73 }; | |
74 | |
75 } // namespace interpreter | |
76 } // namespace internal | |
77 } // namespace v8 | |
78 | |
79 #endif // V8_INTERPRETER_BYTECODE_EXPECTATIONS_PRINTER_H_ | |
OLD | NEW |