OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 5725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5736 ASSERT(ebp_as_smi.is_valid()); | 5736 ASSERT(ebp_as_smi.is_valid()); |
5737 __ mov(ebp_as_smi.reg(), Operand(ebp)); | 5737 __ mov(ebp_as_smi.reg(), Operand(ebp)); |
5738 frame_->Push(&ebp_as_smi); | 5738 frame_->Push(&ebp_as_smi); |
5739 } | 5739 } |
5740 | 5740 |
5741 | 5741 |
5742 void CodeGenerator::GenerateRandomPositiveSmi(ZoneList<Expression*>* args) { | 5742 void CodeGenerator::GenerateRandomPositiveSmi(ZoneList<Expression*>* args) { |
5743 ASSERT(args->length() == 0); | 5743 ASSERT(args->length() == 0); |
5744 frame_->SpillAll(); | 5744 frame_->SpillAll(); |
5745 | 5745 |
5746 // Make sure the frame is aligned like the OS expects. | 5746 int num_arguments = 0; |
Søren Thygesen Gjesse
2010/02/25 12:29:21
Please change this to static const.
| |
5747 static const int kFrameAlignment = OS::ActivationFrameAlignment(); | 5747 __ PrepareCallCFunction(num_arguments, eax); |
5748 if (kFrameAlignment > 0) { | |
5749 ASSERT(IsPowerOf2(kFrameAlignment)); | |
5750 __ mov(edi, Operand(esp)); // Save in callee-saved register. | |
5751 __ and_(esp, -kFrameAlignment); | |
5752 } | |
5753 | 5748 |
5754 // Call V8::RandomPositiveSmi(). | 5749 // Call V8::RandomPositiveSmi(). |
5755 __ call(FUNCTION_ADDR(V8::RandomPositiveSmi), RelocInfo::RUNTIME_ENTRY); | 5750 __ CallCFunction(ExternalReference::random_positive_smi_function(), |
5756 | 5751 num_arguments); |
5757 // Restore stack pointer from callee-saved register edi. | |
5758 if (kFrameAlignment > 0) { | |
5759 __ mov(esp, Operand(edi)); | |
5760 } | |
5761 | 5752 |
5762 Result result = allocator_->Allocate(eax); | 5753 Result result = allocator_->Allocate(eax); |
5763 frame_->Push(&result); | 5754 frame_->Push(&result); |
5764 } | 5755 } |
5765 | 5756 |
5766 | 5757 |
5767 void CodeGenerator::GenerateStringAdd(ZoneList<Expression*>* args) { | 5758 void CodeGenerator::GenerateStringAdd(ZoneList<Expression*>* args) { |
5768 ASSERT_EQ(2, args->length()); | 5759 ASSERT_EQ(2, args->length()); |
5769 | 5760 |
5770 Load(args->at(0)); | 5761 Load(args->at(0)); |
(...skipping 3429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9200 __ mov(ebx, Operand(esp, kPreviousIndexOffset)); | 9191 __ mov(ebx, Operand(esp, kPreviousIndexOffset)); |
9201 __ SmiUntag(ebx); // Previous index from smi. | 9192 __ SmiUntag(ebx); // Previous index from smi. |
9202 | 9193 |
9203 // eax: subject string | 9194 // eax: subject string |
9204 // ebx: previous index | 9195 // ebx: previous index |
9205 // edx: code | 9196 // edx: code |
9206 // edi: encoding of subject string (1 if ascii 0 if two_byte); | 9197 // edi: encoding of subject string (1 if ascii 0 if two_byte); |
9207 // All checks done. Now push arguments for native regexp code. | 9198 // All checks done. Now push arguments for native regexp code. |
9208 __ IncrementCounter(&Counters::regexp_entry_native, 1); | 9199 __ IncrementCounter(&Counters::regexp_entry_native, 1); |
9209 | 9200 |
9201 static const int kRegExpExecuteArguments = 7; | |
9202 __ PrepareCallCFunction(kRegExpExecuteArguments, ecx); | |
9203 | |
9210 // Argument 7: Indicate that this is a direct call from JavaScript. | 9204 // Argument 7: Indicate that this is a direct call from JavaScript. |
9211 __ push(Immediate(1)); | 9205 __ mov(Operand(esp, 6 * kPointerSize), Immediate(1)); |
9212 | 9206 |
9213 // Argument 6: Start (high end) of backtracking stack memory area. | 9207 // Argument 6: Start (high end) of backtracking stack memory area. |
9214 __ mov(ecx, Operand::StaticVariable(address_of_regexp_stack_memory_address)); | 9208 __ mov(ecx, Operand::StaticVariable(address_of_regexp_stack_memory_address)); |
9215 __ add(ecx, Operand::StaticVariable(address_of_regexp_stack_memory_size)); | 9209 __ add(ecx, Operand::StaticVariable(address_of_regexp_stack_memory_size)); |
9216 __ push(ecx); | 9210 __ mov(Operand(esp, 5 * kPointerSize), ecx); |
9217 | 9211 |
9218 // Argument 5: static offsets vector buffer. | 9212 // Argument 5: static offsets vector buffer. |
9219 __ push(Immediate(ExternalReference::address_of_static_offsets_vector())); | 9213 __ mov(Operand(esp, 4 * kPointerSize), |
9214 Immediate(ExternalReference::address_of_static_offsets_vector())); | |
9220 | 9215 |
9221 // Argument 4: End of string data | 9216 // Argument 4: End of string data |
9222 // Argument 3: Start of string data | 9217 // Argument 3: Start of string data |
9223 Label push_two_byte, push_rest; | 9218 Label setup_two_byte, setup_rest; |
9224 __ test(edi, Operand(edi)); | 9219 __ test(edi, Operand(edi)); |
9225 __ mov(edi, FieldOperand(eax, String::kLengthOffset)); | 9220 __ mov(edi, FieldOperand(eax, String::kLengthOffset)); |
9226 __ j(zero, &push_two_byte); | 9221 __ j(zero, &setup_two_byte); |
9227 __ lea(ecx, FieldOperand(eax, edi, times_1, SeqAsciiString::kHeaderSize)); | 9222 __ lea(ecx, FieldOperand(eax, edi, times_1, SeqAsciiString::kHeaderSize)); |
9228 __ push(ecx); // Argument 4. | 9223 __ mov(Operand(esp, 3 * kPointerSize), ecx); // Argument 4. |
9229 __ lea(ecx, FieldOperand(eax, ebx, times_1, SeqAsciiString::kHeaderSize)); | 9224 __ lea(ecx, FieldOperand(eax, ebx, times_1, SeqAsciiString::kHeaderSize)); |
9230 __ push(ecx); // Argument 3. | 9225 __ mov(Operand(esp, 2 * kPointerSize), ecx); // Argument 3. |
9231 __ jmp(&push_rest); | 9226 __ jmp(&setup_rest); |
9232 | 9227 |
9233 __ bind(&push_two_byte); | 9228 __ bind(&setup_two_byte); |
9234 __ lea(ecx, FieldOperand(eax, edi, times_2, SeqTwoByteString::kHeaderSize)); | 9229 __ lea(ecx, FieldOperand(eax, edi, times_2, SeqTwoByteString::kHeaderSize)); |
9235 __ push(ecx); // Argument 4. | 9230 __ mov(Operand(esp, 3 * kPointerSize), ecx); // Argument 4. |
9236 __ lea(ecx, FieldOperand(eax, ebx, times_2, SeqTwoByteString::kHeaderSize)); | 9231 __ lea(ecx, FieldOperand(eax, ebx, times_2, SeqTwoByteString::kHeaderSize)); |
9237 __ push(ecx); // Argument 3. | 9232 __ mov(Operand(esp, 2 * kPointerSize), ecx); // Argument 3. |
9238 | 9233 |
9239 __ bind(&push_rest); | 9234 __ bind(&setup_rest); |
9240 | 9235 |
9241 // Argument 2: Previous index. | 9236 // Argument 2: Previous index. |
9242 __ push(ebx); | 9237 __ mov(Operand(esp, 1 * kPointerSize), ebx); |
9243 | 9238 |
9244 // Argument 1: Subject string. | 9239 // Argument 1: Subject string. |
9245 __ push(eax); | 9240 __ mov(Operand(esp, 0 * kPointerSize), eax); |
9246 | 9241 |
9247 // Locate the code entry and call it. | 9242 // Locate the code entry and call it. |
9248 __ add(Operand(edx), Immediate(Code::kHeaderSize - kHeapObjectTag)); | 9243 __ add(Operand(edx), Immediate(Code::kHeaderSize - kHeapObjectTag)); |
9249 __ call(Operand(edx)); | 9244 __ CallCFunction(edx, kRegExpExecuteArguments); |
9250 // Remove arguments. | |
9251 __ add(Operand(esp), Immediate(7 * kPointerSize)); | |
9252 | 9245 |
9253 // Check the result. | 9246 // Check the result. |
9254 Label success; | 9247 Label success; |
9255 __ cmp(eax, NativeRegExpMacroAssembler::SUCCESS); | 9248 __ cmp(eax, NativeRegExpMacroAssembler::SUCCESS); |
9256 __ j(equal, &success, taken); | 9249 __ j(equal, &success, taken); |
9257 Label failure; | 9250 Label failure; |
9258 __ cmp(eax, NativeRegExpMacroAssembler::FAILURE); | 9251 __ cmp(eax, NativeRegExpMacroAssembler::FAILURE); |
9259 __ j(equal, &failure, taken); | 9252 __ j(equal, &failure, taken); |
9260 __ cmp(eax, NativeRegExpMacroAssembler::EXCEPTION); | 9253 __ cmp(eax, NativeRegExpMacroAssembler::EXCEPTION); |
9261 // If not exception it can only be retry. Handle that in the runtime system. | 9254 // If not exception it can only be retry. Handle that in the runtime system. |
(...skipping 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11015 | 11008 |
11016 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 11009 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
11017 // tagged as a small integer. | 11010 // tagged as a small integer. |
11018 __ bind(&runtime); | 11011 __ bind(&runtime); |
11019 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 11012 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
11020 } | 11013 } |
11021 | 11014 |
11022 #undef __ | 11015 #undef __ |
11023 | 11016 |
11024 } } // namespace v8::internal | 11017 } } // namespace v8::internal |
OLD | NEW |