OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_H_ | 5 #ifndef RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_H_ |
6 #define RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_H_ | 6 #define RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_H_ |
7 | 7 |
8 #include "vm/object.h" | 8 #include "vm/object.h" |
9 #include "vm/regexp_assembler.h" | 9 #include "vm/regexp_assembler.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 class BytecodeRegExpMacroAssembler: public RegExpMacroAssembler { | 13 class BytecodeRegExpMacroAssembler : public RegExpMacroAssembler { |
14 public: | 14 public: |
15 // Create an assembler. Instructions and relocation information are emitted | 15 // Create an assembler. Instructions and relocation information are emitted |
16 // into a buffer, with the instructions starting from the beginning and the | 16 // into a buffer, with the instructions starting from the beginning and the |
17 // relocation information starting from the end of the buffer. See CodeDesc | 17 // relocation information starting from the end of the buffer. See CodeDesc |
18 // for a detailed comment on the layout (globals.h). | 18 // for a detailed comment on the layout (globals.h). |
19 // | 19 // |
20 // If the provided buffer is NULL, the assembler allocates and grows its own | 20 // If the provided buffer is NULL, the assembler allocates and grows its own |
21 // buffer, and buffer_size determines the initial buffer size. The buffer is | 21 // buffer, and buffer_size determines the initial buffer size. The buffer is |
22 // owned by the assembler and deallocated upon destruction of the assembler. | 22 // owned by the assembler and deallocated upon destruction of the assembler. |
23 // | 23 // |
24 // If the provided buffer is not NULL, the assembler uses the provided buffer | 24 // If the provided buffer is not NULL, the assembler uses the provided buffer |
25 // for code generation and assumes its size to be buffer_size. If the buffer | 25 // for code generation and assumes its size to be buffer_size. If the buffer |
26 // is too small, a fatal error occurs. No deallocation of the buffer is done | 26 // is too small, a fatal error occurs. No deallocation of the buffer is done |
27 // upon destruction of the assembler. | 27 // upon destruction of the assembler. |
28 BytecodeRegExpMacroAssembler(ZoneGrowableArray<uint8_t>* buffer, | 28 BytecodeRegExpMacroAssembler(ZoneGrowableArray<uint8_t>* buffer, Zone* zone); |
29 Zone* zone); | |
30 virtual ~BytecodeRegExpMacroAssembler(); | 29 virtual ~BytecodeRegExpMacroAssembler(); |
31 | 30 |
32 // The byte-code interpreter checks on each push anyway. | 31 // The byte-code interpreter checks on each push anyway. |
33 virtual intptr_t stack_limit_slack() { return 1; } | 32 virtual intptr_t stack_limit_slack() { return 1; } |
34 virtual bool CanReadUnaligned() { return false; } | 33 virtual bool CanReadUnaligned() { return false; } |
35 virtual void BindBlock(BlockLabel* label); | 34 virtual void BindBlock(BlockLabel* label); |
36 virtual void AdvanceCurrentPosition(intptr_t by); // Signed cp change. | 35 virtual void AdvanceCurrentPosition(intptr_t by); // Signed cp change. |
37 virtual void PopCurrentPosition(); | 36 virtual void PopCurrentPosition(); |
38 virtual void PushCurrentPosition(); | 37 virtual void PushCurrentPosition(); |
39 virtual void Backtrack(); | 38 virtual void Backtrack(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 virtual IrregexpImplementation Implementation(); | 93 virtual IrregexpImplementation Implementation(); |
95 // virtual Handle<HeapObject> GetCode(Handle<String> source); | 94 // virtual Handle<HeapObject> GetCode(Handle<String> source); |
96 RawTypedData* GetBytecode(); | 95 RawTypedData* GetBytecode(); |
97 | 96 |
98 // New | 97 // New |
99 virtual bool IsClosed() const { | 98 virtual bool IsClosed() const { |
100 // Added by Dart for the IR version. Bytecode version should never need an | 99 // Added by Dart for the IR version. Bytecode version should never need an |
101 // extra goto. | 100 // extra goto. |
102 return true; | 101 return true; |
103 } | 102 } |
104 virtual void Print(const char* str) { UNIMPLEMENTED(); } | 103 virtual void Print(const char* str) { UNIMPLEMENTED(); } |
105 virtual void PrintBlocks() { UNIMPLEMENTED(); } | 104 virtual void PrintBlocks() { UNIMPLEMENTED(); } |
106 ///// | 105 ///// |
107 | 106 |
108 static RawInstance* Interpret(const RegExp& regexp, | 107 static RawInstance* Interpret(const RegExp& regexp, |
109 const String& str, | 108 const String& str, |
110 const Smi& start_index, | 109 const Smi& start_index, |
111 Zone* zone); | 110 Zone* zone); |
112 | 111 |
113 private: | 112 private: |
114 void Expand(); | 113 void Expand(); |
(...skipping 20 matching lines...) Expand all Loading... |
135 | 134 |
136 static const int kInvalidPC = -1; | 135 static const int kInvalidPC = -1; |
137 | 136 |
138 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeRegExpMacroAssembler); | 137 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeRegExpMacroAssembler); |
139 }; | 138 }; |
140 | 139 |
141 | 140 |
142 } // namespace dart | 141 } // namespace dart |
143 | 142 |
144 #endif // RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_H_ | 143 #endif // RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_H_ |
OLD | NEW |