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 // A light-weight assembler for the Irregexp byte code. | 5 // A light-weight assembler for the Irregexp byte code. |
6 | 6 |
7 #include "vm/regexp_bytecodes.h" | 7 #include "vm/regexp_bytecodes.h" |
8 | 8 |
9 #ifndef RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_INL_H_ | 9 #ifndef RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_INL_H_ |
10 #define RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_INL_H_ | 10 #define RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_INL_H_ |
11 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 void BytecodeRegExpMacroAssembler::Emit(uint32_t byte, | 14 void BytecodeRegExpMacroAssembler::Emit(uint32_t byte, |
15 uint32_t twenty_four_bits) { | 15 uint32_t twenty_four_bits) { |
16 uint32_t word = ((twenty_four_bits << BYTECODE_SHIFT) | byte); | 16 uint32_t word = ((twenty_four_bits << BYTECODE_SHIFT) | byte); |
17 ASSERT(pc_ <= buffer_->length()); | 17 ASSERT(pc_ <= buffer_->length()); |
18 if (pc_ + 3 >= buffer_->length()) { | 18 if (pc_ + 3 >= buffer_->length()) { |
19 Expand(); | 19 Expand(); |
20 } | 20 } |
21 *reinterpret_cast<uint32_t*>(buffer_->data() + pc_) = word; | 21 *reinterpret_cast<uint32_t*>(buffer_->data() + pc_) = word; |
22 pc_ += 4; | 22 pc_ += 4; |
23 } | 23 } |
24 | 24 |
25 | |
26 void BytecodeRegExpMacroAssembler::Emit16(uint32_t word) { | 25 void BytecodeRegExpMacroAssembler::Emit16(uint32_t word) { |
27 ASSERT(pc_ <= buffer_->length()); | 26 ASSERT(pc_ <= buffer_->length()); |
28 if (pc_ + 1 >= buffer_->length()) { | 27 if (pc_ + 1 >= buffer_->length()) { |
29 Expand(); | 28 Expand(); |
30 } | 29 } |
31 *reinterpret_cast<uint16_t*>(buffer_->data() + pc_) = word; | 30 *reinterpret_cast<uint16_t*>(buffer_->data() + pc_) = word; |
32 pc_ += 2; | 31 pc_ += 2; |
33 } | 32 } |
34 | 33 |
35 | |
36 void BytecodeRegExpMacroAssembler::Emit8(uint32_t word) { | 34 void BytecodeRegExpMacroAssembler::Emit8(uint32_t word) { |
37 ASSERT(pc_ <= buffer_->length()); | 35 ASSERT(pc_ <= buffer_->length()); |
38 if (pc_ == buffer_->length()) { | 36 if (pc_ == buffer_->length()) { |
39 Expand(); | 37 Expand(); |
40 } | 38 } |
41 *reinterpret_cast<unsigned char*>(buffer_->data() + pc_) = word; | 39 *reinterpret_cast<unsigned char*>(buffer_->data() + pc_) = word; |
42 pc_ += 1; | 40 pc_ += 1; |
43 } | 41 } |
44 | 42 |
45 | |
46 void BytecodeRegExpMacroAssembler::Emit32(uint32_t word) { | 43 void BytecodeRegExpMacroAssembler::Emit32(uint32_t word) { |
47 ASSERT(pc_ <= buffer_->length()); | 44 ASSERT(pc_ <= buffer_->length()); |
48 if (pc_ + 3 >= buffer_->length()) { | 45 if (pc_ + 3 >= buffer_->length()) { |
49 Expand(); | 46 Expand(); |
50 } | 47 } |
51 *reinterpret_cast<uint32_t*>(buffer_->data() + pc_) = word; | 48 *reinterpret_cast<uint32_t*>(buffer_->data() + pc_) = word; |
52 pc_ += 4; | 49 pc_ += 4; |
53 } | 50 } |
54 | 51 |
55 } // namespace dart | 52 } // namespace dart |
56 | 53 |
57 #endif // RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_INL_H_ | 54 #endif // RUNTIME_VM_REGEXP_ASSEMBLER_BYTECODE_INL_H_ |
OLD | NEW |