| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 * bool at_start, | 107 * bool at_start, |
| 108 * byte* stack_area_base, | 108 * byte* stack_area_base, |
| 109 * bool direct_call) | 109 * bool direct_call) |
| 110 */ | 110 */ |
| 111 | 111 |
| 112 #define __ ACCESS_MASM((&masm_)) | 112 #define __ ACCESS_MASM((&masm_)) |
| 113 | 113 |
| 114 RegExpMacroAssemblerX64::RegExpMacroAssemblerX64( | 114 RegExpMacroAssemblerX64::RegExpMacroAssemblerX64( |
| 115 Mode mode, | 115 Mode mode, |
| 116 int registers_to_save) | 116 int registers_to_save) |
| 117 : masm_(Isolate::Current(), NULL, kRegExpCodeSize), | 117 : masm_(NULL, kRegExpCodeSize), |
| 118 no_root_array_scope_(&masm_), | 118 no_root_array_scope_(&masm_), |
| 119 code_relative_fixup_positions_(4), | 119 code_relative_fixup_positions_(4), |
| 120 mode_(mode), | 120 mode_(mode), |
| 121 num_registers_(registers_to_save), | 121 num_registers_(registers_to_save), |
| 122 num_saved_registers_(registers_to_save), | 122 num_saved_registers_(registers_to_save), |
| 123 entry_label_(), | 123 entry_label_(), |
| 124 start_label_(), | 124 start_label_(), |
| 125 success_label_(), | 125 success_label_(), |
| 126 backtrack_label_(), | 126 backtrack_label_(), |
| 127 exit_label_() { | 127 exit_label_() { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 } else { | 395 } else { |
| 396 ASSERT(mode_ == UC16); | 396 ASSERT(mode_ == UC16); |
| 397 // Save important/volatile registers before calling C function. | 397 // Save important/volatile registers before calling C function. |
| 398 #ifndef _WIN64 | 398 #ifndef _WIN64 |
| 399 // Caller save on Linux and callee save in Windows. | 399 // Caller save on Linux and callee save in Windows. |
| 400 __ push(rsi); | 400 __ push(rsi); |
| 401 __ push(rdi); | 401 __ push(rdi); |
| 402 #endif | 402 #endif |
| 403 __ push(backtrack_stackpointer()); | 403 __ push(backtrack_stackpointer()); |
| 404 | 404 |
| 405 static const int num_arguments = 4; | 405 static const int num_arguments = 3; |
| 406 __ PrepareCallCFunction(num_arguments); | 406 __ PrepareCallCFunction(num_arguments); |
| 407 | 407 |
| 408 // Put arguments into parameter registers. Parameters are | 408 // Put arguments into parameter registers. Parameters are |
| 409 // Address byte_offset1 - Address captured substring's start. | 409 // Address byte_offset1 - Address captured substring's start. |
| 410 // Address byte_offset2 - Address of current character position. | 410 // Address byte_offset2 - Address of current character position. |
| 411 // size_t byte_length - length of capture in bytes(!) | 411 // size_t byte_length - length of capture in bytes(!) |
| 412 // Isolate* isolate | |
| 413 #ifdef _WIN64 | 412 #ifdef _WIN64 |
| 414 // Compute and set byte_offset1 (start of capture). | 413 // Compute and set byte_offset1 (start of capture). |
| 415 __ lea(rcx, Operand(rsi, rdx, times_1, 0)); | 414 __ lea(rcx, Operand(rsi, rdx, times_1, 0)); |
| 416 // Set byte_offset2. | 415 // Set byte_offset2. |
| 417 __ lea(rdx, Operand(rsi, rdi, times_1, 0)); | 416 __ lea(rdx, Operand(rsi, rdi, times_1, 0)); |
| 418 // Set byte_length. | 417 // Set byte_length. |
| 419 __ movq(r8, rbx); | 418 __ movq(r8, rbx); |
| 420 // Isolate. | |
| 421 __ LoadAddress(r9, ExternalReference::isolate_address()); | |
| 422 #else // AMD64 calling convention | 419 #else // AMD64 calling convention |
| 423 // Compute byte_offset2 (current position = rsi+rdi). | 420 // Compute byte_offset2 (current position = rsi+rdi). |
| 424 __ lea(rax, Operand(rsi, rdi, times_1, 0)); | 421 __ lea(rax, Operand(rsi, rdi, times_1, 0)); |
| 425 // Compute and set byte_offset1 (start of capture). | 422 // Compute and set byte_offset1 (start of capture). |
| 426 __ lea(rdi, Operand(rsi, rdx, times_1, 0)); | 423 __ lea(rdi, Operand(rsi, rdx, times_1, 0)); |
| 427 // Set byte_offset2. | 424 // Set byte_offset2. |
| 428 __ movq(rsi, rax); | 425 __ movq(rsi, rax); |
| 429 // Set byte_length. | 426 // Set byte_length. |
| 430 __ movq(rdx, rbx); | 427 __ movq(rdx, rbx); |
| 431 // Isolate. | |
| 432 __ LoadAddress(rcx, ExternalReference::isolate_address()); | |
| 433 #endif | 428 #endif |
| 434 ExternalReference compare = | 429 ExternalReference compare = |
| 435 ExternalReference::re_case_insensitive_compare_uc16(masm_.isolate()); | 430 ExternalReference::re_case_insensitive_compare_uc16(masm_.isolate()); |
| 436 __ CallCFunction(compare, num_arguments); | 431 __ CallCFunction(compare, num_arguments); |
| 437 | 432 |
| 438 // Restore original values before reacting on result value. | 433 // Restore original values before reacting on result value. |
| 439 __ Move(code_object_pointer(), masm_.CodeObject()); | 434 __ Move(code_object_pointer(), masm_.CodeObject()); |
| 440 __ pop(backtrack_stackpointer()); | 435 __ pop(backtrack_stackpointer()); |
| 441 #ifndef _WIN64 | 436 #ifndef _WIN64 |
| 442 __ pop(rdi); | 437 __ pop(rdi); |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 | 912 |
| 918 Label grow_failed; | 913 Label grow_failed; |
| 919 // Save registers before calling C function | 914 // Save registers before calling C function |
| 920 #ifndef _WIN64 | 915 #ifndef _WIN64 |
| 921 // Callee-save in Microsoft 64-bit ABI, but not in AMD64 ABI. | 916 // Callee-save in Microsoft 64-bit ABI, but not in AMD64 ABI. |
| 922 __ push(rsi); | 917 __ push(rsi); |
| 923 __ push(rdi); | 918 __ push(rdi); |
| 924 #endif | 919 #endif |
| 925 | 920 |
| 926 // Call GrowStack(backtrack_stackpointer()) | 921 // Call GrowStack(backtrack_stackpointer()) |
| 927 static const int num_arguments = 3; | 922 static const int num_arguments = 2; |
| 928 __ PrepareCallCFunction(num_arguments); | 923 __ PrepareCallCFunction(num_arguments); |
| 929 #ifdef _WIN64 | 924 #ifdef _WIN64 |
| 930 // Microsoft passes parameters in rcx, rdx, r8. | 925 // Microsoft passes parameters in rcx, rdx. |
| 931 // First argument, backtrack stackpointer, is already in rcx. | 926 // First argument, backtrack stackpointer, is already in rcx. |
| 932 __ lea(rdx, Operand(rbp, kStackHighEnd)); // Second argument | 927 __ lea(rdx, Operand(rbp, kStackHighEnd)); // Second argument |
| 933 __ LoadAddress(r8, ExternalReference::isolate_address()); | |
| 934 #else | 928 #else |
| 935 // AMD64 ABI passes parameters in rdi, rsi, rdx. | 929 // AMD64 ABI passes parameters in rdi, rsi. |
| 936 __ movq(rdi, backtrack_stackpointer()); // First argument. | 930 __ movq(rdi, backtrack_stackpointer()); // First argument. |
| 937 __ lea(rsi, Operand(rbp, kStackHighEnd)); // Second argument. | 931 __ lea(rsi, Operand(rbp, kStackHighEnd)); // Second argument. |
| 938 __ LoadAddress(rdx, ExternalReference::isolate_address()); | |
| 939 #endif | 932 #endif |
| 940 ExternalReference grow_stack = | 933 ExternalReference grow_stack = |
| 941 ExternalReference::re_grow_stack(masm_.isolate()); | 934 ExternalReference::re_grow_stack(masm_.isolate()); |
| 942 __ CallCFunction(grow_stack, num_arguments); | 935 __ CallCFunction(grow_stack, num_arguments); |
| 943 // If return NULL, we have failed to grow the stack, and | 936 // If return NULL, we have failed to grow the stack, and |
| 944 // must exit with a stack-overflow exception. | 937 // must exit with a stack-overflow exception. |
| 945 __ testq(rax, rax); | 938 __ testq(rax, rax); |
| 946 __ j(equal, &exit_with_exception); | 939 __ j(equal, &exit_with_exception); |
| 947 // Otherwise use return value as new stack pointer. | 940 // Otherwise use return value as new stack pointer. |
| 948 __ movq(backtrack_stackpointer(), rax); | 941 __ movq(backtrack_stackpointer(), rax); |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 } | 1382 } |
| 1390 } | 1383 } |
| 1391 | 1384 |
| 1392 #undef __ | 1385 #undef __ |
| 1393 | 1386 |
| 1394 #endif // V8_INTERPRETED_REGEXP | 1387 #endif // V8_INTERPRETED_REGEXP |
| 1395 | 1388 |
| 1396 }} // namespace v8::internal | 1389 }} // namespace v8::internal |
| 1397 | 1390 |
| 1398 #endif // V8_TARGET_ARCH_X64 | 1391 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |