Index: src/interpreter/bytecode-array-builder.h |
diff --git a/src/interpreter/bytecode-array-builder.h b/src/interpreter/bytecode-array-builder.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..54fa6a2314e472fe948ad0389c48a09a40c18b1a |
--- /dev/null |
+++ b/src/interpreter/bytecode-array-builder.h |
@@ -0,0 +1,85 @@ |
+// Copyright 2015 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_ARRAY_BUILDER_H_ |
+#define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
+ |
+#include <vector> |
+ |
+#include "src/ast.h" |
+#include "src/interpreter/bytecodes.h" |
+ |
+namespace v8 { |
+namespace internal { |
+ |
+class Isolate; |
+ |
+namespace interpreter { |
+ |
+class BytecodeArrayBuilder { |
+ public: |
+ explicit BytecodeArrayBuilder(Isolate* isolate); |
+ Handle<BytecodeArray> ToBytecodeArray(); |
+ |
+ // Set number of locals required for bytecode. |
rmcilroy
2015/07/31 09:56:19
s/for bytecode/by bytecode array/
oth
2015/07/31 11:20:59
Done.
|
+ void set_locals_count(int number_of_locals); |
+ |
+ // Allocate temporary register used during expression evaluation. |
+ int AllocateTemporaryRegister(); |
+ |
+ // Free temporary register used during expression evaluation. |
+ void FreeTemporaryRegister(int reg); |
+ |
+ // =========================================================================== |
+ // ====================== Constant loads to accumulator ====================== |
+ // =========================================================================== |
rmcilroy
2015/07/31 09:56:19
nit - this type of header format isn't very common
oth
2015/07/31 11:20:59
Done. It's copied compiler/code-generator.h.
|
+ |
+ BytecodeArrayBuilder& LoadLiteral(v8::internal::Smi* value); |
+ BytecodeArrayBuilder& LoadUndefined(); |
+ BytecodeArrayBuilder& LoadNull(); |
+ BytecodeArrayBuilder& LoadTheHole(); |
+ BytecodeArrayBuilder& LoadTrue(); |
+ BytecodeArrayBuilder& LoadFalse(); |
+ |
+ // =========================================================================== |
+ // ====================== Register-accumulator transfers ===================== |
+ // =========================================================================== |
+ |
+ BytecodeArrayBuilder& LoadAccumulatorWithRegister(int reg); |
+ BytecodeArrayBuilder& StoreAccumulatorInRegister(int reg); |
+ |
+ // =========================================================================== |
+ // ================================ Operators ================================ |
+ // =========================================================================== |
+ |
+ BytecodeArrayBuilder& BinaryOperation(Token::Value binop, int reg); |
+ |
+ // =========================================================================== |
+ // ============================== Flow Control =============================== |
+ // =========================================================================== |
+ |
+ BytecodeArrayBuilder& Return(); |
+ |
+ private: |
+ static Bytecode BytecodeForBinaryOperation(Token::Value op); |
+ void Output(Bytecode bytecode, uint8_t r0, uint8_t r1, uint8_t r2); |
+ void Output(Bytecode bytecode, uint8_t r0, uint8_t r1); |
+ void Output(Bytecode bytecode, uint8_t r0); |
+ void Output(Bytecode bytecode); |
+ |
+ Isolate* isolate_; |
+ std::vector<uint8_t> bytecodes_; |
+ bool bytecode_generated_; |
+ |
+ int local_register_count_; |
+ int temporary_register_count_; |
+ int temporary_register_next_; |
+ DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArrayBuilder); |
+}; |
+ |
+} // namespace interpreter |
+} // namespace internal |
+} // namespace v8 |
+ |
+#endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |