| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 status_ = GENERATING; | 72 status_ = GENERATING; |
| 73 CpuFeatures::Scope scope(SSE2); | 73 CpuFeatures::Scope scope(SSE2); |
| 74 | 74 |
| 75 CodeStub::GenerateFPStubs(); | 75 CodeStub::GenerateFPStubs(); |
| 76 | 76 |
| 77 // Open a frame scope to indicate that there is a frame on the stack. The | 77 // Open a frame scope to indicate that there is a frame on the stack. The |
| 78 // MANUAL indicates that the scope shouldn't actually generate code to set up | 78 // MANUAL indicates that the scope shouldn't actually generate code to set up |
| 79 // the frame (that is done in GeneratePrologue). | 79 // the frame (that is done in GeneratePrologue). |
| 80 FrameScope frame_scope(masm_, StackFrame::MANUAL); | 80 FrameScope frame_scope(masm_, StackFrame::MANUAL); |
| 81 | 81 |
| 82 dynamic_frame_alignment_ = chunk()->num_double_slots() > 2 || | |
| 83 info()->osr_ast_id() != AstNode::kNoNumber; | |
| 84 | |
| 85 return GeneratePrologue() && | 82 return GeneratePrologue() && |
| 86 GenerateBody() && | 83 GenerateBody() && |
| 87 GenerateDeferredCode() && | 84 GenerateDeferredCode() && |
| 88 GenerateSafepointTable(); | 85 GenerateSafepointTable(); |
| 89 } | 86 } |
| 90 | 87 |
| 91 | 88 |
| 92 void LCodeGen::FinishCode(Handle<Code> code) { | 89 void LCodeGen::FinishCode(Handle<Code> code) { |
| 93 ASSERT(is_done()); | 90 ASSERT(is_done()); |
| 94 code->set_stack_slots(GetStackSlotCount()); | 91 code->set_stack_slots(GetStackSlotCount()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 Label ok; | 146 Label ok; |
| 150 __ test(ecx, Operand(ecx)); | 147 __ test(ecx, Operand(ecx)); |
| 151 __ j(zero, &ok, Label::kNear); | 148 __ j(zero, &ok, Label::kNear); |
| 152 // +1 for return address. | 149 // +1 for return address. |
| 153 int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize; | 150 int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize; |
| 154 __ mov(Operand(esp, receiver_offset), | 151 __ mov(Operand(esp, receiver_offset), |
| 155 Immediate(isolate()->factory()->undefined_value())); | 152 Immediate(isolate()->factory()->undefined_value())); |
| 156 __ bind(&ok); | 153 __ bind(&ok); |
| 157 } | 154 } |
| 158 | 155 |
| 159 if (dynamic_frame_alignment_) { | |
| 160 Label do_not_pad, align_loop; | |
| 161 STATIC_ASSERT(kDoubleSize == 2 * kPointerSize); | |
| 162 // Align esp to a multiple of 2 * kPointerSize. | |
| 163 __ test(esp, Immediate(kPointerSize)); | |
| 164 __ j(zero, &do_not_pad, Label::kNear); | |
| 165 __ push(Immediate(0)); | |
| 166 __ mov(ebx, esp); | |
| 167 // Copy arguments, receiver, and return address. | |
| 168 __ mov(ecx, Immediate(scope()->num_parameters() + 2)); | |
| 169 | |
| 170 __ bind(&align_loop); | |
| 171 __ mov(eax, Operand(ebx, 1 * kPointerSize)); | |
| 172 __ mov(Operand(ebx, 0), eax); | |
| 173 __ add(Operand(ebx), Immediate(kPointerSize)); | |
| 174 __ dec(ecx); | |
| 175 __ j(not_zero, &align_loop, Label::kNear); | |
| 176 __ mov(Operand(ebx, 0), | |
| 177 Immediate(isolate()->factory()->frame_alignment_marker())); | |
| 178 | |
| 179 __ bind(&do_not_pad); | |
| 180 } | |
| 181 | |
| 182 __ push(ebp); // Caller's frame pointer. | 156 __ push(ebp); // Caller's frame pointer. |
| 183 __ mov(ebp, esp); | 157 __ mov(ebp, esp); |
| 184 __ push(esi); // Callee's context. | 158 __ push(esi); // Callee's context. |
| 185 __ push(edi); // Callee's JS function. | 159 __ push(edi); // Callee's JS function. |
| 186 | 160 |
| 187 // Reserve space for the stack slots needed by the code. | 161 // Reserve space for the stack slots needed by the code. |
| 188 int slots = GetStackSlotCount(); | 162 int slots = GetStackSlotCount(); |
| 189 if (slots > 0) { | 163 if (slots > 0) { |
| 190 if (FLAG_debug_code) { | 164 if (FLAG_debug_code) { |
| 191 __ mov(Operand(eax), Immediate(slots)); | 165 __ mov(Operand(eax), Immediate(slots)); |
| (...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2118 // Preserve the return value on the stack and rely on the runtime call | 2092 // Preserve the return value on the stack and rely on the runtime call |
| 2119 // to return the value in the same register. We're leaving the code | 2093 // to return the value in the same register. We're leaving the code |
| 2120 // managed by the register allocator and tearing down the frame, it's | 2094 // managed by the register allocator and tearing down the frame, it's |
| 2121 // safe to write to the context register. | 2095 // safe to write to the context register. |
| 2122 __ push(eax); | 2096 __ push(eax); |
| 2123 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2097 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 2124 __ CallRuntime(Runtime::kTraceExit, 1); | 2098 __ CallRuntime(Runtime::kTraceExit, 1); |
| 2125 } | 2099 } |
| 2126 __ mov(esp, ebp); | 2100 __ mov(esp, ebp); |
| 2127 __ pop(ebp); | 2101 __ pop(ebp); |
| 2128 if (dynamic_frame_alignment_) { | |
| 2129 Label aligned; | |
| 2130 // Frame alignment marker (padding) is below arguments, | |
| 2131 // and receiver, so its return-address-relative offset is | |
| 2132 // (num_arguments + 2) words. | |
| 2133 __ cmp(Operand(esp, (GetParameterCount() + 2) * kPointerSize), | |
| 2134 Immediate(factory()->frame_alignment_marker())); | |
| 2135 __ j(not_equal, &aligned); | |
| 2136 __ Ret((GetParameterCount() + 2) * kPointerSize, ecx); | |
| 2137 __ bind(&aligned); | |
| 2138 } | |
| 2139 __ Ret((GetParameterCount() + 1) * kPointerSize, ecx); | 2102 __ Ret((GetParameterCount() + 1) * kPointerSize, ecx); |
| 2140 } | 2103 } |
| 2141 | 2104 |
| 2142 | 2105 |
| 2143 void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { | 2106 void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { |
| 2144 Register result = ToRegister(instr->result()); | 2107 Register result = ToRegister(instr->result()); |
| 2145 __ mov(result, Operand::Cell(instr->hydrogen()->cell())); | 2108 __ mov(result, Operand::Cell(instr->hydrogen()->cell())); |
| 2146 if (instr->hydrogen()->RequiresHoleCheck()) { | 2109 if (instr->hydrogen()->RequiresHoleCheck()) { |
| 2147 __ cmp(result, factory()->the_hole_value()); | 2110 __ cmp(result, factory()->the_hole_value()); |
| 2148 DeoptimizeIf(equal, instr->environment()); | 2111 DeoptimizeIf(equal, instr->environment()); |
| (...skipping 2852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5001 FixedArray::kHeaderSize - kPointerSize)); | 4964 FixedArray::kHeaderSize - kPointerSize)); |
| 5002 __ bind(&done); | 4965 __ bind(&done); |
| 5003 } | 4966 } |
| 5004 | 4967 |
| 5005 | 4968 |
| 5006 #undef __ | 4969 #undef __ |
| 5007 | 4970 |
| 5008 } } // namespace v8::internal | 4971 } } // namespace v8::internal |
| 5009 | 4972 |
| 5010 #endif // V8_TARGET_ARCH_IA32 | 4973 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |