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

Side by Side Diff: src/x64/builtins-x64.cc

Issue 6015011: Use the macro assembler Set instead of explicit xor for clearing registers. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 11 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
« no previous file with comments | « src/x64/assembler-x64.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // while rdi holds the function pointer and rsi the context. 415 // while rdi holds the function pointer and rsi the context.
416 #ifdef _WIN64 416 #ifdef _WIN64
417 // MSVC parameters in: 417 // MSVC parameters in:
418 // rcx : entry (ignored) 418 // rcx : entry (ignored)
419 // rdx : function 419 // rdx : function
420 // r8 : receiver 420 // r8 : receiver
421 // r9 : argc 421 // r9 : argc
422 // [rsp+0x20] : argv 422 // [rsp+0x20] : argv
423 423
424 // Clear the context before we push it when entering the JS frame. 424 // Clear the context before we push it when entering the JS frame.
425 __ xor_(rsi, rsi); 425 __ Set(rsi, 0);
426 __ EnterInternalFrame(); 426 __ EnterInternalFrame();
427 427
428 // Load the function context into rsi. 428 // Load the function context into rsi.
429 __ movq(rsi, FieldOperand(rdx, JSFunction::kContextOffset)); 429 __ movq(rsi, FieldOperand(rdx, JSFunction::kContextOffset));
430 430
431 // Push the function and the receiver onto the stack. 431 // Push the function and the receiver onto the stack.
432 __ push(rdx); 432 __ push(rdx);
433 __ push(r8); 433 __ push(r8);
434 434
435 // Load the number of arguments and setup pointer to the arguments. 435 // Load the number of arguments and setup pointer to the arguments.
436 __ movq(rax, r9); 436 __ movq(rax, r9);
437 // Load the previous frame pointer to access C argument on stack 437 // Load the previous frame pointer to access C argument on stack
438 __ movq(kScratchRegister, Operand(rbp, 0)); 438 __ movq(kScratchRegister, Operand(rbp, 0));
439 __ movq(rbx, Operand(kScratchRegister, EntryFrameConstants::kArgvOffset)); 439 __ movq(rbx, Operand(kScratchRegister, EntryFrameConstants::kArgvOffset));
440 // Load the function pointer into rdi. 440 // Load the function pointer into rdi.
441 __ movq(rdi, rdx); 441 __ movq(rdi, rdx);
442 #else // _WIN64 442 #else // _WIN64
443 // GCC parameters in: 443 // GCC parameters in:
444 // rdi : entry (ignored) 444 // rdi : entry (ignored)
445 // rsi : function 445 // rsi : function
446 // rdx : receiver 446 // rdx : receiver
447 // rcx : argc 447 // rcx : argc
448 // r8 : argv 448 // r8 : argv
449 449
450 __ movq(rdi, rsi); 450 __ movq(rdi, rsi);
451 // rdi : function 451 // rdi : function
452 452
453 // Clear the context before we push it when entering the JS frame. 453 // Clear the context before we push it when entering the JS frame.
454 __ xor_(rsi, rsi); 454 __ Set(rsi, 0);
455 // Enter an internal frame. 455 // Enter an internal frame.
456 __ EnterInternalFrame(); 456 __ EnterInternalFrame();
457 457
458 // Push the function and receiver and setup the context. 458 // Push the function and receiver and setup the context.
459 __ push(rdi); 459 __ push(rdi);
460 __ push(rdx); 460 __ push(rdx);
461 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); 461 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
462 462
463 // Load the number of arguments and setup pointer to the arguments. 463 // Load the number of arguments and setup pointer to the arguments.
464 __ movq(rax, rcx); 464 __ movq(rax, rcx);
465 __ movq(rbx, r8); 465 __ movq(rbx, r8);
466 #endif // _WIN64 466 #endif // _WIN64
467 467
468 // Current stack contents: 468 // Current stack contents:
469 // [rsp + 2 * kPointerSize ... ]: Internal frame 469 // [rsp + 2 * kPointerSize ... ]: Internal frame
470 // [rsp + kPointerSize] : function 470 // [rsp + kPointerSize] : function
471 // [rsp] : receiver 471 // [rsp] : receiver
472 // Current register contents: 472 // Current register contents:
473 // rax : argc 473 // rax : argc
474 // rbx : argv 474 // rbx : argv
475 // rsi : context 475 // rsi : context
476 // rdi : function 476 // rdi : function
477 477
478 // Copy arguments to the stack in a loop. 478 // Copy arguments to the stack in a loop.
479 // Register rbx points to array of pointers to handle locations. 479 // Register rbx points to array of pointers to handle locations.
480 // Push the values of these handles. 480 // Push the values of these handles.
481 Label loop, entry; 481 Label loop, entry;
482 __ xor_(rcx, rcx); // Set loop variable to 0. 482 __ Set(rcx, 0); // Set loop variable to 0.
483 __ jmp(&entry); 483 __ jmp(&entry);
484 __ bind(&loop); 484 __ bind(&loop);
485 __ movq(kScratchRegister, Operand(rbx, rcx, times_pointer_size, 0)); 485 __ movq(kScratchRegister, Operand(rbx, rcx, times_pointer_size, 0));
486 __ push(Operand(kScratchRegister, 0)); // dereference handle 486 __ push(Operand(kScratchRegister, 0)); // dereference handle
487 __ addq(rcx, Immediate(1)); 487 __ addq(rcx, Immediate(1));
488 __ bind(&entry); 488 __ bind(&entry);
489 __ cmpq(rcx, rax); 489 __ cmpq(rcx, rax);
490 __ j(not_equal, &loop); 490 __ j(not_equal, &loop);
491 491
492 // Invoke the code. 492 // Invoke the code.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 __ jmp(&shift_arguments); 661 __ jmp(&shift_arguments);
662 } 662 }
663 663
664 664
665 // 3b. Patch the first argument when calling a non-function. The 665 // 3b. Patch the first argument when calling a non-function. The
666 // CALL_NON_FUNCTION builtin expects the non-function callee as 666 // CALL_NON_FUNCTION builtin expects the non-function callee as
667 // receiver, so overwrite the first argument which will ultimately 667 // receiver, so overwrite the first argument which will ultimately
668 // become the receiver. 668 // become the receiver.
669 __ bind(&non_function); 669 __ bind(&non_function);
670 __ movq(Operand(rsp, rax, times_pointer_size, 0), rdi); 670 __ movq(Operand(rsp, rax, times_pointer_size, 0), rdi);
671 __ xor_(rdi, rdi); 671 __ Set(rdi, 0);
672 672
673 // 4. Shift arguments and return address one slot down on the stack 673 // 4. Shift arguments and return address one slot down on the stack
674 // (overwriting the original receiver). Adjust argument count to make 674 // (overwriting the original receiver). Adjust argument count to make
675 // the original first argument the new receiver. 675 // the original first argument the new receiver.
676 __ bind(&shift_arguments); 676 __ bind(&shift_arguments);
677 { Label loop; 677 { Label loop;
678 __ movq(rcx, rax); 678 __ movq(rcx, rax);
679 __ bind(&loop); 679 __ bind(&loop);
680 __ movq(rbx, Operand(rsp, rcx, times_pointer_size, 0)); 680 __ movq(rbx, Operand(rsp, rcx, times_pointer_size, 0));
681 __ movq(Operand(rsp, rcx, times_pointer_size, 1 * kPointerSize), rbx); 681 __ movq(Operand(rsp, rcx, times_pointer_size, 1 * kPointerSize), rbx);
682 __ decq(rcx); 682 __ decq(rcx);
683 __ j(not_sign, &loop); // While non-negative (to copy return address). 683 __ j(not_sign, &loop); // While non-negative (to copy return address).
684 __ pop(rbx); // Discard copy of return address. 684 __ pop(rbx); // Discard copy of return address.
685 __ decq(rax); // One fewer argument (first argument is new receiver). 685 __ decq(rax); // One fewer argument (first argument is new receiver).
686 } 686 }
687 687
688 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin. 688 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin.
689 { Label function; 689 { Label function;
690 __ testq(rdi, rdi); 690 __ testq(rdi, rdi);
691 __ j(not_zero, &function); 691 __ j(not_zero, &function);
692 __ xor_(rbx, rbx); 692 __ Set(rbx, 0);
693 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION); 693 __ GetBuiltinEntry(rdx, Builtins::CALL_NON_FUNCTION);
694 __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), 694 __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)),
695 RelocInfo::CODE_TARGET); 695 RelocInfo::CODE_TARGET);
696 __ bind(&function); 696 __ bind(&function);
697 } 697 }
698 698
699 // 5b. Get the code to call from the function and check that the number of 699 // 5b. Get the code to call from the function and check that the number of
700 // expected arguments matches what we're providing. If so, jump 700 // expected arguments matches what we're providing. If so, jump
701 // (tail-call) to the code in register edx without checking arguments. 701 // (tail-call) to the code in register edx without checking arguments.
702 __ movq(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 702 __ movq(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { 1382 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
1383 __ int3(); 1383 __ int3();
1384 } 1384 }
1385 1385
1386 1386
1387 #undef __ 1387 #undef __
1388 1388
1389 } } // namespace v8::internal 1389 } } // namespace v8::internal
1390 1390
1391 #endif // V8_TARGET_ARCH_X64 1391 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698