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// A light-weight assembler for the Irregexp byte code. 6 7 8#include "src/v8.h" 9 10#include "src/ast.h" 11#include "src/bytecodes-irregexp.h" 12 13#ifndef V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_ 14#define V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_ 15 16namespace v8 { 17namespace internal { 18 19#ifdef V8_INTERPRETED_REGEXP 20 21void RegExpMacroAssemblerIrregexp::Emit(uint32_t byte, 22 uint32_t twenty_four_bits) { 23 uint32_t word = ((twenty_four_bits << BYTECODE_SHIFT) | byte); 24 DCHECK(pc_ <= buffer_.length()); 25 if (pc_ + 3 >= buffer_.length()) { 26 Expand(); 27 } 28 *reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word; 29 pc_ += 4; 30} 31 32 33void RegExpMacroAssemblerIrregexp::Emit16(uint32_t word) { 34 DCHECK(pc_ <= buffer_.length()); 35 if (pc_ + 1 >= buffer_.length()) { 36 Expand(); 37 } 38 *reinterpret_cast<uint16_t*>(buffer_.start() + pc_) = word; 39 pc_ += 2; 40} 41 42 43void RegExpMacroAssemblerIrregexp::Emit8(uint32_t word) { 44 DCHECK(pc_ <= buffer_.length()); 45 if (pc_ == buffer_.length()) { 46 Expand(); 47 } 48 *reinterpret_cast<unsigned char*>(buffer_.start() + pc_) = word; 49 pc_ += 1; 50} 51 52 53void RegExpMacroAssemblerIrregexp::Emit32(uint32_t word) { 54 DCHECK(pc_ <= buffer_.length()); 55 if (pc_ + 3 >= buffer_.length()) { 56 Expand(); 57 } 58 *reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word; 59 pc_ += 4; 60} 61 62#endif // V8_INTERPRETED_REGEXP 63 64} } // namespace v8::internal 65 66#endif // V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_ 67