OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 { | 1874 { |
1875 Label no_interpreter_frame; | 1875 Label no_interpreter_frame; |
1876 __ cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset), | 1876 __ cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset), |
1877 Immediate(Smi::FromInt(StackFrame::STUB))); | 1877 Immediate(Smi::FromInt(StackFrame::STUB))); |
1878 __ j(not_equal, &no_interpreter_frame, Label::kNear); | 1878 __ j(not_equal, &no_interpreter_frame, Label::kNear); |
1879 __ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 1879 __ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
1880 __ bind(&no_interpreter_frame); | 1880 __ bind(&no_interpreter_frame); |
1881 } | 1881 } |
1882 | 1882 |
1883 // Check if next frame is an arguments adaptor frame. | 1883 // Check if next frame is an arguments adaptor frame. |
| 1884 Register caller_args_count_reg = scratch1; |
1884 Label no_arguments_adaptor, formal_parameter_count_loaded; | 1885 Label no_arguments_adaptor, formal_parameter_count_loaded; |
1885 __ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 1886 __ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
1886 __ cmp(Operand(scratch2, StandardFrameConstants::kContextOffset), | 1887 __ cmp(Operand(scratch2, StandardFrameConstants::kContextOffset), |
1887 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1888 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
1888 __ j(not_equal, &no_arguments_adaptor, Label::kNear); | 1889 __ j(not_equal, &no_arguments_adaptor, Label::kNear); |
1889 | 1890 |
1890 // Drop arguments adaptor frame and load arguments count. | 1891 // Drop current frame and load arguments count from arguments adaptor frame. |
1891 __ mov(ebp, scratch2); | 1892 __ mov(ebp, scratch2); |
1892 __ mov(scratch1, Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 1893 __ mov(caller_args_count_reg, |
1893 __ SmiUntag(scratch1); | 1894 Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 1895 __ SmiUntag(caller_args_count_reg); |
1894 __ jmp(&formal_parameter_count_loaded, Label::kNear); | 1896 __ jmp(&formal_parameter_count_loaded, Label::kNear); |
1895 | 1897 |
1896 __ bind(&no_arguments_adaptor); | 1898 __ bind(&no_arguments_adaptor); |
1897 // Load caller's formal parameter count | 1899 // Load caller's formal parameter count |
1898 __ mov(scratch1, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1900 __ mov(scratch1, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1899 __ mov(scratch1, | 1901 __ mov(scratch1, |
1900 FieldOperand(scratch1, JSFunction::kSharedFunctionInfoOffset)); | 1902 FieldOperand(scratch1, JSFunction::kSharedFunctionInfoOffset)); |
1901 __ mov( | 1903 __ mov( |
1902 scratch1, | 1904 caller_args_count_reg, |
1903 FieldOperand(scratch1, SharedFunctionInfo::kFormalParameterCountOffset)); | 1905 FieldOperand(scratch1, SharedFunctionInfo::kFormalParameterCountOffset)); |
1904 __ SmiUntag(scratch1); | 1906 __ SmiUntag(caller_args_count_reg); |
1905 | 1907 |
1906 __ bind(&formal_parameter_count_loaded); | 1908 __ bind(&formal_parameter_count_loaded); |
1907 | 1909 |
1908 // Calculate the destination address where we will put the return address | 1910 ParameterCount callee_args_count(args_reg); |
1909 // after we drop current frame. | 1911 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, |
1910 Register new_sp_reg = scratch2; | 1912 scratch3, ReturnAddressState::kOnStack); |
1911 __ sub(scratch1, args_reg); | |
1912 __ lea(new_sp_reg, Operand(ebp, scratch1, times_pointer_size, | |
1913 StandardFrameConstants::kCallerPCOffset)); | |
1914 | |
1915 if (FLAG_debug_code) { | |
1916 __ cmp(esp, new_sp_reg); | |
1917 __ Check(below, kStackAccessBelowStackPointer); | |
1918 } | |
1919 | |
1920 // Copy receiver and return address as well. | |
1921 Register count_reg = scratch1; | |
1922 __ lea(count_reg, Operand(args_reg, 2)); | |
1923 | |
1924 // Copy return address from caller's frame to current frame's return address | |
1925 // to avoid its trashing and let the following loop copy it to the right | |
1926 // place. | |
1927 Register tmp_reg = scratch3; | |
1928 __ mov(tmp_reg, Operand(ebp, StandardFrameConstants::kCallerPCOffset)); | |
1929 __ mov(Operand(esp, 0), tmp_reg); | |
1930 | |
1931 // Restore caller's frame pointer now as it could be overwritten by | |
1932 // the copying loop. | |
1933 __ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | |
1934 | |
1935 Operand src(esp, count_reg, times_pointer_size, 0); | |
1936 Operand dst(new_sp_reg, count_reg, times_pointer_size, 0); | |
1937 | |
1938 // Now copy callee arguments to the caller frame going backwards to avoid | |
1939 // callee arguments corruption (source and destination areas could overlap). | |
1940 Label loop, entry; | |
1941 __ jmp(&entry, Label::kNear); | |
1942 __ bind(&loop); | |
1943 __ dec(count_reg); | |
1944 __ mov(tmp_reg, src); | |
1945 __ mov(dst, tmp_reg); | |
1946 __ bind(&entry); | |
1947 __ cmp(count_reg, Immediate(0)); | |
1948 __ j(not_equal, &loop, Label::kNear); | |
1949 | |
1950 // Leave current frame. | |
1951 __ mov(esp, new_sp_reg); | |
1952 | |
1953 __ bind(&done); | 1913 __ bind(&done); |
1954 } | 1914 } |
1955 } // namespace | 1915 } // namespace |
1956 | 1916 |
1957 // static | 1917 // static |
1958 void Builtins::Generate_CallFunction(MacroAssembler* masm, | 1918 void Builtins::Generate_CallFunction(MacroAssembler* masm, |
1959 ConvertReceiverMode mode, | 1919 ConvertReceiverMode mode, |
1960 TailCallMode tail_call_mode) { | 1920 TailCallMode tail_call_mode) { |
1961 // ----------- S t a t e ------------- | 1921 // ----------- S t a t e ------------- |
1962 // -- eax : the number of arguments (not including the receiver) | 1922 // -- eax : the number of arguments (not including the receiver) |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2662 | 2622 |
2663 __ bind(&ok); | 2623 __ bind(&ok); |
2664 __ ret(0); | 2624 __ ret(0); |
2665 } | 2625 } |
2666 | 2626 |
2667 #undef __ | 2627 #undef __ |
2668 } // namespace internal | 2628 } // namespace internal |
2669 } // namespace v8 | 2629 } // namespace v8 |
2670 | 2630 |
2671 #endif // V8_TARGET_ARCH_IA32 | 2631 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |