Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
dart::BytecodeRegExpMacroAssembler Class Reference

#include <regexp_assembler_bytecode.h>

Inheritance diagram for dart::BytecodeRegExpMacroAssembler:
dart::RegExpMacroAssembler dart::ZoneAllocated

Public Member Functions

 BytecodeRegExpMacroAssembler (ZoneGrowableArray< uint8_t > *buffer, Zone *zone)
 
virtual ~BytecodeRegExpMacroAssembler ()
 
virtual intptr_t stack_limit_slack ()
 
virtual bool CanReadUnaligned ()
 
virtual void BindBlock (BlockLabel *label)
 
virtual void AdvanceCurrentPosition (intptr_t by)
 
virtual void PopCurrentPosition ()
 
virtual void PushCurrentPosition ()
 
virtual void Backtrack ()
 
virtual void GoTo (BlockLabel *label)
 
virtual void PushBacktrack (BlockLabel *label)
 
virtual bool Succeed ()
 
virtual void Fail ()
 
virtual void PopRegister (intptr_t register_index)
 
virtual void PushRegister (intptr_t register_index)
 
virtual void AdvanceRegister (intptr_t reg, intptr_t by)
 
virtual void SetCurrentPositionFromEnd (intptr_t by)
 
virtual void SetRegister (intptr_t register_index, intptr_t to)
 
virtual void WriteCurrentPositionToRegister (intptr_t reg, intptr_t cp_offset)
 
virtual void ClearRegisters (intptr_t reg_from, intptr_t reg_to)
 
virtual void ReadCurrentPositionFromRegister (intptr_t reg)
 
virtual void WriteStackPointerToRegister (intptr_t reg)
 
virtual void ReadStackPointerFromRegister (intptr_t reg)
 
virtual void LoadCurrentCharacter (intptr_t cp_offset, BlockLabel *on_end_of_input, bool check_bounds=true, intptr_t characters=1)
 
virtual void CheckCharacter (unsigned c, BlockLabel *on_equal)
 
virtual void CheckCharacterAfterAnd (unsigned c, unsigned mask, BlockLabel *on_equal)
 
virtual void CheckCharacterGT (uint16_t limit, BlockLabel *on_greater)
 
virtual void CheckCharacterLT (uint16_t limit, BlockLabel *on_less)
 
virtual void CheckGreedyLoop (BlockLabel *on_tos_equals_current_position)
 
virtual void CheckAtStart (BlockLabel *on_at_start)
 
virtual void CheckNotAtStart (intptr_t cp_offset, BlockLabel *on_not_at_start)
 
virtual void CheckNotCharacter (unsigned c, BlockLabel *on_not_equal)
 
virtual void CheckNotCharacterAfterAnd (unsigned c, unsigned mask, BlockLabel *on_not_equal)
 
virtual void CheckNotCharacterAfterMinusAnd (uint16_t c, uint16_t minus, uint16_t mask, BlockLabel *on_not_equal)
 
virtual void CheckCharacterInRange (uint16_t from, uint16_t to, BlockLabel *on_in_range)
 
virtual void CheckCharacterNotInRange (uint16_t from, uint16_t to, BlockLabel *on_not_in_range)
 
virtual void CheckBitInTable (const TypedData &table, BlockLabel *on_bit_set)
 
virtual void CheckNotBackReference (intptr_t start_reg, bool read_backward, BlockLabel *on_no_match)
 
virtual void CheckNotBackReferenceIgnoreCase (intptr_t start_reg, bool read_backward, bool unicode, BlockLabel *on_no_match)
 
virtual void IfRegisterLT (intptr_t register_index, intptr_t comparand, BlockLabel *if_lt)
 
virtual void IfRegisterGE (intptr_t register_index, intptr_t comparand, BlockLabel *if_ge)
 
virtual void IfRegisterEqPos (intptr_t register_index, BlockLabel *if_eq)
 
virtual IrregexpImplementation Implementation ()
 
TypedDataPtr GetBytecode ()
 
virtual bool IsClosed () const
 
virtual void Print (const char *str)
 
virtual void PrintBlocks ()
 
- Public Member Functions inherited from dart::RegExpMacroAssembler
 RegExpMacroAssembler (Zone *zone)
 
virtual ~RegExpMacroAssembler ()
 
virtual intptr_t stack_limit_slack ()=0
 
virtual bool CanReadUnaligned ()=0
 
virtual void AdvanceCurrentPosition (intptr_t by)=0
 
virtual void AdvanceRegister (intptr_t reg, intptr_t by)=0
 
virtual void Backtrack ()=0
 
virtual void BindBlock (BlockLabel *label)=0
 
virtual void CheckAtStart (BlockLabel *on_at_start)=0
 
virtual void CheckCharacter (unsigned c, BlockLabel *on_equal)=0
 
virtual void CheckCharacterAfterAnd (unsigned c, unsigned and_with, BlockLabel *on_equal)=0
 
virtual void CheckCharacterGT (uint16_t limit, BlockLabel *on_greater)=0
 
virtual void CheckCharacterLT (uint16_t limit, BlockLabel *on_less)=0
 
virtual void CheckGreedyLoop (BlockLabel *on_tos_equals_current_position)=0
 
virtual void CheckNotAtStart (intptr_t cp_offset, BlockLabel *on_not_at_start)=0
 
virtual void CheckNotBackReference (intptr_t start_reg, bool read_backward, BlockLabel *on_no_match)=0
 
virtual void CheckNotBackReferenceIgnoreCase (intptr_t start_reg, bool read_backward, bool unicode, BlockLabel *on_no_match)=0
 
virtual void CheckNotCharacter (unsigned c, BlockLabel *on_not_equal)=0
 
virtual void CheckNotCharacterAfterAnd (unsigned c, unsigned and_with, BlockLabel *on_not_equal)=0
 
virtual void CheckNotCharacterAfterMinusAnd (uint16_t c, uint16_t minus, uint16_t and_with, BlockLabel *on_not_equal)=0
 
virtual void CheckCharacterInRange (uint16_t from, uint16_t to, BlockLabel *on_in_range)=0
 
virtual void CheckCharacterNotInRange (uint16_t from, uint16_t to, BlockLabel *on_not_in_range)=0
 
virtual void CheckBitInTable (const TypedData &table, BlockLabel *on_bit_set)=0
 
virtual void CheckPreemption (bool is_backtrack)
 
virtual void CheckPosition (intptr_t cp_offset, BlockLabel *on_outside_input)
 
virtual bool CheckSpecialCharacterClass (uint16_t type, BlockLabel *on_no_match)
 
virtual void Fail ()=0
 
virtual void IfRegisterGE (intptr_t reg, intptr_t comparand, BlockLabel *if_ge)=0
 
virtual void IfRegisterLT (intptr_t reg, intptr_t comparand, BlockLabel *if_lt)=0
 
virtual void IfRegisterEqPos (intptr_t reg, BlockLabel *if_eq)=0
 
virtual IrregexpImplementation Implementation ()=0
 
virtual bool IsClosed () const =0
 
virtual void GoTo (BlockLabel *to)=0
 
virtual void LoadCurrentCharacter (intptr_t cp_offset, BlockLabel *on_end_of_input, bool check_bounds=true, intptr_t characters=1)=0
 
virtual void PopCurrentPosition ()=0
 
virtual void PopRegister (intptr_t register_index)=0
 
virtual void Print (const char *str)=0
 
virtual void PrintBlocks ()=0
 
virtual void PushBacktrack (BlockLabel *label)=0
 
virtual void PushCurrentPosition ()=0
 
virtual void PushRegister (intptr_t register_index)=0
 
virtual void ReadCurrentPositionFromRegister (intptr_t reg)=0
 
virtual void ReadStackPointerFromRegister (intptr_t reg)=0
 
virtual void SetCurrentPositionFromEnd (intptr_t by)=0
 
virtual void SetRegister (intptr_t register_index, intptr_t to)=0
 
virtual bool Succeed ()=0
 
virtual void WriteCurrentPositionToRegister (intptr_t reg, intptr_t cp_offset)=0
 
virtual void ClearRegisters (intptr_t reg_from, intptr_t reg_to)=0
 
virtual void WriteStackPointerToRegister (intptr_t reg)=0
 
void CheckNotInSurrogatePair (intptr_t cp_offset, BlockLabel *on_failure)
 
void set_slow_safe (bool ssc)
 
bool slow_safe ()
 
void set_global_mode (GlobalMode mode)
 
bool global ()
 
bool global_with_zero_length_check ()
 
bool global_unicode ()
 
Zonezone () const
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Static Public Member Functions

static ObjectPtr Interpret (const RegExp &regexp, const String &str, const Smi &start_index, bool is_sticky, Zone *zone)
 

Additional Inherited Members

- Public Types inherited from dart::RegExpMacroAssembler
enum  { kParamRegExpIndex = 0 , kParamStringIndex , kParamStartOffsetIndex , kParamCount }
 
enum  IrregexpImplementation { kBytecodeImplementation , kIRImplementation }
 
enum  GlobalMode { NOT_GLOBAL , GLOBAL , GLOBAL_NO_ZERO_LENGTH_CHECK , GLOBAL_UNICODE }
 
- Static Public Attributes inherited from dart::RegExpMacroAssembler
static constexpr intptr_t kMaxRegister = (1 << 16) - 1
 
static constexpr intptr_t kMaxCPOffset = (1 << 15) - 1
 
static constexpr intptr_t kMinCPOffset = -(1 << 15)
 
static constexpr intptr_t kTableSizeBits = 7
 
static constexpr intptr_t kTableSize = 1 << kTableSizeBits
 
static constexpr intptr_t kTableMask = kTableSize - 1
 

Detailed Description

Definition at line 13 of file regexp_assembler_bytecode.h.

Constructor & Destructor Documentation

◆ BytecodeRegExpMacroAssembler()

dart::BytecodeRegExpMacroAssembler::BytecodeRegExpMacroAssembler ( ZoneGrowableArray< uint8_t > *  buffer,
Zone zone 
)

Definition at line 19 of file regexp_assembler_bytecode.cc.

23 buffer_(buffer),
24 pc_(0),
25 advance_current_end_(kInvalidPC) {}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ ~BytecodeRegExpMacroAssembler()

dart::BytecodeRegExpMacroAssembler::~BytecodeRegExpMacroAssembler ( )
virtual

Definition at line 27 of file regexp_assembler_bytecode.cc.

27 {
28 if (backtrack_.is_linked()) backtrack_.Unuse();
29}
bool is_linked() const

Member Function Documentation

◆ AdvanceCurrentPosition()

void dart::BytecodeRegExpMacroAssembler::AdvanceCurrentPosition ( intptr_t  by)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 175 of file regexp_assembler_bytecode.cc.

175 {
176 ASSERT(by >= kMinCPOffset);
177 ASSERT(by <= kMaxCPOffset);
178 advance_current_start_ = pc_;
179 advance_current_offset_ = by;
180 Emit(BC_ADVANCE_CP, by);
181 advance_current_end_ = pc_;
182}
static constexpr intptr_t kMinCPOffset
static constexpr intptr_t kMaxCPOffset
#define ASSERT(E)

◆ AdvanceRegister()

