| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 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 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2001 { | 2001 { |
| 2002 Label no_interpreter_frame; | 2002 Label no_interpreter_frame; |
| 2003 __ LoadP(scratch3, MemOperand(fp, StandardFrameConstants::kMarkerOffset)); | 2003 __ LoadP(scratch3, MemOperand(fp, StandardFrameConstants::kMarkerOffset)); |
| 2004 __ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::STUB), r0); | 2004 __ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::STUB), r0); |
| 2005 __ bne(&no_interpreter_frame); | 2005 __ bne(&no_interpreter_frame); |
| 2006 __ LoadP(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 2006 __ LoadP(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 2007 __ bind(&no_interpreter_frame); | 2007 __ bind(&no_interpreter_frame); |
| 2008 } | 2008 } |
| 2009 | 2009 |
| 2010 // Check if next frame is an arguments adaptor frame. | 2010 // Check if next frame is an arguments adaptor frame. |
| 2011 Register caller_args_count_reg = scratch1; |
| 2011 Label no_arguments_adaptor, formal_parameter_count_loaded; | 2012 Label no_arguments_adaptor, formal_parameter_count_loaded; |
| 2012 __ LoadP(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 2013 __ LoadP(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 2013 __ LoadP(scratch3, | 2014 __ LoadP(scratch3, |
| 2014 MemOperand(scratch2, StandardFrameConstants::kContextOffset)); | 2015 MemOperand(scratch2, StandardFrameConstants::kContextOffset)); |
| 2015 __ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); | 2016 __ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
| 2016 __ bne(&no_arguments_adaptor); | 2017 __ bne(&no_arguments_adaptor); |
| 2017 | 2018 |
| 2018 // Drop arguments adaptor frame and load arguments count. | 2019 // Drop current frame and load arguments count from arguments adaptor frame. |
| 2019 __ mr(fp, scratch2); | 2020 __ mr(fp, scratch2); |
| 2020 __ LoadP(scratch1, | 2021 __ LoadP(caller_args_count_reg, |
| 2021 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 2022 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 2022 __ SmiUntag(scratch1); | 2023 __ SmiUntag(caller_args_count_reg); |
| 2023 __ b(&formal_parameter_count_loaded); | 2024 __ b(&formal_parameter_count_loaded); |
| 2024 | 2025 |
| 2025 __ bind(&no_arguments_adaptor); | 2026 __ bind(&no_arguments_adaptor); |
| 2026 // Load caller's formal parameter count | 2027 // Load caller's formal parameter count |
| 2027 __ LoadP(scratch1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 2028 __ LoadP(scratch1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 2028 __ LoadP(scratch1, | 2029 __ LoadP(scratch1, |
| 2029 FieldMemOperand(scratch1, JSFunction::kSharedFunctionInfoOffset)); | 2030 FieldMemOperand(scratch1, JSFunction::kSharedFunctionInfoOffset)); |
| 2030 __ LoadWordArith( | 2031 __ LoadWordArith( |
| 2031 scratch1, FieldMemOperand( | 2032 caller_args_count_reg, |
| 2032 scratch1, SharedFunctionInfo::kFormalParameterCountOffset)); | 2033 FieldMemOperand(scratch1, |
| 2034 SharedFunctionInfo::kFormalParameterCountOffset)); |
| 2033 #if !V8_TARGET_ARCH_PPC64 | 2035 #if !V8_TARGET_ARCH_PPC64 |
| 2034 __ SmiUntag(scratch1); | 2036 __ SmiUntag(caller_args_count_reg); |
| 2035 #endif | 2037 #endif |
| 2036 | 2038 |
| 2037 __ bind(&formal_parameter_count_loaded); | 2039 __ bind(&formal_parameter_count_loaded); |
| 2038 | 2040 |
| 2039 // Calculate the end of destination area where we will put the arguments | 2041 ParameterCount callee_args_count(args_reg); |
| 2040 // after we drop current frame. We add kPointerSize to count the receiver | 2042 __ PrepareForTailCall(callee_args_count, caller_args_count_reg, scratch2, |
| 2041 // argument which is not included into formal parameters count. | 2043 scratch3); |
| 2042 Register dst_reg = scratch2; | |
| 2043 __ ShiftLeftImm(dst_reg, scratch1, Operand(kPointerSizeLog2)); | |
| 2044 __ add(dst_reg, fp, dst_reg); | |
| 2045 __ addi(dst_reg, dst_reg, | |
| 2046 Operand(StandardFrameConstants::kCallerSPOffset + kPointerSize)); | |
| 2047 | |
| 2048 Register src_reg = scratch1; | |
| 2049 __ ShiftLeftImm(src_reg, args_reg, Operand(kPointerSizeLog2)); | |
| 2050 __ add(src_reg, sp, src_reg); | |
| 2051 // Count receiver argument as well (not included in args_reg). | |
| 2052 __ addi(src_reg, src_reg, Operand(kPointerSize)); | |
| 2053 | |
| 2054 if (FLAG_debug_code) { | |
| 2055 __ cmpl(src_reg, dst_reg); | |
| 2056 __ Check(lt, kStackAccessBelowStackPointer); | |
| 2057 } | |
| 2058 | |
| 2059 // Restore caller's frame pointer and return address now as they will be | |
| 2060 // overwritten by the copying loop. | |
| 2061 __ RestoreFrameStateForTailCall(); | |
| 2062 | |
| 2063 // Now copy callee arguments to the caller frame going backwards to avoid | |
| 2064 // callee arguments corruption (source and destination areas could overlap). | |
| 2065 | |
| 2066 // Both src_reg and dst_reg are pointing to the word after the one to copy, | |
| 2067 // so they must be pre-decremented in the loop. | |
| 2068 Register tmp_reg = scratch3; | |
| 2069 Label loop; | |
| 2070 __ addi(tmp_reg, args_reg, Operand(1)); // +1 for receiver | |
| 2071 __ mtctr(tmp_reg); | |
| 2072 __ bind(&loop); | |
| 2073 __ LoadPU(tmp_reg, MemOperand(src_reg, -kPointerSize)); | |
| 2074 __ StorePU(tmp_reg, MemOperand(dst_reg, -kPointerSize)); | |
| 2075 __ bdnz(&loop); | |
| 2076 | |
| 2077 // Leave current frame. | |
| 2078 __ mr(sp, dst_reg); | |
| 2079 | |
| 2080 __ bind(&done); | 2044 __ bind(&done); |
| 2081 } | 2045 } |
| 2082 } // namespace | 2046 } // namespace |
| 2083 | 2047 |
| 2084 // static | 2048 // static |
| 2085 void Builtins::Generate_CallFunction(MacroAssembler* masm, | 2049 void Builtins::Generate_CallFunction(MacroAssembler* masm, |
| 2086 ConvertReceiverMode mode, | 2050 ConvertReceiverMode mode, |
| 2087 TailCallMode tail_call_mode) { | 2051 TailCallMode tail_call_mode) { |
| 2088 // ----------- S t a t e ------------- | 2052 // ----------- S t a t e ------------- |
| 2089 // -- r3 : the number of arguments (not including the receiver) | 2053 // -- r3 : the number of arguments (not including the receiver) |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2651 __ bkpt(0); | 2615 __ bkpt(0); |
| 2652 } | 2616 } |
| 2653 } | 2617 } |
| 2654 | 2618 |
| 2655 | 2619 |
| 2656 #undef __ | 2620 #undef __ |
| 2657 } // namespace internal | 2621 } // namespace internal |
| 2658 } // namespace v8 | 2622 } // namespace v8 |
| 2659 | 2623 |
| 2660 #endif // V8_TARGET_ARCH_PPC | 2624 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |