OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2693 __ test(eax, Operand(eax)); | 2693 __ test(eax, Operand(eax)); |
2694 __ j(condition, &true_value, Label::kNear); | 2694 __ j(condition, &true_value, Label::kNear); |
2695 __ mov(ToRegister(instr->result()), factory()->false_value()); | 2695 __ mov(ToRegister(instr->result()), factory()->false_value()); |
2696 __ jmp(&done, Label::kNear); | 2696 __ jmp(&done, Label::kNear); |
2697 __ bind(&true_value); | 2697 __ bind(&true_value); |
2698 __ mov(ToRegister(instr->result()), factory()->true_value()); | 2698 __ mov(ToRegister(instr->result()), factory()->true_value()); |
2699 __ bind(&done); | 2699 __ bind(&done); |
2700 } | 2700 } |
2701 | 2701 |
2702 | 2702 |
| 2703 void LCodeGen::EmitReturn(LReturn* instr, bool dynamic_frame_alignment) { |
| 2704 int extra_value_count = dynamic_frame_alignment ? 2 : 1; |
| 2705 |
| 2706 if (instr->has_constant_parameter_count()) { |
| 2707 int parameter_count = ToInteger32(instr->constant_parameter_count()); |
| 2708 if (dynamic_frame_alignment && FLAG_debug_code) { |
| 2709 __ cmp(Operand(esp, |
| 2710 (parameter_count + extra_value_count) * kPointerSize), |
| 2711 Immediate(kAlignmentZapValue)); |
| 2712 __ Assert(equal, "expected alignment marker"); |
| 2713 } |
| 2714 __ Ret((parameter_count + extra_value_count) * kPointerSize, ecx); |
| 2715 } else { |
| 2716 Register reg = ToRegister(instr->parameter_count()); |
| 2717 Register return_addr_reg = reg.is(ecx) ? ebx : ecx; |
| 2718 if (dynamic_frame_alignment && FLAG_debug_code) { |
| 2719 ASSERT(extra_value_count == 2); |
| 2720 __ cmp(Operand(esp, reg, times_pointer_size, |
| 2721 extra_value_count * kPointerSize), |
| 2722 Immediate(kAlignmentZapValue)); |
| 2723 __ Assert(equal, "expected alignment marker"); |
| 2724 } |
| 2725 |
| 2726 // emit code to restore stack based on instr->parameter_count() |
| 2727 __ pop(return_addr_reg); // save return address |
| 2728 if (dynamic_frame_alignment) { |
| 2729 __ inc(reg); // 1 more for alignment |
| 2730 } |
| 2731 __ shl(reg, kPointerSizeLog2); |
| 2732 __ add(esp, reg); |
| 2733 __ jmp(return_addr_reg); |
| 2734 } |
| 2735 } |
| 2736 |
| 2737 |
2703 void LCodeGen::DoReturn(LReturn* instr) { | 2738 void LCodeGen::DoReturn(LReturn* instr) { |
2704 if (FLAG_trace && info()->IsOptimizing()) { | 2739 if (FLAG_trace && info()->IsOptimizing()) { |
2705 // Preserve the return value on the stack and rely on the runtime call | 2740 // Preserve the return value on the stack and rely on the runtime call |
2706 // to return the value in the same register. We're leaving the code | 2741 // to return the value in the same register. We're leaving the code |
2707 // managed by the register allocator and tearing down the frame, it's | 2742 // managed by the register allocator and tearing down the frame, it's |
2708 // safe to write to the context register. | 2743 // safe to write to the context register. |
2709 __ push(eax); | 2744 __ push(eax); |
2710 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2745 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2711 __ CallRuntime(Runtime::kTraceExit, 1); | 2746 __ CallRuntime(Runtime::kTraceExit, 1); |
2712 } | 2747 } |
(...skipping 16 matching lines...) Expand all Loading... |
2729 JavaScriptFrameConstants::kDynamicAlignmentStateOffset)); | 2764 JavaScriptFrameConstants::kDynamicAlignmentStateOffset)); |
2730 } | 2765 } |
2731 if (NeedsEagerFrame()) { | 2766 if (NeedsEagerFrame()) { |
2732 __ mov(esp, ebp); | 2767 __ mov(esp, ebp); |
2733 __ pop(ebp); | 2768 __ pop(ebp); |
2734 } | 2769 } |
2735 if (dynamic_frame_alignment_) { | 2770 if (dynamic_frame_alignment_) { |
2736 Label no_padding; | 2771 Label no_padding; |
2737 __ cmp(edx, Immediate(kNoAlignmentPadding)); | 2772 __ cmp(edx, Immediate(kNoAlignmentPadding)); |
2738 __ j(equal, &no_padding); | 2773 __ j(equal, &no_padding); |
2739 if (FLAG_debug_code) { | 2774 |
2740 __ cmp(Operand(esp, (GetParameterCount() + 2) * kPointerSize), | 2775 EmitReturn(instr, true); |
2741 Immediate(kAlignmentZapValue)); | |
2742 __ Assert(equal, "expected alignment marker"); | |
2743 } | |
2744 __ Ret((GetParameterCount() + 2) * kPointerSize, ecx); | |
2745 __ bind(&no_padding); | 2776 __ bind(&no_padding); |
2746 } | 2777 } |
2747 if (info()->IsStub()) { | 2778 |
2748 __ Ret(); | 2779 EmitReturn(instr, false); |
2749 } else { | |
2750 __ Ret((GetParameterCount() + 1) * kPointerSize, ecx); | |
2751 } | |
2752 } | 2780 } |
2753 | 2781 |
2754 | 2782 |
2755 void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { | 2783 void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { |
2756 Register result = ToRegister(instr->result()); | 2784 Register result = ToRegister(instr->result()); |
2757 __ mov(result, Operand::Cell(instr->hydrogen()->cell())); | 2785 __ mov(result, Operand::Cell(instr->hydrogen()->cell())); |
2758 if (instr->hydrogen()->RequiresHoleCheck()) { | 2786 if (instr->hydrogen()->RequiresHoleCheck()) { |
2759 __ cmp(result, factory()->the_hole_value()); | 2787 __ cmp(result, factory()->the_hole_value()); |
2760 DeoptimizeIf(equal, instr->environment()); | 2788 DeoptimizeIf(equal, instr->environment()); |
2761 } | 2789 } |
(...skipping 3497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6259 FixedArray::kHeaderSize - kPointerSize)); | 6287 FixedArray::kHeaderSize - kPointerSize)); |
6260 __ bind(&done); | 6288 __ bind(&done); |
6261 } | 6289 } |
6262 | 6290 |
6263 | 6291 |
6264 #undef __ | 6292 #undef __ |
6265 | 6293 |
6266 } } // namespace v8::internal | 6294 } } // namespace v8::internal |
6267 | 6295 |
6268 #endif // V8_TARGET_ARCH_IA32 | 6296 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |