OLD | NEW |
1 // Copyright 2008-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2008-2009 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // A light-weight assembler for the Irregexp byte code. | 5 // A light-weight assembler for the Irregexp byte code. |
6 | 6 |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/ast.h" | 10 #include "src/ast.h" |
11 #include "src/bytecodes-irregexp.h" | 11 #include "src/bytecodes-irregexp.h" |
12 | 12 |
13 #ifndef V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_ | 13 #ifndef V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_ |
14 #define V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_ | 14 #define V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_ |
15 | 15 |
16 namespace v8 { | 16 namespace v8 { |
17 namespace internal { | 17 namespace internal { |
18 | 18 |
19 #ifdef V8_INTERPRETED_REGEXP | 19 #ifdef V8_INTERPRETED_REGEXP |
20 | 20 |
21 void RegExpMacroAssemblerIrregexp::Emit(uint32_t byte, | 21 void RegExpMacroAssemblerIrregexp::Emit(uint32_t byte, |
22 uint32_t twenty_four_bits) { | 22 uint32_t twenty_four_bits) { |
23 uint32_t word = ((twenty_four_bits << BYTECODE_SHIFT) | byte); | 23 uint32_t word = ((twenty_four_bits << BYTECODE_SHIFT) | byte); |
24 ASSERT(pc_ <= buffer_.length()); | 24 DCHECK(pc_ <= buffer_.length()); |
25 if (pc_ + 3 >= buffer_.length()) { | 25 if (pc_ + 3 >= buffer_.length()) { |
26 Expand(); | 26 Expand(); |
27 } | 27 } |
28 *reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word; | 28 *reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word; |
29 pc_ += 4; | 29 pc_ += 4; |
30 } | 30 } |
31 | 31 |
32 | 32 |
33 void RegExpMacroAssemblerIrregexp::Emit16(uint32_t word) { | 33 void RegExpMacroAssemblerIrregexp::Emit16(uint32_t word) { |
34 ASSERT(pc_ <= buffer_.length()); | 34 DCHECK(pc_ <= buffer_.length()); |
35 if (pc_ + 1 >= buffer_.length()) { | 35 if (pc_ + 1 >= buffer_.length()) { |
36 Expand(); | 36 Expand(); |
37 } | 37 } |
38 *reinterpret_cast<uint16_t*>(buffer_.start() + pc_) = word; | 38 *reinterpret_cast<uint16_t*>(buffer_.start() + pc_) = word; |
39 pc_ += 2; | 39 pc_ += 2; |
40 } | 40 } |
41 | 41 |
42 | 42 |
43 void RegExpMacroAssemblerIrregexp::Emit8(uint32_t word) { | 43 void RegExpMacroAssemblerIrregexp::Emit8(uint32_t word) { |
44 ASSERT(pc_ <= buffer_.length()); | 44 DCHECK(pc_ <= buffer_.length()); |
45 if (pc_ == buffer_.length()) { | 45 if (pc_ == buffer_.length()) { |
46 Expand(); | 46 Expand(); |
47 } | 47 } |
48 *reinterpret_cast<unsigned char*>(buffer_.start() + pc_) = word; | 48 *reinterpret_cast<unsigned char*>(buffer_.start() + pc_) = word; |
49 pc_ += 1; | 49 pc_ += 1; |
50 } | 50 } |
51 | 51 |
52 | 52 |
53 void RegExpMacroAssemblerIrregexp::Emit32(uint32_t word) { | 53 void RegExpMacroAssemblerIrregexp::Emit32(uint32_t word) { |
54 ASSERT(pc_ <= buffer_.length()); | 54 DCHECK(pc_ <= buffer_.length()); |
55 if (pc_ + 3 >= buffer_.length()) { | 55 if (pc_ + 3 >= buffer_.length()) { |
56 Expand(); | 56 Expand(); |
57 } | 57 } |
58 *reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word; | 58 *reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word; |
59 pc_ += 4; | 59 pc_ += 4; |
60 } | 60 } |
61 | 61 |
62 #endif // V8_INTERPRETED_REGEXP | 62 #endif // V8_INTERPRETED_REGEXP |
63 | 63 |
64 } } // namespace v8::internal | 64 } } // namespace v8::internal |
65 | 65 |
66 #endif // V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_ | 66 #endif // V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_ |
OLD | NEW |