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

Side by Side Diff: src/ia32/deoptimizer-ia32.cc

Issue 284503002: Simplify DoubleRegister for the ia32 port. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 6 years, 7 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/code-stubs-ia32.cc ('k') | src/ia32/macro-assembler-ia32.cc » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "v8.h" 5 #include "v8.h"
6 6
7 #if V8_TARGET_ARCH_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "codegen.h" 9 #include "codegen.h"
10 #include "deoptimizer.h" 10 #include "deoptimizer.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) { 180 void Deoptimizer::FillInputFrame(Address tos, JavaScriptFrame* frame) {
181 // Set the register values. The values are not important as there are no 181 // Set the register values. The values are not important as there are no
182 // callee saved registers in JavaScript frames, so all registers are 182 // callee saved registers in JavaScript frames, so all registers are
183 // spilled. Registers ebp and esp are set to the correct values though. 183 // spilled. Registers ebp and esp are set to the correct values though.
184 184
185 for (int i = 0; i < Register::kNumRegisters; i++) { 185 for (int i = 0; i < Register::kNumRegisters; i++) {
186 input_->SetRegister(i, i * 4); 186 input_->SetRegister(i, i * 4);
187 } 187 }
188 input_->SetRegister(esp.code(), reinterpret_cast<intptr_t>(frame->sp())); 188 input_->SetRegister(esp.code(), reinterpret_cast<intptr_t>(frame->sp()));
189 input_->SetRegister(ebp.code(), reinterpret_cast<intptr_t>(frame->fp())); 189 input_->SetRegister(ebp.code(), reinterpret_cast<intptr_t>(frame->fp()));
190 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) { 190 for (int i = 0; i < XMMRegister::kMaxNumAllocatableRegisters; i++) {
191 input_->SetDoubleRegister(i, 0.0); 191 input_->SetDoubleRegister(i, 0.0);
192 } 192 }
193 193
194 // Fill the frame content from the actual data on the frame. 194 // Fill the frame content from the actual data on the frame.
195 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { 195 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) {
196 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); 196 input_->SetFrameSlot(i, Memory::uint32_at(tos + i));
197 } 197 }
198 } 198 }
199 199
200 200
201 void Deoptimizer::SetPlatformCompiledStubRegisters( 201 void Deoptimizer::SetPlatformCompiledStubRegisters(
202 FrameDescription* output_frame, CodeStubInterfaceDescriptor* descriptor) { 202 FrameDescription* output_frame, CodeStubInterfaceDescriptor* descriptor) {
203 intptr_t handler = 203 intptr_t handler =
204 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_); 204 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_);
205 int params = descriptor->GetHandlerParameterCount(); 205 int params = descriptor->GetHandlerParameterCount();
206 output_frame->SetRegister(eax.code(), params); 206 output_frame->SetRegister(eax.code(), params);
207 output_frame->SetRegister(ebx.code(), handler); 207 output_frame->SetRegister(ebx.code(), handler);
208 } 208 }
209 209
210 210
211 void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { 211 void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {
212 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { 212 for (int i = 0; i < XMMRegister::kMaxNumAllocatableRegisters; ++i) {
213 double double_value = input_->GetDoubleRegister(i); 213 double double_value = input_->GetDoubleRegister(i);
214 output_frame->SetDoubleRegister(i, double_value); 214 output_frame->SetDoubleRegister(i, double_value);
215 } 215 }
216 } 216 }
217 217
218 218
219 bool Deoptimizer::HasAlignmentPadding(JSFunction* function) { 219 bool Deoptimizer::HasAlignmentPadding(JSFunction* function) {
220 int parameter_count = function->shared()->formal_parameter_count() + 1; 220 int parameter_count = function->shared()->formal_parameter_count() + 1;
221 unsigned input_frame_size = input_->GetFrameSize(); 221 unsigned input_frame_size = input_->GetFrameSize();
222 unsigned alignment_state_offset = 222 unsigned alignment_state_offset =
223 input_frame_size - parameter_count * kPointerSize - 223 input_frame_size - parameter_count * kPointerSize -
224 StandardFrameConstants::kFixedFrameSize - 224 StandardFrameConstants::kFixedFrameSize -
225 kPointerSize; 225 kPointerSize;
226 ASSERT(JavaScriptFrameConstants::kDynamicAlignmentStateOffset == 226 ASSERT(JavaScriptFrameConstants::kDynamicAlignmentStateOffset ==
227 JavaScriptFrameConstants::kLocal0Offset); 227 JavaScriptFrameConstants::kLocal0Offset);
228 int32_t alignment_state = input_->GetFrameSlot(alignment_state_offset); 228 int32_t alignment_state = input_->GetFrameSlot(alignment_state_offset);
229 return (alignment_state == kAlignmentPaddingPushed); 229 return (alignment_state == kAlignmentPaddingPushed);
230 } 230 }
231 231
232 232
233 #define __ masm()-> 233 #define __ masm()->
234 234
235 void Deoptimizer::EntryGenerator::Generate() { 235 void Deoptimizer::EntryGenerator::Generate() {
236 GeneratePrologue(); 236 GeneratePrologue();
237 237
238 // Save all general purpose registers before messing with them. 238 // Save all general purpose registers before messing with them.
239 const int kNumberOfRegisters = Register::kNumRegisters; 239 const int kNumberOfRegisters = Register::kNumRegisters;
240 240
241 const int kDoubleRegsSize = kDoubleSize * 241 const int kDoubleRegsSize = kDoubleSize *
242 XMMRegister::kNumAllocatableRegisters; 242 XMMRegister::kMaxNumAllocatableRegisters;
243 __ sub(esp, Immediate(kDoubleRegsSize)); 243 __ sub(esp, Immediate(kDoubleRegsSize));
244 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { 244 for (int i = 0; i < XMMRegister::kMaxNumAllocatableRegisters; ++i) {
245 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); 245 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i);
246 int offset = i * kDoubleSize; 246 int offset = i * kDoubleSize;
247 __ movsd(Operand(esp, offset), xmm_reg); 247 __ movsd(Operand(esp, offset), xmm_reg);
248 } 248 }
249 249
250 __ pushad(); 250 __ pushad();
251 251
252 const int kSavedRegistersAreaSize = kNumberOfRegisters * kPointerSize + 252 const int kSavedRegistersAreaSize = kNumberOfRegisters * kPointerSize +
253 kDoubleRegsSize; 253 kDoubleRegsSize;
254 254
(...skipping 28 matching lines...) Expand all
283 __ mov(ebx, Operand(eax, Deoptimizer::input_offset())); 283 __ mov(ebx, Operand(eax, Deoptimizer::input_offset()));
284 284
285 // Fill in the input registers. 285 // Fill in the input registers.
286 for (int i = kNumberOfRegisters - 1; i >= 0; i--) { 286 for (int i = kNumberOfRegisters - 1; i >= 0; i--) {
287 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); 287 int offset = (i * kPointerSize) + FrameDescription::registers_offset();
288 __ pop(Operand(ebx, offset)); 288 __ pop(Operand(ebx, offset));
289 } 289 }
290 290
291 int double_regs_offset = FrameDescription::double_registers_offset(); 291 int double_regs_offset = FrameDescription::double_registers_offset();
292 // Fill in the double input registers. 292 // Fill in the double input registers.
293 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { 293 for (int i = 0; i < XMMRegister::kMaxNumAllocatableRegisters; ++i) {
294 int dst_offset = i * kDoubleSize + double_regs_offset; 294 int dst_offset = i * kDoubleSize + double_regs_offset;
295 int src_offset = i * kDoubleSize; 295 int src_offset = i * kDoubleSize;
296 __ movsd(xmm0, Operand(esp, src_offset)); 296 __ movsd(xmm0, Operand(esp, src_offset));
297 __ movsd(Operand(ebx, dst_offset), xmm0); 297 __ movsd(Operand(ebx, dst_offset), xmm0);
298 } 298 }
299 299
300 // Clear FPU all exceptions. 300 // Clear FPU all exceptions.
301 // TODO(ulan): Find out why the TOP register is not zero here in some cases, 301 // TODO(ulan): Find out why the TOP register is not zero here in some cases,
302 // and check that the generated code never deoptimizes with unbalanced stack. 302 // and check that the generated code never deoptimizes with unbalanced stack.
303 __ fnclex(); 303 __ fnclex();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 __ push(Operand(ebx, ecx, times_1, FrameDescription::frame_content_offset())); 366 __ push(Operand(ebx, ecx, times_1, FrameDescription::frame_content_offset()));
367 __ bind(&inner_loop_header); 367 __ bind(&inner_loop_header);
368 __ test(ecx, ecx); 368 __ test(ecx, ecx);
369 __ j(not_zero, &inner_push_loop); 369 __ j(not_zero, &inner_push_loop);
370 __ add(eax, Immediate(kPointerSize)); 370 __ add(eax, Immediate(kPointerSize));
371 __ bind(&outer_loop_header); 371 __ bind(&outer_loop_header);
372 __ cmp(eax, edx); 372 __ cmp(eax, edx);
373 __ j(below, &outer_push_loop); 373 __ j(below, &outer_push_loop);
374 374
375 // In case of a failed STUB, we have to restore the XMM registers. 375 // In case of a failed STUB, we have to restore the XMM registers.
376 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { 376 for (int i = 0; i < XMMRegister::kMaxNumAllocatableRegisters; ++i) {
377 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); 377 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i);
378 int src_offset = i * kDoubleSize + double_regs_offset; 378 int src_offset = i * kDoubleSize + double_regs_offset;
379 __ movsd(xmm_reg, Operand(ebx, src_offset)); 379 __ movsd(xmm_reg, Operand(ebx, src_offset));
380 } 380 }
381 381
382 // Push state, pc, and continuation from the last output frame. 382 // Push state, pc, and continuation from the last output frame.
383 __ push(Operand(ebx, FrameDescription::state_offset())); 383 __ push(Operand(ebx, FrameDescription::state_offset()));
384 __ push(Operand(ebx, FrameDescription::pc_offset())); 384 __ push(Operand(ebx, FrameDescription::pc_offset()));
385 __ push(Operand(ebx, FrameDescription::continuation_offset())); 385 __ push(Operand(ebx, FrameDescription::continuation_offset()));
386 386
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 UNREACHABLE(); 428 UNREACHABLE();
429 } 429 }
430 430
431 431
432 #undef __ 432 #undef __
433 433
434 434
435 } } // namespace v8::internal 435 } } // namespace v8::internal
436 436
437 #endif // V8_TARGET_ARCH_IA32 437 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/macro-assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698