| 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 431 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 432 CHECK(code->IsCode()); | 432 CHECK(code->IsCode()); |
| 433 | 433 |
| 434 F0 f = FUNCTION_CAST<F0>(code->entry()); | 434 F0 f = FUNCTION_CAST<F0>(code->entry()); |
| 435 int res = f(); | 435 int res = f(); |
| 436 CHECK_EQ(42, res); | 436 CHECK_EQ(42, res); |
| 437 } | 437 } |
| 438 | 438 |
| 439 | 439 |
| 440 #ifdef __GNUC__ | 440 #ifdef __GNUC__ |
| 441 #define ELEMENT_COUNT 4 | 441 #define ELEMENT_COUNT 4u |
| 442 | 442 |
| 443 void DoSSE2(const v8::FunctionCallbackInfo<v8::Value>& args) { | 443 void DoSSE2(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 444 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 444 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 445 HandleScope scope(isolate); | 445 HandleScope scope(isolate); |
| 446 | 446 |
| 447 CHECK(args[0]->IsArray()); | 447 CHECK(args[0]->IsArray()); |
| 448 v8::Local<v8::Array> vec = v8::Local<v8::Array>::Cast(args[0]); | 448 v8::Local<v8::Array> vec = v8::Local<v8::Array>::Cast(args[0]); |
| 449 CHECK_EQ(ELEMENT_COUNT, vec->Length()); | 449 CHECK_EQ(ELEMENT_COUNT, vec->Length()); |
| 450 | 450 |
| 451 v8::internal::byte buffer[256]; | 451 v8::internal::byte buffer[256]; |
| 452 Assembler assm(isolate, buffer, sizeof buffer); | 452 Assembler assm(isolate, buffer, sizeof buffer); |
| 453 | 453 |
| 454 // Remove return address from the stack for fix stack frame alignment. | 454 // Remove return address from the stack for fix stack frame alignment. |
| 455 __ pop(ecx); | 455 __ pop(ecx); |
| 456 | 456 |
| 457 // Store input vector on the stack. | 457 // Store input vector on the stack. |
| 458 for (int i = 0; i < ELEMENT_COUNT; ++i) { | 458 for (unsigned i = 0; i < ELEMENT_COUNT; ++i) { |
| 459 __ push(Immediate(vec->Get(i)->Int32Value())); | 459 __ push(Immediate(vec->Get(i)->Int32Value())); |
| 460 } | 460 } |
| 461 | 461 |
| 462 // Read vector into a xmm register. | 462 // Read vector into a xmm register. |
| 463 __ pxor(xmm0, xmm0); | 463 __ pxor(xmm0, xmm0); |
| 464 __ movdqa(xmm0, Operand(esp, 0)); | 464 __ movdqa(xmm0, Operand(esp, 0)); |
| 465 // Create mask and store it in the return register. | 465 // Create mask and store it in the return register. |
| 466 __ movmskps(eax, xmm0); | 466 __ movmskps(eax, xmm0); |
| 467 | 467 |
| 468 // Remove unused data from the stack. | 468 // Remove unused data from the stack. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 "function foo(vec) {" | 500 "function foo(vec) {" |
| 501 " return do_sse2(vec);" | 501 " return do_sse2(vec);" |
| 502 "}"); | 502 "}"); |
| 503 | 503 |
| 504 v8::Local<v8::Object> global_object = env->Global(); | 504 v8::Local<v8::Object> global_object = env->Global(); |
| 505 v8::Local<v8::Function> foo = | 505 v8::Local<v8::Function> foo = |
| 506 v8::Local<v8::Function>::Cast(global_object->Get(v8_str("foo"))); | 506 v8::Local<v8::Function>::Cast(global_object->Get(v8_str("foo"))); |
| 507 | 507 |
| 508 int32_t vec[ELEMENT_COUNT] = { -1, 1, 1, 1 }; | 508 int32_t vec[ELEMENT_COUNT] = { -1, 1, 1, 1 }; |
| 509 v8::Local<v8::Array> v8_vec = v8::Array::New(isolate, ELEMENT_COUNT); | 509 v8::Local<v8::Array> v8_vec = v8::Array::New(isolate, ELEMENT_COUNT); |
| 510 for (int i = 0; i < ELEMENT_COUNT; i++) { | 510 for (unsigned i = 0; i < ELEMENT_COUNT; i++) { |
| 511 v8_vec->Set(i, v8_num(vec[i])); | 511 v8_vec->Set(i, v8_num(vec[i])); |
| 512 } | 512 } |
| 513 | 513 |
| 514 v8::Local<v8::Value> args[] = { v8_vec }; | 514 v8::Local<v8::Value> args[] = { v8_vec }; |
| 515 v8::Local<v8::Value> result = foo->Call(global_object, 1, args); | 515 v8::Local<v8::Value> result = foo->Call(global_object, 1, args); |
| 516 | 516 |
| 517 // The mask should be 0b1000. | 517 // The mask should be 0b1000. |
| 518 CHECK_EQ(8, result->Int32Value()); | 518 CHECK_EQ(8, result->Int32Value()); |
| 519 } | 519 } |
| 520 | 520 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 542 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 542 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 543 #ifdef OBJECT_PRINT | 543 #ifdef OBJECT_PRINT |
| 544 OFStream os(stdout); | 544 OFStream os(stdout); |
| 545 code->Print(os); | 545 code->Print(os); |
| 546 #endif | 546 #endif |
| 547 | 547 |
| 548 F4 f = FUNCTION_CAST<F4>(code->entry()); | 548 F4 f = FUNCTION_CAST<F4>(code->entry()); |
| 549 uint64_t value1 = V8_2PART_UINT64_C(0x12345678, 87654321); | 549 uint64_t value1 = V8_2PART_UINT64_C(0x12345678, 87654321); |
| 550 CHECK_EQ(0x12345678, f(uint64_to_double(value1))); | 550 CHECK_EQ(0x12345678, f(uint64_to_double(value1))); |
| 551 uint64_t value2 = V8_2PART_UINT64_C(0x87654321, 12345678); | 551 uint64_t value2 = V8_2PART_UINT64_C(0x87654321, 12345678); |
| 552 CHECK_EQ(0x87654321, f(uint64_to_double(value2))); | 552 CHECK_EQ(static_cast<int>(0x87654321), f(uint64_to_double(value2))); |
| 553 } | 553 } |
| 554 | 554 |
| 555 | 555 |
| 556 typedef int (*F8)(float x, float y); | 556 typedef int (*F8)(float x, float y); |
| 557 TEST(AssemblerIa32SSE) { | 557 TEST(AssemblerIa32SSE) { |
| 558 CcTest::InitializeVM(); | 558 CcTest::InitializeVM(); |
| 559 | 559 |
| 560 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); | 560 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); |
| 561 HandleScope scope(isolate); | 561 HandleScope scope(isolate); |
| 562 v8::internal::byte buffer[256]; | 562 v8::internal::byte buffer[256]; |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 1037 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 1038 #ifdef OBJECT_PRINT | 1038 #ifdef OBJECT_PRINT |
| 1039 OFStream os(stdout); | 1039 OFStream os(stdout); |
| 1040 code->Print(os); | 1040 code->Print(os); |
| 1041 #endif | 1041 #endif |
| 1042 | 1042 |
| 1043 F10 f = FUNCTION_CAST<F10>(code->entry()); | 1043 F10 f = FUNCTION_CAST<F10>(code->entry()); |
| 1044 CHECK_EQ(0, f(9.26621069e-05f, -2.4607749f, -1.09587872f)); | 1044 CHECK_EQ(0, f(9.26621069e-05f, -2.4607749f, -1.09587872f)); |
| 1045 } | 1045 } |
| 1046 #undef __ | 1046 #undef __ |
| OLD | NEW |