Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

Issue 7976024: Add dynamic stack frame alignment to optimized functions with untagged doubles on the stack. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Incorporate code review comments. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 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
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 STATIC_ASSERT(kDoubleSize == 2 * kPointerSize);
161 // Align esp to a multiple of 2 * kPointerSize.
162 __ test(esp, Immediate(kPointerSize));
163 __ j(zero, &do_not_pad, Label::kNear);
164 __ push(Immediate(0));
165 __ mov(ebx, esp);
166 // Copy arguments, receiver, and return address.
167 __ mov(ecx, Immediate(scope()->num_parameters() + 2));
168
169 __ bind(&align_loop);
170 __ mov(eax, Operand(ebx, 1 * kPointerSize));
171 __ mov(Operand(ebx, 0), eax);
172 __ add(Operand(ebx), Immediate(kPointerSize));
173 __ dec(ecx);
174 __ j(not_zero, &align_loop, Label::kNear);
175 __ mov(Operand(ebx, 0),
176 Immediate(isolate()->factory()->frame_alignment_marker()));
177
178 __ bind(&do_not_pad);
179 }
180
155 __ push(ebp); // Caller's frame pointer. 181 __ push(ebp); // Caller's frame pointer.
156 __ mov(ebp, esp); 182 __ mov(ebp, esp);
157 __ push(esi); // Callee's context. 183 __ push(esi); // Callee's context.
158 __ push(edi); // Callee's JS function. 184 __ push(edi); // Callee's JS function.
159 185
160 // Reserve space for the stack slots needed by the code. 186 // Reserve space for the stack slots needed by the code.
161 int slots = GetStackSlotCount(); 187 int slots = GetStackSlotCount();
162 if (slots > 0) { 188 if (slots > 0) {
163 if (FLAG_debug_code) { 189 if (FLAG_debug_code) {
164 __ mov(Operand(eax), Immediate(slots)); 190 __ mov(Operand(eax), Immediate(slots));
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 // Preserve the return value on the stack and rely on the runtime call 2037 // 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 2038 // 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 2039 // managed by the register allocator and tearing down the frame, it's
2014 // safe to write to the context register. 2040 // safe to write to the context register.
2015 __ push(eax); 2041 __ push(eax);
2016 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 2042 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2017 __ CallRuntime(Runtime::kTraceExit, 1); 2043 __ CallRuntime(Runtime::kTraceExit, 1);
2018 } 2044 }
2019 __ mov(esp, ebp); 2045 __ mov(esp, ebp);
2020 __ pop(ebp); 2046 __ pop(ebp);
2047 if (dynamic_frame_alignment_) {
2048 Label aligned;
2049 // Frame alignment marker (padding) is below arguments,
2050 // and receiver, so its return-address-relative offset is
2051 // (num_arguments + 2) words.
2052 __ cmp(Operand(esp, (GetParameterCount() + 2) * kPointerSize),
2053 Immediate(factory()->frame_alignment_marker()));
2054 __ j(not_equal, &aligned);
2055 __ Ret((GetParameterCount() + 2) * kPointerSize, ecx);
2056 __ bind(&aligned);
2057 }
2021 __ Ret((GetParameterCount() + 1) * kPointerSize, ecx); 2058 __ Ret((GetParameterCount() + 1) * kPointerSize, ecx);
2022 } 2059 }
2023 2060
2024 2061
2025 void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { 2062 void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
2026 Register result = ToRegister(instr->result()); 2063 Register result = ToRegister(instr->result());
2027 __ mov(result, Operand::Cell(instr->hydrogen()->cell())); 2064 __ mov(result, Operand::Cell(instr->hydrogen()->cell()));
2028 if (instr->hydrogen()->check_hole_value()) { 2065 if (instr->hydrogen()->check_hole_value()) {
2029 __ cmp(result, factory()->the_hole_value()); 2066 __ cmp(result, factory()->the_hole_value());
2030 DeoptimizeIf(equal, instr->environment()); 2067 DeoptimizeIf(equal, instr->environment());
(...skipping 2392 matching lines...) Expand 10 before | Expand all | Expand 10 after
4423 env->deoptimization_index()); 4460 env->deoptimization_index());
4424 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4461 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4425 } 4462 }
4426 4463
4427 4464
4428 #undef __ 4465 #undef __
4429 4466
4430 } } // namespace v8::internal 4467 } } // namespace v8::internal
4431 4468
4432 #endif // V8_TARGET_ARCH_IA32 4469 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698