Files
sdk/runtime/vm/regexp/regexp_assembler_bytecode_inl.h
T
Ryan Macnak 262b759e06 [vm] Place regexp sources in their own directory.
This makes it easier to see their cost in binary size tools.

TEST=ci
Change-Id: I6079ad9fb9b7c9450bb8d255e9a794a38ec9ae62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388641
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-10-08 17:28:49 +00:00

55 lines
1.5 KiB
C++

// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// A light-weight assembler for the Irregexp byte code.
#include "vm/regexp/regexp_bytecodes.h"
#ifndef RUNTIME_VM_REGEXP_REGEXP_ASSEMBLER_BYTECODE_INL_H_
#define RUNTIME_VM_REGEXP_REGEXP_ASSEMBLER_BYTECODE_INL_H_
namespace dart {
void BytecodeRegExpMacroAssembler::Emit(uint32_t byte,
uint32_t twenty_four_bits) {
uint32_t word = ((twenty_four_bits << BYTECODE_SHIFT) | byte);
ASSERT(pc_ <= buffer_->length());
if (pc_ + 3 >= buffer_->length()) {
Expand();
}
*reinterpret_cast<uint32_t*>(buffer_->data() + pc_) = word;
pc_ += 4;
}
void BytecodeRegExpMacroAssembler::Emit16(uint32_t word) {
ASSERT(pc_ <= buffer_->length());
if (pc_ + 1 >= buffer_->length()) {
Expand();
}
*reinterpret_cast<uint16_t*>(buffer_->data() + pc_) = word;
pc_ += 2;
}
void BytecodeRegExpMacroAssembler::Emit8(uint32_t word) {
ASSERT(pc_ <= buffer_->length());
if (pc_ == buffer_->length()) {
Expand();
}
*reinterpret_cast<unsigned char*>(buffer_->data() + pc_) = word;
pc_ += 1;
}
void BytecodeRegExpMacroAssembler::Emit32(uint32_t word) {
ASSERT(pc_ <= buffer_->length());
if (pc_ + 3 >= buffer_->length()) {
Expand();
}
*reinterpret_cast<uint32_t*>(buffer_->data() + pc_) = word;
pc_ += 4;
}
} // namespace dart
#endif // RUNTIME_VM_REGEXP_REGEXP_ASSEMBLER_BYTECODE_INL_H_