OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 29 matching lines...) Expand all Loading... |
40 using v8::internal::Condition; | 40 using v8::internal::Condition; |
41 using v8::internal::FUNCTION_CAST; | 41 using v8::internal::FUNCTION_CAST; |
42 using v8::internal::HandleScope; | 42 using v8::internal::HandleScope; |
43 using v8::internal::Immediate; | 43 using v8::internal::Immediate; |
44 using v8::internal::Isolate; | 44 using v8::internal::Isolate; |
45 using v8::internal::Label; | 45 using v8::internal::Label; |
46 using v8::internal::MacroAssembler; | 46 using v8::internal::MacroAssembler; |
47 using v8::internal::OS; | 47 using v8::internal::OS; |
48 using v8::internal::Operand; | 48 using v8::internal::Operand; |
49 using v8::internal::RelocInfo; | 49 using v8::internal::RelocInfo; |
| 50 using v8::internal::Representation; |
50 using v8::internal::Smi; | 51 using v8::internal::Smi; |
51 using v8::internal::SmiIndex; | 52 using v8::internal::SmiIndex; |
52 using v8::internal::byte; | 53 using v8::internal::byte; |
53 using v8::internal::carry; | 54 using v8::internal::carry; |
54 using v8::internal::greater; | 55 using v8::internal::greater; |
55 using v8::internal::greater_equal; | 56 using v8::internal::greater_equal; |
56 using v8::internal::kIntSize; | 57 using v8::internal::kIntSize; |
57 using v8::internal::kPointerSize; | 58 using v8::internal::kPointerSize; |
58 using v8::internal::kSmiTagMask; | 59 using v8::internal::kSmiTagMask; |
59 using v8::internal::kSmiValueSize; | 60 using v8::internal::kSmiValueSize; |
(...skipping 2567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2627 | 2628 |
2628 | 2629 |
2629 CodeDesc desc; | 2630 CodeDesc desc; |
2630 masm->GetCode(&desc); | 2631 masm->GetCode(&desc); |
2631 // Call the function from C++. | 2632 // Call the function from C++. |
2632 int result = FUNCTION_CAST<F0>(buffer)(); | 2633 int result = FUNCTION_CAST<F0>(buffer)(); |
2633 CHECK_EQ(0, result); | 2634 CHECK_EQ(0, result); |
2634 } | 2635 } |
2635 | 2636 |
2636 | 2637 |
| 2638 TEST(LoadAndStoreWithRepresentation) { |
| 2639 v8::internal::V8::Initialize(NULL); |
| 2640 |
| 2641 // Allocate an executable page of memory. |
| 2642 size_t actual_size; |
| 2643 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 2644 &actual_size, |
| 2645 true)); |
| 2646 CHECK(buffer); |
| 2647 Isolate* isolate = CcTest::i_isolate(); |
| 2648 HandleScope handles(isolate); |
| 2649 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| 2650 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. |
| 2651 masm->set_allow_stub_calls(false); |
| 2652 EntryCode(masm); |
| 2653 __ subq(rsp, Immediate(1 * kPointerSize)); |
| 2654 Label exit; |
| 2655 |
| 2656 // Test 1. |
| 2657 __ movq(rax, Immediate(1)); // Test number. |
| 2658 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); |
| 2659 __ movq(rcx, Immediate(-1)); |
| 2660 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Byte()); |
| 2661 __ movq(rcx, Operand(rsp, 0 * kPointerSize)); |
| 2662 __ movl(rdx, Immediate(255)); |
| 2663 __ cmpq(rcx, rdx); |
| 2664 __ j(not_equal, &exit); |
| 2665 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::Byte()); |
| 2666 __ cmpq(rcx, rdx); |
| 2667 __ j(not_equal, &exit); |
| 2668 |
| 2669 // Test 2. |
| 2670 __ movq(rax, Immediate(2)); // Test number. |
| 2671 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); |
| 2672 __ Set(rcx, V8_2PART_UINT64_C(0xdeadbeaf, 12345678)); |
| 2673 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Smi()); |
| 2674 __ movq(rcx, Operand(rsp, 0 * kPointerSize)); |
| 2675 __ Set(rdx, V8_2PART_UINT64_C(0xdeadbeaf, 12345678)); |
| 2676 __ cmpq(rcx, rdx); |
| 2677 __ j(not_equal, &exit); |
| 2678 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::Smi()); |
| 2679 __ cmpq(rcx, rdx); |
| 2680 __ j(not_equal, &exit); |
| 2681 |
| 2682 // Test 3. |
| 2683 __ movq(rax, Immediate(3)); // Test number. |
| 2684 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); |
| 2685 __ movq(rcx, Immediate(-1)); |
| 2686 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Integer32()); |
| 2687 __ movq(rcx, Operand(rsp, 0 * kPointerSize)); |
| 2688 __ movl(rdx, Immediate(-1)); |
| 2689 __ cmpq(rcx, rdx); |
| 2690 __ j(not_equal, &exit); |
| 2691 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::Integer32()); |
| 2692 __ cmpq(rcx, rdx); |
| 2693 __ j(not_equal, &exit); |
| 2694 |
| 2695 // Test 4. |
| 2696 __ movq(rax, Immediate(4)); // Test number. |
| 2697 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); |
| 2698 __ movl(rcx, Immediate(0x44332211)); |
| 2699 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::HeapObject()); |
| 2700 __ movq(rcx, Operand(rsp, 0 * kPointerSize)); |
| 2701 __ movl(rdx, Immediate(0x44332211)); |
| 2702 __ cmpq(rcx, rdx); |
| 2703 __ j(not_equal, &exit); |
| 2704 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::HeapObject()); |
| 2705 __ cmpq(rcx, rdx); |
| 2706 __ j(not_equal, &exit); |
| 2707 |
| 2708 // Test 5. |
| 2709 __ movq(rax, Immediate(5)); // Test number. |
| 2710 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); |
| 2711 __ Set(rcx, V8_2PART_UINT64_C(0x12345678, deadbeaf)); |
| 2712 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::Tagged()); |
| 2713 __ movq(rcx, Operand(rsp, 0 * kPointerSize)); |
| 2714 __ Set(rdx, V8_2PART_UINT64_C(0x12345678, deadbeaf)); |
| 2715 __ cmpq(rcx, rdx); |
| 2716 __ j(not_equal, &exit); |
| 2717 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::Tagged()); |
| 2718 __ cmpq(rcx, rdx); |
| 2719 __ j(not_equal, &exit); |
| 2720 |
| 2721 // Test 6. |
| 2722 __ movq(rax, Immediate(6)); // Test number. |
| 2723 __ movq(Operand(rsp, 0 * kPointerSize), Immediate(0)); |
| 2724 __ Set(rcx, V8_2PART_UINT64_C(0x11223344, 55667788)); |
| 2725 __ Store(Operand(rsp, 0 * kPointerSize), rcx, Representation::External()); |
| 2726 __ movq(rcx, Operand(rsp, 0 * kPointerSize)); |
| 2727 __ Set(rdx, V8_2PART_UINT64_C(0x11223344, 55667788)); |
| 2728 __ cmpq(rcx, rdx); |
| 2729 __ j(not_equal, &exit); |
| 2730 __ Load(rdx, Operand(rsp, 0 * kPointerSize), Representation::External()); |
| 2731 __ cmpq(rcx, rdx); |
| 2732 __ j(not_equal, &exit); |
| 2733 |
| 2734 __ xor_(rax, rax); // Success. |
| 2735 __ bind(&exit); |
| 2736 __ addq(rsp, Immediate(1 * kPointerSize)); |
| 2737 ExitCode(masm); |
| 2738 __ ret(0); |
| 2739 |
| 2740 CodeDesc desc; |
| 2741 masm->GetCode(&desc); |
| 2742 // Call the function from C++. |
| 2743 int result = FUNCTION_CAST<F0>(buffer)(); |
| 2744 CHECK_EQ(0, result); |
| 2745 } |
| 2746 |
2637 | 2747 |
2638 #undef __ | 2748 #undef __ |
OLD | NEW |