| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 5 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
| 6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 6 #define V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "src/ast.h" | 10 #include "src/ast.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 int feedback_slot, | 68 int feedback_slot, |
| 69 LanguageMode language_mode); | 69 LanguageMode language_mode); |
| 70 | 70 |
| 71 // Call a JS function. The JSFunction or Callable to be called should be in | 71 // Call a JS function. The JSFunction or Callable to be called should be in |
| 72 // |callable|, the receiver should be in |receiver| and all subsequent | 72 // |callable|, the receiver should be in |receiver| and all subsequent |
| 73 // arguments should be in registers <receiver + 1> to | 73 // arguments should be in registers <receiver + 1> to |
| 74 // <receiver + 1 + arg_count>. | 74 // <receiver + 1 + arg_count>. |
| 75 BytecodeArrayBuilder& Call(Register callable, Register receiver, | 75 BytecodeArrayBuilder& Call(Register callable, Register receiver, |
| 76 size_t arg_count); | 76 size_t arg_count); |
| 77 | 77 |
| 78 // Call the runtime function with |function_id|. The first argument should be |
| 79 // in |first_arg| and all subsequent arguments should be in registers |
| 80 // <first_arg + 1> to <first_arg + 1 + arg_count>. |
| 81 BytecodeArrayBuilder& CallRuntime(Runtime::FunctionId function_id, |
| 82 Register first_arg, size_t arg_count); |
| 83 |
| 78 // Operators (register == lhs, accumulator = rhs). | 84 // Operators (register == lhs, accumulator = rhs). |
| 79 BytecodeArrayBuilder& BinaryOperation(Token::Value binop, Register reg); | 85 BytecodeArrayBuilder& BinaryOperation(Token::Value binop, Register reg); |
| 80 | 86 |
| 81 // Tests. | 87 // Tests. |
| 82 BytecodeArrayBuilder& CompareOperation(Token::Value op, Register reg, | 88 BytecodeArrayBuilder& CompareOperation(Token::Value op, Register reg, |
| 83 LanguageMode language_mode); | 89 LanguageMode language_mode); |
| 84 | 90 |
| 85 // Casts | 91 // Casts |
| 86 BytecodeArrayBuilder& CastAccumulatorToBoolean(); | 92 BytecodeArrayBuilder& CastAccumulatorToBoolean(); |
| 87 | 93 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 100 // Accessors | 106 // Accessors |
| 101 Zone* zone() const { return zone_; } | 107 Zone* zone() const { return zone_; } |
| 102 | 108 |
| 103 private: | 109 private: |
| 104 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } | 110 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } |
| 105 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } | 111 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } |
| 106 Isolate* isolate() const { return isolate_; } | 112 Isolate* isolate() const { return isolate_; } |
| 107 | 113 |
| 108 static Bytecode BytecodeForBinaryOperation(Token::Value op); | 114 static Bytecode BytecodeForBinaryOperation(Token::Value op); |
| 109 static Bytecode BytecodeForCompareOperation(Token::Value op); | 115 static Bytecode BytecodeForCompareOperation(Token::Value op); |
| 110 static bool FitsInIdxOperand(int value); | 116 |
| 111 static bool FitsInIdxOperand(size_t value); | 117 static bool FitsInIdx8Operand(int value); |
| 118 static bool FitsInIdx8Operand(size_t value); |
| 112 static bool FitsInImm8Operand(int value); | 119 static bool FitsInImm8Operand(int value); |
| 120 static bool FitsInIdx16Operand(int value); |
| 121 |
| 113 static Bytecode GetJumpWithConstantOperand(Bytecode jump_with_smi8_operand); | 122 static Bytecode GetJumpWithConstantOperand(Bytecode jump_with_smi8_operand); |
| 114 | 123 |
| 115 template <size_t N> | 124 template <size_t N> |
| 116 INLINE(void Output(Bytecode bytecode, uint32_t(&oprands)[N])); | 125 INLINE(void Output(Bytecode bytecode, uint32_t(&oprands)[N])); |
| 117 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, | 126 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
| 118 uint32_t operand2); | 127 uint32_t operand2); |
| 119 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1); | 128 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1); |
| 120 void Output(Bytecode bytecode, uint32_t operand0); | 129 void Output(Bytecode bytecode, uint32_t operand0); |
| 121 void Output(Bytecode bytecode); | 130 void Output(Bytecode bytecode); |
| 131 |
| 122 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, | 132 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, |
| 123 BytecodeLabel* label); | 133 BytecodeLabel* label); |
| 124 void PatchJump(const ZoneVector<uint8_t>::iterator& jump_target, | 134 void PatchJump(const ZoneVector<uint8_t>::iterator& jump_target, |
| 125 ZoneVector<uint8_t>::iterator jump_location); | 135 ZoneVector<uint8_t>::iterator jump_location); |
| 126 | 136 |
| 127 void EnsureReturn(); | 137 void EnsureReturn(); |
| 128 | 138 |
| 129 bool OperandIsValid(Bytecode bytecode, int operand_index, | 139 bool OperandIsValid(Bytecode bytecode, int operand_index, |
| 130 uint32_t operand_value) const; | 140 uint32_t operand_value) const; |
| 131 bool LastBytecodeInSameBlock() const; | 141 bool LastBytecodeInSameBlock() const; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 223 |
| 214 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 224 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
| 215 }; | 225 }; |
| 216 | 226 |
| 217 | 227 |
| 218 } // namespace interpreter | 228 } // namespace interpreter |
| 219 } // namespace internal | 229 } // namespace internal |
| 220 } // namespace v8 | 230 } // namespace v8 |
| 221 | 231 |
| 222 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 232 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
| OLD | NEW |