Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 status_ = GENERATING; | 71 status_ = GENERATING; |
| 72 CpuFeatures::Scope scope(SSE2); | 72 CpuFeatures::Scope scope(SSE2); |
| 73 | 73 |
| 74 CodeStub::GenerateFPStubs(); | 74 CodeStub::GenerateFPStubs(); |
| 75 | 75 |
| 76 // Open a frame scope to indicate that there is a frame on the stack. The | 76 // Open a frame scope to indicate that there is a frame on the stack. The |
| 77 // MANUAL indicates that the scope shouldn't actually generate code to set up | 77 // MANUAL indicates that the scope shouldn't actually generate code to set up |
| 78 // the frame (that is done in GeneratePrologue). | 78 // the frame (that is done in GeneratePrologue). |
| 79 FrameScope frame_scope(masm_, StackFrame::MANUAL); | 79 FrameScope frame_scope(masm_, StackFrame::MANUAL); |
| 80 | 80 |
| 81 set_dynamic_frame_alignment(chunk()->num_double_slots() > 2 || | |
| 82 info()->osr_ast_id() != AstNode::kNoNumber); | |
| 83 | |
| 81 return GeneratePrologue() && | 84 return GeneratePrologue() && |
| 82 GenerateBody() && | 85 GenerateBody() && |
| 83 GenerateDeferredCode() && | 86 GenerateDeferredCode() && |
| 84 GenerateSafepointTable(); | 87 GenerateSafepointTable(); |
| 85 } | 88 } |
| 86 | 89 |
| 87 | 90 |
| 88 void LCodeGen::FinishCode(Handle<Code> code) { | 91 void LCodeGen::FinishCode(Handle<Code> code) { |
| 89 ASSERT(is_done()); | 92 ASSERT(is_done()); |
| 90 code->set_stack_slots(GetStackSlotCount()); | 93 code->set_stack_slots(GetStackSlotCount()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 Label ok; | 148 Label ok; |
| 146 __ test(ecx, Operand(ecx)); | 149 __ test(ecx, Operand(ecx)); |
| 147 __ j(zero, &ok, Label::kNear); | 150 __ j(zero, &ok, Label::kNear); |
| 148 // +1 for return address. | 151 // +1 for return address. |
| 149 int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize; | 152 int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize; |
| 150 __ mov(Operand(esp, receiver_offset), | 153 __ mov(Operand(esp, receiver_offset), |
| 151 Immediate(isolate()->factory()->undefined_value())); | 154 Immediate(isolate()->factory()->undefined_value())); |
| 152 __ bind(&ok); | 155 __ bind(&ok); |
| 153 } | 156 } |
| 154 | 157 |
| 158 if (dynamic_frame_alignment()) { | |
| 159 Label do_not_pad, align_loop; | |
| 160 __ mov(ebx, esp); | |
|
Kevin Millikin (Chromium)
2011/09/23 09:38:49
Can you test(esp, 4)?
William Hesse
2011/09/23 12:50:11
Done.
| |
| 161 __ and_(ebx, Immediate(0x4)); | |
|
Kevin Millikin (Chromium)
2011/09/23 09:38:49
Is this better (kDoubleSize - 1) or (kDoubleSize >
William Hesse
2011/09/23 12:50:11
Done.
| |
| 162 __ j(zero, &do_not_pad, Label::kNear); | |
| 163 __ mov(ebx, esp); | |
|
Kevin Millikin (Chromium)
2011/09/23 09:38:49
The last move after the loop might be slightly mor
William Hesse
2011/09/23 12:50:11
Done.
| |
| 164 __ push(Immediate(0)); | |
| 165 __ mov(ecx, Immediate(scope()->num_parameters() + 2)); | |
|
Kevin Millikin (Chromium)
2011/09/23 09:38:49
Comment should say 2 is receiver + return address.
William Hesse
2011/09/23 12:50:11
Done.
| |
| 166 | |
| 167 __ bind(&align_loop); | |
| 168 __ mov(eax, Operand(ebx, 0)); | |
| 169 __ mov(Operand(ebx, -1 * kPointerSize), eax); | |
| 170 __ add(Operand(ebx), Immediate(kPointerSize)); | |
| 171 __ dec(ecx); | |
| 172 __ j(not_zero, &align_loop, Label::kNear); | |
| 173 __ mov(Operand(ebx, -1 * kPointerSize), | |
| 174 Immediate(isolate()->factory()->frame_alignment_marker())); | |
| 175 | |
| 176 __ bind(&do_not_pad); | |
| 177 } | |
| 178 | |
| 155 __ push(ebp); // Caller's frame pointer. | 179 __ push(ebp); // Caller's frame pointer. |
| 156 __ mov(ebp, esp); | 180 __ mov(ebp, esp); |
| 157 __ push(esi); // Callee's context. | 181 __ push(esi); // Callee's context. |
| 158 __ push(edi); // Callee's JS function. | 182 __ push(edi); // Callee's JS function. |
| 159 | 183 |
| 160 // Reserve space for the stack slots needed by the code. | 184 // Reserve space for the stack slots needed by the code. |
| 161 int slots = GetStackSlotCount(); | 185 int slots = GetStackSlotCount(); |
| 162 if (slots > 0) { | 186 if (slots > 0) { |
| 163 if (FLAG_debug_code) { | 187 if (FLAG_debug_code) { |
| 164 __ mov(Operand(eax), Immediate(slots)); | 188 __ mov(Operand(eax), Immediate(slots)); |
| (...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2009 void LCodeGen::DoReturn(LReturn* instr) { | 2033 void LCodeGen::DoReturn(LReturn* instr) { |
| 2010 if (FLAG_trace) { | 2034 if (FLAG_trace) { |
| 2011 // Preserve the return value on the stack and rely on the runtime call | 2035 // Preserve the return value on the stack and rely on the runtime call |
| 2012 // to return the value in the same register. We're leaving the code | 2036 // to return the value in the same register. We're leaving the code |
| 2013 // managed by the register allocator and tearing down the frame, it's | 2037 // managed by the register allocator and tearing down the frame, it's |
| 2014 // safe to write to the context register. | 2038 // safe to write to the context register. |
| 2015 __ push(eax); | 2039 __ push(eax); |
| 2016 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2040 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
| 2017 __ CallRuntime(Runtime::kTraceExit, 1); | 2041 __ CallRuntime(Runtime::kTraceExit, 1); |
| 2018 } | 2042 } |
| 2043 if (dynamic_frame_alignment()) { | |
| 2044 Label aligned; | |
| 2045 __ cmp(Operand(ebp, (GetParameterCount() + 3) * kPointerSize), | |
|
Kevin Millikin (Chromium)
2011/09/23 09:38:49
3 ~ caller's fp, return address, receiver.
William Hesse
2011/09/23 12:50:11
Done.
| |
| 2046 Immediate(factory()->frame_alignment_marker())); | |
| 2047 __ j(not_equal, &aligned); | |
| 2048 __ mov(esp, ebp); | |
| 2049 __ pop(ebp); | |
|
Kevin Millikin (Chromium)
2011/09/23 09:38:49
Slightly more compact is:
__ mov(esp, ebp);
__ po
William Hesse
2011/09/23 12:50:11
Done.
| |
| 2050 __ Ret((GetParameterCount() + 2) * kPointerSize, ecx); | |
| 2051 __ bind(&aligned); | |
| 2052 } | |
| 2019 __ mov(esp, ebp); | 2053 __ mov(esp, ebp); |
| 2020 __ pop(ebp); | 2054 __ pop(ebp); |
| 2021 __ Ret((GetParameterCount() + 1) * kPointerSize, ecx); | 2055 __ Ret((GetParameterCount() + 1) * kPointerSize, ecx); |
| 2022 } | 2056 } |
| 2023 | 2057 |
| 2024 | 2058 |
| 2025 void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { | 2059 void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { |
| 2026 Register result = ToRegister(instr->result()); | 2060 Register result = ToRegister(instr->result()); |
| 2027 __ mov(result, Operand::Cell(instr->hydrogen()->cell())); | 2061 __ mov(result, Operand::Cell(instr->hydrogen()->cell())); |
| 2028 if (instr->hydrogen()->check_hole_value()) { | 2062 if (instr->hydrogen()->check_hole_value()) { |
| (...skipping 2392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4421 env->deoptimization_index()); | 4455 env->deoptimization_index()); |
| 4422 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); | 4456 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); |
| 4423 } | 4457 } |
| 4424 | 4458 |
| 4425 | 4459 |
| 4426 #undef __ | 4460 #undef __ |
| 4427 | 4461 |
| 4428 } } // namespace v8::internal | 4462 } } // namespace v8::internal |
| 4429 | 4463 |
| 4430 #endif // V8_TARGET_ARCH_IA32 | 4464 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |