| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <string.h> | 28 #include <string.h> |
| 29 #include "v8.h" | 29 #include "v8.h" |
| 30 #include "log.h" | 30 #include "log.h" |
| 31 #include "ast.h" | 31 #include "ast.h" |
| 32 #include "macro-assembler.h" | 32 #include "macro-assembler.h" |
| 33 #include "regexp-macro-assembler.h" |
| 34 #include "macro-assembler-ia32.h" |
| 33 #include "regexp-macro-assembler-ia32.h" | 35 #include "regexp-macro-assembler-ia32.h" |
| 34 | 36 |
| 35 namespace v8 { namespace internal { | 37 namespace v8 { namespace internal { |
| 38 |
| 36 /* | 39 /* |
| 37 * This assembler uses the following register assignment convention | 40 * This assembler uses the following register assignment convention |
| 38 * - edx : current character. Must be loaded using LoadCurrentCharacter | 41 * - edx : current character. Must be loaded using LoadCurrentCharacter |
| 39 * before using any of the dispatch methods. | 42 * before using any of the dispatch methods. |
| 40 * - edi : current position in input, as negative offset from end of string. | 43 * - edi : current position in input, as negative offset from end of string. |
| 41 * Please notice that this is the byte offset, not the character offset! | 44 * Please notice that this is the byte offset, not the character offset! |
| 42 * - esi : end of input (points to byte after last character in input). | 45 * - esi : end of input (points to byte after last character in input). |
| 43 * - ebp : points to the location above the registers on the stack, | 46 * - ebp : points to the location above the registers on the stack, |
| 44 * as if by the "enter <register_count>" opcode. | 47 * as if by the "enter <register_count>" opcode. |
| 45 * - esp : points to tip of backtracking stack. | 48 * - esp : points to tip of backtracking stack. |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 351 |
| 349 | 352 |
| 350 Handle<Object> RegExpMacroAssemblerIA32::GetCode() { | 353 Handle<Object> RegExpMacroAssemblerIA32::GetCode() { |
| 351 // Finalize code - write the entry point code now we know how many | 354 // Finalize code - write the entry point code now we know how many |
| 352 // registers we need. | 355 // registers we need. |
| 353 | 356 |
| 354 // Entry code: | 357 // Entry code: |
| 355 __ bind(&entry_label_); | 358 __ bind(&entry_label_); |
| 356 __ push(esi); | 359 __ push(esi); |
| 357 __ push(edi); | 360 __ push(edi); |
| 358 __ enter(Immediate(num_registers_ * sizeof(uint32_t))); | 361 __ enter(Immediate(num_registers_ * kPointerSize)); |
| 359 __ mov(esi, Operand(ebp, kInputEndOffset)); | 362 __ mov(esi, Operand(ebp, kInputEndOffset)); |
| 360 __ mov(edi, Operand(ebp, kInputStartOffset)); | 363 __ mov(edi, Operand(ebp, kInputStartOffset)); |
| 361 __ sub(edi, Operand(esi)); | 364 __ sub(edi, Operand(esi)); |
| 362 __ mov(edx, Operand(ebp, kInputBuffer)); | 365 __ mov(edx, Operand(ebp, kInputBuffer)); |
| 363 __ mov(edx, Operand(edx, 0)); | 366 __ mov(edx, Operand(edx, 0)); |
| 364 __ add(esi, Operand(edx)); | 367 __ add(esi, Operand(edx)); |
| 365 if (num_saved_registers_ > 0) { | 368 if (num_saved_registers_ > 0) { |
| 366 // Fill saved registers with initial value = start offset - 1 | 369 // Fill saved registers with initial value = start offset - 1 |
| 367 __ mov(ecx, -num_saved_registers_); | 370 __ mov(ecx, -num_saved_registers_); |
| 368 __ mov(eax, Operand(edi)); | 371 __ mov(eax, Operand(edi)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 381 // copy captures to output | 384 // copy captures to output |
| 382 __ mov(ebx, Operand(ebp, kRegisterOutput)); | 385 __ mov(ebx, Operand(ebp, kRegisterOutput)); |
| 383 __ mov(ecx, Operand(ebp, kInputEndOffset)); | 386 __ mov(ecx, Operand(ebp, kInputEndOffset)); |
| 384 __ sub(ecx, Operand(ebp, kInputStartOffset)); | 387 __ sub(ecx, Operand(ebp, kInputStartOffset)); |
| 385 for (int i = 0; i < num_saved_registers_; i++) { | 388 for (int i = 0; i < num_saved_registers_; i++) { |
| 386 __ mov(eax, register_location(i)); | 389 __ mov(eax, register_location(i)); |
| 387 __ add(eax, Operand(ecx)); // Convert to index from start, not end. | 390 __ add(eax, Operand(ecx)); // Convert to index from start, not end. |
| 388 if (char_size() == 2) { | 391 if (char_size() == 2) { |
| 389 __ shr(eax); | 392 __ shr(eax); |
| 390 } | 393 } |
| 391 __ mov(Operand(ebx, i * sizeof(int32_t)), eax); | 394 __ mov(Operand(ebx, i * kPointerSize), eax); |
| 392 } | 395 } |
| 393 } | 396 } |
| 394 __ mov(eax, Immediate(1)); | 397 __ mov(eax, Immediate(1)); |
| 395 | 398 |
| 396 __ bind(&exit_label_); | 399 __ bind(&exit_label_); |
| 397 __ leave(); | 400 __ leave(); |
| 398 __ pop(edi); | 401 __ pop(edi); |
| 399 __ pop(esi); | 402 __ pop(esi); |
| 400 __ ret(0); | 403 __ ret(0); |
| 401 | 404 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 void RegExpMacroAssemblerIA32::WriteStackPointerToRegister(int reg) { | 512 void RegExpMacroAssemblerIA32::WriteStackPointerToRegister(int reg) { |
| 510 __ mov(register_location(reg), esp); | 513 __ mov(register_location(reg), esp); |
| 511 } | 514 } |
| 512 | 515 |
| 513 | 516 |
| 514 // Private methods: | 517 // Private methods: |
| 515 | 518 |
| 516 Operand RegExpMacroAssemblerIA32::register_location( | 519 Operand RegExpMacroAssemblerIA32::register_location( |
| 517 int register_index) { | 520 int register_index) { |
| 518 ASSERT(register_index < (1<<30)); | 521 ASSERT(register_index < (1<<30)); |
| 519 return Operand(ebp, -(register_index + 1) * sizeof(uint32_t)); | 522 return Operand(ebp, -(register_index + 1) * kPointerSize); |
| 520 } | 523 } |
| 521 | 524 |
| 522 | 525 |
| 523 size_t RegExpMacroAssemblerIA32::char_size() { | 526 size_t RegExpMacroAssemblerIA32::char_size() { |
| 524 return static_cast<size_t>(mode_); | 527 return static_cast<size_t>(mode_); |
| 525 } | 528 } |
| 526 | 529 |
| 527 | 530 |
| 528 void RegExpMacroAssemblerIA32::BranchOrBacktrack(Condition condition, | 531 void RegExpMacroAssemblerIA32::BranchOrBacktrack(Condition condition, |
| 529 Label* to) { | 532 Label* to) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 } | 625 } |
| 623 | 626 |
| 624 | 627 |
| 625 void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(Register reg, | 628 void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(Register reg, |
| 626 ArraySlice* buffer) { | 629 ArraySlice* buffer) { |
| 627 __ mov(reg, buffer->array()); | 630 __ mov(reg, buffer->array()); |
| 628 __ add(Operand(reg), Immediate(buffer->base_offset())); | 631 __ add(Operand(reg), Immediate(buffer->base_offset())); |
| 629 } | 632 } |
| 630 | 633 |
| 631 #undef __ | 634 #undef __ |
| 632 }} | 635 }} // namespace v8::internal |
| OLD | NEW |