39 #ifdef V8_INTERPRETED_REGEXP
41 RegExpMacroAssemblerIrregexp::RegExpMacroAssemblerIrregexp(Vector<byte> buffer,
43 : RegExpMacroAssembler(zone),
47 advance_current_end_(kInvalidPC),
48 isolate_(zone->isolate()) { }
51 RegExpMacroAssemblerIrregexp::~RegExpMacroAssemblerIrregexp() {
52 if (backtrack_.is_linked()) backtrack_.Unuse();
53 if (own_buffer_) buffer_.Dispose();
57 RegExpMacroAssemblerIrregexp::IrregexpImplementation
58 RegExpMacroAssemblerIrregexp::Implementation() {
59 return kBytecodeImplementation;
63 void RegExpMacroAssemblerIrregexp::Bind(Label* l) {
64 advance_current_end_ = kInvalidPC;
70 pos = *
reinterpret_cast<int32_t*
>(buffer_.start() + fixup);
71 *
reinterpret_cast<uint32_t*
>(buffer_.start() + fixup) = pc_;
78 void RegExpMacroAssemblerIrregexp::EmitOrLink(Label* l) {
79 if (l ==
NULL) l = &backtrack_;
93 void RegExpMacroAssemblerIrregexp::PopRegister(
int register_index) {
94 ASSERT(register_index >= 0);
95 ASSERT(register_index <= kMaxRegister);
96 Emit(BC_POP_REGISTER, register_index);
100 void RegExpMacroAssemblerIrregexp::PushRegister(
102 StackCheckFlag check_stack_limit) {
103 ASSERT(register_index >= 0);
104 ASSERT(register_index <= kMaxRegister);
105 Emit(BC_PUSH_REGISTER, register_index);
109 void RegExpMacroAssemblerIrregexp::WriteCurrentPositionToRegister(
110 int register_index,
int cp_offset) {
111 ASSERT(register_index >= 0);
112 ASSERT(register_index <= kMaxRegister);
113 Emit(BC_SET_REGISTER_TO_CP, register_index);
118 void RegExpMacroAssemblerIrregexp::ClearRegisters(
int reg_from,
int reg_to) {
119 ASSERT(reg_from <= reg_to);
120 for (
int reg = reg_from; reg <= reg_to; reg++) {
121 SetRegister(reg, -1);
126 void RegExpMacroAssemblerIrregexp::ReadCurrentPositionFromRegister(
127 int register_index) {
128 ASSERT(register_index >= 0);
129 ASSERT(register_index <= kMaxRegister);
130 Emit(BC_SET_CP_TO_REGISTER, register_index);
134 void RegExpMacroAssemblerIrregexp::WriteStackPointerToRegister(
135 int register_index) {
136 ASSERT(register_index >= 0);
137 ASSERT(register_index <= kMaxRegister);
138 Emit(BC_SET_REGISTER_TO_SP, register_index);
142 void RegExpMacroAssemblerIrregexp::ReadStackPointerFromRegister(
143 int register_index) {
144 ASSERT(register_index >= 0);
145 ASSERT(register_index <= kMaxRegister);
146 Emit(BC_SET_SP_TO_REGISTER, register_index);
150 void RegExpMacroAssemblerIrregexp::SetCurrentPositionFromEnd(
int by) {
152 Emit(BC_SET_CURRENT_POSITION_FROM_END, by);
156 void RegExpMacroAssemblerIrregexp::SetRegister(
int register_index,
int to) {
157 ASSERT(register_index >= 0);
158 ASSERT(register_index <= kMaxRegister);
159 Emit(BC_SET_REGISTER, register_index);
164 void RegExpMacroAssemblerIrregexp::AdvanceRegister(
int register_index,
int by) {
165 ASSERT(register_index >= 0);
166 ASSERT(register_index <= kMaxRegister);
167 Emit(BC_ADVANCE_REGISTER, register_index);
172 void RegExpMacroAssemblerIrregexp::PopCurrentPosition() {
177 void RegExpMacroAssemblerIrregexp::PushCurrentPosition() {
182 void RegExpMacroAssemblerIrregexp::Backtrack() {
187 void RegExpMacroAssemblerIrregexp::GoTo(Label* l) {
188 if (advance_current_end_ == pc_) {
190 pc_ = advance_current_start_;
191 Emit(BC_ADVANCE_CP_AND_GOTO, advance_current_offset_);
193 advance_current_end_ = kInvalidPC;
202 void RegExpMacroAssemblerIrregexp::PushBacktrack(Label* l) {
208 bool RegExpMacroAssemblerIrregexp::Succeed() {
219 void RegExpMacroAssemblerIrregexp::AdvanceCurrentPosition(
int by) {
220 ASSERT(by >= kMinCPOffset);
221 ASSERT(by <= kMaxCPOffset);
222 advance_current_start_ = pc_;
223 advance_current_offset_ = by;
224 Emit(BC_ADVANCE_CP, by);
225 advance_current_end_ = pc_;
229 void RegExpMacroAssemblerIrregexp::CheckGreedyLoop(
230 Label* on_tos_equals_current_position) {
231 Emit(BC_CHECK_GREEDY, 0);
232 EmitOrLink(on_tos_equals_current_position);
236 void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(
int cp_offset,
240 ASSERT(cp_offset >= kMinCPOffset);
241 ASSERT(cp_offset <= kMaxCPOffset);
244 if (characters == 4) {
245 bytecode = BC_LOAD_4_CURRENT_CHARS;
246 }
else if (characters == 2) {
247 bytecode = BC_LOAD_2_CURRENT_CHARS;
250 bytecode = BC_LOAD_CURRENT_CHAR;
253 if (characters == 4) {
254 bytecode = BC_LOAD_4_CURRENT_CHARS_UNCHECKED;
255 }
else if (characters == 2) {
256 bytecode = BC_LOAD_2_CURRENT_CHARS_UNCHECKED;
259 bytecode = BC_LOAD_CURRENT_CHAR_UNCHECKED;
262 Emit(bytecode, cp_offset);
263 if (check_bounds) EmitOrLink(on_failure);
267 void RegExpMacroAssemblerIrregexp::CheckCharacterLT(
uc16 limit,
269 Emit(BC_CHECK_LT, limit);
274 void RegExpMacroAssemblerIrregexp::CheckCharacterGT(
uc16 limit,
276 Emit(BC_CHECK_GT, limit);
277 EmitOrLink(on_greater);
281 void RegExpMacroAssemblerIrregexp::CheckCharacter(uint32_t c, Label* on_equal) {
283 Emit(BC_CHECK_4_CHARS, 0);
286 Emit(BC_CHECK_CHAR, c);
288 EmitOrLink(on_equal);
292 void RegExpMacroAssemblerIrregexp::CheckAtStart(Label* on_at_start) {
293 Emit(BC_CHECK_AT_START, 0);
294 EmitOrLink(on_at_start);
298 void RegExpMacroAssemblerIrregexp::CheckNotAtStart(Label* on_not_at_start) {
299 Emit(BC_CHECK_NOT_AT_START, 0);
300 EmitOrLink(on_not_at_start);
304 void RegExpMacroAssemblerIrregexp::CheckNotCharacter(uint32_t c,
305 Label* on_not_equal) {
307 Emit(BC_CHECK_NOT_4_CHARS, 0);
310 Emit(BC_CHECK_NOT_CHAR, c);
312 EmitOrLink(on_not_equal);
316 void RegExpMacroAssemblerIrregexp::CheckCharacterAfterAnd(
321 Emit(BC_AND_CHECK_4_CHARS, 0);
324 Emit(BC_AND_CHECK_CHAR, c);
327 EmitOrLink(on_equal);
331 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterAnd(
334 Label* on_not_equal) {
336 Emit(BC_AND_CHECK_NOT_4_CHARS, 0);
339 Emit(BC_AND_CHECK_NOT_CHAR, c);
342 EmitOrLink(on_not_equal);
346 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterMinusAnd(
350 Label* on_not_equal) {
351 Emit(BC_MINUS_AND_CHECK_NOT_CHAR, c);
354 EmitOrLink(on_not_equal);
358 void RegExpMacroAssemblerIrregexp::CheckCharacterInRange(
361 Label* on_in_range) {
362 Emit(BC_CHECK_CHAR_IN_RANGE, 0);
365 EmitOrLink(on_in_range);
369 void RegExpMacroAssemblerIrregexp::CheckCharacterNotInRange(
372 Label* on_not_in_range) {
373 Emit(BC_CHECK_CHAR_NOT_IN_RANGE, 0);
376 EmitOrLink(on_not_in_range);
380 void RegExpMacroAssemblerIrregexp::CheckBitInTable(
381 Handle<ByteArray> table, Label* on_bit_set) {
382 Emit(BC_CHECK_BIT_IN_TABLE, 0);
383 EmitOrLink(on_bit_set);
387 if (table->get(i + j) != 0) byte |= 1 << j;
394 void RegExpMacroAssemblerIrregexp::CheckNotBackReference(
int start_reg,
395 Label* on_not_equal) {
397 ASSERT(start_reg <= kMaxRegister);
398 Emit(BC_CHECK_NOT_BACK_REF, start_reg);
399 EmitOrLink(on_not_equal);
403 void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase(
405 Label* on_not_equal) {
407 ASSERT(start_reg <= kMaxRegister);
408 Emit(BC_CHECK_NOT_BACK_REF_NO_CASE, start_reg);
409 EmitOrLink(on_not_equal);
413 void RegExpMacroAssemblerIrregexp::IfRegisterLT(
int register_index,
415 Label* on_less_than) {
416 ASSERT(register_index >= 0);
417 ASSERT(register_index <= kMaxRegister);
418 Emit(BC_CHECK_REGISTER_LT, register_index);
420 EmitOrLink(on_less_than);
424 void RegExpMacroAssemblerIrregexp::IfRegisterGE(
int register_index,
426 Label* on_greater_or_equal) {
427 ASSERT(register_index >= 0);
428 ASSERT(register_index <= kMaxRegister);
429 Emit(BC_CHECK_REGISTER_GE, register_index);
431 EmitOrLink(on_greater_or_equal);
435 void RegExpMacroAssemblerIrregexp::IfRegisterEqPos(
int register_index,
437 ASSERT(register_index >= 0);
438 ASSERT(register_index <= kMaxRegister);
439 Emit(BC_CHECK_REGISTER_EQ_POS, register_index);
444 Handle<HeapObject> RegExpMacroAssemblerIrregexp::GetCode(
445 Handle<String> source) {
448 Handle<ByteArray> array = isolate_->factory()->NewByteArray(length());
449 Copy(array->GetDataStartAddress());
454 int RegExpMacroAssemblerIrregexp::length() {
459 void RegExpMacroAssemblerIrregexp::Copy(
Address a) {
464 void RegExpMacroAssemblerIrregexp::Expand() {
465 bool old_buffer_was_our_own = own_buffer_;
466 Vector<byte> old_buffer = buffer_;
469 OS::MemCopy(buffer_.start(), old_buffer.start(), old_buffer.length());
470 if (old_buffer_was_our_own) {
471 old_buffer.Dispose();
475 #endif // V8_INTERPRETED_REGEXP
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
void Fail(const v8::FunctionCallbackInfo< v8::Value > &args)
#define ASSERT(condition)
static void MemCopy(void *dest, const void *src, size_t size)
static Vector< T > New(int length)
const unsigned int MAX_FIRST_ARG