OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 15 matching lines...) Expand all Loading... |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_H_ | 28 #ifndef V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_H_ |
29 #define V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_H_ | 29 #define V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_H_ |
30 | 30 |
31 namespace v8 { namespace internal { | 31 namespace v8 { namespace internal { |
32 | 32 |
33 | 33 |
34 class RegExpMacroAssemblerIrregexp: public RegExpMacroAssembler { | 34 class RegExpMacroAssemblerIrregexp: public RegExpMacroAssembler { |
35 public: | 35 public: |
36 explicit RegExpMacroAssemblerIrregexp(IrregexpAssembler* assembler) | 36 // Create an assembler. Instructions and relocation information are emitted |
37 : assembler_(assembler) { | 37 // into a buffer, with the instructions starting from the beginning and the |
38 } | 38 // relocation information starting from the end of the buffer. See CodeDesc |
| 39 // for a detailed comment on the layout (globals.h). |
| 40 // |
| 41 // If the provided buffer is NULL, the assembler allocates and grows its own |
| 42 // buffer, and buffer_size determines the initial buffer size. The buffer is |
| 43 // owned by the assembler and deallocated upon destruction of the assembler. |
| 44 // |
| 45 // If the provided buffer is not NULL, the assembler uses the provided buffer |
| 46 // for code generation and assumes its size to be buffer_size. If the buffer |
| 47 // is too small, a fatal error occurs. No deallocation of the buffer is done |
| 48 // upon destruction of the assembler. |
| 49 explicit RegExpMacroAssemblerIrregexp(Vector<byte>); |
39 virtual ~RegExpMacroAssemblerIrregexp(); | 50 virtual ~RegExpMacroAssemblerIrregexp(); |
40 virtual void Bind(Label* label); | 51 virtual void Bind(Label* label); |
41 virtual void EmitOrLink(Label* label); | 52 virtual void EmitOrLink(Label* label); |
42 virtual void AdvanceCurrentPosition(int by); // Signed cp change. | 53 virtual void AdvanceCurrentPosition(int by); // Signed cp change. |
43 virtual void PopCurrentPosition(); | 54 virtual void PopCurrentPosition(); |
44 virtual void PushCurrentPosition(); | 55 virtual void PushCurrentPosition(); |
45 virtual void Backtrack(); | 56 virtual void Backtrack(); |
46 virtual void GoTo(Label* label); | 57 virtual void GoTo(Label* label); |
47 virtual void PushBacktrack(Label* label); | 58 virtual void PushBacktrack(Label* label); |
48 virtual void Succeed(); | 59 virtual void Succeed(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 const Vector<Label*>& destinations); | 92 const Vector<Label*>& destinations); |
82 virtual void DispatchHighByteMap(byte start, | 93 virtual void DispatchHighByteMap(byte start, |
83 Label* byte_map, | 94 Label* byte_map, |
84 const Vector<Label*>& destinations); | 95 const Vector<Label*>& destinations); |
85 virtual void IfRegisterLT(int register_index, int comparand, Label* if_lt); | 96 virtual void IfRegisterLT(int register_index, int comparand, Label* if_lt); |
86 virtual void IfRegisterGE(int register_index, int comparand, Label* if_ge); | 97 virtual void IfRegisterGE(int register_index, int comparand, Label* if_ge); |
87 | 98 |
88 virtual IrregexpImplementation Implementation(); | 99 virtual IrregexpImplementation Implementation(); |
89 virtual Handle<Object> GetCode(); | 100 virtual Handle<Object> GetCode(); |
90 private: | 101 private: |
91 IrregexpAssembler* assembler_; | 102 void Expand(); |
| 103 // Code and bitmap emission. |
| 104 inline void Emit32(uint32_t x); |
| 105 inline void Emit16(uint32_t x); |
| 106 inline void Emit(uint32_t x); |
| 107 // Bytecode buffer. |
| 108 int length(); |
| 109 void Copy(Address a); |
| 110 |
| 111 |
| 112 |
| 113 // The buffer into which code and relocation info are generated. |
| 114 Vector<byte> buffer_; |
| 115 // The program counter. |
| 116 int pc_; |
| 117 // True if the assembler owns the buffer, false if buffer is external. |
| 118 bool own_buffer_; |
| 119 |
| 120 DISALLOW_IMPLICIT_CONSTRUCTORS(RegExpMacroAssemblerIrregexp); |
92 }; | 121 }; |
93 | 122 |
94 } } // namespace v8::internal | 123 } } // namespace v8::internal |
95 | 124 |
96 #endif // V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_H_ | 125 #endif // V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_H_ |
OLD | NEW |