blob: a60212903d88df72f9007fecdb955e66428118ea [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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_MACRO_ASSEMBLER_IRREGEXP_INL_H_
6#define V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_
7
Ben Murdoch097c5b22016-05-18 11:27:45 +01008#ifdef V8_INTERPRETED_REGEXP
9
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000010#include "src/ast/ast.h"
11#include "src/regexp/bytecodes-irregexp.h"
12
13namespace v8 {
14namespace internal {
15
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000016void RegExpMacroAssemblerIrregexp::Emit(uint32_t byte,
17 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 Expand();
22 }
23 *reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word;
24 pc_ += 4;
25}
26
27
28void RegExpMacroAssemblerIrregexp::Emit16(uint32_t word) {
29 DCHECK(pc_ <= buffer_.length());
30 if (pc_ + 1 >= buffer_.length()) {
31 Expand();
32 }
33 *reinterpret_cast<uint16_t*>(buffer_.start() + pc_) = word;
34 pc_ += 2;
35}
36
37
38void RegExpMacroAssemblerIrregexp::Emit8(uint32_t word) {
39 DCHECK(pc_ <= buffer_.length());
40 if (pc_ == buffer_.length()) {
41 Expand();
42 }
43 *reinterpret_cast<unsigned char*>(buffer_.start() + pc_) = word;
44 pc_ += 1;
45}
46
47
48void RegExpMacroAssemblerIrregexp::Emit32(uint32_t word) {
49 DCHECK(pc_ <= buffer_.length());
50 if (pc_ + 3 >= buffer_.length()) {
51 Expand();
52 }
53 *reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word;
54 pc_ += 4;
55}
56
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000057} // namespace internal
58} // namespace v8
59
Ben Murdoch097c5b22016-05-18 11:27:45 +010060#endif // V8_INTERPRETED_REGEXP
61
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000062#endif // V8_REGEXP_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_