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

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

Issue 2365001: X64: Fix issue 678. Bug in some Win64 C calls from generated code. (Closed)
Patch Set: Created 10 years, 6 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
« no previous file with comments | « no previous file | 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 2623 matching lines...) Expand 10 before | Expand all | Expand 10 after
2634 movq(dst, FieldOperand(dst, JSFunction::kContextOffset)); 2634 movq(dst, FieldOperand(dst, JSFunction::kContextOffset));
2635 } 2635 }
2636 // The context may be an intermediate context, not a function context. 2636 // The context may be an intermediate context, not a function context.
2637 movq(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); 2637 movq(dst, Operand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX)));
2638 } else { // context is the current function context. 2638 } else { // context is the current function context.
2639 // The context may be an intermediate context, not a function context. 2639 // The context may be an intermediate context, not a function context.
2640 movq(dst, Operand(rsi, Context::SlotOffset(Context::FCONTEXT_INDEX))); 2640 movq(dst, Operand(rsi, Context::SlotOffset(Context::FCONTEXT_INDEX)));
2641 } 2641 }
2642 } 2642 }
2643 2643
2644
2644 int MacroAssembler::ArgumentStackSlotsForCFunctionCall(int num_arguments) { 2645 int MacroAssembler::ArgumentStackSlotsForCFunctionCall(int num_arguments) {
2645 // On Windows stack slots are reserved by the caller for all arguments 2646 // On Windows stack slots are reserved by the caller for all arguments
2646 // including the ones passed in registers. On Linux 6 arguments are passed in 2647 // including the ones passed in registers, and space is alwaysallocated for
Rico 2010/05/28 08:20:02 always->allocated -> always allocated
2647 // registers and the caller does not reserve stack slots for them. 2648 // the four register arguments even if the function takes fewer than four
2649 // arguments.
2650 // On Linux the first six arguments are passed in registers and the caller
2651 // does not reserve stack slots for them.
2648 ASSERT(num_arguments >= 0); 2652 ASSERT(num_arguments >= 0);
2649 #ifdef _WIN64 2653 #ifdef _WIN64
2650 static const int kArgumentsWithoutStackSlot = 0; 2654 static const int kMinimumStackSlots = 4;
2655 if (num_arguments < kMinimumStackSlots) return kMinimumStackSlots;
2656 return num_arguments;
2651 #else 2657 #else
2652 static const int kArgumentsWithoutStackSlot = 6; 2658 static const int kRegisterPassedArguments = 6;
2659 if (num_arguments < kRegisterPassedArguments) return 0;
2660 return num_arguments - kRegisterPassedArguments;
2653 #endif 2661 #endif
2654 return num_arguments > kArgumentsWithoutStackSlot ?
2655 num_arguments - kArgumentsWithoutStackSlot : 0;
2656 } 2662 }
2657 2663
2664
2658 void MacroAssembler::PrepareCallCFunction(int num_arguments) { 2665 void MacroAssembler::PrepareCallCFunction(int num_arguments) {
2659 int frame_alignment = OS::ActivationFrameAlignment(); 2666 int frame_alignment = OS::ActivationFrameAlignment();
2660 ASSERT(frame_alignment != 0); 2667 ASSERT(frame_alignment != 0);
2661 ASSERT(num_arguments >= 0); 2668 ASSERT(num_arguments >= 0);
2662 // Make stack end at alignment and allocate space for arguments and old rsp. 2669 // Make stack end at alignment and allocate space for arguments and old rsp.
2663 movq(kScratchRegister, rsp); 2670 movq(kScratchRegister, rsp);
2664 ASSERT(IsPowerOf2(frame_alignment)); 2671 ASSERT(IsPowerOf2(frame_alignment));
2665 int argument_slots_on_stack = 2672 int argument_slots_on_stack =
2666 ArgumentStackSlotsForCFunctionCall(num_arguments); 2673 ArgumentStackSlotsForCFunctionCall(num_arguments);
2667 subq(rsp, Immediate((argument_slots_on_stack + 1) * kPointerSize)); 2674 subq(rsp, Immediate((argument_slots_on_stack + 1) * kPointerSize));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 CPU::FlushICache(address_, size_); 2713 CPU::FlushICache(address_, size_);
2707 2714
2708 // Check that the code was patched as expected. 2715 // Check that the code was patched as expected.
2709 ASSERT(masm_.pc_ == address_ + size_); 2716 ASSERT(masm_.pc_ == address_ + size_);
2710 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2717 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2711 } 2718 }
2712 2719
2713 } } // namespace v8::internal 2720 } } // namespace v8::internal
2714 2721
2715 #endif // V8_TARGET_ARCH_X64 2722 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698