| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 InitializeVM(); | 173 InitializeVM(); |
| 174 if (!CpuFeatures::IsSupported(SSE2)) return; | 174 if (!CpuFeatures::IsSupported(SSE2)) return; |
| 175 | 175 |
| 176 v8::HandleScope scope; | 176 v8::HandleScope scope; |
| 177 | 177 |
| 178 v8::internal::byte buffer[256]; | 178 v8::internal::byte buffer[256]; |
| 179 Isolate* isolate = Isolate::Current(); | 179 Isolate* isolate = Isolate::Current(); |
| 180 Assembler assm(isolate, buffer, sizeof buffer); | 180 Assembler assm(isolate, buffer, sizeof buffer); |
| 181 | 181 |
| 182 CHECK(CpuFeatures::IsSupported(SSE2)); | 182 CHECK(CpuFeatures::IsSupported(SSE2)); |
| 183 { CpuFeatures::Scope fscope(SSE2); | 183 { CpuFeatureScope fscope(&assm, SSE2); |
| 184 __ cvttss2si(eax, Operand(esp, 4)); | 184 __ cvttss2si(eax, Operand(esp, 4)); |
| 185 __ ret(0); | 185 __ ret(0); |
| 186 } | 186 } |
| 187 | 187 |
| 188 CodeDesc desc; | 188 CodeDesc desc; |
| 189 assm.GetCode(&desc); | 189 assm.GetCode(&desc); |
| 190 Code* code = Code::cast(isolate->heap()->CreateCode( | 190 Code* code = Code::cast(isolate->heap()->CreateCode( |
| 191 desc, | 191 desc, |
| 192 Code::ComputeFlags(Code::STUB), | 192 Code::ComputeFlags(Code::STUB), |
| 193 Handle<Code>())->ToObjectChecked()); | 193 Handle<Code>())->ToObjectChecked()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 209 InitializeVM(); | 209 InitializeVM(); |
| 210 if (!CpuFeatures::IsSupported(SSE2)) return; | 210 if (!CpuFeatures::IsSupported(SSE2)) return; |
| 211 | 211 |
| 212 v8::HandleScope scope; | 212 v8::HandleScope scope; |
| 213 | 213 |
| 214 v8::internal::byte buffer[256]; | 214 v8::internal::byte buffer[256]; |
| 215 Isolate* isolate = Isolate::Current(); | 215 Isolate* isolate = Isolate::Current(); |
| 216 Assembler assm(isolate, buffer, sizeof buffer); | 216 Assembler assm(isolate, buffer, sizeof buffer); |
| 217 | 217 |
| 218 CHECK(CpuFeatures::IsSupported(SSE2)); | 218 CHECK(CpuFeatures::IsSupported(SSE2)); |
| 219 CpuFeatures::Scope fscope(SSE2); | 219 CpuFeatureScope fscope(&assm, SSE2); |
| 220 __ cvttsd2si(eax, Operand(esp, 4)); | 220 __ cvttsd2si(eax, Operand(esp, 4)); |
| 221 __ ret(0); | 221 __ ret(0); |
| 222 | 222 |
| 223 CodeDesc desc; | 223 CodeDesc desc; |
| 224 assm.GetCode(&desc); | 224 assm.GetCode(&desc); |
| 225 Code* code = Code::cast(isolate->heap()->CreateCode( | 225 Code* code = Code::cast(isolate->heap()->CreateCode( |
| 226 desc, | 226 desc, |
| 227 Code::ComputeFlags(Code::STUB), | 227 Code::ComputeFlags(Code::STUB), |
| 228 Handle<Code>())->ToObjectChecked()); | 228 Handle<Code>())->ToObjectChecked()); |
| 229 // don't print the code - our disassembler can't handle cvttsd2si | 229 // don't print the code - our disassembler can't handle cvttsd2si |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 } | 262 } |
| 263 | 263 |
| 264 | 264 |
| 265 typedef double (*F5)(double x, double y); | 265 typedef double (*F5)(double x, double y); |
| 266 | 266 |
| 267 TEST(AssemblerIa326) { | 267 TEST(AssemblerIa326) { |
| 268 InitializeVM(); | 268 InitializeVM(); |
| 269 if (!CpuFeatures::IsSupported(SSE2)) return; | 269 if (!CpuFeatures::IsSupported(SSE2)) return; |
| 270 | 270 |
| 271 v8::HandleScope scope; | 271 v8::HandleScope scope; |
| 272 CHECK(CpuFeatures::IsSupported(SSE2)); | |
| 273 CpuFeatures::Scope fscope(SSE2); | |
| 274 v8::internal::byte buffer[256]; | 272 v8::internal::byte buffer[256]; |
| 275 Isolate* isolate = Isolate::Current(); | 273 Isolate* isolate = Isolate::Current(); |
| 276 Assembler assm(isolate, buffer, sizeof buffer); | 274 Assembler assm(isolate, buffer, sizeof buffer); |
| 277 | 275 |
| 276 CpuFeatureScope fscope(&assm, SSE2); |
| 278 __ movdbl(xmm0, Operand(esp, 1 * kPointerSize)); | 277 __ movdbl(xmm0, Operand(esp, 1 * kPointerSize)); |
| 279 __ movdbl(xmm1, Operand(esp, 3 * kPointerSize)); | 278 __ movdbl(xmm1, Operand(esp, 3 * kPointerSize)); |
| 280 __ addsd(xmm0, xmm1); | 279 __ addsd(xmm0, xmm1); |
| 281 __ mulsd(xmm0, xmm1); | 280 __ mulsd(xmm0, xmm1); |
| 282 __ subsd(xmm0, xmm1); | 281 __ subsd(xmm0, xmm1); |
| 283 __ divsd(xmm0, xmm1); | 282 __ divsd(xmm0, xmm1); |
| 284 // Copy xmm0 to st(0) using eight bytes of stack. | 283 // Copy xmm0 to st(0) using eight bytes of stack. |
| 285 __ sub(esp, Immediate(8)); | 284 __ sub(esp, Immediate(8)); |
| 286 __ movdbl(Operand(esp, 0), xmm0); | 285 __ movdbl(Operand(esp, 0), xmm0); |
| 287 __ fld_d(Operand(esp, 0)); | 286 __ fld_d(Operand(esp, 0)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 309 } | 308 } |
| 310 | 309 |
| 311 | 310 |
| 312 typedef double (*F6)(int x); | 311 typedef double (*F6)(int x); |
| 313 | 312 |
| 314 TEST(AssemblerIa328) { | 313 TEST(AssemblerIa328) { |
| 315 InitializeVM(); | 314 InitializeVM(); |
| 316 if (!CpuFeatures::IsSupported(SSE2)) return; | 315 if (!CpuFeatures::IsSupported(SSE2)) return; |
| 317 | 316 |
| 318 v8::HandleScope scope; | 317 v8::HandleScope scope; |
| 319 CHECK(CpuFeatures::IsSupported(SSE2)); | |
| 320 CpuFeatures::Scope fscope(SSE2); | |
| 321 v8::internal::byte buffer[256]; | 318 v8::internal::byte buffer[256]; |
| 322 Isolate* isolate = Isolate::Current(); | 319 Isolate* isolate = Isolate::Current(); |
| 323 Assembler assm(isolate, buffer, sizeof buffer); | 320 Assembler assm(isolate, buffer, sizeof buffer); |
| 321 CpuFeatureScope fscope(&assm, SSE2); |
| 324 __ mov(eax, Operand(esp, 4)); | 322 __ mov(eax, Operand(esp, 4)); |
| 325 __ cvtsi2sd(xmm0, eax); | 323 __ cvtsi2sd(xmm0, eax); |
| 326 // Copy xmm0 to st(0) using eight bytes of stack. | 324 // Copy xmm0 to st(0) using eight bytes of stack. |
| 327 __ sub(esp, Immediate(8)); | 325 __ sub(esp, Immediate(8)); |
| 328 __ movdbl(Operand(esp, 0), xmm0); | 326 __ movdbl(Operand(esp, 0), xmm0); |
| 329 __ fld_d(Operand(esp, 0)); | 327 __ fld_d(Operand(esp, 0)); |
| 330 __ add(esp, Immediate(8)); | 328 __ add(esp, Immediate(8)); |
| 331 __ ret(0); | 329 __ ret(0); |
| 332 CodeDesc desc; | 330 CodeDesc desc; |
| 333 assm.GetCode(&desc); | 331 assm.GetCode(&desc); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 479 |
| 482 F0 f = FUNCTION_CAST<F0>(code->entry()); | 480 F0 f = FUNCTION_CAST<F0>(code->entry()); |
| 483 int res = f(); | 481 int res = f(); |
| 484 CHECK_EQ(42, res); | 482 CHECK_EQ(42, res); |
| 485 } | 483 } |
| 486 | 484 |
| 487 | 485 |
| 488 | 486 |
| 489 | 487 |
| 490 #undef __ | 488 #undef __ |
| OLD | NEW |