| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 | 2 |
| 3 // A light-weight assembler for the Regexp2000 byte code. | 3 // A light-weight assembler for the Irregexp byte code. |
| 4 | 4 |
| 5 #ifndef V8_ASSEMBLER_RE2K_H_ | 5 #ifndef V8_ASSEMBLER_IRREGEXP_H_ |
| 6 #define V8_ASSEMBLER_RE2K_H_ | 6 #define V8_ASSEMBLER_IRREGEXP_H_ |
| 7 | 7 |
| 8 namespace v8 { namespace internal { | 8 namespace v8 { namespace internal { |
| 9 | 9 |
| 10 | 10 |
| 11 class Re2kAssembler { | 11 class IrregexpAssembler { |
| 12 public: | 12 public: |
| 13 // Create an assembler. Instructions and relocation information are emitted | 13 // Create an assembler. Instructions and relocation information are emitted |
| 14 // into a buffer, with the instructions starting from the beginning and the | 14 // into a buffer, with the instructions starting from the beginning and the |
| 15 // relocation information starting from the end of the buffer. See CodeDesc | 15 // relocation information starting from the end of the buffer. See CodeDesc |
| 16 // for a detailed comment on the layout (globals.h). | 16 // for a detailed comment on the layout (globals.h). |
| 17 // | 17 // |
| 18 // If the provided buffer is NULL, the assembler allocates and grows its own | 18 // If the provided buffer is NULL, the assembler allocates and grows its own |
| 19 // buffer, and buffer_size determines the initial buffer size. The buffer is | 19 // buffer, and buffer_size determines the initial buffer size. The buffer is |
| 20 // owned by the assembler and deallocated upon destruction of the assembler. | 20 // owned by the assembler and deallocated upon destruction of the assembler. |
| 21 // | 21 // |
| 22 // If the provided buffer is not NULL, the assembler uses the provided buffer | 22 // If the provided buffer is not NULL, the assembler uses the provided buffer |
| 23 // for code generation and assumes its size to be buffer_size. If the buffer | 23 // for code generation and assumes its size to be buffer_size. If the buffer |
| 24 // is too small, a fatal error occurs. No deallocation of the buffer is done | 24 // is too small, a fatal error occurs. No deallocation of the buffer is done |
| 25 // upon destruction of the assembler. | 25 // upon destruction of the assembler. |
| 26 explicit Re2kAssembler(Vector<byte>); | 26 explicit IrregexpAssembler(Vector<byte>); |
| 27 ~Re2kAssembler(); | 27 ~IrregexpAssembler(); |
| 28 | 28 |
| 29 // CP = current position in source. | 29 // CP = current position in source. |
| 30 // BT = backtrack label. | 30 // BT = backtrack label. |
| 31 | 31 |
| 32 // Stack. | 32 // Stack. |
| 33 void PushCurrentPosition(int cp_offset = 0); | 33 void PushCurrentPosition(int cp_offset = 0); |
| 34 void PushBacktrack(Label* l); | 34 void PushBacktrack(Label* l); |
| 35 void PushRegister(int index); | 35 void PushRegister(int index); |
| 36 void WriteCurrentPositionToRegister(int index, int cp_offset = 0); | 36 void WriteCurrentPositionToRegister(int index, int cp_offset = 0); |
| 37 void ReadCurrentPositionFromRegister(int index); | 37 void ReadCurrentPositionFromRegister(int index); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 inline void Emit16(uint32_t x); | 107 inline void Emit16(uint32_t x); |
| 108 inline void Emit(uint32_t x); | 108 inline void Emit(uint32_t x); |
| 109 | 109 |
| 110 // Bytecode buffer. | 110 // Bytecode buffer. |
| 111 int length(); | 111 int length(); |
| 112 void Copy(Address a); | 112 void Copy(Address a); |
| 113 | 113 |
| 114 inline void EmitOrLink(Label* l); | 114 inline void EmitOrLink(Label* l); |
| 115 private: | 115 private: |
| 116 // Don't use this. | 116 // Don't use this. |
| 117 Re2kAssembler() { UNREACHABLE(); } | 117 IrregexpAssembler() { UNREACHABLE(); } |
| 118 // The buffer into which code and relocation info are generated. | 118 // The buffer into which code and relocation info are generated. |
| 119 Vector<byte> buffer_; | 119 Vector<byte> buffer_; |
| 120 | 120 |
| 121 inline void CheckRegister(int byte_code, | 121 inline void CheckRegister(int byte_code, |
| 122 int reg_index, | 122 int reg_index, |
| 123 uint16_t vs, | 123 uint16_t vs, |
| 124 Label* on_true); | 124 Label* on_true); |
| 125 // Code generation. | 125 // Code generation. |
| 126 int pc_; // The program counter; moves forward. | 126 int pc_; // The program counter; moves forward. |
| 127 | 127 |
| 128 // True if the assembler owns the buffer, false if buffer is external. | 128 // True if the assembler owns the buffer, false if buffer is external. |
| 129 bool own_buffer_; | 129 bool own_buffer_; |
| 130 | 130 |
| 131 void Expand(); | 131 void Expand(); |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 | 134 |
| 135 } } // namespace v8::internal | 135 } } // namespace v8::internal |
| 136 | 136 |
| 137 #endif // V8_ASSEMBLER_RE2K_H_ | 137 #endif // V8_ASSEMBLER_IRREGEXP_H_ |
| OLD | NEW |