V8 Project
regexp-macro-assembler-irregexp-inl.h
Go to the documentation of this file.
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 
16 namespace v8 {
17 namespace internal {
18 
19 #ifdef V8_INTERPRETED_REGEXP
20 
21 void 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 
33 void 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 
43 void 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 
53 void 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_
#define DCHECK(condition)
Definition: logging.h:205
unsigned short uint16_t
Definition: unicode.cc:23
const int BYTECODE_SHIFT
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20