regexp-macro-assembler-irregexp-inl.h 1.56 KB
Newer Older
1
// Copyright 2008-2009 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5 6
#ifndef V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_
#define V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_
7

8 9
#ifdef V8_INTERPRETED_REGEXP

10
#include "src/ast/ast.h"
11
#include "src/regexp/bytecodes-irregexp.h"
12

13 14
namespace v8 {
namespace internal {
15

erik.corry@gmail.com's avatar
erik.corry@gmail.com committed
16 17
void RegExpMacroAssemblerIrregexp::Emit(uint32_t byte,
                                        uint32_t twenty_four_bits) {
18
  uint32_t word = ((twenty_four_bits << BYTECODE_SHIFT) | byte);
19
  DCHECK(pc_ <= buffer_.length());
20
  if (pc_  + 3 >= buffer_.length()) {
21 22
    Expand();
  }
23
  *reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word;
24
  pc_ += 4;
25 26 27
}


28
void RegExpMacroAssemblerIrregexp::Emit16(uint32_t word) {
29
  DCHECK(pc_ <= buffer_.length());
30 31 32
  if (pc_ + 1 >= buffer_.length()) {
    Expand();
  }
33
  *reinterpret_cast<uint16_t*>(buffer_.start() + pc_) = word;
34 35 36 37
  pc_ += 2;
}


38
void RegExpMacroAssemblerIrregexp::Emit8(uint32_t word) {
39
  DCHECK(pc_ <= buffer_.length());
40 41 42 43 44 45 46 47
  if (pc_ == buffer_.length()) {
    Expand();
  }
  *reinterpret_cast<unsigned char*>(buffer_.start() + pc_) = word;
  pc_ += 1;
}


48
void RegExpMacroAssemblerIrregexp::Emit32(uint32_t word) {
49
  DCHECK(pc_ <= buffer_.length());
50 51 52
  if (pc_ + 3 >= buffer_.length()) {
    Expand();
  }
53
  *reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word;
54 55 56
  pc_ += 4;
}

57 58
}  // namespace internal
}  // namespace v8
59

60 61
#endif  // V8_INTERPRETED_REGEXP

62
#endif  // V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_