OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 static bool all_zeroes(const byte* beg, const byte* end) { | 53 static bool all_zeroes(const byte* beg, const byte* end) { |
54 CHECK(beg); | 54 CHECK(beg); |
55 CHECK(beg <= end); | 55 CHECK(beg <= end); |
56 while (beg < end) { | 56 while (beg < end) { |
57 if (*beg++ != 0) | 57 if (*beg++ != 0) |
58 return false; | 58 return false; |
59 } | 59 } |
60 return true; | 60 return true; |
61 } | 61 } |
62 | 62 |
63 TEST(BYTESWAP) { | |
64 CcTest::InitializeVM(); | |
65 Isolate* isolate = CcTest::i_isolate(); | |
66 HandleScope handles(isolate); | |
67 | |
68 typedef struct { | |
balazs.kilvady
2016/06/27 09:25:54
Please use struct T {}; In C++ no need to typedef
| |
69 int32_t r1; | |
70 int32_t r2; | |
71 int32_t r3; | |
72 int32_t r4; | |
73 int32_t r5; | |
74 } T; | |
75 T t; | |
76 | |
77 MacroAssembler assembler(isolate, NULL, 0, | |
78 v8::internal::CodeObjectRequired::kYes); | |
79 MacroAssembler* masm = &assembler; | |
80 | |
81 __ lw(a2, MemOperand(a0, offsetof(T, r1))); | |
82 __ nop(); | |
83 __ ByteSwapSigned(a2, 4); | |
84 __ sw(a2, MemOperand(a0, offsetof(T, r1))); | |
85 | |
86 __ lw(a2, MemOperand(a0, offsetof(T, r2))); | |
87 __ nop(); | |
88 __ ByteSwapSigned(a2, 2); | |
89 __ sw(a2, MemOperand(a0, offsetof(T, r2))); | |
90 | |
91 __ lw(a2, MemOperand(a0, offsetof(T, r3))); | |
92 __ nop(); | |
93 __ ByteSwapSigned(a2, 1); | |
94 __ sw(a2, MemOperand(a0, offsetof(T, r3))); | |
95 | |
96 __ lw(a2, MemOperand(a0, offsetof(T, r4))); | |
97 __ nop(); | |
98 __ ByteSwapUnsigned(a2, 1); | |
99 __ sw(a2, MemOperand(a0, offsetof(T, r4))); | |
100 | |
101 __ lw(a2, MemOperand(a0, offsetof(T, r5))); | |
102 __ nop(); | |
103 __ ByteSwapUnsigned(a2, 2); | |
104 __ sw(a2, MemOperand(a0, offsetof(T, r5))); | |
105 | |
106 __ jr(ra); | |
107 __ nop(); | |
108 | |
109 CodeDesc desc; | |
110 masm->GetCode(&desc); | |
111 Handle<Code> code = isolate->factory()->NewCode( | |
112 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
113 ::F f = FUNCTION_CAST<::F>(code->entry()); | |
114 t.r1 = 0x781A15C3; | |
115 t.r2 = 0x2CDE; | |
116 t.r3 = 0x9F; | |
117 t.r4 = 0x9F; | |
118 t.r5 = 0x2CDE; | |
119 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0); | |
120 USE(dummy); | |
121 | |
122 CHECK_EQ(static_cast<int32_t>(0xC3151A78), t.r1); | |
123 CHECK_EQ(static_cast<int32_t>(0xDE2C0000), t.r2); | |
124 CHECK_EQ(static_cast<int32_t>(0x9FFFFFFF), t.r3); | |
125 CHECK_EQ(static_cast<int32_t>(0x9F000000), t.r4); | |
126 CHECK_EQ(static_cast<int32_t>(0xDE2C0000), t.r5); | |
127 } | |
63 | 128 |
64 TEST(CopyBytes) { | 129 TEST(CopyBytes) { |
65 CcTest::InitializeVM(); | 130 CcTest::InitializeVM(); |
66 Isolate* isolate = CcTest::i_isolate(); | 131 Isolate* isolate = CcTest::i_isolate(); |
67 HandleScope handles(isolate); | 132 HandleScope handles(isolate); |
68 | 133 |
69 const int data_size = 1 * KB; | 134 const int data_size = 1 * KB; |
70 size_t act_size; | 135 size_t act_size; |
71 | 136 |
72 // Allocate two blocks to copy data between. | 137 // Allocate two blocks to copy data between. |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1162 int32_t out_offset) { | 1227 int32_t out_offset) { |
1163 __ Uldc1(f0, MemOperand(a0, in_offset), t0); | 1228 __ Uldc1(f0, MemOperand(a0, in_offset), t0); |
1164 __ Usdc1(f0, MemOperand(a0, out_offset), t0); | 1229 __ Usdc1(f0, MemOperand(a0, out_offset), t0); |
1165 })); | 1230 })); |
1166 } | 1231 } |
1167 } | 1232 } |
1168 } | 1233 } |
1169 } | 1234 } |
1170 | 1235 |
1171 #undef __ | 1236 #undef __ |
OLD | NEW |