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

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

Issue 12391055: Cleaned up CpuFeature scope handling. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed nits Created 7 years, 9 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/deoptimizer-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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if (!FLAG_fast_math) return &exp; 107 if (!FLAG_fast_math) return &exp;
108 size_t actual_size; 108 size_t actual_size;
109 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true)); 109 byte* buffer = static_cast<byte*>(OS::Allocate(1 * KB, &actual_size, true));
110 if (buffer == NULL) return &exp; 110 if (buffer == NULL) return &exp;
111 ExternalReference::InitializeMathExpData(); 111 ExternalReference::InitializeMathExpData();
112 112
113 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); 113 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
114 // esp[1 * kPointerSize]: raw double input 114 // esp[1 * kPointerSize]: raw double input
115 // esp[0 * kPointerSize]: return address 115 // esp[0 * kPointerSize]: return address
116 { 116 {
117 CpuFeatures::Scope use_sse2(SSE2); 117 CpuFeatureScope use_sse2(&masm, SSE2);
118 XMMRegister input = xmm1; 118 XMMRegister input = xmm1;
119 XMMRegister result = xmm2; 119 XMMRegister result = xmm2;
120 __ movdbl(input, Operand(esp, 1 * kPointerSize)); 120 __ movdbl(input, Operand(esp, 1 * kPointerSize));
121 __ push(eax); 121 __ push(eax);
122 __ push(ebx); 122 __ push(ebx);
123 123
124 MathExpGenerator::EmitMathExp(&masm, input, result, xmm0, eax, ebx); 124 MathExpGenerator::EmitMathExp(&masm, input, result, xmm0, eax, ebx);
125 125
126 __ pop(ebx); 126 __ pop(ebx);
127 __ pop(eax); 127 __ pop(eax);
(...skipping 19 matching lines...) Expand all
147 &actual_size, 147 &actual_size,
148 true)); 148 true));
149 // If SSE2 is not available, we can use libc's implementation to ensure 149 // If SSE2 is not available, we can use libc's implementation to ensure
150 // consistency since code by fullcodegen's calls into runtime in that case. 150 // consistency since code by fullcodegen's calls into runtime in that case.
151 if (buffer == NULL || !CpuFeatures::IsSupported(SSE2)) return &sqrt; 151 if (buffer == NULL || !CpuFeatures::IsSupported(SSE2)) return &sqrt;
152 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size)); 152 MacroAssembler masm(NULL, buffer, static_cast<int>(actual_size));
153 // esp[1 * kPointerSize]: raw double input 153 // esp[1 * kPointerSize]: raw double input
154 // esp[0 * kPointerSize]: return address 154 // esp[0 * kPointerSize]: return address
155 // Move double input into registers. 155 // Move double input into registers.
156 { 156 {
157 CpuFeatures::Scope use_sse2(SSE2); 157 CpuFeatureScope use_sse2(&masm, SSE2);
158 __ movdbl(xmm0, Operand(esp, 1 * kPointerSize)); 158 __ movdbl(xmm0, Operand(esp, 1 * kPointerSize));
159 __ sqrtsd(xmm0, xmm0); 159 __ sqrtsd(xmm0, xmm0);
160 __ movdbl(Operand(esp, 1 * kPointerSize), xmm0); 160 __ movdbl(Operand(esp, 1 * kPointerSize), xmm0);
161 // Load result into floating point register as return value. 161 // Load result into floating point register as return value.
162 __ fld_d(Operand(esp, 1 * kPointerSize)); 162 __ fld_d(Operand(esp, 1 * kPointerSize));
163 __ Ret(); 163 __ Ret();
164 } 164 }
165 165
166 CodeDesc desc; 166 CodeDesc desc;
167 masm.GetCode(&desc); 167 masm.GetCode(&desc);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 207
208 if (FLAG_debug_code) { 208 if (FLAG_debug_code) {
209 __ cmp(Operand(esp, kSizeOffset + stack_offset), 209 __ cmp(Operand(esp, kSizeOffset + stack_offset),
210 Immediate(OS::kMinComplexMemCopy)); 210 Immediate(OS::kMinComplexMemCopy));
211 Label ok; 211 Label ok;
212 __ j(greater_equal, &ok); 212 __ j(greater_equal, &ok);
213 __ int3(); 213 __ int3();
214 __ bind(&ok); 214 __ bind(&ok);
215 } 215 }
216 if (CpuFeatures::IsSupported(SSE2)) { 216 if (CpuFeatures::IsSupported(SSE2)) {
217 CpuFeatures::Scope enable(SSE2); 217 CpuFeatureScope enable(&masm, SSE2);
218 __ push(edi); 218 __ push(edi);
219 __ push(esi); 219 __ push(esi);
220 stack_offset += 2 * kPointerSize; 220 stack_offset += 2 * kPointerSize;
221 Register dst = edi; 221 Register dst = edi;
222 Register src = esi; 222 Register src = esi;
223 Register count = ecx; 223 Register count = ecx;
224 __ mov(dst, Operand(esp, stack_offset + kDestinationOffset)); 224 __ mov(dst, Operand(esp, stack_offset + kDestinationOffset));
225 __ mov(src, Operand(esp, stack_offset + kSourceOffset)); 225 __ mov(src, Operand(esp, stack_offset + kSourceOffset));
226 __ mov(count, Operand(esp, stack_offset + kSizeOffset)); 226 __ mov(count, Operand(esp, stack_offset + kSizeOffset));
227 227
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 EMIT_REMEMBERED_SET, 472 EMIT_REMEMBERED_SET,
473 OMIT_SMI_CHECK); 473 OMIT_SMI_CHECK);
474 474
475 __ mov(edi, FieldOperand(esi, FixedArray::kLengthOffset)); 475 __ mov(edi, FieldOperand(esi, FixedArray::kLengthOffset));
476 476
477 // Prepare for conversion loop. 477 // Prepare for conversion loop.
478 ExternalReference canonical_the_hole_nan_reference = 478 ExternalReference canonical_the_hole_nan_reference =
479 ExternalReference::address_of_the_hole_nan(); 479 ExternalReference::address_of_the_hole_nan();
480 XMMRegister the_hole_nan = xmm1; 480 XMMRegister the_hole_nan = xmm1;
481 if (CpuFeatures::IsSupported(SSE2)) { 481 if (CpuFeatures::IsSupported(SSE2)) {
482 CpuFeatures::Scope use_sse2(SSE2); 482 CpuFeatureScope use_sse2(masm, SSE2);
483 __ movdbl(the_hole_nan, 483 __ movdbl(the_hole_nan,
484 Operand::StaticVariable(canonical_the_hole_nan_reference)); 484 Operand::StaticVariable(canonical_the_hole_nan_reference));
485 } 485 }
486 __ jmp(&entry); 486 __ jmp(&entry);
487 487
488 // Call into runtime if GC is required. 488 // Call into runtime if GC is required.
489 __ bind(&gc_required); 489 __ bind(&gc_required);
490 // Restore registers before jumping into runtime. 490 // Restore registers before jumping into runtime.
491 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 491 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
492 __ pop(ebx); 492 __ pop(ebx);
493 __ pop(eax); 493 __ pop(eax);
494 __ jmp(fail); 494 __ jmp(fail);
495 495
496 // Convert and copy elements 496 // Convert and copy elements
497 // esi: source FixedArray 497 // esi: source FixedArray
498 __ bind(&loop); 498 __ bind(&loop);
499 __ mov(ebx, FieldOperand(esi, edi, times_2, FixedArray::kHeaderSize)); 499 __ mov(ebx, FieldOperand(esi, edi, times_2, FixedArray::kHeaderSize));
500 // ebx: current element from source 500 // ebx: current element from source
501 // edi: index of current element 501 // edi: index of current element
502 __ JumpIfNotSmi(ebx, &convert_hole); 502 __ JumpIfNotSmi(ebx, &convert_hole);
503 503
504 // Normal smi, convert it to double and store. 504 // Normal smi, convert it to double and store.
505 __ SmiUntag(ebx); 505 __ SmiUntag(ebx);
506 if (CpuFeatures::IsSupported(SSE2)) { 506 if (CpuFeatures::IsSupported(SSE2)) {
507 CpuFeatures::Scope fscope(SSE2); 507 CpuFeatureScope fscope(masm, SSE2);
508 __ cvtsi2sd(xmm0, ebx); 508 __ cvtsi2sd(xmm0, ebx);
509 __ movdbl(FieldOperand(eax, edi, times_4, FixedDoubleArray::kHeaderSize), 509 __ movdbl(FieldOperand(eax, edi, times_4, FixedDoubleArray::kHeaderSize),
510 xmm0); 510 xmm0);
511 } else { 511 } else {
512 __ push(ebx); 512 __ push(ebx);
513 __ fild_s(Operand(esp, 0)); 513 __ fild_s(Operand(esp, 0));
514 __ pop(ebx); 514 __ pop(ebx);
515 __ fstp_d(FieldOperand(eax, edi, times_4, FixedDoubleArray::kHeaderSize)); 515 __ fstp_d(FieldOperand(eax, edi, times_4, FixedDoubleArray::kHeaderSize));
516 } 516 }
517 __ jmp(&entry); 517 __ jmp(&entry);
518 518
519 // Found hole, store hole_nan_as_double instead. 519 // Found hole, store hole_nan_as_double instead.
520 __ bind(&convert_hole); 520 __ bind(&convert_hole);
521 521
522 if (FLAG_debug_code) { 522 if (FLAG_debug_code) {
523 __ cmp(ebx, masm->isolate()->factory()->the_hole_value()); 523 __ cmp(ebx, masm->isolate()->factory()->the_hole_value());
524 __ Assert(equal, "object found in smi-only array"); 524 __ Assert(equal, "object found in smi-only array");
525 } 525 }
526 526
527 if (CpuFeatures::IsSupported(SSE2)) { 527 if (CpuFeatures::IsSupported(SSE2)) {
528 CpuFeatures::Scope use_sse2(SSE2); 528 CpuFeatureScope use_sse2(masm, SSE2);
529 __ movdbl(FieldOperand(eax, edi, times_4, FixedDoubleArray::kHeaderSize), 529 __ movdbl(FieldOperand(eax, edi, times_4, FixedDoubleArray::kHeaderSize),
530 the_hole_nan); 530 the_hole_nan);
531 } else { 531 } else {
532 __ fld_d(Operand::StaticVariable(canonical_the_hole_nan_reference)); 532 __ fld_d(Operand::StaticVariable(canonical_the_hole_nan_reference));
533 __ fstp_d(FieldOperand(eax, edi, times_4, FixedDoubleArray::kHeaderSize)); 533 __ fstp_d(FieldOperand(eax, edi, times_4, FixedDoubleArray::kHeaderSize));
534 } 534 }
535 535
536 __ bind(&entry); 536 __ bind(&entry);
537 __ sub(edi, Immediate(Smi::FromInt(1))); 537 __ sub(edi, Immediate(Smi::FromInt(1)));
538 __ j(not_sign, &loop); 538 __ j(not_sign, &loop);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 __ bind(&loop); 628 __ bind(&loop);
629 // ebx: index of current element (smi-tagged) 629 // ebx: index of current element (smi-tagged)
630 uint32_t offset = FixedDoubleArray::kHeaderSize + sizeof(kHoleNanLower32); 630 uint32_t offset = FixedDoubleArray::kHeaderSize + sizeof(kHoleNanLower32);
631 __ cmp(FieldOperand(edi, ebx, times_4, offset), Immediate(kHoleNanUpper32)); 631 __ cmp(FieldOperand(edi, ebx, times_4, offset), Immediate(kHoleNanUpper32));
632 __ j(equal, &convert_hole); 632 __ j(equal, &convert_hole);
633 633
634 // Non-hole double, copy value into a heap number. 634 // Non-hole double, copy value into a heap number.
635 __ AllocateHeapNumber(edx, esi, no_reg, &gc_required); 635 __ AllocateHeapNumber(edx, esi, no_reg, &gc_required);
636 // edx: new heap number 636 // edx: new heap number
637 if (CpuFeatures::IsSupported(SSE2)) { 637 if (CpuFeatures::IsSupported(SSE2)) {
638 CpuFeatures::Scope fscope(SSE2); 638 CpuFeatureScope fscope(masm, SSE2);
639 __ movdbl(xmm0, 639 __ movdbl(xmm0,
640 FieldOperand(edi, ebx, times_4, FixedDoubleArray::kHeaderSize)); 640 FieldOperand(edi, ebx, times_4, FixedDoubleArray::kHeaderSize));
641 __ movdbl(FieldOperand(edx, HeapNumber::kValueOffset), xmm0); 641 __ movdbl(FieldOperand(edx, HeapNumber::kValueOffset), xmm0);
642 } else { 642 } else {
643 __ mov(esi, FieldOperand(edi, ebx, times_4, FixedDoubleArray::kHeaderSize)); 643 __ mov(esi, FieldOperand(edi, ebx, times_4, FixedDoubleArray::kHeaderSize));
644 __ mov(FieldOperand(edx, HeapNumber::kValueOffset), esi); 644 __ mov(FieldOperand(edx, HeapNumber::kValueOffset), esi);
645 __ mov(esi, FieldOperand(edi, ebx, times_4, offset)); 645 __ mov(esi, FieldOperand(edi, ebx, times_4, offset));
646 __ mov(FieldOperand(edx, HeapNumber::kValueOffset + kPointerSize), esi); 646 __ mov(FieldOperand(edx, HeapNumber::kValueOffset + kPointerSize), esi);
647 } 647 }
648 __ mov(FieldOperand(eax, ebx, times_2, FixedArray::kHeaderSize), edx); 648 __ mov(FieldOperand(eax, ebx, times_2, FixedArray::kHeaderSize), edx);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 Code* stub = GetCodeAgeStub(age, parity); 958 Code* stub = GetCodeAgeStub(age, parity);
959 CodePatcher patcher(sequence, young_length); 959 CodePatcher patcher(sequence, young_length);
960 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32); 960 patcher.masm()->call(stub->instruction_start(), RelocInfo::NONE32);
961 } 961 }
962 } 962 }
963 963
964 964
965 } } // namespace v8::internal 965 } } // namespace v8::internal
966 966
967 #endif // V8_TARGET_ARCH_IA32 967 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/ia32/deoptimizer-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698