2009-02-19 10:03:27 +00:00
|
|
|
// Copyright 2008-2009 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-11-25 11:07:48 +00:00
|
|
|
|
2008-11-26 12:18:17 +00:00
|
|
|
// A light-weight assembler for the Irregexp byte code.
|
2008-11-25 11:07:48 +00:00
|
|
|
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/v8.h"
|
2014-06-20 08:40:11 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/ast.h"
|
|
|
|
#include "src/bytecodes-irregexp.h"
|
2008-11-25 11:07:48 +00:00
|
|
|
|
2009-05-04 13:36:43 +00:00
|
|
|
#ifndef V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_
|
|
|
|
#define V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_
|
2008-11-25 11:07:48 +00:00
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-11-25 11:07:48 +00:00
|
|
|
|
2010-04-19 19:30:11 +00:00
|
|
|
#ifdef V8_INTERPRETED_REGEXP
|
2008-11-25 11:07:48 +00:00
|
|
|
|
2009-01-20 18:58:30 +00:00
|
|
|
void RegExpMacroAssemblerIrregexp::Emit(uint32_t byte,
|
|
|
|
uint32_t twenty_four_bits) {
|
2009-01-20 18:50:01 +00:00
|
|
|
uint32_t word = ((twenty_four_bits << BYTECODE_SHIFT) | byte);
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(pc_ <= buffer_.length());
|
2009-01-20 18:50:01 +00:00
|
|
|
if (pc_ + 3 >= buffer_.length()) {
|
2008-11-25 11:07:48 +00:00
|
|
|
Expand();
|
|
|
|
}
|
2009-01-21 08:20:40 +00:00
|
|
|
*reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word;
|
2009-01-20 18:50:01 +00:00
|
|
|
pc_ += 4;
|
2008-11-25 11:07:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-28 10:37:06 +00:00
|
|
|
void RegExpMacroAssemblerIrregexp::Emit16(uint32_t word) {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(pc_ <= buffer_.length());
|
2008-11-25 11:07:48 +00:00
|
|
|
if (pc_ + 1 >= buffer_.length()) {
|
|
|
|
Expand();
|
|
|
|
}
|
2009-01-21 08:20:40 +00:00
|
|
|
*reinterpret_cast<uint16_t*>(buffer_.start() + pc_) = word;
|
2008-11-25 11:07:48 +00:00
|
|
|
pc_ += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-30 07:43:48 +00:00
|
|
|
void RegExpMacroAssemblerIrregexp::Emit8(uint32_t word) {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(pc_ <= buffer_.length());
|
2012-03-30 07:43:48 +00:00
|
|
|
if (pc_ == buffer_.length()) {
|
|
|
|
Expand();
|
|
|
|
}
|
|
|
|
*reinterpret_cast<unsigned char*>(buffer_.start() + pc_) = word;
|
|
|
|
pc_ += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-28 10:37:06 +00:00
|
|
|
void RegExpMacroAssemblerIrregexp::Emit32(uint32_t word) {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(pc_ <= buffer_.length());
|
2008-11-25 11:07:48 +00:00
|
|
|
if (pc_ + 3 >= buffer_.length()) {
|
|
|
|
Expand();
|
|
|
|
}
|
2009-01-21 08:20:40 +00:00
|
|
|
*reinterpret_cast<uint32_t*>(buffer_.start() + pc_) = word;
|
2008-11-25 11:07:48 +00:00
|
|
|
pc_ += 4;
|
|
|
|
}
|
|
|
|
|
2010-04-19 19:30:11 +00:00
|
|
|
#endif // V8_INTERPRETED_REGEXP
|
2008-11-25 11:07:48 +00:00
|
|
|
|
|
|
|
} } // namespace v8::internal
|
2009-05-04 13:36:43 +00:00
|
|
|
|
|
|
|
#endif // V8_REGEXP_MACRO_ASSEMBLER_IRREGEXP_INL_H_
|