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

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 6067004: Version 3.0.4... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 12 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.h ('k') | src/ia32/codegen-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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 2454 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 2465
2466 void TypeRecordingBinaryOpStub::GenerateRegisterArgsPush(MacroAssembler* masm) { 2466 void TypeRecordingBinaryOpStub::GenerateRegisterArgsPush(MacroAssembler* masm) {
2467 __ pop(ecx); 2467 __ pop(ecx);
2468 __ push(edx); 2468 __ push(edx);
2469 __ push(eax); 2469 __ push(eax);
2470 __ push(ecx); 2470 __ push(ecx);
2471 } 2471 }
2472 2472
2473 2473
2474 void TranscendentalCacheStub::Generate(MacroAssembler* masm) { 2474 void TranscendentalCacheStub::Generate(MacroAssembler* masm) {
2475 // Input on stack: 2475 // TAGGED case:
2476 // esp[4]: argument (should be number). 2476 // Input:
2477 // esp[0]: return address. 2477 // esp[4]: tagged number input argument (should be number).
2478 // Test that eax is a number. 2478 // esp[0]: return address.
2479 // Output:
2480 // eax: tagged double result.
2481 // UNTAGGED case:
2482 // Input::
2483 // esp[0]: return address.
2484 // xmm1: untagged double input argument
2485 // Output:
2486 // xmm1: untagged double result.
2487
2479 Label runtime_call; 2488 Label runtime_call;
2480 Label runtime_call_clear_stack; 2489 Label runtime_call_clear_stack;
2481 NearLabel input_not_smi; 2490 Label skip_cache;
2482 NearLabel loaded; 2491 const bool tagged = (argument_type_ == TAGGED);
2483 __ mov(eax, Operand(esp, kPointerSize)); 2492 if (tagged) {
2484 __ test(eax, Immediate(kSmiTagMask)); 2493 // Test that eax is a number.
2485 __ j(not_zero, &input_not_smi); 2494 NearLabel input_not_smi;
2486 // Input is a smi. Untag and load it onto the FPU stack. 2495 NearLabel loaded;
2487 // Then load the low and high words of the double into ebx, edx. 2496 __ mov(eax, Operand(esp, kPointerSize));
2488 STATIC_ASSERT(kSmiTagSize == 1); 2497 __ test(eax, Immediate(kSmiTagMask));
2489 __ sar(eax, 1); 2498 __ j(not_zero, &input_not_smi);
2490 __ sub(Operand(esp), Immediate(2 * kPointerSize)); 2499 // Input is a smi. Untag and load it onto the FPU stack.
2491 __ mov(Operand(esp, 0), eax); 2500 // Then load the low and high words of the double into ebx, edx.
2492 __ fild_s(Operand(esp, 0)); 2501 STATIC_ASSERT(kSmiTagSize == 1);
2493 __ fst_d(Operand(esp, 0)); 2502 __ sar(eax, 1);
2494 __ pop(edx); 2503 __ sub(Operand(esp), Immediate(2 * kPointerSize));
2495 __ pop(ebx); 2504 __ mov(Operand(esp, 0), eax);
2496 __ jmp(&loaded); 2505 __ fild_s(Operand(esp, 0));
2497 __ bind(&input_not_smi); 2506 __ fst_d(Operand(esp, 0));
2498 // Check if input is a HeapNumber. 2507 __ pop(edx);
2499 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); 2508 __ pop(ebx);
2500 __ cmp(Operand(ebx), Immediate(Factory::heap_number_map())); 2509 __ jmp(&loaded);
2501 __ j(not_equal, &runtime_call); 2510 __ bind(&input_not_smi);
2502 // Input is a HeapNumber. Push it on the FPU stack and load its 2511 // Check if input is a HeapNumber.
2503 // low and high words into ebx, edx. 2512 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
2504 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); 2513 __ cmp(Operand(ebx), Immediate(Factory::heap_number_map()));
2505 __ mov(edx, FieldOperand(eax, HeapNumber::kExponentOffset)); 2514 __ j(not_equal, &runtime_call);
2506 __ mov(ebx, FieldOperand(eax, HeapNumber::kMantissaOffset)); 2515 // Input is a HeapNumber. Push it on the FPU stack and load its
2516 // low and high words into ebx, edx.
2517 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset));
2518 __ mov(edx, FieldOperand(eax, HeapNumber::kExponentOffset));
2519 __ mov(ebx, FieldOperand(eax, HeapNumber::kMantissaOffset));
2507 2520
2508 __ bind(&loaded); 2521 __ bind(&loaded);
2509 // ST[0] == double value 2522 } else { // UNTAGGED.
2523 if (CpuFeatures::IsSupported(SSE4_1)) {
2524 CpuFeatures::Scope sse4_scope(SSE4_1);
2525 __ pextrd(Operand(edx), xmm1, 0x1); // copy xmm1[63..32] to edx.
2526 } else {
2527 __ pshufd(xmm0, xmm1, 0x1);
2528 __ movd(Operand(edx), xmm0);
2529 }
2530 __ movd(Operand(ebx), xmm1);
2531 }
2532
2533 // ST[0] or xmm1 == double value
2510 // ebx = low 32 bits of double value 2534 // ebx = low 32 bits of double value
2511 // edx = high 32 bits of double value 2535 // edx = high 32 bits of double value
2512 // Compute hash (the shifts are arithmetic): 2536 // Compute hash (the shifts are arithmetic):
2513 // h = (low ^ high); h ^= h >> 16; h ^= h >> 8; h = h & (cacheSize - 1); 2537 // h = (low ^ high); h ^= h >> 16; h ^= h >> 8; h = h & (cacheSize - 1);
2514 __ mov(ecx, ebx); 2538 __ mov(ecx, ebx);
2515 __ xor_(ecx, Operand(edx)); 2539 __ xor_(ecx, Operand(edx));
2516 __ mov(eax, ecx); 2540 __ mov(eax, ecx);
2517 __ sar(eax, 16); 2541 __ sar(eax, 16);
2518 __ xor_(ecx, Operand(eax)); 2542 __ xor_(ecx, Operand(eax));
2519 __ mov(eax, ecx); 2543 __ mov(eax, ecx);
2520 __ sar(eax, 8); 2544 __ sar(eax, 8);
2521 __ xor_(ecx, Operand(eax)); 2545 __ xor_(ecx, Operand(eax));
2522 ASSERT(IsPowerOf2(TranscendentalCache::kCacheSize)); 2546 ASSERT(IsPowerOf2(TranscendentalCache::kCacheSize));
2523 __ and_(Operand(ecx), Immediate(TranscendentalCache::kCacheSize - 1)); 2547 __ and_(Operand(ecx), Immediate(TranscendentalCache::kCacheSize - 1));
2524 2548
2525 // ST[0] == double value. 2549 // ST[0] or xmm1 == double value.
2526 // ebx = low 32 bits of double value. 2550 // ebx = low 32 bits of double value.
2527 // edx = high 32 bits of double value. 2551 // edx = high 32 bits of double value.
2528 // ecx = TranscendentalCache::hash(double value). 2552 // ecx = TranscendentalCache::hash(double value).
2529 __ mov(eax, 2553 __ mov(eax,
2530 Immediate(ExternalReference::transcendental_cache_array_address())); 2554 Immediate(ExternalReference::transcendental_cache_array_address()));
2531 // Eax points to cache array. 2555 // Eax points to cache array.
2532 __ mov(eax, Operand(eax, type_ * sizeof(TranscendentalCache::caches_[0]))); 2556 __ mov(eax, Operand(eax, type_ * sizeof(TranscendentalCache::caches_[0])));
2533 // Eax points to the cache for the type type_. 2557 // Eax points to the cache for the type type_.
2534 // If NULL, the cache hasn't been initialized yet, so go through runtime. 2558 // If NULL, the cache hasn't been initialized yet, so go through runtime.
2535 __ test(eax, Operand(eax)); 2559 __ test(eax, Operand(eax));
(...skipping 16 matching lines...) Expand all
2552 __ lea(ecx, Operand(ecx, ecx, times_2, 0)); 2576 __ lea(ecx, Operand(ecx, ecx, times_2, 0));
2553 __ lea(ecx, Operand(eax, ecx, times_4, 0)); 2577 __ lea(ecx, Operand(eax, ecx, times_4, 0));
2554 // Check if cache matches: Double value is stored in uint32_t[2] array. 2578 // Check if cache matches: Double value is stored in uint32_t[2] array.
2555 NearLabel cache_miss; 2579 NearLabel cache_miss;
2556 __ cmp(ebx, Operand(ecx, 0)); 2580 __ cmp(ebx, Operand(ecx, 0));
2557 __ j(not_equal, &cache_miss); 2581 __ j(not_equal, &cache_miss);
2558 __ cmp(edx, Operand(ecx, kIntSize)); 2582 __ cmp(edx, Operand(ecx, kIntSize));
2559 __ j(not_equal, &cache_miss); 2583 __ j(not_equal, &cache_miss);
2560 // Cache hit! 2584 // Cache hit!
2561 __ mov(eax, Operand(ecx, 2 * kIntSize)); 2585 __ mov(eax, Operand(ecx, 2 * kIntSize));
2562 __ fstp(0); 2586 if (tagged) {
2563 __ ret(kPointerSize); 2587 __ fstp(0);
2588 __ ret(kPointerSize);
2589 } else { // UNTAGGED.
2590 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset));
2591 __ Ret();
2592 }
2564 2593
2565 __ bind(&cache_miss); 2594 __ bind(&cache_miss);
2566 // Update cache with new value. 2595 // Update cache with new value.
2567 // We are short on registers, so use no_reg as scratch. 2596 // We are short on registers, so use no_reg as scratch.
2568 // This gives slightly larger code. 2597 // This gives slightly larger code.
2569 __ AllocateHeapNumber(eax, edi, no_reg, &runtime_call_clear_stack); 2598 if (tagged) {
2599 __ AllocateHeapNumber(eax, edi, no_reg, &runtime_call_clear_stack);
2600 } else { // UNTAGGED.
2601 __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache);
2602 __ sub(Operand(esp), Immediate(kDoubleSize));
2603 __ movdbl(Operand(esp, 0), xmm1);
2604 __ fld_d(Operand(esp, 0));
2605 __ add(Operand(esp), Immediate(kDoubleSize));
2606 }
2570 GenerateOperation(masm); 2607 GenerateOperation(masm);
2571 __ mov(Operand(ecx, 0), ebx); 2608 __ mov(Operand(ecx, 0), ebx);
2572 __ mov(Operand(ecx, kIntSize), edx); 2609 __ mov(Operand(ecx, kIntSize), edx);
2573 __ mov(Operand(ecx, 2 * kIntSize), eax); 2610 __ mov(Operand(ecx, 2 * kIntSize), eax);
2574 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); 2611 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset));
2575 __ ret(kPointerSize); 2612 if (tagged) {
2613 __ ret(kPointerSize);
2614 } else { // UNTAGGED.
2615 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset));
2616 __ Ret();
2576 2617
2577 __ bind(&runtime_call_clear_stack); 2618 // Skip cache and return answer directly, only in untagged case.
2578 __ fstp(0); 2619 __ bind(&skip_cache);
2579 __ bind(&runtime_call); 2620 __ sub(Operand(esp), Immediate(kDoubleSize));
2580 __ TailCallExternalReference(ExternalReference(RuntimeFunction()), 1, 1); 2621 __ movdbl(Operand(esp, 0), xmm1);
2622 __ fld_d(Operand(esp, 0));
2623 GenerateOperation(masm);
2624 __ fstp_d(Operand(esp, 0));
2625 __ movdbl(xmm1, Operand(esp, 0));
2626 __ add(Operand(esp), Immediate(kDoubleSize));
2627 // We return the value in xmm1 without adding it to the cache, but
2628 // we cause a scavenging GC so that future allocations will succeed.
2629 __ EnterInternalFrame();
2630 // Allocate an unused object bigger than a HeapNumber.
2631 __ push(Immediate(Smi::FromInt(2 * kDoubleSize)));
2632 __ CallRuntimeSaveDoubles(Runtime::kAllocateInNewSpace);
2633 __ LeaveInternalFrame();
2634 __ Ret();
2635 }
2636
2637 // Call runtime, doing whatever allocation and cleanup is necessary.
2638 if (tagged) {
2639 __ bind(&runtime_call_clear_stack);
2640 __ fstp(0);
2641 __ bind(&runtime_call);
2642 __ TailCallExternalReference(ExternalReference(RuntimeFunction()), 1, 1);
2643 } else { // UNTAGGED.
2644 __ bind(&runtime_call_clear_stack);
2645 __ bind(&runtime_call);
2646 __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache);
2647 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm1);
2648 __ EnterInternalFrame();
2649 __ push(eax);
2650 __ CallRuntime(RuntimeFunction(), 1);
2651 __ LeaveInternalFrame();
2652 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset));
2653 __ Ret();
2654 }
2581 } 2655 }
2582 2656
2583 2657
2584 Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() { 2658 Runtime::FunctionId TranscendentalCacheStub::RuntimeFunction() {
2585 switch (type_) { 2659 switch (type_) {
2586 // Add more cases when necessary.
2587 case TranscendentalCache::SIN: return Runtime::kMath_sin; 2660 case TranscendentalCache::SIN: return Runtime::kMath_sin;
2588 case TranscendentalCache::COS: return Runtime::kMath_cos; 2661 case TranscendentalCache::COS: return Runtime::kMath_cos;
2589 case TranscendentalCache::LOG: return Runtime::kMath_log; 2662 case TranscendentalCache::LOG: return Runtime::kMath_log;
2590 default: 2663 default:
2591 UNIMPLEMENTED(); 2664 UNIMPLEMENTED();
2592 return Runtime::kAbort; 2665 return Runtime::kAbort;
2593 } 2666 }
2594 } 2667 }
2595 2668
2596 2669
2597 void TranscendentalCacheStub::GenerateOperation(MacroAssembler* masm) { 2670 void TranscendentalCacheStub::GenerateOperation(MacroAssembler* masm) {
2598 // Only free register is edi. 2671 // Only free register is edi.
2599 // Input value is on FP stack, and also in ebx/edx. Address of result 2672 // Input value is on FP stack, and also in ebx/edx.
2600 // (a newly allocated HeapNumber) is in eax. 2673 // Input value is possibly in xmm1.
2601 NearLabel done; 2674 // Address of result (a newly allocated HeapNumber) may be in eax.
2602 if (type_ == TranscendentalCache::SIN || type_ == TranscendentalCache::COS) { 2675 if (type_ == TranscendentalCache::SIN || type_ == TranscendentalCache::COS) {
2603 // Both fsin and fcos require arguments in the range +/-2^63 and 2676 // Both fsin and fcos require arguments in the range +/-2^63 and
2604 // return NaN for infinities and NaN. They can share all code except 2677 // return NaN for infinities and NaN. They can share all code except
2605 // the actual fsin/fcos operation. 2678 // the actual fsin/fcos operation.
2606 NearLabel in_range; 2679 NearLabel in_range, done;
2607 // If argument is outside the range -2^63..2^63, fsin/cos doesn't 2680 // If argument is outside the range -2^63..2^63, fsin/cos doesn't
2608 // work. We must reduce it to the appropriate range. 2681 // work. We must reduce it to the appropriate range.
2609 __ mov(edi, edx); 2682 __ mov(edi, edx);
2610 __ and_(Operand(edi), Immediate(0x7ff00000)); // Exponent only. 2683 __ and_(Operand(edi), Immediate(0x7ff00000)); // Exponent only.
2611 int supported_exponent_limit = 2684 int supported_exponent_limit =
2612 (63 + HeapNumber::kExponentBias) << HeapNumber::kExponentShift; 2685 (63 + HeapNumber::kExponentBias) << HeapNumber::kExponentShift;
2613 __ cmp(Operand(edi), Immediate(supported_exponent_limit)); 2686 __ cmp(Operand(edi), Immediate(supported_exponent_limit));
2614 __ j(below, &in_range, taken); 2687 __ j(below, &in_range, taken);
2615 // Check for infinity and NaN. Both return NaN for sin. 2688 // Check for infinity and NaN. Both return NaN for sin.
2616 __ cmp(Operand(edi), Immediate(0x7ff00000)); 2689 __ cmp(Operand(edi), Immediate(0x7ff00000));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2676 __ bind(&done); 2749 __ bind(&done);
2677 } else { 2750 } else {
2678 ASSERT(type_ == TranscendentalCache::LOG); 2751 ASSERT(type_ == TranscendentalCache::LOG);
2679 __ fldln2(); 2752 __ fldln2();
2680 __ fxch(); 2753 __ fxch();
2681 __ fyl2x(); 2754 __ fyl2x();
2682 } 2755 }
2683 } 2756 }
2684 2757
2685 2758
2686 void TranscendentalCacheSSE2Stub::Generate(MacroAssembler* masm) {
2687 // Input on stack:
2688 // esp[0]: return address.
2689 // Input in registers:
2690 // xmm1: untagged double input argument.
2691 // Output:
2692 // xmm1: untagged double result.
2693 Label skip_cache;
2694 Label call_runtime;
2695
2696 // Input is an untagged double in xmm1.
2697 // Compute hash (the shifts are arithmetic):
2698 // h = (low ^ high); h ^= h >> 16; h ^= h >> 8; h = h & (cacheSize - 1);
2699 if (CpuFeatures::IsSupported(SSE4_1)) {
2700 CpuFeatures::Scope sse4_scope(SSE4_1);
2701 __ pextrd(Operand(edx), xmm1, 0x1); // copy xmm1[63..32] to edx.
2702 } else {
2703 __ pshufd(xmm0, xmm1, 0x1);
2704 __ movd(Operand(edx), xmm0);
2705 }
2706 __ movd(Operand(ebx), xmm1);
2707
2708 // xmm1 = double value
2709 // ebx = low 32 bits of double value
2710 // edx = high 32 bits of double value
2711 // Compute hash (the shifts are arithmetic):
2712 // h = (low ^ high); h ^= h >> 16; h ^= h >> 8; h = h & (cacheSize - 1);
2713 __ mov(ecx, ebx);
2714 __ xor_(ecx, Operand(edx));
2715 __ mov(eax, ecx);
2716 __ sar(eax, 16);
2717 __ xor_(ecx, Operand(eax));
2718 __ mov(eax, ecx);
2719 __ sar(eax, 8);
2720 __ xor_(ecx, Operand(eax));
2721 ASSERT(IsPowerOf2(TranscendentalCache::kCacheSize));
2722 __ and_(Operand(ecx), Immediate(TranscendentalCache::kCacheSize - 1));
2723
2724 // xmm1 = double value.
2725 // ebx = low 32 bits of double value.
2726 // edx = high 32 bits of double value.
2727 // ecx = TranscendentalCache::hash(double value).
2728 __ mov(eax,
2729 Immediate(ExternalReference::transcendental_cache_array_address()));
2730 // Eax points to cache array.
2731 __ mov(eax, Operand(eax, type_ * sizeof(TranscendentalCache::caches_[0])));
2732 // Eax points to the cache for the type type_.
2733 // If NULL, the cache hasn't been initialized yet, so go through runtime.
2734 __ test(eax, Operand(eax));
2735 __ j(zero, &call_runtime);
2736 #ifdef DEBUG
2737 // Check that the layout of cache elements match expectations.
2738 { TranscendentalCache::Element test_elem[2];
2739 char* elem_start = reinterpret_cast<char*>(&test_elem[0]);
2740 char* elem2_start = reinterpret_cast<char*>(&test_elem[1]);
2741 char* elem_in0 = reinterpret_cast<char*>(&(test_elem[0].in[0]));
2742 char* elem_in1 = reinterpret_cast<char*>(&(test_elem[0].in[1]));
2743 char* elem_out = reinterpret_cast<char*>(&(test_elem[0].output));
2744 CHECK_EQ(12, elem2_start - elem_start); // Two uint_32's and a pointer.
2745 CHECK_EQ(0, elem_in0 - elem_start);
2746 CHECK_EQ(kIntSize, elem_in1 - elem_start);
2747 CHECK_EQ(2 * kIntSize, elem_out - elem_start);
2748 }
2749 #endif
2750 // Find the address of the ecx'th entry in the cache, i.e., &eax[ecx*12].
2751 __ lea(ecx, Operand(ecx, ecx, times_2, 0));
2752 __ lea(ecx, Operand(eax, ecx, times_4, 0));
2753 // Check if cache matches: Double value is stored in uint32_t[2] array.
2754 NearLabel cache_miss;
2755 __ cmp(ebx, Operand(ecx, 0));
2756 __ j(not_equal, &cache_miss);
2757 __ cmp(edx, Operand(ecx, kIntSize));
2758 __ j(not_equal, &cache_miss);
2759 // Cache hit!
2760 __ mov(eax, Operand(ecx, 2 * kIntSize));
2761 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset));
2762 __ Ret();
2763
2764 __ bind(&cache_miss);
2765 // Update cache with new value.
2766 // We are short on registers, so use no_reg as scratch.
2767 // This gives slightly larger code.
2768 __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache);
2769 __ sub(Operand(esp), Immediate(kDoubleSize));
2770 __ movdbl(Operand(esp, 0), xmm1);
2771 __ fld_d(Operand(esp, 0));
2772 __ add(Operand(esp), Immediate(kDoubleSize));
2773 GenerateOperation(masm);
2774 __ mov(Operand(ecx, 0), ebx);
2775 __ mov(Operand(ecx, kIntSize), edx);
2776 __ mov(Operand(ecx, 2 * kIntSize), eax);
2777 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset));
2778 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset));
2779 __ Ret();
2780
2781 __ bind(&skip_cache);
2782 __ sub(Operand(esp), Immediate(kDoubleSize));
2783 __ movdbl(Operand(esp, 0), xmm1);
2784 __ fld_d(Operand(esp, 0));
2785 GenerateOperation(masm);
2786 __ fstp_d(Operand(esp, 0));
2787 __ movdbl(xmm1, Operand(esp, 0));
2788 __ add(Operand(esp), Immediate(kDoubleSize));
2789 __ Ret();
2790
2791 __ bind(&call_runtime);
2792 __ AllocateHeapNumber(eax, edi, no_reg, &skip_cache);
2793 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm1);
2794 __ EnterInternalFrame();
2795 __ push(eax);
2796 __ CallRuntime(RuntimeFunction(), 1);
2797 __ LeaveInternalFrame();
2798 __ movdbl(xmm1, FieldOperand(eax, HeapNumber::kValueOffset));
2799 __ Ret();
2800 }
2801
2802
2803 Runtime::FunctionId TranscendentalCacheSSE2Stub::RuntimeFunction() {
2804 switch (type_) {
2805 // Add more cases when necessary.
2806 case TranscendentalCache::LOG: return Runtime::kMath_log;
2807 default:
2808 UNIMPLEMENTED();
2809 return Runtime::kAbort;
2810 }
2811 }
2812
2813
2814 void TranscendentalCacheSSE2Stub::GenerateOperation(MacroAssembler* masm) {
2815 // Only free register is edi.
2816 // Input value is on FP stack and in xmm1.
2817
2818 ASSERT(type_ == TranscendentalCache::LOG);
2819 __ fldln2();
2820 __ fxch();
2821 __ fyl2x();
2822 }
2823
2824
2825 // Get the integer part of a heap number. Surprisingly, all this bit twiddling 2759 // Get the integer part of a heap number. Surprisingly, all this bit twiddling
2826 // is faster than using the built-in instructions on floating point registers. 2760 // is faster than using the built-in instructions on floating point registers.
2827 // Trashes edi and ebx. Dest is ecx. Source cannot be ecx or one of the 2761 // Trashes edi and ebx. Dest is ecx. Source cannot be ecx or one of the
2828 // trashed registers. 2762 // trashed registers.
2829 void IntegerConvert(MacroAssembler* masm, 2763 void IntegerConvert(MacroAssembler* masm,
2830 Register source, 2764 Register source,
2831 TypeInfo type_info, 2765 TypeInfo type_info,
2832 bool use_sse3, 2766 bool use_sse3,
2833 Label* conversion_failure) { 2767 Label* conversion_failure) {
2834 ASSERT(!source.is(ecx) && !source.is(edi) && !source.is(ebx)); 2768 ASSERT(!source.is(ecx) && !source.is(edi) && !source.is(ebx));
(...skipping 3636 matching lines...) Expand 10 before | Expand all | Expand 10 after
6471 // Do a tail call to the rewritten stub. 6405 // Do a tail call to the rewritten stub.
6472 __ jmp(Operand(edi)); 6406 __ jmp(Operand(edi));
6473 } 6407 }
6474 6408
6475 6409
6476 #undef __ 6410 #undef __
6477 6411
6478 } } // namespace v8::internal 6412 } } // namespace v8::internal
6479 6413
6480 #endif // V8_TARGET_ARCH_IA32 6414 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.h ('k') | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698