| 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 | |
| 84 // Operators (register == lhs, accumulator = rhs). | 78 // Operators (register == lhs, accumulator = rhs). |
| 85 BytecodeArrayBuilder& BinaryOperation(Token::Value binop, Register reg); | 79 BytecodeArrayBuilder& BinaryOperation(Token::Value binop, Register reg); |
| 86 | 80 |
| 87 // Tests. | 81 // Tests. |
| 88 BytecodeArrayBuilder& CompareOperation(Token::Value op, Register reg, | 82 BytecodeArrayBuilder& CompareOperation(Token::Value op, Register reg, |
| 89 LanguageMode language_mode); | 83 LanguageMode language_mode); |
| 90 | 84 |
| 91 // Casts | 85 // Casts |
| 92 BytecodeArrayBuilder& CastAccumulatorToBoolean(); | 86 BytecodeArrayBuilder& CastAccumulatorToBoolean(); |
| 93 | 87 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 106 // Accessors | 100 // Accessors |
| 107 Zone* zone() const { return zone_; } | 101 Zone* zone() const { return zone_; } |
| 108 | 102 |
| 109 private: | 103 private: |
| 110 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } | 104 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } |
| 111 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } | 105 const ZoneVector<uint8_t>* bytecodes() const { return &bytecodes_; } |
| 112 Isolate* isolate() const { return isolate_; } | 106 Isolate* isolate() const { return isolate_; } |
| 113 | 107 |
| 114 static Bytecode BytecodeForBinaryOperation(Token::Value op); | 108 static Bytecode BytecodeForBinaryOperation(Token::Value op); |
| 115 static Bytecode BytecodeForCompareOperation(Token::Value op); | 109 static Bytecode BytecodeForCompareOperation(Token::Value op); |
| 116 | 110 static bool FitsInIdxOperand(int value); |
| 117 static bool FitsInIdx8Operand(int value); | 111 static bool FitsInIdxOperand(size_t value); |
| 118 static bool FitsInIdx8Operand(size_t value); | |
| 119 static bool FitsInImm8Operand(int value); | 112 static bool FitsInImm8Operand(int value); |
| 120 static bool FitsInIdx16Operand(int value); | |
| 121 | |
| 122 static Bytecode GetJumpWithConstantOperand(Bytecode jump_with_smi8_operand); | 113 static Bytecode GetJumpWithConstantOperand(Bytecode jump_with_smi8_operand); |
| 123 | 114 |
| 124 template <size_t N> | 115 template <size_t N> |
| 125 INLINE(void Output(Bytecode bytecode, uint32_t(&oprands)[N])); | 116 INLINE(void Output(Bytecode bytecode, uint32_t(&oprands)[N])); |
| 126 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, | 117 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1, |
| 127 uint32_t operand2); | 118 uint32_t operand2); |
| 128 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1); | 119 void Output(Bytecode bytecode, uint32_t operand0, uint32_t operand1); |
| 129 void Output(Bytecode bytecode, uint32_t operand0); | 120 void Output(Bytecode bytecode, uint32_t operand0); |
| 130 void Output(Bytecode bytecode); | 121 void Output(Bytecode bytecode); |
| 131 | |
| 132 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, | 122 BytecodeArrayBuilder& OutputJump(Bytecode jump_bytecode, |
| 133 BytecodeLabel* label); | 123 BytecodeLabel* label); |
| 134 void PatchJump(const ZoneVector<uint8_t>::iterator& jump_target, | 124 void PatchJump(const ZoneVector<uint8_t>::iterator& jump_target, |
| 135 ZoneVector<uint8_t>::iterator jump_location); | 125 ZoneVector<uint8_t>::iterator jump_location); |
| 136 | 126 |
| 137 void EnsureReturn(); | 127 void EnsureReturn(); |
| 138 | 128 |
| 139 bool OperandIsValid(Bytecode bytecode, int operand_index, | 129 bool OperandIsValid(Bytecode bytecode, int operand_index, |
| 140 uint32_t operand_value) const; | 130 uint32_t operand_value) const; |
| 141 bool LastBytecodeInSameBlock() const; | 131 bool LastBytecodeInSameBlock() const; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 213 |
| 224 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); | 214 DISALLOW_COPY_AND_ASSIGN(TemporaryRegisterScope); |
| 225 }; | 215 }; |
| 226 | 216 |
| 227 | 217 |
| 228 } // namespace interpreter | 218 } // namespace interpreter |
| 229 } // namespace internal | 219 } // namespace internal |
| 230 } // namespace v8 | 220 } // namespace v8 |
| 231 | 221 |
| 232 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ | 222 #endif // V8_INTERPRETER_BYTECODE_ARRAY_BUILDER_H_ |
| OLD | NEW |