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 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2416 // rsp[16]: previous index | 2416 // rsp[16]: previous index |
2417 // rsp[24]: subject string | 2417 // rsp[24]: subject string |
2418 // rsp[32]: JSRegExp object | 2418 // rsp[32]: JSRegExp object |
2419 | 2419 |
2420 static const int kLastMatchInfoOffset = 1 * kPointerSize; | 2420 static const int kLastMatchInfoOffset = 1 * kPointerSize; |
2421 static const int kPreviousIndexOffset = 2 * kPointerSize; | 2421 static const int kPreviousIndexOffset = 2 * kPointerSize; |
2422 static const int kSubjectOffset = 3 * kPointerSize; | 2422 static const int kSubjectOffset = 3 * kPointerSize; |
2423 static const int kJSRegExpOffset = 4 * kPointerSize; | 2423 static const int kJSRegExpOffset = 4 * kPointerSize; |
2424 | 2424 |
2425 Label runtime; | 2425 Label runtime; |
2426 | |
2427 // Ensure that a RegExp stack is allocated. | 2426 // Ensure that a RegExp stack is allocated. |
2428 ExternalReference address_of_regexp_stack_memory_address = | 2427 ExternalReference address_of_regexp_stack_memory_address = |
2429 ExternalReference::address_of_regexp_stack_memory_address(); | 2428 ExternalReference::address_of_regexp_stack_memory_address(); |
2430 ExternalReference address_of_regexp_stack_memory_size = | 2429 ExternalReference address_of_regexp_stack_memory_size = |
2431 ExternalReference::address_of_regexp_stack_memory_size(); | 2430 ExternalReference::address_of_regexp_stack_memory_size(); |
2432 __ movq(kScratchRegister, address_of_regexp_stack_memory_size); | 2431 __ movq(kScratchRegister, address_of_regexp_stack_memory_size); |
2433 __ movq(kScratchRegister, Operand(kScratchRegister, 0)); | 2432 __ movq(kScratchRegister, Operand(kScratchRegister, 0)); |
2434 __ testq(kScratchRegister, kScratchRegister); | 2433 __ testq(kScratchRegister, kScratchRegister); |
2435 __ j(zero, &runtime); | 2434 __ j(zero, &runtime); |
2436 | 2435 |
2437 | 2436 |
2438 // Check that the first argument is a JSRegExp object. | 2437 // Check that the first argument is a JSRegExp object. |
2439 __ movq(rax, Operand(rsp, kJSRegExpOffset)); | 2438 __ movq(rax, Operand(rsp, kJSRegExpOffset)); |
2440 __ JumpIfSmi(rax, &runtime); | 2439 __ JumpIfSmi(rax, &runtime); |
2441 __ CmpObjectType(rax, JS_REGEXP_TYPE, kScratchRegister); | 2440 __ CmpObjectType(rax, JS_REGEXP_TYPE, kScratchRegister); |
2442 __ j(not_equal, &runtime); | 2441 __ j(not_equal, &runtime); |
2443 // Check that the RegExp has been compiled (data contains a fixed array). | 2442 // Check that the RegExp has been compiled (data contains a fixed array). |
2444 __ movq(rcx, FieldOperand(rax, JSRegExp::kDataOffset)); | 2443 __ movq(rax, FieldOperand(rax, JSRegExp::kDataOffset)); |
2445 if (FLAG_debug_code) { | 2444 if (FLAG_debug_code) { |
2446 Condition is_smi = masm->CheckSmi(rcx); | 2445 Condition is_smi = masm->CheckSmi(rax); |
2447 __ Check(NegateCondition(is_smi), | 2446 __ Check(NegateCondition(is_smi), |
2448 "Unexpected type for RegExp data, FixedArray expected"); | 2447 "Unexpected type for RegExp data, FixedArray expected"); |
2449 __ CmpObjectType(rcx, FIXED_ARRAY_TYPE, kScratchRegister); | 2448 __ CmpObjectType(rax, FIXED_ARRAY_TYPE, kScratchRegister); |
2450 __ Check(equal, "Unexpected type for RegExp data, FixedArray expected"); | 2449 __ Check(equal, "Unexpected type for RegExp data, FixedArray expected"); |
2451 } | 2450 } |
2452 | 2451 |
2453 // rcx: RegExp data (FixedArray) | 2452 // rax: RegExp data (FixedArray) |
2454 // Check the type of the RegExp. Only continue if type is JSRegExp::IRREGEXP. | 2453 // Check the type of the RegExp. Only continue if type is JSRegExp::IRREGEXP. |
2455 __ SmiToInteger32(rbx, FieldOperand(rcx, JSRegExp::kDataTagOffset)); | 2454 __ SmiToInteger32(rbx, FieldOperand(rax, JSRegExp::kDataTagOffset)); |
2456 __ cmpl(rbx, Immediate(JSRegExp::IRREGEXP)); | 2455 __ cmpl(rbx, Immediate(JSRegExp::IRREGEXP)); |
2457 __ j(not_equal, &runtime); | 2456 __ j(not_equal, &runtime); |
2458 | 2457 |
2459 // rcx: RegExp data (FixedArray) | 2458 // rax: RegExp data (FixedArray) |
2460 // Check that the number of captures fit in the static offsets vector buffer. | 2459 // Check that the number of captures fit in the static offsets vector buffer. |
2461 __ SmiToInteger32(rdx, | 2460 __ SmiToInteger32(rdx, |
2462 FieldOperand(rcx, JSRegExp::kIrregexpCaptureCountOffset)); | 2461 FieldOperand(rax, JSRegExp::kIrregexpCaptureCountOffset)); |
2463 // Calculate number of capture registers (number_of_captures + 1) * 2. | 2462 // Calculate number of capture registers (number_of_captures + 1) * 2. |
2464 __ leal(rdx, Operand(rdx, rdx, times_1, 2)); | 2463 __ leal(rdx, Operand(rdx, rdx, times_1, 2)); |
2465 // Check that the static offsets vector buffer is large enough. | 2464 // Check that the static offsets vector buffer is large enough. |
2466 __ cmpl(rdx, Immediate(OffsetsVector::kStaticOffsetsVectorSize)); | 2465 __ cmpl(rdx, Immediate(OffsetsVector::kStaticOffsetsVectorSize)); |
2467 __ j(above, &runtime); | 2466 __ j(above, &runtime); |
2468 | 2467 |
2469 // rcx: RegExp data (FixedArray) | 2468 // rax: RegExp data (FixedArray) |
2470 // rdx: Number of capture registers | 2469 // rdx: Number of capture registers |
2471 // Check that the second argument is a string. | 2470 // Check that the second argument is a string. |
2472 __ movq(rdi, Operand(rsp, kSubjectOffset)); | 2471 __ movq(rdi, Operand(rsp, kSubjectOffset)); |
2473 __ JumpIfSmi(rdi, &runtime); | 2472 __ JumpIfSmi(rdi, &runtime); |
2474 Condition is_string = masm->IsObjectStringType(rdi, rbx, rbx); | 2473 Condition is_string = masm->IsObjectStringType(rdi, rbx, rbx); |
2475 __ j(NegateCondition(is_string), &runtime); | 2474 __ j(NegateCondition(is_string), &runtime); |
2476 | 2475 |
2477 // rdi: Subject string. | 2476 // rdi: Subject string. |
2478 // rax: RegExp data (FixedArray). | 2477 // rax: RegExp data (FixedArray). |
2479 // rdx: Number of capture registers. | 2478 // rdx: Number of capture registers. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2577 // rdi: subject string | 2576 // rdi: subject string |
2578 // rbx: previous index | 2577 // rbx: previous index |
2579 // rcx: encoding of subject string (1 if ascii 0 if two_byte); | 2578 // rcx: encoding of subject string (1 if ascii 0 if two_byte); |
2580 // r11: code | 2579 // r11: code |
2581 // All checks done. Now push arguments for native regexp code. | 2580 // All checks done. Now push arguments for native regexp code. |
2582 __ IncrementCounter(&Counters::regexp_entry_native, 1); | 2581 __ IncrementCounter(&Counters::regexp_entry_native, 1); |
2583 | 2582 |
2584 static const int kRegExpExecuteArguments = 7; | 2583 static const int kRegExpExecuteArguments = 7; |
2585 int argument_slots_on_stack = | 2584 int argument_slots_on_stack = |
2586 masm->ArgumentStackSlotsForCFunctionCall(kRegExpExecuteArguments); | 2585 masm->ArgumentStackSlotsForCFunctionCall(kRegExpExecuteArguments); |
2587 __ EnterApiExitFrame(argument_slots_on_stack); // Clobbers rax! | 2586 __ EnterApiExitFrame(argument_slots_on_stack); |
2588 | 2587 |
2589 // Argument 7: Indicate that this is a direct call from JavaScript. | 2588 // Argument 7: Indicate that this is a direct call from JavaScript. |
2590 __ movq(Operand(rsp, (argument_slots_on_stack - 1) * kPointerSize), | 2589 __ movq(Operand(rsp, (argument_slots_on_stack - 1) * kPointerSize), |
2591 Immediate(1)); | 2590 Immediate(1)); |
2592 | 2591 |
2593 // Argument 6: Start (high end) of backtracking stack memory area. | 2592 // Argument 6: Start (high end) of backtracking stack memory area. |
2594 __ movq(kScratchRegister, address_of_regexp_stack_memory_address); | 2593 __ movq(kScratchRegister, address_of_regexp_stack_memory_address); |
2595 __ movq(r9, Operand(kScratchRegister, 0)); | 2594 __ movq(r9, Operand(kScratchRegister, 0)); |
2596 __ movq(kScratchRegister, address_of_regexp_stack_memory_size); | 2595 __ movq(kScratchRegister, address_of_regexp_stack_memory_size); |
2597 __ addq(r9, Operand(kScratchRegister, 0)); | 2596 __ addq(r9, Operand(kScratchRegister, 0)); |
(...skipping 2542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5140 FieldOperand(elements, PixelArray::kExternalPointerOffset)); | 5139 FieldOperand(elements, PixelArray::kExternalPointerOffset)); |
5141 __ movb(Operand(external_pointer, untagged_key, times_1, 0), untagged_value); | 5140 __ movb(Operand(external_pointer, untagged_key, times_1, 0), untagged_value); |
5142 __ ret(0); // Return value in eax. | 5141 __ ret(0); // Return value in eax. |
5143 } | 5142 } |
5144 | 5143 |
5145 #undef __ | 5144 #undef __ |
5146 | 5145 |
5147 } } // namespace v8::internal | 5146 } } // namespace v8::internal |
5148 | 5147 |
5149 #endif // V8_TARGET_ARCH_X64 | 5148 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |