| 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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
| 6 | 6 |
| 7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
| 8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.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 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1973 { | 1973 { |
| 1974 Label no_interpreter_frame; | 1974 Label no_interpreter_frame; |
| 1975 __ lw(scratch3, MemOperand(fp, StandardFrameConstants::kMarkerOffset)); | 1975 __ lw(scratch3, MemOperand(fp, StandardFrameConstants::kMarkerOffset)); |
| 1976 __ Branch(&no_interpreter_frame, ne, scratch3, | 1976 __ Branch(&no_interpreter_frame, ne, scratch3, |
| 1977 Operand(Smi::FromInt(StackFrame::STUB))); | 1977 Operand(Smi::FromInt(StackFrame::STUB))); |
| 1978 __ lw(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 1978 __ lw(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 1979 __ bind(&no_interpreter_frame); | 1979 __ bind(&no_interpreter_frame); |
| 1980 } | 1980 } |
| 1981 | 1981 |
| 1982 // Check if next frame is an arguments adaptor frame. | 1982 // Check if next frame is an arguments adaptor frame. |
| 1983 Register caller_args_count_reg = scratch1; |
| 1983 Label no_arguments_adaptor, formal_parameter_count_loaded; | 1984 Label no_arguments_adaptor, formal_parameter_count_loaded; |
| 1984 __ lw(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 1985 __ lw(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 1985 __ lw(scratch3, MemOperand(scratch2, StandardFrameConstants::kContextOffset)); | 1986 __ lw(scratch3, MemOperand(scratch2, StandardFrameConstants::kContextOffset)); |
| 1986 __ Branch(&no_arguments_adaptor, ne, scratch3, | 1987 __ Branch(&no_arguments_adaptor, ne, scratch3, |
| 1987 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1988 Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
| 1988 | 1989 |
| 1989 // Drop arguments adaptor frame and load arguments count. | 1990 // Drop current frame and load arguments count from arguments adaptor frame. |
| 1990 __ mov(fp, scratch2); | 1991 __ mov(fp, scratch2); |
| 1991 __ lw(scratch1, | 1992 __ lw(caller_args_count_reg, |
| 1992 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 1993 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 1993 __ SmiUntag(scratch1); | 1994 __ SmiUntag(caller_args_count_reg); |
| 1994 __ Branch(&formal_parameter_count_loaded); | 1995 __ Branch(&formal_parameter_count_loaded); |
| 1995 | 1996 |
| 1996 __ bind(&no_arguments_adaptor); | 1997 __ bind(&no_arguments_adaptor); |
| 1997 // Load caller's formal parameter count | 1998 // Load caller's formal parameter count |
| 1998 __ lw(scratch1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1999 __ lw(scratch1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1999 __ lw(scratch1, | 2000 __ lw(scratch1, |
| 2000 FieldMemOperand(scratch1, JSFunction::kSharedFunctionInfoOffset)); | 2001 FieldMemOperand(scratch1, JSFunction::kSharedFunctionInfoOffset)); |
| 2001 __ lw(scratch1, | 2002 __ lw(caller_args_count_reg, |
| 2002 FieldMemOperand(scratch1, | 2003 FieldMemOperand(scratch1, |
| 2003 SharedFunctionInfo::kFormalParameterCountOffset)); | 2004 SharedFunctionInfo::kFormalParameterCountOffset)); |
| 2004 __ SmiUntag(scratch1); | 2005 __ SmiUntag(caller_args_count_reg); |
| 2005 | 2006 |
| 2006 __ bind(&formal_parameter_count_loaded); | 2007 __ bind(&formal_parameter_count_loaded); |
| 2007 | 2008 |
| 2008 // Calculate the end of destination area where we will put the arguments | 2009 ParameterCount callee_args_count(args_reg); |
| 2009 // after we drop current frame. We add kPointerSize to count the receiver | 2010 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, |
| 2010 // argument which is not included into formal parameters count. | 2011 scratch3); |
| 2011 Register dst_reg = scratch2; | |
| 2012 __ Lsa(dst_reg, fp, scratch1, kPointerSizeLog2); | |
| 2013 __ Addu(dst_reg, dst_reg, | |
| 2014 Operand(StandardFrameConstants::kCallerSPOffset + kPointerSize)); | |
| 2015 | |
| 2016 Register src_reg = scratch1; | |
| 2017 __ Lsa(src_reg, sp, args_reg, kPointerSizeLog2); | |
| 2018 // Count receiver argument as well (not included in args_reg). | |
| 2019 __ Addu(src_reg, src_reg, Operand(kPointerSize)); | |
| 2020 | |
| 2021 if (FLAG_debug_code) { | |
| 2022 __ Check(lo, kStackAccessBelowStackPointer, src_reg, Operand(dst_reg)); | |
| 2023 } | |
| 2024 | |
| 2025 // Restore caller's frame pointer and return address now as they will be | |
| 2026 // overwritten by the copying loop. | |
| 2027 __ lw(ra, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); | |
| 2028 __ lw(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | |
| 2029 | |
| 2030 // Now copy callee arguments to the caller frame going backwards to avoid | |
| 2031 // callee arguments corruption (source and destination areas could overlap). | |
| 2032 | |
| 2033 // Both src_reg and dst_reg are pointing to the word after the one to copy, | |
| 2034 // so they must be pre-decremented in the loop. | |
| 2035 Register tmp_reg = scratch3; | |
| 2036 Label loop, entry; | |
| 2037 __ Branch(&entry); | |
| 2038 __ bind(&loop); | |
| 2039 __ Subu(src_reg, src_reg, Operand(kPointerSize)); | |
| 2040 __ Subu(dst_reg, dst_reg, Operand(kPointerSize)); | |
| 2041 __ lw(tmp_reg, MemOperand(src_reg)); | |
| 2042 __ sw(tmp_reg, MemOperand(dst_reg)); | |
| 2043 __ bind(&entry); | |
| 2044 __ Branch(&loop, ne, sp, Operand(src_reg)); | |
| 2045 | |
| 2046 // Leave current frame. | |
| 2047 __ mov(sp, dst_reg); | |
| 2048 | |
| 2049 __ bind(&done); | 2012 __ bind(&done); |
| 2050 } | 2013 } |
| 2051 } // namespace | 2014 } // namespace |
| 2052 | 2015 |
| 2053 // static | 2016 // static |
| 2054 void Builtins::Generate_CallFunction(MacroAssembler* masm, | 2017 void Builtins::Generate_CallFunction(MacroAssembler* masm, |
| 2055 ConvertReceiverMode mode, | 2018 ConvertReceiverMode mode, |
| 2056 TailCallMode tail_call_mode) { | 2019 TailCallMode tail_call_mode) { |
| 2057 // ----------- S t a t e ------------- | 2020 // ----------- S t a t e ------------- |
| 2058 // -- a0 : the number of arguments (not including the receiver) | 2021 // -- a0 : the number of arguments (not including the receiver) |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2655 } | 2618 } |
| 2656 } | 2619 } |
| 2657 | 2620 |
| 2658 | 2621 |
| 2659 #undef __ | 2622 #undef __ |
| 2660 | 2623 |
| 2661 } // namespace internal | 2624 } // namespace internal |
| 2662 } // namespace v8 | 2625 } // namespace v8 |
| 2663 | 2626 |
| 2664 #endif // V8_TARGET_ARCH_MIPS | 2627 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |