regexp-bytecode-generator-inl.h (1728B)
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 3 // found in the LICENSE file. 4 5 #ifndef V8_REGEXP_REGEXP_BYTECODE_GENERATOR_INL_H_ 6 #define V8_REGEXP_REGEXP_BYTECODE_GENERATOR_INL_H_ 7 8 #include "irregexp/imported/regexp-bytecode-generator.h" 9 // Include the non-inl header before the rest of the headers. 10 11 #include "irregexp/imported/regexp-bytecodes.h" 12 13 namespace v8 { 14 namespace internal { 15 16 void RegExpBytecodeGenerator::Emit(uint32_t byte, uint32_t twenty_four_bits) { 17 DCHECK(is_uint24(twenty_four_bits)); 18 Emit32((twenty_four_bits << BYTECODE_SHIFT) | byte); 19 } 20 21 void RegExpBytecodeGenerator::Emit(uint32_t byte, int32_t twenty_four_bits) { 22 DCHECK(is_int24(twenty_four_bits)); 23 Emit32((static_cast<uint32_t>(twenty_four_bits) << BYTECODE_SHIFT) | byte); 24 } 25 26 void RegExpBytecodeGenerator::Emit16(uint32_t word) { 27 DCHECK(pc_ <= static_cast<int>(buffer_.size())); 28 if (pc_ + 1 >= static_cast<int>(buffer_.size())) { 29 ExpandBuffer(); 30 } 31 *reinterpret_cast<uint16_t*>(buffer_.data() + pc_) = word; 32 pc_ += 2; 33 } 34 35 void RegExpBytecodeGenerator::Emit8(uint32_t word) { 36 DCHECK(pc_ <= static_cast<int>(buffer_.size())); 37 if (pc_ == static_cast<int>(buffer_.size())) { 38 ExpandBuffer(); 39 } 40 *reinterpret_cast<unsigned char*>(buffer_.data() + pc_) = word; 41 pc_ += 1; 42 } 43 44 void RegExpBytecodeGenerator::Emit32(uint32_t word) { 45 DCHECK(pc_ <= static_cast<int>(buffer_.size())); 46 if (pc_ + 3 >= static_cast<int>(buffer_.size())) { 47 ExpandBuffer(); 48 } 49 *reinterpret_cast<uint32_t*>(buffer_.data() + pc_) = word; 50 pc_ += 4; 51 } 52 53 } // namespace internal 54 } // namespace v8 55 56 #endif // V8_REGEXP_REGEXP_BYTECODE_GENERATOR_INL_H_