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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 { | 1900 { |
1901 Label no_interpreter_frame; | 1901 Label no_interpreter_frame; |
1902 __ cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset), | 1902 __ cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset), |
1903 Immediate(Smi::FromInt(StackFrame::STUB))); | 1903 Immediate(Smi::FromInt(StackFrame::STUB))); |
1904 __ j(not_equal, &no_interpreter_frame, Label::kNear); | 1904 __ j(not_equal, &no_interpreter_frame, Label::kNear); |
1905 __ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 1905 __ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
1906 __ bind(&no_interpreter_frame); | 1906 __ bind(&no_interpreter_frame); |
1907 } | 1907 } |
1908 | 1908 |
1909 // Check if next frame is an arguments adaptor frame. | 1909 // Check if next frame is an arguments adaptor frame. |
| 1910 Register caller_args_count_reg = scratch1; |
1910 Label no_arguments_adaptor, formal_parameter_count_loaded; | 1911 Label no_arguments_adaptor, formal_parameter_count_loaded; |
1911 __ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 1912 __ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
1912 __ cmp(Operand(scratch2, StandardFrameConstants::kContextOffset), | 1913 __ cmp(Operand(scratch2, StandardFrameConstants::kContextOffset), |
1913 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1914 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
1914 __ j(not_equal, &no_arguments_adaptor, Label::kNear); | 1915 __ j(not_equal, &no_arguments_adaptor, Label::kNear); |
1915 | 1916 |
1916 // Drop arguments adaptor frame and load arguments count. | 1917 // Drop current frame and load arguments count from arguments adaptor frame. |
1917 __ mov(ebp, scratch2); | 1918 __ mov(ebp, scratch2); |
1918 __ mov(scratch1, Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 1919 __ mov(caller_args_count_reg, |
1919 __ SmiUntag(scratch1); | 1920 Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 1921 __ SmiUntag(caller_args_count_reg); |
1920 __ jmp(&formal_parameter_count_loaded, Label::kNear); | 1922 __ jmp(&formal_parameter_count_loaded, Label::kNear); |
1921 | 1923 |
1922 __ bind(&no_arguments_adaptor); | 1924 __ bind(&no_arguments_adaptor); |
1923 // Load caller's formal parameter count | 1925 // Load caller's formal parameter count |
1924 __ mov(scratch1, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1926 __ mov(scratch1, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1925 __ mov(scratch1, | 1927 __ mov(scratch1, |
1926 FieldOperand(scratch1, JSFunction::kSharedFunctionInfoOffset)); | 1928 FieldOperand(scratch1, JSFunction::kSharedFunctionInfoOffset)); |
1927 __ mov( | 1929 __ mov( |
1928 scratch1, | 1930 caller_args_count_reg, |
1929 FieldOperand(scratch1, SharedFunctionInfo::kFormalParameterCountOffset)); | 1931 FieldOperand(scratch1, SharedFunctionInfo::kFormalParameterCountOffset)); |
1930 __ SmiUntag(scratch1); | 1932 __ SmiUntag(caller_args_count_reg); |
1931 | 1933 |
1932 __ bind(&formal_parameter_count_loaded); | 1934 __ bind(&formal_parameter_count_loaded); |
1933 | 1935 |
1934 // Calculate the destination address where we will put the return address | 1936 ParameterCount callee_args_count(args_reg); |
1935 // after we drop current frame. | 1937 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, |
1936 Register new_sp_reg = scratch2; | 1938 scratch3, ReturnAddressState::kOnStack); |
1937 __ sub(scratch1, args_reg); | |
1938 __ lea(new_sp_reg, Operand(ebp, scratch1, times_pointer_size, | |
1939 StandardFrameConstants::kCallerPCOffset)); | |
1940 | |
1941 if (FLAG_debug_code) { | |
1942 __ cmp(esp, new_sp_reg); | |
1943 __ Check(below, kStackAccessBelowStackPointer); | |
1944 } | |
1945 | |
1946 // Copy receiver and return address as well. | |
1947 Register count_reg = scratch1; | |
1948 __ lea(count_reg, Operand(args_reg, 2)); | |
1949 | |
1950 // Copy return address from caller's frame to current frame's return address | |
1951 // to avoid its trashing and let the following loop copy it to the right | |
1952 // place. | |
1953 Register tmp_reg = scratch3; | |
1954 __ mov(tmp_reg, Operand(ebp, StandardFrameConstants::kCallerPCOffset)); | |
1955 __ mov(Operand(esp, 0), tmp_reg); | |
1956 | |
1957 // Restore caller's frame pointer now as it could be overwritten by | |
1958 // the copying loop. | |
1959 __ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | |
1960 | |
1961 Operand src(esp, count_reg, times_pointer_size, 0); | |
1962 Operand dst(new_sp_reg, count_reg, times_pointer_size, 0); | |
1963 | |
1964 // Now copy callee arguments to the caller frame going backwards to avoid | |
1965 // callee arguments corruption (source and destination areas could overlap). | |
1966 Label loop, entry; | |
1967 __ jmp(&entry, Label::kNear); | |
1968 __ bind(&loop); | |
1969 __ dec(count_reg); | |
1970 __ mov(tmp_reg, src); | |
1971 __ mov(dst, tmp_reg); | |
1972 __ bind(&entry); | |
1973 __ cmp(count_reg, Immediate(0)); | |
1974 __ j(not_equal, &loop, Label::kNear); | |
1975 | |
1976 // Leave current frame. | |
1977 __ mov(esp, new_sp_reg); | |
1978 | |
1979 __ bind(&done); | 1939 __ bind(&done); |
1980 } | 1940 } |
1981 } // namespace | 1941 } // namespace |
1982 | 1942 |
1983 // static | 1943 // static |
1984 void Builtins::Generate_CallFunction(MacroAssembler* masm, | 1944 void Builtins::Generate_CallFunction(MacroAssembler* masm, |
1985 ConvertReceiverMode mode, | 1945 ConvertReceiverMode mode, |
1986 TailCallMode tail_call_mode) { | 1946 TailCallMode tail_call_mode) { |
1987 // ----------- S t a t e ------------- | 1947 // ----------- S t a t e ------------- |
1988 // -- eax : the number of arguments (not including the receiver) | 1948 // -- eax : the number of arguments (not including the receiver) |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2688 | 2648 |
2689 __ bind(&ok); | 2649 __ bind(&ok); |
2690 __ ret(0); | 2650 __ ret(0); |
2691 } | 2651 } |
2692 | 2652 |
2693 #undef __ | 2653 #undef __ |
2694 } // namespace internal | 2654 } // namespace internal |
2695 } // namespace v8 | 2655 } // namespace v8 |
2696 | 2656 |
2697 #endif // V8_TARGET_ARCH_X87 | 2657 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |