Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/x64/regexp-macro-assembler-x64.cc

Issue 174394: X64: Small changes to let WIN64 platform compile. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/x64/frames-x64.h ('K') | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 // Compare to end of capture, and loop if not done. 312 // Compare to end of capture, and loop if not done.
313 __ cmpq(r9, rbx); 313 __ cmpq(r9, rbx);
314 __ j(below, &loop); 314 __ j(below, &loop);
315 315
316 // Compute new value of character position after the matched part. 316 // Compute new value of character position after the matched part.
317 __ movq(rdi, r11); 317 __ movq(rdi, r11);
318 __ subq(rdi, rsi); 318 __ subq(rdi, rsi);
319 } else { 319 } else {
320 ASSERT(mode_ == UC16); 320 ASSERT(mode_ == UC16);
321 // Save important/volatile registers before calling C function. 321 // Save important/volatile registers before calling C function.
322 #ifndef __MSVC__ 322 #ifndef _WIN64
323 // Callee save on Win64 323 // Callee save on Win64
324 __ push(rsi); 324 __ push(rsi);
325 __ push(rdi); 325 __ push(rdi);
326 #endif 326 #endif
327 __ push(backtrack_stackpointer()); 327 __ push(backtrack_stackpointer());
328 328
329 int num_arguments = 3; 329 int num_arguments = 3;
330 FrameAlign(num_arguments); 330 FrameAlign(num_arguments);
331 331
332 // Put arguments into parameter registers. Parameters are 332 // Put arguments into parameter registers. Parameters are
333 // Address byte_offset1 - Address captured substring's start. 333 // Address byte_offset1 - Address captured substring's start.
334 // Address byte_offset2 - Address of current character position. 334 // Address byte_offset2 - Address of current character position.
335 // size_t byte_length - length of capture in bytes(!) 335 // size_t byte_length - length of capture in bytes(!)
336 #ifdef __MSVC__ 336 #ifdef _WIN64
337 // Compute and set byte_offset1 (start of capture). 337 // Compute and set byte_offset1 (start of capture).
338 __ lea(rcx, Operand(rsi, rdx, times_1, 0)); 338 __ lea(rcx, Operand(rsi, rdx, times_1, 0));
339 // Set byte_offset2. 339 // Set byte_offset2.
340 __ lea(rdx, Operand(rsi, rdi, times_1, 0)); 340 __ lea(rdx, Operand(rsi, rdi, times_1, 0));
341 // Set byte_length. 341 // Set byte_length.
342 __ movq(r8, rbx); 342 __ movq(r8, rbx);
343 #else // AMD64 calling convention 343 #else // AMD64 calling convention
344 // Compute byte_offset2 (current position = rsi+rdi). 344 // Compute byte_offset2 (current position = rsi+rdi).
345 __ lea(rax, Operand(rsi, rdi, times_1, 0)); 345 __ lea(rax, Operand(rsi, rdi, times_1, 0));
346 // Compute and set byte_offset1 (start of capture). 346 // Compute and set byte_offset1 (start of capture).
347 __ lea(rdi, Operand(rsi, rdx, times_1, 0)); 347 __ lea(rdi, Operand(rsi, rdx, times_1, 0));
348 // Set byte_offset2. 348 // Set byte_offset2.
349 __ movq(rsi, rax); 349 __ movq(rsi, rax);
350 // Set byte_length. 350 // Set byte_length.
351 __ movq(rdx, rbx); 351 __ movq(rdx, rbx);
352 #endif 352 #endif
353 Address function_address = FUNCTION_ADDR(&CaseInsensitiveCompareUC16); 353 Address function_address = FUNCTION_ADDR(&CaseInsensitiveCompareUC16);
354 CallCFunction(function_address, num_arguments); 354 CallCFunction(function_address, num_arguments);
355 355
356 // Restore original values before reacting on result value. 356 // Restore original values before reacting on result value.
357 __ Move(code_object_pointer(), masm_->CodeObject()); 357 __ Move(code_object_pointer(), masm_->CodeObject());
358 __ pop(backtrack_stackpointer()); 358 __ pop(backtrack_stackpointer());
359 #ifndef __MSVC__ 359 #ifndef _WIN64
360 __ pop(rdi); 360 __ pop(rdi);
361 __ pop(rsi); 361 __ pop(rsi);
362 #endif 362 #endif
363 363
364 // Check if function returned non-zero for success or zero for failure. 364 // Check if function returned non-zero for success or zero for failure.
365 __ testq(rax, rax); 365 __ testq(rax, rax);
366 BranchOrBacktrack(zero, on_no_match); 366 BranchOrBacktrack(zero, on_no_match);
367 // On success, increment position by length of capture. 367 // On success, increment position by length of capture.
368 // Requires that rbx is callee save (true for both Win64 and AMD64 ABIs). 368 // Requires that rbx is callee save (true for both Win64 and AMD64 ABIs).
369 __ addq(rdi, rbx); 369 __ addq(rdi, rbx);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 // Finalize code - write the entry point code now we know how many 597 // Finalize code - write the entry point code now we know how many
598 // registers we need. 598 // registers we need.
599 599
600 // Entry code: 600 // Entry code:
601 __ bind(&entry_label_); 601 __ bind(&entry_label_);
602 // Start new stack frame. 602 // Start new stack frame.
603 __ push(rbp); 603 __ push(rbp);
604 __ movq(rbp, rsp); 604 __ movq(rbp, rsp);
605 // Save parameters and callee-save registers. Order here should correspond 605 // Save parameters and callee-save registers. Order here should correspond
606 // to order of kBackup_ebx etc. 606 // to order of kBackup_ebx etc.
607 #ifdef __MSVC__ 607 #ifdef _WIN64
608 // MSVC passes arguments in rcx, rdx, r8, r9, with backing stack slots. 608 // MSVC passes arguments in rcx, rdx, r8, r9, with backing stack slots.
609 // Store register parameters in pre-allocated stack slots, 609 // Store register parameters in pre-allocated stack slots,
610 __ movq(Operand(rbp, kInputString), rcx); 610 __ movq(Operand(rbp, kInputString), rcx);
611 __ movq(Operand(rbp, kStartIndex), rdx); 611 __ movq(Operand(rbp, kStartIndex), rdx);
612 __ movq(Operand(rbp, kInputStart), r8); 612 __ movq(Operand(rbp, kInputStart), r8);
613 __ movq(Operand(rbp, kInputEnd), r9); 613 __ movq(Operand(rbp, kInputEnd), r9);
614 // Callee-save on Win64. 614 // Callee-save on Win64.
615 __ push(rsi); 615 __ push(rsi);
616 __ push(rdi); 616 __ push(rdi);
617 __ push(rbx); 617 __ push(rbx);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 } 733 }
734 __ movl(Operand(rbx, i * kIntSize), rax); 734 __ movl(Operand(rbx, i * kIntSize), rax);
735 } 735 }
736 } 736 }
737 __ movq(rax, Immediate(SUCCESS)); 737 __ movq(rax, Immediate(SUCCESS));
738 } 738 }
739 739
740 // Exit and return rax 740 // Exit and return rax
741 __ bind(&exit_label_); 741 __ bind(&exit_label_);
742 742
743 #ifdef __MSVC__ 743 #ifdef _WIN64
744 // Restore callee save registers. 744 // Restore callee save registers.
745 __ lea(rsp, Operand(rbp, kLastCalleeSaveRegister)); 745 __ lea(rsp, Operand(rbp, kLastCalleeSaveRegister));
746 __ pop(rbx); 746 __ pop(rbx);
747 __ pop(rdi); 747 __ pop(rdi);
748 __ pop(rsi); 748 __ pop(rsi);
749 // Stack now at rbp. 749 // Stack now at rbp.
750 #else 750 #else
751 // Restore callee save register. 751 // Restore callee save register.
752 __ movq(rbx, Operand(rbp, kBackup_rbx)); 752 __ movq(rbx, Operand(rbp, kBackup_rbx));
753 // Skip rsp to rbp. 753 // Skip rsp to rbp.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 SafeReturn(); 787 SafeReturn();
788 } 788 }
789 789
790 // Backtrack stack overflow code. 790 // Backtrack stack overflow code.
791 if (stack_overflow_label_.is_linked()) { 791 if (stack_overflow_label_.is_linked()) {
792 SafeCallTarget(&stack_overflow_label_); 792 SafeCallTarget(&stack_overflow_label_);
793 // Reached if the backtrack-stack limit has been hit. 793 // Reached if the backtrack-stack limit has been hit.
794 794
795 Label grow_failed; 795 Label grow_failed;
796 // Save registers before calling C function 796 // Save registers before calling C function
797 #ifndef __MSVC__ 797 #ifndef _WIN64
798 // Callee-save in Microsoft 64-bit ABI, but not in AMD64 ABI. 798 // Callee-save in Microsoft 64-bit ABI, but not in AMD64 ABI.
799 __ push(rsi); 799 __ push(rsi);
800 __ push(rdi); 800 __ push(rdi);
801 #endif 801 #endif
802 802
803 // Call GrowStack(backtrack_stackpointer()) 803 // Call GrowStack(backtrack_stackpointer())
804 int num_arguments = 2; 804 int num_arguments = 2;
805 FrameAlign(num_arguments); 805 FrameAlign(num_arguments);
806 #ifdef __MSVC__ 806 #ifdef _WIN64
807 // Microsoft passes parameters in rcx, rdx. 807 // Microsoft passes parameters in rcx, rdx.
808 // First argument, backtrack stackpointer, is already in rcx. 808 // First argument, backtrack stackpointer, is already in rcx.
809 __ lea(rdx, Operand(rbp, kStackHighEnd)); // Second argument 809 __ lea(rdx, Operand(rbp, kStackHighEnd)); // Second argument
810 #else 810 #else
811 // AMD64 ABI passes paremeters in rdi, rsi. 811 // AMD64 ABI passes paremeters in rdi, rsi.
812 __ movq(rdi, backtrack_stackpointer()); // First argument. 812 __ movq(rdi, backtrack_stackpointer()); // First argument.
813 __ lea(rsi, Operand(rbp, kStackHighEnd)); // Second argument. 813 __ lea(rsi, Operand(rbp, kStackHighEnd)); // Second argument.
814 #endif 814 #endif
815 CallCFunction(FUNCTION_ADDR(&GrowStack), num_arguments); 815 CallCFunction(FUNCTION_ADDR(&GrowStack), num_arguments);
816 // If return NULL, we have failed to grow the stack, and 816 // If return NULL, we have failed to grow the stack, and
817 // must exit with a stack-overflow exception. 817 // must exit with a stack-overflow exception.
818 __ testq(rax, rax); 818 __ testq(rax, rax);
819 __ j(equal, &exit_with_exception); 819 __ j(equal, &exit_with_exception);
820 // Otherwise use return value as new stack pointer. 820 // Otherwise use return value as new stack pointer.
821 __ movq(backtrack_stackpointer(), rax); 821 __ movq(backtrack_stackpointer(), rax);
822 // Restore saved registers and continue. 822 // Restore saved registers and continue.
823 __ Move(code_object_pointer(), masm_->CodeObject()); 823 __ Move(code_object_pointer(), masm_->CodeObject());
824 #ifndef __MSVC__ 824 #ifndef _WIN64
825 __ pop(rdi); 825 __ pop(rdi);
826 __ pop(rsi); 826 __ pop(rsi);
827 #endif 827 #endif
828 SafeReturn(); 828 SafeReturn();
829 } 829 }
830 830
831 if (exit_with_exception.is_linked()) { 831 if (exit_with_exception.is_linked()) {
832 // If any of the code above needed to exit with an exception. 832 // If any of the code above needed to exit with an exception.
833 __ bind(&exit_with_exception); 833 __ bind(&exit_with_exception);
834 // Exit with Result EXCEPTION(-1) to signal thrown exception. 834 // Exit with Result EXCEPTION(-1) to signal thrown exception.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 } 973 }
974 974
975 975
976 // Private methods: 976 // Private methods:
977 977
978 void RegExpMacroAssemblerX64::CallCheckStackGuardState() { 978 void RegExpMacroAssemblerX64::CallCheckStackGuardState() {
979 // This function call preserves no register values. Caller should 979 // This function call preserves no register values. Caller should
980 // store anything volatile in a C call or overwritten by this function. 980 // store anything volatile in a C call or overwritten by this function.
981 int num_arguments = 3; 981 int num_arguments = 3;
982 FrameAlign(num_arguments); 982 FrameAlign(num_arguments);
983 #ifdef __MSVC__ 983 #ifdef _WIN64
984 // Second argument: Code* of self. (Do this before overwriting r8). 984 // Second argument: Code* of self. (Do this before overwriting r8).
985 __ movq(rdx, code_object_pointer()); 985 __ movq(rdx, code_object_pointer());
986 // Third argument: RegExp code frame pointer. 986 // Third argument: RegExp code frame pointer.
987 __ movq(r8, rbp); 987 __ movq(r8, rbp);
988 // First argument: Next address on the stack (will be address of 988 // First argument: Next address on the stack (will be address of
989 // return address). 989 // return address).
990 __ lea(rcx, Operand(rsp, -kPointerSize)); 990 __ lea(rcx, Operand(rsp, -kPointerSize));
991 #else 991 #else
992 // Third argument: RegExp code frame pointer. 992 // Third argument: RegExp code frame pointer.
993 __ movq(rdx, rbp); 993 __ movq(rdx, rbp);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 void RegExpMacroAssemblerX64::FrameAlign(int num_arguments) { 1235 void RegExpMacroAssemblerX64::FrameAlign(int num_arguments) {
1236 // TODO(lrn): Since we no longer use the system stack arbitrarily (but we do 1236 // TODO(lrn): Since we no longer use the system stack arbitrarily (but we do
1237 // use it, e.g., for SafeCall), we know the number of elements on the stack 1237 // use it, e.g., for SafeCall), we know the number of elements on the stack
1238 // since the last frame alignment. We might be able to do this simpler then. 1238 // since the last frame alignment. We might be able to do this simpler then.
1239 int frameAlignment = OS::ActivationFrameAlignment(); 1239 int frameAlignment = OS::ActivationFrameAlignment();
1240 ASSERT(frameAlignment != 0); 1240 ASSERT(frameAlignment != 0);
1241 // Make stack end at alignment and make room for num_arguments pointers 1241 // Make stack end at alignment and make room for num_arguments pointers
1242 // (on Win64 only) and the original value of rsp. 1242 // (on Win64 only) and the original value of rsp.
1243 __ movq(kScratchRegister, rsp); 1243 __ movq(kScratchRegister, rsp);
1244 ASSERT(IsPowerOf2(frameAlignment)); 1244 ASSERT(IsPowerOf2(frameAlignment));
1245 #ifdef __MSVC__ 1245 #ifdef _WIN64
1246 // Allocate space for parameters and old rsp. 1246 // Allocate space for parameters and old rsp.
1247 __ subq(rsp, Immediate((num_arguments + 1) * kPointerSize)); 1247 __ subq(rsp, Immediate((num_arguments + 1) * kPointerSize));
1248 __ and_(rsp, -frameAlignment); 1248 __ and_(rsp, Immediate(-frameAlignment));
1249 __ movq(Operand(rsp, num_arguments * kPointerSize), kScratchRegister); 1249 __ movq(Operand(rsp, num_arguments * kPointerSize), kScratchRegister);
1250 #else 1250 #else
1251 // Allocate space for old rsp. 1251 // Allocate space for old rsp.
1252 __ subq(rsp, Immediate(kPointerSize)); 1252 __ subq(rsp, Immediate(kPointerSize));
1253 __ and_(rsp, Immediate(-frameAlignment)); 1253 __ and_(rsp, Immediate(-frameAlignment));
1254 __ movq(Operand(rsp, 0), kScratchRegister); 1254 __ movq(Operand(rsp, 0), kScratchRegister);
1255 #endif 1255 #endif
1256 } 1256 }
1257 1257
1258 1258
1259 void RegExpMacroAssemblerX64::CallCFunction(Address function_address, 1259 void RegExpMacroAssemblerX64::CallCFunction(Address function_address,
1260 int num_arguments) { 1260 int num_arguments) {
1261 // Don't compile regexps with serialization enabled. The addresses of the C++ 1261 // Don't compile regexps with serialization enabled. The addresses of the C++
1262 // function being called isn't relocatable. 1262 // function being called isn't relocatable.
1263 ASSERT(!Serializer::enabled()); 1263 ASSERT(!Serializer::enabled());
1264 __ movq(rax, reinterpret_cast<intptr_t>(function_address), RelocInfo::NONE); 1264 __ movq(rax, reinterpret_cast<intptr_t>(function_address), RelocInfo::NONE);
1265 __ call(rax); 1265 __ call(rax);
1266 ASSERT(OS::ActivationFrameAlignment() != 0); 1266 ASSERT(OS::ActivationFrameAlignment() != 0);
1267 #ifdef __MSVC__ 1267 #ifdef _WIN64
1268 __ movq(rsp, Operand(rsp, num_arguments * kPointerSize)); 1268 __ movq(rsp, Operand(rsp, num_arguments * kPointerSize));
1269 #else 1269 #else
1270 __ pop(rsp); 1270 __ pop(rsp);
1271 #endif 1271 #endif
1272 } 1272 }
1273 1273
1274 1274
1275 void RegExpMacroAssemblerX64::LoadCurrentCharacterUnchecked(int cp_offset, 1275 void RegExpMacroAssemblerX64::LoadCurrentCharacterUnchecked(int cp_offset,
1276 int characters) { 1276 int characters) {
1277 if (mode_ == ASCII) { 1277 if (mode_ == ASCII) {
(...skipping 14 matching lines...) Expand all
1292 ASSERT(characters == 1); 1292 ASSERT(characters == 1);
1293 __ movzxwl(current_character(), 1293 __ movzxwl(current_character(),
1294 Operand(rsi, rdi, times_1, cp_offset * sizeof(uc16))); 1294 Operand(rsi, rdi, times_1, cp_offset * sizeof(uc16)));
1295 } 1295 }
1296 } 1296 }
1297 } 1297 }
1298 1298
1299 1299
1300 #undef __ 1300 #undef __
1301 }} // namespace v8::internal 1301 }} // namespace v8::internal
OLDNEW
« src/x64/frames-x64.h ('K') | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698