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

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

Issue 90643003: Experimental implementation: Exposing SIMD instructions into JavaScript Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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/assembler-ia32.cc ('k') | src/ia32/disasm-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 // 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 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 xmm_value_t zero = {{0.0, 0.0}};
190 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) { 191 for (int i = 0; i < DoubleRegister::NumAllocatableRegisters(); i++) {
191 input_->SetDoubleRegister(i, 0.0); 192 input_->SetXMMRegister(i, zero);
192 } 193 }
193 194
194 // Fill the frame content from the actual data on the frame. 195 // Fill the frame content from the actual data on the frame.
195 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) { 196 for (unsigned i = 0; i < input_->GetFrameSize(); i += kPointerSize) {
196 input_->SetFrameSlot(i, Memory::uint32_at(tos + i)); 197 input_->SetFrameSlot(i, Memory::uint32_at(tos + i));
197 } 198 }
198 } 199 }
199 200
200 201
201 void Deoptimizer::SetPlatformCompiledStubRegisters( 202 void Deoptimizer::SetPlatformCompiledStubRegisters(
202 FrameDescription* output_frame, CodeStubInterfaceDescriptor* descriptor) { 203 FrameDescription* output_frame, CodeStubInterfaceDescriptor* descriptor) {
203 intptr_t handler = 204 intptr_t handler =
204 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_); 205 reinterpret_cast<intptr_t>(descriptor->deoptimization_handler_);
205 int params = descriptor->GetHandlerParameterCount(); 206 int params = descriptor->GetHandlerParameterCount();
206 output_frame->SetRegister(eax.code(), params); 207 output_frame->SetRegister(eax.code(), params);
207 output_frame->SetRegister(ebx.code(), handler); 208 output_frame->SetRegister(ebx.code(), handler);
208 } 209 }
209 210
210 211
211 void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) { 212 void Deoptimizer::CopyDoubleRegisters(FrameDescription* output_frame) {
212 if (!CpuFeatures::IsSupported(SSE2)) return; 213 if (!CpuFeatures::IsSupported(SSE2)) return;
213 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { 214 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) {
214 double double_value = input_->GetDoubleRegister(i); 215 xmm_value_t xmm_value = input_->GetXMMRegister(i);
215 output_frame->SetDoubleRegister(i, double_value); 216 output_frame->SetXMMRegister(i, xmm_value);
216 } 217 }
217 } 218 }
218 219
219 220
220 bool Deoptimizer::HasAlignmentPadding(JSFunction* function) { 221 bool Deoptimizer::HasAlignmentPadding(JSFunction* function) {
221 int parameter_count = function->shared()->formal_parameter_count() + 1; 222 int parameter_count = function->shared()->formal_parameter_count() + 1;
222 unsigned input_frame_size = input_->GetFrameSize(); 223 unsigned input_frame_size = input_->GetFrameSize();
223 unsigned alignment_state_offset = 224 unsigned alignment_state_offset =
224 input_frame_size - parameter_count * kPointerSize - 225 input_frame_size - parameter_count * kPointerSize -
225 StandardFrameConstants::kFixedFrameSize - 226 StandardFrameConstants::kFixedFrameSize -
(...skipping 13 matching lines...) Expand all
239 240
240 241
241 #define __ masm()-> 242 #define __ masm()->
242 243
243 void Deoptimizer::EntryGenerator::Generate() { 244 void Deoptimizer::EntryGenerator::Generate() {
244 GeneratePrologue(); 245 GeneratePrologue();
245 246
246 // Save all general purpose registers before messing with them. 247 // Save all general purpose registers before messing with them.
247 const int kNumberOfRegisters = Register::kNumRegisters; 248 const int kNumberOfRegisters = Register::kNumRegisters;
248 249
249 const int kDoubleRegsSize = kDoubleSize * 250 const int kXMMRegsSize = kFloat32x4Size *
250 XMMRegister::kNumAllocatableRegisters; 251 XMMRegister::kNumAllocatableRegisters;
251 __ sub(esp, Immediate(kDoubleRegsSize)); 252 __ sub(esp, Immediate(kXMMRegsSize));
252 if (CpuFeatures::IsSupported(SSE2)) { 253 if (CpuFeatures::IsSupported(SSE2)) {
253 CpuFeatureScope scope(masm(), SSE2); 254 CpuFeatureScope scope(masm(), SSE2);
254 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { 255 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) {
255 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); 256 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i);
256 int offset = i * kDoubleSize; 257 int offset = i * kFloat32x4Size;
257 __ movsd(Operand(esp, offset), xmm_reg); 258 __ movups(Operand(esp, offset), xmm_reg);
258 } 259 }
259 } 260 }
260 261
261 __ pushad(); 262 __ pushad();
262 263
263 const int kSavedRegistersAreaSize = kNumberOfRegisters * kPointerSize + 264 const int kSavedRegistersAreaSize = kNumberOfRegisters * kPointerSize +
264 kDoubleRegsSize; 265 kXMMRegsSize;
265 266
266 // Get the bailout id from the stack. 267 // Get the bailout id from the stack.
267 __ mov(ebx, Operand(esp, kSavedRegistersAreaSize)); 268 __ mov(ebx, Operand(esp, kSavedRegistersAreaSize));
268 269
269 // Get the address of the location in the code object 270 // Get the address of the location in the code object
270 // and compute the fp-to-sp delta in register edx. 271 // and compute the fp-to-sp delta in register edx.
271 __ mov(ecx, Operand(esp, kSavedRegistersAreaSize + 1 * kPointerSize)); 272 __ mov(ecx, Operand(esp, kSavedRegistersAreaSize + 1 * kPointerSize));
272 __ lea(edx, Operand(esp, kSavedRegistersAreaSize + 2 * kPointerSize)); 273 __ lea(edx, Operand(esp, kSavedRegistersAreaSize + 2 * kPointerSize));
273 274
274 __ sub(edx, ebp); 275 __ sub(edx, ebp);
(...skipping 17 matching lines...) Expand all
292 // Preserve deoptimizer object in register eax and get the input 293 // Preserve deoptimizer object in register eax and get the input
293 // frame descriptor pointer. 294 // frame descriptor pointer.
294 __ mov(ebx, Operand(eax, Deoptimizer::input_offset())); 295 __ mov(ebx, Operand(eax, Deoptimizer::input_offset()));
295 296
296 // Fill in the input registers. 297 // Fill in the input registers.
297 for (int i = kNumberOfRegisters - 1; i >= 0; i--) { 298 for (int i = kNumberOfRegisters - 1; i >= 0; i--) {
298 int offset = (i * kPointerSize) + FrameDescription::registers_offset(); 299 int offset = (i * kPointerSize) + FrameDescription::registers_offset();
299 __ pop(Operand(ebx, offset)); 300 __ pop(Operand(ebx, offset));
300 } 301 }
301 302
302 int double_regs_offset = FrameDescription::double_registers_offset(); 303 int xmm_regs_offset = FrameDescription::xmm_registers_offset();
303 if (CpuFeatures::IsSupported(SSE2)) { 304 if (CpuFeatures::IsSupported(SSE2)) {
304 CpuFeatureScope scope(masm(), SSE2); 305 CpuFeatureScope scope(masm(), SSE2);
305 // Fill in the double input registers. 306 // Fill in the double input registers.
306 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { 307 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) {
307 int dst_offset = i * kDoubleSize + double_regs_offset; 308 int dst_offset = i * kFloat32x4Size + xmm_regs_offset;
308 int src_offset = i * kDoubleSize; 309 int src_offset = i * kFloat32x4Size;
309 __ movsd(xmm0, Operand(esp, src_offset)); 310 __ movups(xmm0, Operand(esp, src_offset));
310 __ movsd(Operand(ebx, dst_offset), xmm0); 311 __ movups(Operand(ebx, dst_offset), xmm0);
311 } 312 }
312 } 313 }
313 314
314 // Clear FPU all exceptions. 315 // Clear FPU all exceptions.
315 // TODO(ulan): Find out why the TOP register is not zero here in some cases, 316 // TODO(ulan): Find out why the TOP register is not zero here in some cases,
316 // and check that the generated code never deoptimizes with unbalanced stack. 317 // and check that the generated code never deoptimizes with unbalanced stack.
317 __ fnclex(); 318 __ fnclex();
318 319
319 // Remove the bailout id, return address and the double registers. 320 // Remove the bailout id, return address and the double registers.
320 __ add(esp, Immediate(kDoubleRegsSize + 2 * kPointerSize)); 321 __ add(esp, Immediate(kXMMRegsSize + 2 * kPointerSize));
321 322
322 // Compute a pointer to the unwinding limit in register ecx; that is 323 // Compute a pointer to the unwinding limit in register ecx; that is
323 // the first stack slot not part of the input frame. 324 // the first stack slot not part of the input frame.
324 __ mov(ecx, Operand(ebx, FrameDescription::frame_size_offset())); 325 __ mov(ecx, Operand(ebx, FrameDescription::frame_size_offset()));
325 __ add(ecx, esp); 326 __ add(ecx, esp);
326 327
327 // Unwind the stack down to - but not including - the unwinding 328 // Unwind the stack down to - but not including - the unwinding
328 // limit and copy the contents of the activation frame to the input 329 // limit and copy the contents of the activation frame to the input
329 // frame description. 330 // frame description.
330 __ lea(edx, Operand(ebx, FrameDescription::frame_content_offset())); 331 __ lea(edx, Operand(ebx, FrameDescription::frame_content_offset()));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 __ add(eax, Immediate(kPointerSize)); 385 __ add(eax, Immediate(kPointerSize));
385 __ bind(&outer_loop_header); 386 __ bind(&outer_loop_header);
386 __ cmp(eax, edx); 387 __ cmp(eax, edx);
387 __ j(below, &outer_push_loop); 388 __ j(below, &outer_push_loop);
388 389
389 // In case of a failed STUB, we have to restore the XMM registers. 390 // In case of a failed STUB, we have to restore the XMM registers.
390 if (CpuFeatures::IsSupported(SSE2)) { 391 if (CpuFeatures::IsSupported(SSE2)) {
391 CpuFeatureScope scope(masm(), SSE2); 392 CpuFeatureScope scope(masm(), SSE2);
392 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) { 393 for (int i = 0; i < XMMRegister::kNumAllocatableRegisters; ++i) {
393 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i); 394 XMMRegister xmm_reg = XMMRegister::FromAllocationIndex(i);
394 int src_offset = i * kDoubleSize + double_regs_offset; 395 int src_offset = i * kFloat32x4Size+ xmm_regs_offset;
395 __ movsd(xmm_reg, Operand(ebx, src_offset)); 396 __ movups(xmm_reg, Operand(ebx, src_offset));
396 } 397 }
397 } 398 }
398 399
399 // Push state, pc, and continuation from the last output frame. 400 // Push state, pc, and continuation from the last output frame.
400 __ push(Operand(ebx, FrameDescription::state_offset())); 401 __ push(Operand(ebx, FrameDescription::state_offset()));
401 __ push(Operand(ebx, FrameDescription::pc_offset())); 402 __ push(Operand(ebx, FrameDescription::pc_offset()));
402 __ push(Operand(ebx, FrameDescription::continuation_offset())); 403 __ push(Operand(ebx, FrameDescription::continuation_offset()));
403 404
404 405
405 // Push the registers from the last output frame. 406 // Push the registers from the last output frame.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 SetFrameSlot(offset, value); 440 SetFrameSlot(offset, value);
440 } 441 }
441 442
442 443
443 #undef __ 444 #undef __
444 445
445 446
446 } } // namespace v8::internal 447 } } // namespace v8::internal
447 448
448 #endif // V8_TARGET_ARCH_IA32 449 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/assembler-ia32.cc ('k') | src/ia32/disasm-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698