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

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

Issue 10532066: Reimplement dynamic frame alignment for frames that are compiled via OSR or have more than 2 double… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: presubmit fixes Created 8 years, 6 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 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
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
82 return GeneratePrologue() && 85 return GeneratePrologue() &&
83 GenerateBody() && 86 GenerateBody() &&
84 GenerateDeferredCode() && 87 GenerateDeferredCode() &&
85 GenerateSafepointTable(); 88 GenerateSafepointTable();
86 } 89 }
87 90
88 91
89 void LCodeGen::FinishCode(Handle<Code> code) { 92 void LCodeGen::FinishCode(Handle<Code> code) {
90 ASSERT(is_done()); 93 ASSERT(is_done());
91 code->set_stack_slots(GetStackSlotCount()); 94 code->set_stack_slots(GetStackSlotCount());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 Label ok; 149 Label ok;
147 __ test(ecx, Operand(ecx)); 150 __ test(ecx, Operand(ecx));
148 __ j(zero, &ok, Label::kNear); 151 __ j(zero, &ok, Label::kNear);
149 // +1 for return address. 152 // +1 for return address.
150 int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize; 153 int receiver_offset = (scope()->num_parameters() + 1) * kPointerSize;
151 __ mov(Operand(esp, receiver_offset), 154 __ mov(Operand(esp, receiver_offset),
152 Immediate(isolate()->factory()->undefined_value())); 155 Immediate(isolate()->factory()->undefined_value()));
153 __ bind(&ok); 156 __ bind(&ok);
154 } 157 }
155 158
159 // Move state of dynamic frame alignment into edx.
160 __ mov(edx, Immediate(kNoAlignmentPadding));
161
162 if (dynamic_frame_alignment_) {
163 Label do_not_pad, align_loop;
164 STATIC_ASSERT(kDoubleSize == 2 * kPointerSize);
165 // Align esp to a multiple of 2 * kPointerSize.
166 __ test(esp, Immediate(kPointerSize));
167 __ j(zero, &do_not_pad, Label::kNear);
168 __ push(Immediate(0));
169 __ mov(ebx, esp);
170 __ mov(edx, Immediate(kAlignmentPaddingPushed));
171 // Copy arguments, receiver, and return address.
172 __ mov(ecx, Immediate(scope()->num_parameters() + 2));
173
174 __ bind(&align_loop);
175 __ mov(eax, Operand(ebx, 1 * kPointerSize));
176 __ mov(Operand(ebx, 0), eax);
177 __ add(Operand(ebx), Immediate(kPointerSize));
178 __ dec(ecx);
179 __ j(not_zero, &align_loop, Label::kNear);
180 __ mov(Operand(ebx, 0), Immediate(kAlignmentZapValue));
181 __ bind(&do_not_pad);
182 }
183
156 __ push(ebp); // Caller's frame pointer. 184 __ push(ebp); // Caller's frame pointer.
157 __ mov(ebp, esp); 185 __ mov(ebp, esp);
158 __ push(esi); // Callee's context. 186 __ push(esi); // Callee's context.
159 __ push(edi); // Callee's JS function. 187 __ push(edi); // Callee's JS function.
160 188
161 // Reserve space for the stack slots needed by the code. 189 // Reserve space for the stack slots needed by the code.
162 int slots = GetStackSlotCount(); 190 int slots = GetStackSlotCount();
163 if (slots > 0) { 191 ASSERT_GE(slots, 1);
164 if (FLAG_debug_code) { 192 if (FLAG_debug_code) {
165 __ mov(Operand(eax), Immediate(slots)); 193 __ mov(Operand(eax), Immediate(slots));
166 Label loop; 194 Label loop;
167 __ bind(&loop); 195 __ bind(&loop);
168 __ push(Immediate(kSlotsZapValue)); 196 __ push(Immediate(kSlotsZapValue));
169 __ dec(eax); 197 __ dec(eax);
170 __ j(not_zero, &loop); 198 __ j(not_zero, &loop);
171 } else { 199 } else {
172 __ sub(Operand(esp), Immediate(slots * kPointerSize)); 200 __ sub(Operand(esp), Immediate(slots * kPointerSize));
173 #ifdef _MSC_VER 201 #ifdef _MSC_VER
174 // On windows, you may not access the stack more than one page below 202 // On windows, you may not access the stack more than one page below
175 // the most recently mapped page. To make the allocated area randomly 203 // the most recently mapped page. To make the allocated area randomly
176 // accessible, we write to each page in turn (the value is irrelevant). 204 // accessible, we write to each page in turn (the value is irrelevant).
177 const int kPageSize = 4 * KB; 205 const int kPageSize = 4 * KB;
178 for (int offset = slots * kPointerSize - kPageSize; 206 for (int offset = slots * kPointerSize - kPageSize;
179 offset > 0; 207 offset > 0;
180 offset -= kPageSize) { 208 offset -= kPageSize) {
181 __ mov(Operand(esp, offset), eax); 209 __ mov(Operand(esp, offset), eax);
182 } 210 }
183 #endif 211 #endif
184 }
185 } 212 }
186 213
214 // Store dynamic frame alignment state in the first local.
215 __ mov(Operand(ebp, JavaScriptFrameConstants::kLocal0Offset), edx);
danno 2012/06/11 10:53:14 To reduce the theoretical expense of the tag in th
216
187 // Possibly allocate a local context. 217 // Possibly allocate a local context.
188 int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; 218 int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
189 if (heap_slots > 0) { 219 if (heap_slots > 0) {
190 Comment(";;; Allocate local context"); 220 Comment(";;; Allocate local context");
191 // Argument to NewContext is the function, which is still in edi. 221 // Argument to NewContext is the function, which is still in edi.
192 __ push(edi); 222 __ push(edi);
193 if (heap_slots <= FastNewContextStub::kMaximumSlots) { 223 if (heap_slots <= FastNewContextStub::kMaximumSlots) {
194 FastNewContextStub stub(heap_slots); 224 FastNewContextStub stub(heap_slots);
195 __ CallStub(&stub); 225 __ CallStub(&stub);
196 } else { 226 } else {
(...skipping 1894 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 void LCodeGen::DoReturn(LReturn* instr) { 2121 void LCodeGen::DoReturn(LReturn* instr) {
2092 if (FLAG_trace) { 2122 if (FLAG_trace) {
2093 // Preserve the return value on the stack and rely on the runtime call 2123 // Preserve the return value on the stack and rely on the runtime call
2094 // to return the value in the same register. We're leaving the code 2124 // to return the value in the same register. We're leaving the code
2095 // managed by the register allocator and tearing down the frame, it's 2125 // managed by the register allocator and tearing down the frame, it's
2096 // safe to write to the context register. 2126 // safe to write to the context register.
2097 __ push(eax); 2127 __ push(eax);
2098 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 2128 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2099 __ CallRuntime(Runtime::kTraceExit, 1); 2129 __ CallRuntime(Runtime::kTraceExit, 1);
2100 } 2130 }
2131 if (dynamic_frame_alignment_) {
2132 // Fetch the state of the dynamic frame alignment.
2133 __ mov(edx, Operand(ebp, JavaScriptFrameConstants::kLocal0Offset));
danno 2012/06/11 10:53:14 Can you alias something like kFrameAlignmentCookie
2134 }
2101 __ mov(esp, ebp); 2135 __ mov(esp, ebp);
2102 __ pop(ebp); 2136 __ pop(ebp);
2137 if (dynamic_frame_alignment_) {
2138 Label no_padding;
2139 __ cmp(edx, Immediate(kNoAlignmentPadding));
2140 __ j(equal, &no_padding);
2141 if (FLAG_debug_code) {
2142 __ cmp(Operand(esp, (GetParameterCount() + 2) * kPointerSize),
2143 Immediate(kAlignmentZapValue));
2144 __ Assert(equal, "expected alignment marker");
2145 }
2146 __ Ret((GetParameterCount() + 2) * kPointerSize, ecx);
2147 __ bind(&no_padding);
2148 }
2103 __ Ret((GetParameterCount() + 1) * kPointerSize, ecx); 2149 __ Ret((GetParameterCount() + 1) * kPointerSize, ecx);
2104 } 2150 }
2105 2151
2106 2152
2107 void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) { 2153 void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
2108 Register result = ToRegister(instr->result()); 2154 Register result = ToRegister(instr->result());
2109 __ mov(result, Operand::Cell(instr->hydrogen()->cell())); 2155 __ mov(result, Operand::Cell(instr->hydrogen()->cell()));
2110 if (instr->hydrogen()->RequiresHoleCheck()) { 2156 if (instr->hydrogen()->RequiresHoleCheck()) {
2111 __ cmp(result, factory()->the_hole_value()); 2157 __ cmp(result, factory()->the_hole_value());
2112 DeoptimizeIf(equal, instr->environment()); 2158 DeoptimizeIf(equal, instr->environment());
(...skipping 2991 matching lines...) Expand 10 before | Expand all | Expand 10 after
5104 FixedArray::kHeaderSize - kPointerSize)); 5150 FixedArray::kHeaderSize - kPointerSize));
5105 __ bind(&done); 5151 __ bind(&done);
5106 } 5152 }
5107 5153
5108 5154
5109 #undef __ 5155 #undef __
5110 5156
5111 } } // namespace v8::internal 5157 } } // namespace v8::internal
5112 5158
5113 #endif // V8_TARGET_ARCH_IA32 5159 #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