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

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

Issue 6691054: [Arguments] Merge (7442,7496] from bleeding_edge. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/arguments
Patch Set: Created 9 years, 8 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/macro-assembler-x64.h ('k') | src/x64/regexp-macro-assembler-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 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 22 matching lines...) Expand all
33 #include "codegen-inl.h" 33 #include "codegen-inl.h"
34 #include "assembler-x64.h" 34 #include "assembler-x64.h"
35 #include "macro-assembler-x64.h" 35 #include "macro-assembler-x64.h"
36 #include "serialize.h" 36 #include "serialize.h"
37 #include "debug.h" 37 #include "debug.h"
38 #include "heap.h" 38 #include "heap.h"
39 39
40 namespace v8 { 40 namespace v8 {
41 namespace internal { 41 namespace internal {
42 42
43 MacroAssembler::MacroAssembler(void* buffer, int size) 43 MacroAssembler::MacroAssembler(Isolate* arg_isolate, void* buffer, int size)
44 : Assembler(buffer, size), 44 : Assembler(arg_isolate, buffer, size),
45 generating_stub_(false), 45 generating_stub_(false),
46 allow_stub_calls_(true), 46 allow_stub_calls_(true),
47 root_array_available_(true), 47 root_array_available_(true) {
48 code_object_(isolate()->heap()->undefined_value()) { 48 if (isolate() != NULL) {
49 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(),
50 isolate());
51 }
49 } 52 }
50 53
51 54
52 static intptr_t RootRegisterDelta(ExternalReference other, Isolate* isolate) { 55 static intptr_t RootRegisterDelta(ExternalReference other, Isolate* isolate) {
53 Address roots_register_value = kRootRegisterBias + 56 Address roots_register_value = kRootRegisterBias +
54 reinterpret_cast<Address>(isolate->heap()->roots_address()); 57 reinterpret_cast<Address>(isolate->heap()->roots_address());
55 intptr_t delta = other.address() - roots_register_value; 58 intptr_t delta = other.address() - roots_register_value;
56 return delta; 59 return delta;
57 } 60 }
58 61
(...skipping 2785 matching lines...) Expand 10 before | Expand all | Expand 10 after
2844 return num_arguments - kRegisterPassedArguments; 2847 return num_arguments - kRegisterPassedArguments;
2845 #endif 2848 #endif
2846 } 2849 }
2847 2850
2848 2851
2849 void MacroAssembler::PrepareCallCFunction(int num_arguments) { 2852 void MacroAssembler::PrepareCallCFunction(int num_arguments) {
2850 int frame_alignment = OS::ActivationFrameAlignment(); 2853 int frame_alignment = OS::ActivationFrameAlignment();
2851 ASSERT(frame_alignment != 0); 2854 ASSERT(frame_alignment != 0);
2852 ASSERT(num_arguments >= 0); 2855 ASSERT(num_arguments >= 0);
2853 2856
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. 2857 // Make stack end at alignment and allocate space for arguments and old rsp.
2858 movq(kScratchRegister, rsp); 2858 movq(kScratchRegister, rsp);
2859 ASSERT(IsPowerOf2(frame_alignment)); 2859 ASSERT(IsPowerOf2(frame_alignment));
2860 int argument_slots_on_stack = 2860 int argument_slots_on_stack =
2861 ArgumentStackSlotsForCFunctionCall(num_arguments); 2861 ArgumentStackSlotsForCFunctionCall(num_arguments);
2862 subq(rsp, Immediate((argument_slots_on_stack + 1) * kPointerSize)); 2862 subq(rsp, Immediate((argument_slots_on_stack + 1) * kPointerSize));
2863 and_(rsp, Immediate(-frame_alignment)); 2863 and_(rsp, Immediate(-frame_alignment));
2864 movq(Operand(rsp, argument_slots_on_stack * kPointerSize), kScratchRegister); 2864 movq(Operand(rsp, argument_slots_on_stack * kPointerSize), kScratchRegister);
2865 } 2865 }
2866 2866
2867 2867
2868 void MacroAssembler::CallCFunction(ExternalReference function, 2868 void MacroAssembler::CallCFunction(ExternalReference function,
2869 int num_arguments) { 2869 int num_arguments) {
2870 LoadAddress(rax, function); 2870 LoadAddress(rax, function);
2871 CallCFunction(rax, num_arguments); 2871 CallCFunction(rax, num_arguments);
2872 } 2872 }
2873 2873
2874 2874
2875 void MacroAssembler::CallCFunction(Register function, int num_arguments) { 2875 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. 2876 // Check stack alignment.
2897 if (emit_debug_code()) { 2877 if (emit_debug_code()) {
2898 CheckStackAlignment(); 2878 CheckStackAlignment();
2899 } 2879 }
2900 2880
2901 call(function); 2881 call(function);
2902 ASSERT(OS::ActivationFrameAlignment() != 0); 2882 ASSERT(OS::ActivationFrameAlignment() != 0);
2903 ASSERT(num_arguments >= 0); 2883 ASSERT(num_arguments >= 0);
2904 num_arguments += 1;
2905 int argument_slots_on_stack = 2884 int argument_slots_on_stack =
2906 ArgumentStackSlotsForCFunctionCall(num_arguments); 2885 ArgumentStackSlotsForCFunctionCall(num_arguments);
2907 movq(rsp, Operand(rsp, argument_slots_on_stack * kPointerSize)); 2886 movq(rsp, Operand(rsp, argument_slots_on_stack * kPointerSize));
2908 } 2887 }
2909 2888
2910 2889
2911 CodePatcher::CodePatcher(byte* address, int size) 2890 CodePatcher::CodePatcher(byte* address, int size)
2912 : address_(address), size_(size), masm_(address, size + Assembler::kGap) { 2891 : address_(address),
2892 size_(size),
2893 masm_(Isolate::Current(), address, size + Assembler::kGap) {
2913 // Create a new macro assembler pointing to the address of the code to patch. 2894 // 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 2895 // The size is adjusted with kGap on order for the assembler to generate size
2915 // bytes of instructions without failing with buffer size constraints. 2896 // bytes of instructions without failing with buffer size constraints.
2916 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2897 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2917 } 2898 }
2918 2899
2919 2900
2920 CodePatcher::~CodePatcher() { 2901 CodePatcher::~CodePatcher() {
2921 // Indicate that code has changed. 2902 // Indicate that code has changed.
2922 CPU::FlushICache(address_, size_); 2903 CPU::FlushICache(address_, size_);
2923 2904
2924 // Check that the code was patched as expected. 2905 // Check that the code was patched as expected.
2925 ASSERT(masm_.pc_ == address_ + size_); 2906 ASSERT(masm_.pc_ == address_ + size_);
2926 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 2907 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
2927 } 2908 }
2928 2909
2929 } } // namespace v8::internal 2910 } } // namespace v8::internal
2930 2911
2931 #endif // V8_TARGET_ARCH_X64 2912 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.h ('k') | src/x64/regexp-macro-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698