39 #ifdef V8_INTERPRETED_REGEXP
41 RegExpMacroAssemblerIrregexp::RegExpMacroAssemblerIrregexp(Vector<byte> buffer)
45 advance_current_end_(kInvalidPC) {
49 RegExpMacroAssemblerIrregexp::~RegExpMacroAssemblerIrregexp() {
50 if (backtrack_.is_linked()) backtrack_.Unuse();
51 if (own_buffer_)
buffer_.Dispose();
55 RegExpMacroAssemblerIrregexp::IrregexpImplementation
56 RegExpMacroAssemblerIrregexp::Implementation() {
57 return kBytecodeImplementation;
61 void RegExpMacroAssemblerIrregexp::Bind(Label* l) {
62 advance_current_end_ = kInvalidPC;
69 *
reinterpret_cast<uint32_t*
>(
buffer_.start() + fixup) = pc_;
76 void RegExpMacroAssemblerIrregexp::EmitOrLink(Label* l) {
77 if (l ==
NULL) l = &backtrack_;
91 void RegExpMacroAssemblerIrregexp::PopRegister(
int register_index) {
92 ASSERT(register_index >= 0);
93 ASSERT(register_index <= kMaxRegister);
94 Emit(BC_POP_REGISTER, register_index);
98 void RegExpMacroAssemblerIrregexp::PushRegister(
100 StackCheckFlag check_stack_limit) {
101 ASSERT(register_index >= 0);
102 ASSERT(register_index <= kMaxRegister);
103 Emit(BC_PUSH_REGISTER, register_index);
107 void RegExpMacroAssemblerIrregexp::WriteCurrentPositionToRegister(
108 int register_index,
int cp_offset) {
109 ASSERT(register_index >= 0);
110 ASSERT(register_index <= kMaxRegister);
111 Emit(BC_SET_REGISTER_TO_CP, register_index);
116 void RegExpMacroAssemblerIrregexp::ClearRegisters(
int reg_from,
int reg_to) {
117 ASSERT(reg_from <= reg_to);
118 for (
int reg = reg_from; reg <= reg_to; reg++) {
119 SetRegister(reg, -1);
124 void RegExpMacroAssemblerIrregexp::ReadCurrentPositionFromRegister(
125 int register_index) {
126 ASSERT(register_index >= 0);
127 ASSERT(register_index <= kMaxRegister);
128 Emit(BC_SET_CP_TO_REGISTER, register_index);
132 void RegExpMacroAssemblerIrregexp::WriteStackPointerToRegister(
133 int register_index) {
134 ASSERT(register_index >= 0);
135 ASSERT(register_index <= kMaxRegister);
136 Emit(BC_SET_REGISTER_TO_SP, register_index);
140 void RegExpMacroAssemblerIrregexp::ReadStackPointerFromRegister(
141 int register_index) {
142 ASSERT(register_index >= 0);
143 ASSERT(register_index <= kMaxRegister);
144 Emit(BC_SET_SP_TO_REGISTER, register_index);
148 void RegExpMacroAssemblerIrregexp::SetCurrentPositionFromEnd(
int by) {
150 Emit(BC_SET_CURRENT_POSITION_FROM_END, by);
154 void RegExpMacroAssemblerIrregexp::SetRegister(
int register_index,
int to) {
155 ASSERT(register_index >= 0);
156 ASSERT(register_index <= kMaxRegister);
157 Emit(BC_SET_REGISTER, register_index);
162 void RegExpMacroAssemblerIrregexp::AdvanceRegister(
int register_index,
int by) {
163 ASSERT(register_index >= 0);
164 ASSERT(register_index <= kMaxRegister);
165 Emit(BC_ADVANCE_REGISTER, register_index);
170 void RegExpMacroAssemblerIrregexp::PopCurrentPosition() {
175 void RegExpMacroAssemblerIrregexp::PushCurrentPosition() {
180 void RegExpMacroAssemblerIrregexp::Backtrack() {
185 void RegExpMacroAssemblerIrregexp::GoTo(Label* l) {
186 if (advance_current_end_ == pc_) {
188 pc_ = advance_current_start_;
189 Emit(BC_ADVANCE_CP_AND_GOTO, advance_current_offset_);
191 advance_current_end_ = kInvalidPC;
200 void RegExpMacroAssemblerIrregexp::PushBacktrack(Label* l) {
206 bool RegExpMacroAssemblerIrregexp::Succeed() {
217 void RegExpMacroAssemblerIrregexp::AdvanceCurrentPosition(
int by) {
218 ASSERT(by >= kMinCPOffset);
219 ASSERT(by <= kMaxCPOffset);
220 advance_current_start_ = pc_;
221 advance_current_offset_ = by;
222 Emit(BC_ADVANCE_CP, by);
223 advance_current_end_ = pc_;
227 void RegExpMacroAssemblerIrregexp::CheckGreedyLoop(
228 Label* on_tos_equals_current_position) {
229 Emit(BC_CHECK_GREEDY, 0);
230 EmitOrLink(on_tos_equals_current_position);
234 void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(
int cp_offset,
238 ASSERT(cp_offset >= kMinCPOffset);
239 ASSERT(cp_offset <= kMaxCPOffset);
242 if (characters == 4) {
243 bytecode = BC_LOAD_4_CURRENT_CHARS;
244 }
else if (characters == 2) {
245 bytecode = BC_LOAD_2_CURRENT_CHARS;
248 bytecode = BC_LOAD_CURRENT_CHAR;
251 if (characters == 4) {
252 bytecode = BC_LOAD_4_CURRENT_CHARS_UNCHECKED;
253 }
else if (characters == 2) {
254 bytecode = BC_LOAD_2_CURRENT_CHARS_UNCHECKED;
257 bytecode = BC_LOAD_CURRENT_CHAR_UNCHECKED;
260 Emit(bytecode, cp_offset);
261 if (check_bounds) EmitOrLink(on_failure);
265 void RegExpMacroAssemblerIrregexp::CheckCharacterLT(
uc16 limit,
267 Emit(BC_CHECK_LT, limit);
272 void RegExpMacroAssemblerIrregexp::CheckCharacterGT(
uc16 limit,
274 Emit(BC_CHECK_GT, limit);
275 EmitOrLink(on_greater);
279 void RegExpMacroAssemblerIrregexp::CheckCharacter(uint32_t c, Label* on_equal) {
281 Emit(BC_CHECK_4_CHARS, 0);
284 Emit(BC_CHECK_CHAR, c);
286 EmitOrLink(on_equal);
290 void RegExpMacroAssemblerIrregexp::CheckAtStart(Label* on_at_start) {
291 Emit(BC_CHECK_AT_START, 0);
292 EmitOrLink(on_at_start);
296 void RegExpMacroAssemblerIrregexp::CheckNotAtStart(Label* on_not_at_start) {
297 Emit(BC_CHECK_NOT_AT_START, 0);
298 EmitOrLink(on_not_at_start);
302 void RegExpMacroAssemblerIrregexp::CheckNotCharacter(uint32_t c,
303 Label* on_not_equal) {
305 Emit(BC_CHECK_NOT_4_CHARS, 0);
308 Emit(BC_CHECK_NOT_CHAR, c);
310 EmitOrLink(on_not_equal);
314 void RegExpMacroAssemblerIrregexp::CheckCharacterAfterAnd(
319 Emit(BC_AND_CHECK_4_CHARS, 0);
322 Emit(BC_AND_CHECK_CHAR, c);
325 EmitOrLink(on_equal);
329 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterAnd(
332 Label* on_not_equal) {
334 Emit(BC_AND_CHECK_NOT_4_CHARS, 0);
337 Emit(BC_AND_CHECK_NOT_CHAR, c);
340 EmitOrLink(on_not_equal);
344 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterMinusAnd(
348 Label* on_not_equal) {
349 Emit(BC_MINUS_AND_CHECK_NOT_CHAR, c);
352 EmitOrLink(on_not_equal);
356 void RegExpMacroAssemblerIrregexp::CheckCharacterInRange(
359 Label* on_in_range) {
360 Emit(BC_CHECK_CHAR_IN_RANGE, 0);
363 EmitOrLink(on_in_range);
367 void RegExpMacroAssemblerIrregexp::CheckCharacterNotInRange(
370 Label* on_not_in_range) {
371 Emit(BC_CHECK_CHAR_NOT_IN_RANGE, 0);
374 EmitOrLink(on_not_in_range);
378 void RegExpMacroAssemblerIrregexp::CheckBitInTable(
379 Handle<ByteArray> table, Label* on_bit_set) {
380 Emit(BC_CHECK_BIT_IN_TABLE, 0);
381 EmitOrLink(on_bit_set);
385 if (table->get(i + j) != 0) byte |= 1 << j;
392 void RegExpMacroAssemblerIrregexp::CheckNotBackReference(
int start_reg,
393 Label* on_not_equal) {
395 ASSERT(start_reg <= kMaxRegister);
396 Emit(BC_CHECK_NOT_BACK_REF, start_reg);
397 EmitOrLink(on_not_equal);
401 void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase(
403 Label* on_not_equal) {
405 ASSERT(start_reg <= kMaxRegister);
406 Emit(BC_CHECK_NOT_BACK_REF_NO_CASE, start_reg);
407 EmitOrLink(on_not_equal);
411 void RegExpMacroAssemblerIrregexp::CheckCharacters(
412 Vector<const uc16> str,
415 bool check_end_of_string) {
416 ASSERT(cp_offset >= kMinCPOffset);
417 ASSERT(cp_offset + str.length() - 1 <= kMaxCPOffset);
420 for (
int i = str.length() - 1; i >= 0; i--) {
421 if (check_end_of_string && i == str.length() - 1) {
422 Emit(BC_LOAD_CURRENT_CHAR, cp_offset + i);
423 EmitOrLink(on_failure);
425 Emit(BC_LOAD_CURRENT_CHAR_UNCHECKED, cp_offset + i);
427 Emit(BC_CHECK_NOT_CHAR, str[i]);
428 EmitOrLink(on_failure);
433 void RegExpMacroAssemblerIrregexp::IfRegisterLT(
int register_index,
435 Label* on_less_than) {
436 ASSERT(register_index >= 0);
437 ASSERT(register_index <= kMaxRegister);
438 Emit(BC_CHECK_REGISTER_LT, register_index);
440 EmitOrLink(on_less_than);
444 void RegExpMacroAssemblerIrregexp::IfRegisterGE(
int register_index,
446 Label* on_greater_or_equal) {
447 ASSERT(register_index >= 0);
448 ASSERT(register_index <= kMaxRegister);
449 Emit(BC_CHECK_REGISTER_GE, register_index);
451 EmitOrLink(on_greater_or_equal);
455 void RegExpMacroAssemblerIrregexp::IfRegisterEqPos(
int register_index,
457 ASSERT(register_index >= 0);
458 ASSERT(register_index <= kMaxRegister);
459 Emit(BC_CHECK_REGISTER_EQ_POS, register_index);
464 Handle<HeapObject> RegExpMacroAssemblerIrregexp::GetCode(
465 Handle<String> source) {
468 Handle<ByteArray> array =
FACTORY->NewByteArray(length());
469 Copy(array->GetDataStartAddress());
474 int RegExpMacroAssemblerIrregexp::length() {
480 memcpy(a,
buffer_.start(), length());
484 void RegExpMacroAssemblerIrregexp::Expand() {
485 bool old_buffer_was_our_own = own_buffer_;
486 Vector<byte> old_buffer =
buffer_;
489 memcpy(
buffer_.start(), old_buffer.start(), old_buffer.length());
490 if (old_buffer_was_our_own) {
491 old_buffer.Dispose();
495 #endif // V8_INTERPRETED_REGEXP
v8::Handle< v8::Value > Fail(const v8::Arguments &args)
#define ASSERT(condition)
StringInputBuffer *const buffer_
static Vector< T > New(int length)
const unsigned int MAX_FIRST_ARG
activate correct semantics for inheriting readonliness enable harmony semantics for typeof enable harmony enable harmony proxies enable all harmony harmony_scoping harmony_proxies harmony_scoping tracks arrays with only smi values automatically unbox arrays of doubles use crankshaft use hydrogen range analysis use hydrogen global value numbering use function inlining maximum number of AST nodes considered for a single inlining loop invariant code motion print statistics for hydrogen trace generated IR for specified phases trace register allocator trace range analysis trace representation types environment for every instruction put a break point before deoptimizing polymorphic inlining perform array bounds checks elimination trace on stack replacement optimize closures functions with arguments object optimize functions containing for in loops profiler considers IC stability primitive functions trigger their own optimization re try self optimization if it failed insert an interrupt check at function exit execution budget before interrupt is triggered call count before self optimization self_optimization count_based_interrupts weighted_back_edges trace_opt emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of SAHF instruction if enable use of VFP3 instructions if available this implies enabling ARMv7 enable use of ARMv7 instructions if enable use of MIPS FPU instructions if NULL
Handle< JSObject > Copy(Handle< JSObject > obj)