| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 typedef int (*F3)(float x); | 158 typedef int (*F3)(float x); |
| 159 | 159 |
| 160 TEST(AssemblerIa323) { | 160 TEST(AssemblerIa323) { |
| 161 InitializeVM(); | 161 InitializeVM(); |
| 162 v8::HandleScope scope; | 162 v8::HandleScope scope; |
| 163 | 163 |
| 164 v8::internal::byte buffer[256]; | 164 v8::internal::byte buffer[256]; |
| 165 Assembler assm(buffer, sizeof buffer); | 165 Assembler assm(buffer, sizeof buffer); |
| 166 | 166 |
| 167 Serializer::disable(); // Needed for Probe when running without snapshot. | |
| 168 CpuFeatures::Probe(); | |
| 169 CHECK(CpuFeatures::IsSupported(CpuFeatures::SSE2)); | 167 CHECK(CpuFeatures::IsSupported(CpuFeatures::SSE2)); |
| 170 { CpuFeatures::Scope fscope(CpuFeatures::SSE2); | 168 { CpuFeatures::Scope fscope(CpuFeatures::SSE2); |
| 171 __ cvttss2si(eax, Operand(esp, 4)); | 169 __ cvttss2si(eax, Operand(esp, 4)); |
| 172 __ ret(0); | 170 __ ret(0); |
| 173 } | 171 } |
| 174 | 172 |
| 175 CodeDesc desc; | 173 CodeDesc desc; |
| 176 assm.GetCode(&desc); | 174 assm.GetCode(&desc); |
| 177 Code* code = | 175 Code* code = |
| 178 Code::cast(Heap::CreateCode(desc, NULL, Code::ComputeFlags(Code::STUB))); | 176 Code::cast(Heap::CreateCode(desc, NULL, Code::ComputeFlags(Code::STUB))); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 190 | 188 |
| 191 typedef int (*F4)(double x); | 189 typedef int (*F4)(double x); |
| 192 | 190 |
| 193 TEST(AssemblerIa324) { | 191 TEST(AssemblerIa324) { |
| 194 InitializeVM(); | 192 InitializeVM(); |
| 195 v8::HandleScope scope; | 193 v8::HandleScope scope; |
| 196 | 194 |
| 197 v8::internal::byte buffer[256]; | 195 v8::internal::byte buffer[256]; |
| 198 Assembler assm(buffer, sizeof buffer); | 196 Assembler assm(buffer, sizeof buffer); |
| 199 | 197 |
| 200 Serializer::disable(); // Needed for Probe when running without snapshot. | |
| 201 CpuFeatures::Probe(); | |
| 202 CHECK(CpuFeatures::IsSupported(CpuFeatures::SSE2)); | 198 CHECK(CpuFeatures::IsSupported(CpuFeatures::SSE2)); |
| 203 CpuFeatures::Scope fscope(CpuFeatures::SSE2); | 199 CpuFeatures::Scope fscope(CpuFeatures::SSE2); |
| 204 __ cvttsd2si(eax, Operand(esp, 4)); | 200 __ cvttsd2si(eax, Operand(esp, 4)); |
| 205 __ ret(0); | 201 __ ret(0); |
| 206 | 202 |
| 207 CodeDesc desc; | 203 CodeDesc desc; |
| 208 assm.GetCode(&desc); | 204 assm.GetCode(&desc); |
| 209 Code* code = | 205 Code* code = |
| 210 Code::cast(Heap::CreateCode(desc, NULL, Code::ComputeFlags(Code::STUB))); | 206 Code::cast(Heap::CreateCode(desc, NULL, Code::ComputeFlags(Code::STUB))); |
| 211 // don't print the code - our disassembler can't handle cvttsd2si | 207 // don't print the code - our disassembler can't handle cvttsd2si |
| (...skipping 27 matching lines...) Expand all Loading... |
| 239 int res = f(); | 235 int res = f(); |
| 240 CHECK_EQ(42, res); | 236 CHECK_EQ(42, res); |
| 241 } | 237 } |
| 242 | 238 |
| 243 | 239 |
| 244 typedef double (*F5)(double x, double y); | 240 typedef double (*F5)(double x, double y); |
| 245 | 241 |
| 246 TEST(AssemblerIa326) { | 242 TEST(AssemblerIa326) { |
| 247 InitializeVM(); | 243 InitializeVM(); |
| 248 v8::HandleScope scope; | 244 v8::HandleScope scope; |
| 249 Serializer::disable(); // Needed for Probe when running without snapshot. | |
| 250 CpuFeatures::Probe(); | |
| 251 CHECK(CpuFeatures::IsSupported(CpuFeatures::SSE2)); | 245 CHECK(CpuFeatures::IsSupported(CpuFeatures::SSE2)); |
| 252 CpuFeatures::Scope fscope(CpuFeatures::SSE2); | 246 CpuFeatures::Scope fscope(CpuFeatures::SSE2); |
| 253 v8::internal::byte buffer[256]; | 247 v8::internal::byte buffer[256]; |
| 254 Assembler assm(buffer, sizeof buffer); | 248 Assembler assm(buffer, sizeof buffer); |
| 255 | 249 |
| 256 __ movdbl(xmm0, Operand(esp, 1 * kPointerSize)); | 250 __ movdbl(xmm0, Operand(esp, 1 * kPointerSize)); |
| 257 __ movdbl(xmm1, Operand(esp, 3 * kPointerSize)); | 251 __ movdbl(xmm1, Operand(esp, 3 * kPointerSize)); |
| 258 __ addsd(xmm0, xmm1); | 252 __ addsd(xmm0, xmm1); |
| 259 __ mulsd(xmm0, xmm1); | 253 __ mulsd(xmm0, xmm1); |
| 260 __ subsd(xmm0, xmm1); | 254 __ subsd(xmm0, xmm1); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 283 ::printf("f() = %f\n", res); | 277 ::printf("f() = %f\n", res); |
| 284 CHECK(2.29 < res && res < 2.31); | 278 CHECK(2.29 < res && res < 2.31); |
| 285 } | 279 } |
| 286 | 280 |
| 287 | 281 |
| 288 typedef double (*F6)(int x); | 282 typedef double (*F6)(int x); |
| 289 | 283 |
| 290 TEST(AssemblerIa328) { | 284 TEST(AssemblerIa328) { |
| 291 InitializeVM(); | 285 InitializeVM(); |
| 292 v8::HandleScope scope; | 286 v8::HandleScope scope; |
| 293 Serializer::disable(); // Needed for Probe when running without snapshot. | |
| 294 CpuFeatures::Probe(); | |
| 295 CHECK(CpuFeatures::IsSupported(CpuFeatures::SSE2)); | 287 CHECK(CpuFeatures::IsSupported(CpuFeatures::SSE2)); |
| 296 CpuFeatures::Scope fscope(CpuFeatures::SSE2); | 288 CpuFeatures::Scope fscope(CpuFeatures::SSE2); |
| 297 v8::internal::byte buffer[256]; | 289 v8::internal::byte buffer[256]; |
| 298 Assembler assm(buffer, sizeof buffer); | 290 Assembler assm(buffer, sizeof buffer); |
| 299 __ mov(eax, Operand(esp, 4)); | 291 __ mov(eax, Operand(esp, 4)); |
| 300 __ cvtsi2sd(xmm0, Operand(eax)); | 292 __ cvtsi2sd(xmm0, Operand(eax)); |
| 301 // Copy xmm0 to st(0) using eight bytes of stack. | 293 // Copy xmm0 to st(0) using eight bytes of stack. |
| 302 __ sub(Operand(esp), Immediate(8)); | 294 __ sub(Operand(esp), Immediate(8)); |
| 303 __ movdbl(Operand(esp, 0), xmm0); | 295 __ movdbl(Operand(esp, 0), xmm0); |
| 304 __ fld_d(Operand(esp, 0)); | 296 __ fld_d(Operand(esp, 0)); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 #endif | 359 #endif |
| 368 | 360 |
| 369 F7 f = FUNCTION_CAST<F7>(Code::cast(code)->entry()); | 361 F7 f = FUNCTION_CAST<F7>(Code::cast(code)->entry()); |
| 370 CHECK_EQ(kLess, f(1.1, 2.2)); | 362 CHECK_EQ(kLess, f(1.1, 2.2)); |
| 371 CHECK_EQ(kEqual, f(2.2, 2.2)); | 363 CHECK_EQ(kEqual, f(2.2, 2.2)); |
| 372 CHECK_EQ(kGreater, f(3.3, 2.2)); | 364 CHECK_EQ(kGreater, f(3.3, 2.2)); |
| 373 CHECK_EQ(kNaN, f(OS::nan_value(), 1.1)); | 365 CHECK_EQ(kNaN, f(OS::nan_value(), 1.1)); |
| 374 } | 366 } |
| 375 | 367 |
| 376 #undef __ | 368 #undef __ |
| OLD | NEW |