OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2008 the V8 project authors. All rights reserved. | |
2 // Redistribution and use in source and binary forms, with or without | |
3 // modification, are permitted provided that the following conditions are | |
4 // met: | |
5 // | |
6 // * Redistributions of source code must retain the above copyright | |
7 // notice, this list of conditions and the following disclaimer. | |
8 // * Redistributions in binary form must reproduce the above | |
9 // copyright notice, this list of conditions and the following | |
10 // disclaimer in the documentation and/or other materials provided | |
11 // with the distribution. | |
12 // * Neither the name of Google Inc. nor the names of its | |
13 // contributors may be used to endorse or promote products derived | |
14 // from this software without specific prior written permission. | |
15 // | |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
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. | |
27 | |
28 // A light-weight assembler for the Regexp2000 byte code. | |
29 | |
30 | |
31 #include "v8.h" | |
32 #include "ast.h" | |
33 #include "bytecodes-irregexp.h" | |
34 #include "assembler-irregexp.h" | |
35 | |
36 | |
37 namespace v8 { namespace internal { | |
38 | |
39 | |
40 void IrregexpAssembler::Emit(uint32_t byte) { | |
41 ASSERT(pc_ <= buffer_.length()); | |
42 if (pc_ == buffer_.length()) { | |
43 Expand(); | |
44 } | |
45 buffer_[pc_++] = byte; | |
46 } | |
47 | |
48 | |
49 void IrregexpAssembler::Emit16(uint32_t word) { | |
50 ASSERT(pc_ <= buffer_.length()); | |
51 if (pc_ + 1 >= buffer_.length()) { | |
52 Expand(); | |
53 } | |
54 Store16(buffer_.start() + pc_, word); | |
55 pc_ += 2; | |
56 } | |
57 | |
58 | |
59 void IrregexpAssembler::Emit32(uint32_t word) { | |
60 ASSERT(pc_ <= buffer_.length()); | |
61 if (pc_ + 3 >= buffer_.length()) { | |
62 Expand(); | |
63 } | |
64 Store32(buffer_.start() + pc_, word); | |
65 pc_ += 4; | |
66 } | |
67 | |
68 | |
69 void IrregexpAssembler::EmitOrLink(Label* l) { | |
Mads Ager (chromium)
2008/11/25 21:09:41
Indentation is off here. Use 2 spaces instead of
Erik Corry
2008/11/26 12:18:36
Fixed.
| |
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 | |
OLD | NEW |