void dart::BytecodeRegExpMacroAssembler::AdvanceRegister ( intptr_t  reg,
intptr_t  by 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 127 of file regexp_assembler_bytecode.cc.

128 {
129 ASSERT(register_index >= 0);
130 ASSERT(register_index <= kMaxRegister);
131 Emit(BC_ADVANCE_REGISTER, register_index);
132 Emit32(by);
133}
static constexpr intptr_t kMaxRegister

◆ Backtrack()

void dart::BytecodeRegExpMacroAssembler::Backtrack ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 143 of file regexp_assembler_bytecode.cc.

143 {
144 Emit(BC_POP_BT, 0);
145}

◆ BindBlock()

void dart::BytecodeRegExpMacroAssembler::BindBlock ( BlockLabel label)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 36 of file regexp_assembler_bytecode.cc.

36 {
37 advance_current_end_ = kInvalidPC;
38 ASSERT(!l->is_bound());
39 if (l->is_linked()) {
40 intptr_t pos = l->pos();
41 while (pos != 0) {
42 intptr_t fixup = pos;
43 pos = *reinterpret_cast<int32_t*>(buffer_->data() + fixup);
44 *reinterpret_cast<uint32_t*>(buffer_->data() + fixup) = pc_;
45 }
46 }
47 l->BindTo(pc_);
48}
SkPoint pos

◆ CanReadUnaligned()

virtual bool dart::BytecodeRegExpMacroAssembler::CanReadUnaligned ( )
inlinevirtual

Implements dart::RegExpMacroAssembler.

Definition at line 33 of file regexp_assembler_bytecode.h.

33{ return false; }

◆ CheckAtStart()

void dart::BytecodeRegExpMacroAssembler::CheckAtStart ( BlockLabel on_at_start)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 243 of file regexp_assembler_bytecode.cc.

243 {
244 Emit(BC_CHECK_AT_START, 0);
245 EmitOrLink(on_at_start);
246}

◆ CheckBitInTable()

void dart::BytecodeRegExpMacroAssembler::CheckBitInTable ( const TypedData table,
BlockLabel on_bit_set 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 325 of file regexp_assembler_bytecode.cc.

326 {
327 Emit(BC_CHECK_BIT_IN_TABLE, 0);
328 EmitOrLink(on_bit_set);
329 for (int i = 0; i < kTableSize; i += kBitsPerByte) {
330 int byte = 0;
331 for (int j = 0; j < kBitsPerByte; j++) {
332 if (table.GetUint8(i + j) != 0) byte |= 1 << j;
333 }
334 Emit8(byte);
335 }
336}
SI F table(const skcms_Curve *curve, F v)
static constexpr intptr_t kTableSize
constexpr intptr_t kBitsPerByte
Definition: globals.h:463

◆ CheckCharacter()

void dart::BytecodeRegExpMacroAssembler::CheckCharacter ( unsigned  c,
BlockLabel on_equal 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 232 of file regexp_assembler_bytecode.cc.

233 {
234 if (c > MAX_FIRST_ARG) {
235 Emit(BC_CHECK_4_CHARS, 0);
236 Emit32(c);
237 } else {
238 Emit(BC_CHECK_CHAR, c);
239 }
240 EmitOrLink(on_equal);
241}
const unsigned int MAX_FIRST_ARG

◆ CheckCharacterAfterAnd()

void dart::BytecodeRegExpMacroAssembler::CheckCharacterAfterAnd ( unsigned  c,
unsigned  mask,
BlockLabel on_equal 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 266 of file regexp_assembler_bytecode.cc.

269 {
270 if (c > MAX_FIRST_ARG) {
271 Emit(BC_AND_CHECK_4_CHARS, 0);
272 Emit32(c);
273 } else {
274 Emit(BC_AND_CHECK_CHAR, c);
275 }
276 Emit32(mask);
277 EmitOrLink(on_equal);
278}

◆ CheckCharacterGT()

void dart::BytecodeRegExpMacroAssembler::CheckCharacterGT ( uint16_t  limit,
BlockLabel on_greater 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 226 of file regexp_assembler_bytecode.cc.

227 {
228 Emit(BC_CHECK_GT, limit);
229 EmitOrLink(on_greater);
230}

◆ CheckCharacterInRange()

void dart::BytecodeRegExpMacroAssembler::CheckCharacterInRange ( uint16_t  from,
uint16_t  to,
BlockLabel on_in_range 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 305 of file regexp_assembler_bytecode.cc.

308 {
309 Emit(BC_CHECK_CHAR_IN_RANGE, 0);
310 Emit16(from);
311 Emit16(to);
312 EmitOrLink(on_in_range);
313}

◆ CheckCharacterLT()

void dart::BytecodeRegExpMacroAssembler::CheckCharacterLT ( uint16_t  limit,
BlockLabel on_less 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 220 of file regexp_assembler_bytecode.cc.

221 {
222 Emit(BC_CHECK_LT, limit);
223 EmitOrLink(on_less);
224}

◆ CheckCharacterNotInRange()

void dart::BytecodeRegExpMacroAssembler::CheckCharacterNotInRange ( uint16_t  from,
uint16_t  to,
BlockLabel on_not_in_range 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 315 of file regexp_assembler_bytecode.cc.

318 {
319 Emit(BC_CHECK_CHAR_NOT_IN_RANGE, 0);
320 Emit16(from);
321 Emit16(to);
322 EmitOrLink(on_not_in_range);
323}

◆ CheckGreedyLoop()

void dart::BytecodeRegExpMacroAssembler::CheckGreedyLoop ( BlockLabel on_tos_equals_current_position)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 184 of file regexp_assembler_bytecode.cc.

185 {
186 Emit(BC_CHECK_GREEDY, 0);
187 EmitOrLink(on_tos_equals_current_position);
188}

◆ CheckNotAtStart()

void dart::BytecodeRegExpMacroAssembler::CheckNotAtStart ( intptr_t  cp_offset,
BlockLabel on_not_at_start 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 248 of file regexp_assembler_bytecode.cc.

250 {
251 Emit(BC_CHECK_NOT_AT_START, cp_offset);
252 EmitOrLink(on_not_at_start);
253}

◆ CheckNotBackReference()

void dart::BytecodeRegExpMacroAssembler::CheckNotBackReference ( intptr_t  start_reg,
bool  read_backward,
BlockLabel on_no_match 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 338 of file regexp_assembler_bytecode.cc.

341 {
342 ASSERT(start_reg >= 0);
343 ASSERT(start_reg <= kMaxRegister);
344 Emit(read_backward ? BC_CHECK_NOT_BACK_REF_BACKWARD : BC_CHECK_NOT_BACK_REF,
345 start_reg);
346 EmitOrLink(on_not_equal);
347}

◆ CheckNotBackReferenceIgnoreCase()

void dart::BytecodeRegExpMacroAssembler::CheckNotBackReferenceIgnoreCase ( intptr_t  start_reg,
bool  read_backward,
bool  unicode,
BlockLabel on_no_match 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 349 of file regexp_assembler_bytecode.cc.

353 {
354 ASSERT(start_reg >= 0);
355 ASSERT(start_reg <= kMaxRegister);
356 Emit(read_backward ? (unicode ? BC_CHECK_NOT_BACK_REF_NO_CASE_UNICODE_BACKWARD
357 : BC_CHECK_NOT_BACK_REF_NO_CASE_BACKWARD)
358 : (unicode ? BC_CHECK_NOT_BACK_REF_NO_CASE_UNICODE
359 : BC_CHECK_NOT_BACK_REF_NO_CASE),
360 start_reg);
361 EmitOrLink(on_not_equal);
362}

◆ CheckNotCharacter()

void dart::BytecodeRegExpMacroAssembler::CheckNotCharacter ( unsigned  c,
BlockLabel on_not_equal 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 255 of file regexp_assembler_bytecode.cc.

256 {
257 if (c > MAX_FIRST_ARG) {
258 Emit(BC_CHECK_NOT_4_CHARS, 0);
259 Emit32(c);
260 } else {
261 Emit(BC_CHECK_NOT_CHAR, c);
262 }
263 EmitOrLink(on_not_equal);
264}

◆ CheckNotCharacterAfterAnd()

void dart::BytecodeRegExpMacroAssembler::CheckNotCharacterAfterAnd ( unsigned  c,
unsigned  mask,
BlockLabel on_not_equal 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 280 of file regexp_assembler_bytecode.cc.

283 {
284 if (c > MAX_FIRST_ARG) {
285 Emit(BC_AND_CHECK_NOT_4_CHARS, 0);
286 Emit32(c);
287 } else {
288 Emit(BC_AND_CHECK_NOT_CHAR, c);
289 }
290 Emit32(mask);
291 EmitOrLink(on_not_equal);
292}

◆ CheckNotCharacterAfterMinusAnd()

void dart::BytecodeRegExpMacroAssembler::CheckNotCharacterAfterMinusAnd ( uint16_t  c,
uint16_t  minus,
uint16_t  mask,
BlockLabel on_not_equal 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 294 of file regexp_assembler_bytecode.cc.

298 {
299 Emit(BC_MINUS_AND_CHECK_NOT_CHAR, c);
300 Emit16(minus);
301 Emit16(mask);
302 EmitOrLink(on_not_equal);
303}

◆ ClearRegisters()

void dart::BytecodeRegExpMacroAssembler::ClearRegisters ( intptr_t  reg_from,
intptr_t  reg_to 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 85 of file regexp_assembler_bytecode.cc.

86 {
87 ASSERT(reg_from <= reg_to);
88 for (int reg = reg_from; reg <= reg_to; reg++) {
89 SetRegister(reg, -1);
90 }
91}
virtual void SetRegister(intptr_t register_index, intptr_t to)

◆ Fail()

void dart::BytecodeRegExpMacroAssembler::Fail ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 171 of file regexp_assembler_bytecode.cc.

171 {
172 Emit(BC_FAIL, 0);
173}

◆ GetBytecode()

TypedDataPtr dart::BytecodeRegExpMacroAssembler::GetBytecode ( )

Definition at line 393 of file regexp_assembler_bytecode.cc.

393 {
394 BindBlock(&backtrack_);
395 Emit(BC_POP_BT, 0);
396
397 intptr_t len = length();
398 const TypedData& bytecode =
399 TypedData::Handle(TypedData::New(kTypedDataUint8ArrayCid, len));
400
401 NoSafepointScope no_safepoint;
402 memmove(bytecode.DataAddr(0), buffer_->data(), len);
403
404 return bytecode.ptr();
405}
virtual void BindBlock(BlockLabel *label)
static Object & Handle()
Definition: object.h:407
static TypedDataPtr New(intptr_t class_id, intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.cc:25587

◆ GoTo()

void dart::BytecodeRegExpMacroAssembler::GoTo ( BlockLabel label)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 147 of file regexp_assembler_bytecode.cc.

147 {
148 if (advance_current_end_ == pc_) {
149 // Combine advance current and goto.
150 pc_ = advance_current_start_;
151 Emit(BC_ADVANCE_CP_AND_GOTO, advance_current_offset_);
152 EmitOrLink(l);
153 advance_current_end_ = kInvalidPC;
154 } else {
155 // Regular goto.
156 Emit(BC_GOTO, 0);
157 EmitOrLink(l);
158 }
159}

◆ IfRegisterEqPos()

void dart::BytecodeRegExpMacroAssembler::IfRegisterEqPos ( intptr_t  register_index,
BlockLabel if_eq 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 385 of file regexp_assembler_bytecode.cc.

386 {
387 ASSERT(register_index >= 0);
388 ASSERT(register_index <= kMaxRegister);
389 Emit(BC_CHECK_REGISTER_EQ_POS, register_index);
390 EmitOrLink(on_eq);
391}

◆ IfRegisterGE()

void dart::BytecodeRegExpMacroAssembler::IfRegisterGE ( intptr_t  register_index,
intptr_t  comparand,
BlockLabel if_ge 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 374 of file regexp_assembler_bytecode.cc.

377 {
378 ASSERT(register_index >= 0);
379 ASSERT(register_index <= kMaxRegister);
380 Emit(BC_CHECK_REGISTER_GE, register_index);
381 Emit32(comparand);
382 EmitOrLink(on_greater_or_equal);
383}

◆ IfRegisterLT()

void dart::BytecodeRegExpMacroAssembler::IfRegisterLT ( intptr_t  register_index,
intptr_t  comparand,
BlockLabel if_lt 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 364 of file regexp_assembler_bytecode.cc.

366 {
367 ASSERT(register_index >= 0);
368 ASSERT(register_index <= kMaxRegister);
369 Emit(BC_CHECK_REGISTER_LT, register_index);
370 Emit32(comparand);
371 EmitOrLink(on_less_than);
372}

◆ Implementation()

BytecodeRegExpMacroAssembler::IrregexpImplementation dart::BytecodeRegExpMacroAssembler::Implementation ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 32 of file regexp_assembler_bytecode.cc.

◆ Interpret()

ObjectPtr dart::BytecodeRegExpMacroAssembler::Interpret ( const RegExp regexp,
const String str,
const Smi start_index,
bool  is_sticky,
Zone zone 
)
static

Definition at line 509 of file regexp_assembler_bytecode.cc.

513 {
514 intptr_t required_registers = Prepare(regexp, subject, sticky, zone);
515 if (required_registers < 0) {
516 // Compiling failed with an exception.
517 UNREACHABLE();
518 }
519
520 // V8 uses a shared copy on the isolate when smaller than some threshold.
521 int32_t* output_registers = zone->Alloc<int32_t>(required_registers);
522
523 const Object& result =
524 Object::Handle(zone, ExecRaw(regexp, subject, start_index.Value(), sticky,
525 output_registers, required_registers, zone));
526 if (result.ptr() == Bool::True().ptr()) {
527 intptr_t capture_count = regexp.num_bracket_expressions();
528 intptr_t capture_register_count = (capture_count + 1) * 2;
529 ASSERT(required_registers >= capture_register_count);
530
531 const TypedData& result = TypedData::Handle(
532 TypedData::New(kTypedDataInt32ArrayCid, capture_register_count));
533 {
534#ifdef DEBUG
535 // These indices will be used with substring operations that don't check
536 // bounds, so sanity check them here.
537 for (intptr_t i = 0; i < capture_register_count; i++) {
538 int32_t val = output_registers[i];
539 ASSERT(val == -1 || (val >= 0 && val <= subject.Length()));
540 }
541#endif
542
543 NoSafepointScope no_safepoint;
544 memmove(result.DataAddr(0), output_registers,
545 capture_register_count * sizeof(int32_t));
546 }
547
548 return result.ptr();
549 }
550 if (result.ptr() == Object::null()) {
551 // internal exception
552 UNREACHABLE();
553 }
554 if (result.IsError()) {
556 UNREACHABLE();
557 }
558 ASSERT(result.ptr() == Bool::False().ptr());
559 return Instance::null();
560}
#define UNREACHABLE()
Definition: assert.h:248
static const Bool & False()
Definition: object.h:10799
static const Bool & True()
Definition: object.h:10797
static DART_NORETURN void PropagateError(const Error &error)
Definition: exceptions.cc:1003
static ObjectPtr null()
Definition: object.h:433
ObjectPtr ptr() const
Definition: object.h:332
ElementType * Alloc(intptr_t length)
GAsyncResult * result
static ObjectPtr ExecRaw(const RegExp &regexp, const String &subject, int32_t index, bool sticky, int32_t *output, intptr_t output_size, Zone *zone)
static intptr_t Prepare(const RegExp &regexp, const String &subject, bool sticky, Zone *zone)

◆ IsClosed()

virtual bool dart::BytecodeRegExpMacroAssembler::IsClosed ( ) const
inlinevirtual

Implements dart::RegExpMacroAssembler.

Definition at line 101 of file regexp_assembler_bytecode.h.

101 {
102 // Added by Dart for the IR version. Bytecode version should never need an
103 // extra goto.
104 return true;
105 }

◆ LoadCurrentCharacter()

void dart::BytecodeRegExpMacroAssembler::LoadCurrentCharacter ( intptr_t  cp_offset,
BlockLabel on_end_of_input,
bool  check_bounds = true,
intptr_t  characters = 1 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 190 of file regexp_assembler_bytecode.cc.

193 {
194 ASSERT(cp_offset >= kMinCPOffset);
195 ASSERT(cp_offset <= kMaxCPOffset);
196 int bytecode;
197 if (check_bounds) {
198 if (characters == 4) {
199 bytecode = BC_LOAD_4_CURRENT_CHARS;
200 } else if (characters == 2) {
201 bytecode = BC_LOAD_2_CURRENT_CHARS;
202 } else {
203 ASSERT(characters == 1);
204 bytecode = BC_LOAD_CURRENT_CHAR;
205 }
206 } else {
207 if (characters == 4) {
208 bytecode = BC_LOAD_4_CURRENT_CHARS_UNCHECKED;
209 } else if (characters == 2) {
210 bytecode = BC_LOAD_2_CURRENT_CHARS_UNCHECKED;
211 } else {
212 ASSERT(characters == 1);
213 bytecode = BC_LOAD_CURRENT_CHAR_UNCHECKED;
214 }
215 }
216 Emit(bytecode, cp_offset);
217 if (check_bounds) EmitOrLink(on_failure);
218}
void check_bounds(skiatest::Reporter *reporter, const SkPath &path)
Definition: ShadowTest.cpp:183

◆ PopCurrentPosition()

void dart::BytecodeRegExpMacroAssembler::PopCurrentPosition ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 135 of file regexp_assembler_bytecode.cc.

135 {
136 Emit(BC_POP_CP, 0);
137}

◆ PopRegister()

void dart::BytecodeRegExpMacroAssembler::PopRegister ( intptr_t  register_index)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 64 of file regexp_assembler_bytecode.cc.

64 {
65 ASSERT(register_index >= 0);
66 ASSERT(register_index <= kMaxRegister);
67 Emit(BC_POP_REGISTER, register_index);
68}

◆ Print()

virtual void dart::BytecodeRegExpMacroAssembler::Print ( const char *  str)
inlinevirtual

Implements dart::RegExpMacroAssembler.

Definition at line 106 of file regexp_assembler_bytecode.h.

106{ UNIMPLEMENTED(); }
#define UNIMPLEMENTED

◆ PrintBlocks()

virtual void dart::BytecodeRegExpMacroAssembler::PrintBlocks ( )
inlinevirtual

Implements dart::RegExpMacroAssembler.

Definition at line 107 of file regexp_assembler_bytecode.h.

107{ UNIMPLEMENTED(); }

◆ PushBacktrack()

void dart::BytecodeRegExpMacroAssembler::PushBacktrack ( BlockLabel label)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 161 of file regexp_assembler_bytecode.cc.

161 {
162 Emit(BC_PUSH_BT, 0);
163 EmitOrLink(l);
164}

◆ PushCurrentPosition()

void dart::BytecodeRegExpMacroAssembler::PushCurrentPosition ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 139 of file regexp_assembler_bytecode.cc.

139 {
140 Emit(BC_PUSH_CP, 0);
141}

◆ PushRegister()

void dart::BytecodeRegExpMacroAssembler::PushRegister ( intptr_t  register_index)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 70 of file regexp_assembler_bytecode.cc.

70 {
71 ASSERT(register_index >= 0);
72 ASSERT(register_index <= kMaxRegister);
73 Emit(BC_PUSH_REGISTER, register_index);
74}

◆ ReadCurrentPositionFromRegister()

void dart::BytecodeRegExpMacroAssembler::ReadCurrentPositionFromRegister ( intptr_t  reg)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 93 of file regexp_assembler_bytecode.cc.

94 {
95 ASSERT(register_index >= 0);
96 ASSERT(register_index <= kMaxRegister);
97 Emit(BC_SET_CP_TO_REGISTER, register_index);
98}

◆ ReadStackPointerFromRegister()

void dart::BytecodeRegExpMacroAssembler::ReadStackPointerFromRegister ( intptr_t  reg)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 107 of file regexp_assembler_bytecode.cc.

108 {
109 ASSERT(register_index >= 0);
110 ASSERT(register_index <= kMaxRegister);
111 Emit(BC_SET_SP_TO_REGISTER, register_index);
112}

◆ SetCurrentPositionFromEnd()

void dart::BytecodeRegExpMacroAssembler::SetCurrentPositionFromEnd ( intptr_t  by)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 114 of file regexp_assembler_bytecode.cc.

114 {
115 ASSERT(Utils::IsUint(24, by));
116 Emit(BC_SET_CURRENT_POSITION_FROM_END, by);
117}
static bool IsUint(intptr_t N, T value)
Definition: utils.h:328

◆ SetRegister()

void dart::BytecodeRegExpMacroAssembler::SetRegister ( intptr_t  register_index,
intptr_t  to 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 119 of file regexp_assembler_bytecode.cc.

120 {
121 ASSERT(register_index >= 0);
122 ASSERT(register_index <= kMaxRegister);
123 Emit(BC_SET_REGISTER, register_index);
124 Emit32(to);
125}

◆ stack_limit_slack()

virtual intptr_t dart::BytecodeRegExpMacroAssembler::stack_limit_slack ( )
inlinevirtual

Implements dart::RegExpMacroAssembler.

Definition at line 32 of file regexp_assembler_bytecode.h.

32{ return 1; }

◆ Succeed()

bool dart::BytecodeRegExpMacroAssembler::Succeed ( )
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 166 of file regexp_assembler_bytecode.cc.

166 {
167 Emit(BC_SUCCEED, 0);
168 return false; // Restart matching for global regexp not supported.
169}

◆ WriteCurrentPositionToRegister()

void dart::BytecodeRegExpMacroAssembler::WriteCurrentPositionToRegister ( intptr_t  reg,
intptr_t  cp_offset 
)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 76 of file regexp_assembler_bytecode.cc.

78 {
79 ASSERT(register_index >= 0);
80 ASSERT(register_index <= kMaxRegister);
81 Emit(BC_SET_REGISTER_TO_CP, register_index);
82 Emit32(cp_offset); // Current position offset.
83}

◆ WriteStackPointerToRegister()

void dart::BytecodeRegExpMacroAssembler::WriteStackPointerToRegister ( intptr_t  reg)
virtual

Implements dart::RegExpMacroAssembler.

Definition at line 100 of file regexp_assembler_bytecode.cc.

101 {
102 ASSERT(register_index >= 0);
103 ASSERT(register_index <= kMaxRegister);
104 Emit(BC_SET_REGISTER_TO_SP, register_index);
105}

The documentation for this class was generated from the following files: