| 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 2833 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2844   return num_arguments - kRegisterPassedArguments; | 2844   return num_arguments - kRegisterPassedArguments; | 
| 2845 #endif | 2845 #endif | 
| 2846 } | 2846 } | 
| 2847 | 2847 | 
| 2848 | 2848 | 
| 2849 void MacroAssembler::PrepareCallCFunction(int num_arguments) { | 2849 void MacroAssembler::PrepareCallCFunction(int num_arguments) { | 
| 2850   int frame_alignment = OS::ActivationFrameAlignment(); | 2850   int frame_alignment = OS::ActivationFrameAlignment(); | 
| 2851   ASSERT(frame_alignment != 0); | 2851   ASSERT(frame_alignment != 0); | 
| 2852   ASSERT(num_arguments >= 0); | 2852   ASSERT(num_arguments >= 0); | 
| 2853 | 2853 | 
| 2854   // Reserve space for Isolate address which is always passed as last parameter |  | 
| 2855   num_arguments += 1; |  | 
| 2856 |  | 
| 2857   // Make stack end at alignment and allocate space for arguments and old rsp. | 2854   // Make stack end at alignment and allocate space for arguments and old rsp. | 
| 2858   movq(kScratchRegister, rsp); | 2855   movq(kScratchRegister, rsp); | 
| 2859   ASSERT(IsPowerOf2(frame_alignment)); | 2856   ASSERT(IsPowerOf2(frame_alignment)); | 
| 2860   int argument_slots_on_stack = | 2857   int argument_slots_on_stack = | 
| 2861       ArgumentStackSlotsForCFunctionCall(num_arguments); | 2858       ArgumentStackSlotsForCFunctionCall(num_arguments); | 
| 2862   subq(rsp, Immediate((argument_slots_on_stack + 1) * kPointerSize)); | 2859   subq(rsp, Immediate((argument_slots_on_stack + 1) * kPointerSize)); | 
| 2863   and_(rsp, Immediate(-frame_alignment)); | 2860   and_(rsp, Immediate(-frame_alignment)); | 
| 2864   movq(Operand(rsp, argument_slots_on_stack * kPointerSize), kScratchRegister); | 2861   movq(Operand(rsp, argument_slots_on_stack * kPointerSize), kScratchRegister); | 
| 2865 } | 2862 } | 
| 2866 | 2863 | 
| 2867 | 2864 | 
| 2868 void MacroAssembler::CallCFunction(ExternalReference function, | 2865 void MacroAssembler::CallCFunction(ExternalReference function, | 
| 2869                                    int num_arguments) { | 2866                                    int num_arguments) { | 
| 2870   LoadAddress(rax, function); | 2867   LoadAddress(rax, function); | 
| 2871   CallCFunction(rax, num_arguments); | 2868   CallCFunction(rax, num_arguments); | 
| 2872 } | 2869 } | 
| 2873 | 2870 | 
| 2874 | 2871 | 
| 2875 void MacroAssembler::CallCFunction(Register function, int num_arguments) { | 2872 void MacroAssembler::CallCFunction(Register function, int num_arguments) { | 
| 2876   // Pass current isolate address as additional parameter. |  | 
| 2877   if (num_arguments < kRegisterPassedArguments) { |  | 
| 2878 #ifdef _WIN64 |  | 
| 2879     // First four arguments are passed in registers on Windows. |  | 
| 2880     Register arg_to_reg[] = {rcx, rdx, r8, r9}; |  | 
| 2881 #else |  | 
| 2882     // First six arguments are passed in registers on other platforms. |  | 
| 2883     Register arg_to_reg[] = {rdi, rsi, rdx, rcx, r8, r9}; |  | 
| 2884 #endif |  | 
| 2885     Register reg = arg_to_reg[num_arguments]; |  | 
| 2886     LoadAddress(reg, ExternalReference::isolate_address()); |  | 
| 2887   } else { |  | 
| 2888     // Push Isolate pointer after all parameters. |  | 
| 2889     int argument_slots_on_stack = |  | 
| 2890         ArgumentStackSlotsForCFunctionCall(num_arguments); |  | 
| 2891     LoadAddress(kScratchRegister, ExternalReference::isolate_address()); |  | 
| 2892     movq(Operand(rsp, argument_slots_on_stack * kPointerSize), |  | 
| 2893          kScratchRegister); |  | 
| 2894   } |  | 
| 2895 |  | 
| 2896   // Check stack alignment. | 2873   // Check stack alignment. | 
| 2897   if (emit_debug_code()) { | 2874   if (emit_debug_code()) { | 
| 2898     CheckStackAlignment(); | 2875     CheckStackAlignment(); | 
| 2899   } | 2876   } | 
| 2900 | 2877 | 
| 2901   call(function); | 2878   call(function); | 
| 2902   ASSERT(OS::ActivationFrameAlignment() != 0); | 2879   ASSERT(OS::ActivationFrameAlignment() != 0); | 
| 2903   ASSERT(num_arguments >= 0); | 2880   ASSERT(num_arguments >= 0); | 
| 2904   num_arguments += 1; |  | 
| 2905   int argument_slots_on_stack = | 2881   int argument_slots_on_stack = | 
| 2906       ArgumentStackSlotsForCFunctionCall(num_arguments); | 2882       ArgumentStackSlotsForCFunctionCall(num_arguments); | 
| 2907   movq(rsp, Operand(rsp, argument_slots_on_stack * kPointerSize)); | 2883   movq(rsp, Operand(rsp, argument_slots_on_stack * kPointerSize)); | 
| 2908 } | 2884 } | 
| 2909 | 2885 | 
| 2910 | 2886 | 
| 2911 CodePatcher::CodePatcher(byte* address, int size) | 2887 CodePatcher::CodePatcher(byte* address, int size) | 
| 2912     : address_(address), size_(size), masm_(address, size + Assembler::kGap) { | 2888     : address_(address), size_(size), masm_(address, size + Assembler::kGap) { | 
| 2913   // Create a new macro assembler pointing to the address of the code to patch. | 2889   // Create a new macro assembler pointing to the address of the code to patch. | 
| 2914   // The size is adjusted with kGap on order for the assembler to generate size | 2890   // The size is adjusted with kGap on order for the assembler to generate size | 
| 2915   // bytes of instructions without failing with buffer size constraints. | 2891   // bytes of instructions without failing with buffer size constraints. | 
| 2916   ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2892   ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 
| 2917 } | 2893 } | 
| 2918 | 2894 | 
| 2919 | 2895 | 
| 2920 CodePatcher::~CodePatcher() { | 2896 CodePatcher::~CodePatcher() { | 
| 2921   // Indicate that code has changed. | 2897   // Indicate that code has changed. | 
| 2922   CPU::FlushICache(address_, size_); | 2898   CPU::FlushICache(address_, size_); | 
| 2923 | 2899 | 
| 2924   // Check that the code was patched as expected. | 2900   // Check that the code was patched as expected. | 
| 2925   ASSERT(masm_.pc_ == address_ + size_); | 2901   ASSERT(masm_.pc_ == address_ + size_); | 
| 2926   ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2902   ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 
| 2927 } | 2903 } | 
| 2928 | 2904 | 
| 2929 } }  // namespace v8::internal | 2905 } }  // namespace v8::internal | 
| 2930 | 2906 | 
| 2931 #endif  // V8_TARGET_ARCH_X64 | 2907 #endif  // V8_TARGET_ARCH_X64 | 
| OLD | NEW | 
|---|