Chromium Code Reviews| 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 Regexp2000 byte code. |
| 4 | 4 |
| 5 #ifndef V8_ASSEMBLER_RE2K_H_ | 5 #ifndef V8_ASSEMBLER_RE2K_H_ |
| 6 #define V8_ASSEMBLER_RE2K_H_ | 6 #define V8_ASSEMBLER_RE2K_H_ |
| 7 | 7 |
| 8 namespace v8 { namespace internal { | 8 namespace v8 { namespace internal { |
| 9 | 9 |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 explicit Re2kAssembler(Vector<byte>); | 26 explicit Re2kAssembler(Vector<byte>); |
| 27 ~Re2kAssembler(); | 27 ~Re2kAssembler(); |
| 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 SetRegister(int index, int cp_offset = 0); | 36 void SetRegisterToCurrentPosition(int index, int cp_offset = 0); |
| 37 void SetRegister(int index, int value); | |
| 37 | 38 |
| 38 void PopCurrentPosition(); | 39 void PopCurrentPosition(); |
| 39 void PopBacktrack(); | 40 void PopBacktrack(); |
| 40 void PopRegister(int index); | 41 void PopRegister(int index); |
| 41 | 42 |
| 42 void Fail(); | 43 void Fail(); |
| 43 void FailIfWithin(int distance_from_end); | 44 void FailIfWithin(int distance_from_end); |
| 44 void Succeed(); | 45 void Succeed(); |
| 45 | 46 |
| 47 void Break(); // This insn will cause a fatal VM error if hit. | |
|
Lasse Reichstein
2008/11/07 10:57:35
insn->instruction
| |
| 48 | |
| 46 void Bind(Label* l); // binds an unbound label L to the current code position | 49 void Bind(Label* l); // binds an unbound label L to the current code position |
| 47 | 50 |
| 48 void AdvanceCP(int cp_offset = 1); | 51 void AdvanceCP(int cp_offset = 1); |
| 49 | 52 |
| 50 void GoTo(Label* l); | 53 void GoTo(Label* l); |
| 51 | 54 |
| 52 // Loads current char into a register. | 55 // Loads current char into a register. |
| 53 void LoadCurrentChar(int cp_offset = 0); | 56 void LoadCurrentChar(int cp_offset = 0); |
| 54 | 57 |
| 55 // Checks current char register against a singleton. | 58 // Checks current char register against a singleton. |
| 56 void CheckChar(uc16 c, Label* on_mismatch); | 59 void CheckChar(uc16 c, Label* on_mismatch); |
| 57 void CheckNotChar(uc16 c, Label* on_match); | 60 void CheckNotChar(uc16 c, Label* on_match); |
| 58 | 61 |
| 62 // Checks current char register against the magic end-of-input symbol. | |
| 63 void CheckEnd(Label* on_not_end); | |
| 64 void CheckNotEnd(Label* on_end); | |
| 65 | |
| 59 // Checks current char register against a range. | 66 // Checks current char register against a range. |
| 60 void CheckRange(uc16 start, uc16 end, Label* on_mismatch); | 67 void CheckRange(uc16 start, uc16 end, Label* on_mismatch); |
| 61 void CheckNotRange(uc16 start, uc16 end, Label* on_match); | 68 void CheckNotRange(uc16 start, uc16 end, Label* on_match); |
| 62 | 69 |
| 63 | |
| 64 // Checks that the current char is in the range and that the corresponding bit | 70 // Checks that the current char is in the range and that the corresponding bit |
| 65 // is set in the bitmap. | 71 // is set in the bitmap. |
| 66 void CheckBitmap(uc16 start, uc16 end, const byte* bits, Label* on_mismatch); | 72 void CheckBitmap(uc16 start, uc16 end, const byte* bits, Label* on_mismatch); |
| 67 void CheckNotBitmap(uc16 start, uc16 end, const byte* bits, Label* on_match); | 73 void CheckNotBitmap(uc16 start, uc16 end, const byte* bits, Label* on_match); |
| 68 | 74 |
| 69 // Checks current position (plus optional offset) for a match against a | 75 // Checks current position (plus optional offset) for a match against a |
| 70 // previous capture. Advances current position by the length of the capture | 76 // previous capture. Advances current position by the length of the capture |
| 71 // iff it matches. The capture is stored in a given register and the | 77 // iff it matches. The capture is stored in a given register and the |
| 72 // the register after. | 78 // the register after. |
| 73 void CheckBackref(int capture_index, Label* on_mismatch, int cp_offset = 0); | 79 void CheckBackref(int capture_index, Label* on_mismatch, int cp_offset = 0); |
| 74 void CheckNotBackref(int capture_index, Label* on_match, int cp_offset = 0); | 80 void CheckNotBackref(int capture_index, Label* on_match, int cp_offset = 0); |
| 75 | 81 |
| 76 // Checks a register for equal, less than or equal, less than, greater than | 82 // Checks a register for equal, less than or equal, less than, greater than |
| 77 // or equal, greater than, not equal. | 83 // or equal, greater than, not equal. |
| 78 void CheckRegisterEq(int reg_index, uint16_t vs, Label* on_equal); | |
| 79 void CheckRegisterLe(int reg_index, uint16_t vs, Label* on_less_equal); | |
| 80 void CheckRegisterLt(int reg_index, uint16_t vs, Label* on_less_than); | 84 void CheckRegisterLt(int reg_index, uint16_t vs, Label* on_less_than); |
| 81 void CheckRegisterGe(int reg_index, uint16_t vs, Label* on_greater_equal); | 85 void CheckRegisterGe(int reg_index, uint16_t vs, Label* on_greater_equal); |
| 82 void CheckRegisterGt(int reg_index, uint16_t vs, Label* on_greater_than); | |
| 83 void CheckRegisterNe(int reg_index, uint16_t vs, Label* on_not_equal); | |
| 84 | 86 |
| 85 // Code and bitmap emission. | 87 // Code and bitmap emission. |
| 86 inline void Emit32(uint32_t x); | 88 inline void Emit32(uint32_t x); |
| 87 inline void Emit16(uint32_t x); | 89 inline void Emit16(uint32_t x); |
| 88 inline void Emit(uint32_t x); | 90 inline void Emit(uint32_t x); |
| 89 | 91 |
| 90 // Bytecode buffer. | 92 // Bytecode buffer. |
| 91 int length(); | 93 int length(); |
| 92 void Copy(Address a); | 94 void Copy(Address a); |
| 93 | 95 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 107 // True if the assembler owns the buffer, false if buffer is external. | 109 // True if the assembler owns the buffer, false if buffer is external. |
| 108 bool own_buffer_; | 110 bool own_buffer_; |
| 109 | 111 |
| 110 inline void EmitOrLink(Label* l); | 112 inline void EmitOrLink(Label* l); |
| 111 }; | 113 }; |
| 112 | 114 |
| 113 | 115 |
| 114 } } // namespace v8::internal | 116 } } // namespace v8::internal |
| 115 | 117 |
| 116 #endif // V8_ASSEMBLER_RE2K_H_ | 118 #endif // V8_ASSEMBLER_RE2K_H_ |
| OLD | NEW |