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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 // Check that the source data hasn't been clobbered. | 128 // Check that the source data hasn't been clobbered. |
129 for (int i = 0; i < data_size; i++) { | 129 for (int i = 0; i < data_size; i++) { |
130 CHECK(src_buffer[i] == to_non_zero(i)); | 130 CHECK(src_buffer[i] == to_non_zero(i)); |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 | 134 |
| 135 typedef int (*F5)(void*, void*, void*, void*, void*); |
| 136 |
| 137 |
| 138 TEST(LoadAndStoreWithRepresentation) { |
| 139 v8::internal::V8::Initialize(NULL); |
| 140 |
| 141 // Allocate an executable page of memory. |
| 142 size_t actual_size; |
| 143 byte* buffer = static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize, |
| 144 &actual_size, |
| 145 true)); |
| 146 CHECK(buffer); |
| 147 Isolate* isolate = CcTest::i_isolate(); |
| 148 HandleScope handles(isolate); |
| 149 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size)); |
| 150 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro. |
| 151 masm->set_allow_stub_calls(false); |
| 152 __ sub(sp, sp, Operand(1 * kPointerSize)); |
| 153 Label exit; |
| 154 |
| 155 // Test 1. |
| 156 __ mov(r0, Operand(1)); // Test number. |
| 157 __ mov(r1, Operand(0)); |
| 158 __ str(r1, MemOperand(sp, 0 * kPointerSize)); |
| 159 __ mov(r2, Operand(-1)); |
| 160 __ Store(r2, MemOperand(sp, 0 * kPointerSize), Representation::UInteger8()); |
| 161 __ ldr(r3, MemOperand(sp, 0 * kPointerSize)); |
| 162 __ mov(r2, Operand(255)); |
| 163 __ cmp(r3, r2); |
| 164 __ b(ne, &exit); |
| 165 __ mov(r2, Operand(255)); |
| 166 __ Load(r3, MemOperand(sp, 0 * kPointerSize), Representation::UInteger8()); |
| 167 __ cmp(r3, r2); |
| 168 __ b(ne, &exit); |
| 169 |
| 170 // Test 2. |
| 171 __ mov(r0, Operand(2)); // Test number. |
| 172 __ mov(r1, Operand(0)); |
| 173 __ str(r1, MemOperand(sp, 0 * kPointerSize)); |
| 174 __ mov(r2, Operand(-1)); |
| 175 __ Store(r2, MemOperand(sp, 0 * kPointerSize), Representation::Integer8()); |
| 176 __ ldr(r3, MemOperand(sp, 0 * kPointerSize)); |
| 177 __ mov(r2, Operand(255)); |
| 178 __ cmp(r3, r2); |
| 179 __ b(ne, &exit); |
| 180 __ mov(r2, Operand(-1)); |
| 181 __ Load(r3, MemOperand(sp, 0 * kPointerSize), Representation::Integer8()); |
| 182 __ cmp(r3, r2); |
| 183 __ b(ne, &exit); |
| 184 |
| 185 // Test 3. |
| 186 __ mov(r0, Operand(3)); // Test number. |
| 187 __ mov(r1, Operand(0)); |
| 188 __ str(r1, MemOperand(sp, 0 * kPointerSize)); |
| 189 __ mov(r2, Operand(-1)); |
| 190 __ Store(r2, MemOperand(sp, 0 * kPointerSize), Representation::UInteger16()); |
| 191 __ ldr(r3, MemOperand(sp, 0 * kPointerSize)); |
| 192 __ mov(r2, Operand(65535)); |
| 193 __ cmp(r3, r2); |
| 194 __ b(ne, &exit); |
| 195 __ mov(r2, Operand(65535)); |
| 196 __ Load(r3, MemOperand(sp, 0 * kPointerSize), Representation::UInteger16()); |
| 197 __ cmp(r3, r2); |
| 198 __ b(ne, &exit); |
| 199 |
| 200 // Test 4. |
| 201 __ mov(r0, Operand(4)); // Test number. |
| 202 __ mov(r1, Operand(0)); |
| 203 __ str(r1, MemOperand(sp, 0 * kPointerSize)); |
| 204 __ mov(r2, Operand(-1)); |
| 205 __ Store(r2, MemOperand(sp, 0 * kPointerSize), Representation::Integer16()); |
| 206 __ ldr(r3, MemOperand(sp, 0 * kPointerSize)); |
| 207 __ mov(r2, Operand(65535)); |
| 208 __ cmp(r3, r2); |
| 209 __ b(ne, &exit); |
| 210 __ mov(r2, Operand(-1)); |
| 211 __ Load(r3, MemOperand(sp, 0 * kPointerSize), Representation::Integer16()); |
| 212 __ cmp(r3, r2); |
| 213 __ b(ne, &exit); |
| 214 |
| 215 __ mov(r0, Operand(0)); // Success. |
| 216 __ bind(&exit); |
| 217 __ add(sp, sp, Operand(1 * kPointerSize)); |
| 218 __ bx(lr); |
| 219 |
| 220 CodeDesc desc; |
| 221 masm->GetCode(&desc); |
| 222 Object* code = isolate->heap()->CreateCode( |
| 223 desc, |
| 224 Code::ComputeFlags(Code::STUB), |
| 225 Handle<Code>())->ToObjectChecked(); |
| 226 CHECK(code->IsCode()); |
| 227 |
| 228 // Call the function from C++. |
| 229 F5 f = FUNCTION_CAST<F5>(Code::cast(code)->entry()); |
| 230 CHECK_EQ(0, CALL_GENERATED_CODE(f, 0, 0, 0, 0, 0)); |
| 231 } |
135 | 232 |
136 #undef __ | 233 #undef __ |
OLD | NEW |