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

Side by Side Diff: runtime/vm/assembler_dbc_test.cc

Issue 2162173002: DBC: Misc double instructions (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Make test deopt Created 4 years, 5 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
« no previous file with comments | « runtime/tests/vm/dart/double_to_smi_test.dart ('k') | runtime/vm/constants_dbc.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 (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_DBC) 6 #if defined(TARGET_ARCH_DBC)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/stack_frame.h" 9 #include "vm/stack_frame.h"
10 #include "vm/unit_test.h" 10 #include "vm/unit_test.h"
(...skipping 2474 matching lines...) Expand 10 before | Expand all | Expand 10 after
2485 __ LoadConstant(0, Smi::Handle(Smi::New(-1))); 2485 __ LoadConstant(0, Smi::Handle(Smi::New(-1)));
2486 __ Return(0); 2486 __ Return(0);
2487 } 2487 }
2488 2488
2489 2489
2490 ASSEMBLER_TEST_RUN(IfUGtFalse, test) { 2490 ASSEMBLER_TEST_RUN(IfUGtFalse, test) {
2491 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code())); 2491 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
2492 } 2492 }
2493 2493
2494 2494
2495 // - Min, Max rA, rB, rC
2496 //
2497 // FP[rA] <- {min, max}(FP[rB], FP[rC]). Assumes that FP[rB], and FP[rC] are
2498 // Smis.
2499 ASSEMBLER_TEST_GENERATE(Min, assembler) {
2500 __ Frame(3);
2501 __ LoadConstant(0, Smi::Handle(Smi::New(42)));
2502 __ LoadConstant(1, Smi::Handle(Smi::New(500)));
2503 __ Min(2, 0, 1);
2504 __ Return(2);
2505 }
2506
2507
2508 ASSEMBLER_TEST_RUN(Min, test) {
2509 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
2510 }
2511
2512
2513 ASSEMBLER_TEST_GENERATE(Max, assembler) {
2514 __ Frame(3);
2515 __ LoadConstant(0, Smi::Handle(Smi::New(42)));
2516 __ LoadConstant(1, Smi::Handle(Smi::New(5)));
2517 __ Max(2, 0, 1);
2518 __ Return(2);
2519 }
2520
2521
2522 ASSEMBLER_TEST_RUN(Max, test) {
2523 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
2524 }
2525
2526
2495 #if defined(ARCH_IS_64_BIT) 2527 #if defined(ARCH_IS_64_BIT)
2496 // - UnboxDouble rA, rD 2528 // - UnboxDouble rA, rD
2497 // 2529 //
2498 // Unbox the double in FP[rD] into FP[rA]. Assumes FP[rD] is a double. 2530 // Unbox the double in FP[rD] into FP[rA]. Assumes FP[rD] is a double.
2499 // 2531 //
2500 // - CheckedUnboxDouble rA, rD 2532 // - CheckedUnboxDouble rA, rD
2501 // 2533 //
2502 // Unboxes FP[rD] into FP[rA] and skips the following instruction unless 2534 // Unboxes FP[rD] into FP[rA] and skips the following instruction unless
2503 // FP[rD] is not a double or a Smi. When FP[rD] is a Smi, converts it to a 2535 // FP[rD] is not a double or a Smi. When FP[rD] is a Smi, converts it to a
2504 // double. 2536 // double.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
2631 __ UnboxDouble(0, 0); 2663 __ UnboxDouble(0, 0);
2632 __ DNeg(1, 0); 2664 __ DNeg(1, 0);
2633 __ Return(1); 2665 __ Return(1);
2634 } 2666 }
2635 2667
2636 2668
2637 ASSEMBLER_TEST_RUN(DNeg, test) { 2669 ASSEMBLER_TEST_RUN(DNeg, test) {
2638 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(test->code())); 2670 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(test->code()));
2639 } 2671 }
2640 2672
2673
2674 ASSEMBLER_TEST_GENERATE(DSqrt, assembler) {
2675 __ Frame(2);
2676 __ LoadConstant(0, Double::Handle(Double::New(36.0, Heap::kOld)));
2677 __ UnboxDouble(0, 0);
2678 __ DSqrt(1, 0);
2679 __ Return(1);
2680 }
2681
2682
2683 ASSEMBLER_TEST_RUN(DSqrt, test) {
2684 EXPECT_EQ(6.0, EXECUTE_TEST_CODE_DOUBLE(test->code()));
2685 }
2686
2687
2688 // - SmiToDouble rA, rD
2689 //
2690 // Convert the Smi in FP[rD] to an unboxed double in FP[rA].
2691 //
2692 // - DoubleToSmi rA, rD
2693 //
2694 // If the unboxed double in FP[rD] can be converted to a Smi in FP[rA], then
2695 // this instruction does so, and skips the following instruction. Otherwise,
2696 // the following instruction is not skipped.
2697 ASSEMBLER_TEST_GENERATE(SmiToDouble, assembler) {
2698 __ Frame(2);
2699 __ LoadConstant(0, Smi::Handle(Smi::New(42)));
2700 __ SmiToDouble(1, 0);
2701 __ Return(1);
2702 }
2703
2704
2705 ASSEMBLER_TEST_RUN(SmiToDouble, test) {
2706 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(test->code()));
2707 }
2708
2709
2710 ASSEMBLER_TEST_GENERATE(DoubleToSmi, assembler) {
2711 __ Frame(2);
2712 __ LoadConstant(0, Double::Handle(Double::New(42.0, Heap::kOld)));
2713 __ LoadConstant(1, Smi::Handle(Smi::New(-1)));
2714 __ UnboxDouble(0, 0);
2715 __ DoubleToSmi(1, 0);
2716 __ LoadConstant(1, Smi::Handle(Smi::New(-1)));
2717 __ Return(1);
2718 }
2719
2720
2721 ASSEMBLER_TEST_RUN(DoubleToSmi, test) {
2722 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
2723 }
2724
2725
2726 ASSEMBLER_TEST_GENERATE(DoubleToSmiNearMax, assembler) {
2727 const double m = static_cast<double>(Smi::kMaxValue - 1000);
2728 __ Frame(2);
2729 __ LoadConstant(0, Double::Handle(Double::New(m, Heap::kOld)));
2730 __ LoadConstant(1, Smi::Handle(Smi::New(42)));
2731 __ UnboxDouble(0, 0);
2732 __ DoubleToSmi(0, 0);
2733 __ LoadConstant(1, Smi::Handle(Smi::New(-1)));
2734 __ Return(1);
2735 }
2736
2737
2738 ASSEMBLER_TEST_RUN(DoubleToSmiNearMax, test) {
2739 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
2740 }
2741
2742
2743 ASSEMBLER_TEST_GENERATE(DoubleToSmiNearMin, assembler) {
2744 const double m = static_cast<double>(Smi::kMinValue);
2745 __ Frame(2);
2746 __ LoadConstant(0, Double::Handle(Double::New(m, Heap::kOld)));
2747 __ LoadConstant(1, Smi::Handle(Smi::New(42)));
2748 __ UnboxDouble(0, 0);
2749 __ DoubleToSmi(0, 0);
2750 __ LoadConstant(1, Smi::Handle(Smi::New(-1)));
2751 __ Return(1);
2752 }
2753
2754
2755 ASSEMBLER_TEST_RUN(DoubleToSmiNearMin, test) {
2756 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
2757 }
2758
2759
2760 ASSEMBLER_TEST_GENERATE(DoubleToSmiFailPos, assembler) {
2761 const double pos_overflow = static_cast<double>(Smi::kMaxValue + 1);
2762 __ Frame(2);
2763 __ LoadConstant(0, Double::Handle(Double::New(pos_overflow, Heap::kOld)));
2764 __ LoadConstant(1, Smi::Handle(Smi::New(-1)));
2765 __ UnboxDouble(0, 0);
2766 __ DoubleToSmi(1, 0);
2767 __ LoadConstant(1, Smi::Handle(Smi::New(42)));
2768 __ Return(1);
2769 }
2770
2771
2772 ASSEMBLER_TEST_RUN(DoubleToSmiFailPos, test) {
2773 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
2774 }
2775
2776
2777 ASSEMBLER_TEST_GENERATE(DoubleToSmiFailNeg, assembler) {
2778 const double neg_overflow = static_cast<double>(Smi::kMinValue - 1000);
2779 __ Frame(2);
2780 __ LoadConstant(0, Double::Handle(Double::New(neg_overflow, Heap::kOld)));
2781 __ LoadConstant(1, Smi::Handle(Smi::New(-1)));
2782 __ UnboxDouble(0, 0);
2783 __ DoubleToSmi(1, 0);
2784 __ LoadConstant(1, Smi::Handle(Smi::New(42)));
2785 __ Return(1);
2786 }
2787
2788
2789 ASSEMBLER_TEST_RUN(DoubleToSmiFailNeg, test) {
2790 EXPECT_EQ(42, EXECUTE_TEST_CODE_INTPTR(test->code()));
2791 }
2792
2793
2794 ASSEMBLER_TEST_GENERATE(DMin, assembler) {
2795 __ Frame(3);
2796 __ LoadConstant(0, Double::Handle(Double::New(42.0, Heap::kOld)));
2797 __ LoadConstant(1, Double::Handle(Double::New(500.0, Heap::kOld)));
2798 __ UnboxDouble(0, 0);
2799 __ UnboxDouble(1, 1);
2800 __ DMin(2, 0, 1);
2801 __ Return(2);
2802 }
2803
2804
2805 ASSEMBLER_TEST_RUN(DMin, test) {
2806 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(test->code()));
2807 }
2808
2809
2810 ASSEMBLER_TEST_GENERATE(DMax, assembler) {
2811 __ Frame(3);
2812 __ LoadConstant(0, Double::Handle(Double::New(42.0, Heap::kOld)));
2813 __ LoadConstant(1, Double::Handle(Double::New(5.0, Heap::kOld)));
2814 __ UnboxDouble(0, 0);
2815 __ UnboxDouble(1, 1);
2816 __ DMax(2, 0, 1);
2817 __ Return(2);
2818 }
2819
2820
2821 ASSEMBLER_TEST_RUN(DMax, test) {
2822 EXPECT_EQ(42.0, EXECUTE_TEST_CODE_DOUBLE(test->code()));
2823 }
2824
2641 #endif // defined(ARCH_IS_64_BIT) 2825 #endif // defined(ARCH_IS_64_BIT)
2642 2826
2643 } // namespace dart 2827 } // namespace dart
2644 2828
2645 #endif // defined(TARGET_ARCH_DBC) 2829 #endif // defined(TARGET_ARCH_DBC)
OLDNEW
« no previous file with comments | « runtime/tests/vm/dart/double_to_smi_test.dart ('k') | runtime/vm/constants_dbc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698