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 13 matching lines...) Expand all Loading... |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
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 // A light-weight assembler for the Irregexp byte code. | 28 // A light-weight assembler for the Irregexp byte code. |
29 | 29 |
30 | 30 |
31 #include "v8.h" | 31 #include "v8.h" |
32 #include "ast.h" | 32 #include "ast.h" |
33 #include "bytecodes-irregexp.h" | 33 #include "bytecodes-irregexp.h" |
34 #include "assembler-irregexp.h" | |
35 | 34 |
36 | 35 |
37 namespace v8 { namespace internal { | 36 namespace v8 { namespace internal { |
38 | 37 |
39 | 38 |
40 void IrregexpAssembler::Emit(uint32_t byte) { | 39 void RegExpMacroAssemblerIrregexp::Emit(uint32_t byte) { |
41 ASSERT(pc_ <= buffer_.length()); | 40 ASSERT(pc_ <= buffer_.length()); |
42 if (pc_ == buffer_.length()) { | 41 if (pc_ == buffer_.length()) { |
43 Expand(); | 42 Expand(); |
44 } | 43 } |
45 buffer_[pc_++] = byte; | 44 buffer_[pc_++] = byte; |
46 } | 45 } |
47 | 46 |
48 | 47 |
49 void IrregexpAssembler::Emit16(uint32_t word) { | 48 void RegExpMacroAssemblerIrregexp::Emit16(uint32_t word) { |
50 ASSERT(pc_ <= buffer_.length()); | 49 ASSERT(pc_ <= buffer_.length()); |
51 if (pc_ + 1 >= buffer_.length()) { | 50 if (pc_ + 1 >= buffer_.length()) { |
52 Expand(); | 51 Expand(); |
53 } | 52 } |
54 Store16(buffer_.start() + pc_, word); | 53 Store16(buffer_.start() + pc_, word); |
55 pc_ += 2; | 54 pc_ += 2; |
56 } | 55 } |
57 | 56 |
58 | 57 |
59 void IrregexpAssembler::Emit32(uint32_t word) { | 58 void RegExpMacroAssemblerIrregexp::Emit32(uint32_t word) { |
60 ASSERT(pc_ <= buffer_.length()); | 59 ASSERT(pc_ <= buffer_.length()); |
61 if (pc_ + 3 >= buffer_.length()) { | 60 if (pc_ + 3 >= buffer_.length()) { |
62 Expand(); | 61 Expand(); |
63 } | 62 } |
64 Store32(buffer_.start() + pc_, word); | 63 Store32(buffer_.start() + pc_, word); |
65 pc_ += 4; | 64 pc_ += 4; |
66 } | 65 } |
67 | 66 |
68 | 67 |
69 void IrregexpAssembler::EmitOrLink(Label* l) { | |
70 if (l->is_bound()) { | |
71 Emit32(l->pos()); | |
72 } else { | |
73 int pos = 0; | |
74 if (l->is_linked()) { | |
75 pos = l->pos(); | |
76 } | |
77 l->link_to(pc_); | |
78 Emit32(pos); | |
79 } | |
80 } | |
81 | |
82 } } // namespace v8::internal | 68 } } // namespace v8::internal |
OLD | NEW |