OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/assembler.h" | 5 #include "src/assembler.h" |
6 #include "src/codegen.h" | 6 #include "src/codegen.h" |
7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
8 #include "src/compiler/raw-machine-assembler.h" | 8 #include "src/compiler/raw-machine-assembler.h" |
9 #include "src/machine-type.h" | 9 #include "src/machine-type.h" |
10 #include "src/register-configuration.h" | 10 #include "src/register-configuration.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 if (FLAG_print_opt_code) { | 251 if (FLAG_print_opt_code) { |
252 OFStream os(stdout); | 252 OFStream os(stdout); |
253 code->Disassemble(name, os); | 253 code->Disassemble(name, os); |
254 } | 254 } |
255 #endif | 255 #endif |
256 return code; | 256 return code; |
257 } | 257 } |
258 | 258 |
259 | 259 |
260 Handle<Code> WrapWithCFunction(Handle<Code> inner, CallDescriptor* desc) { | 260 Handle<Code> WrapWithCFunction(Handle<Code> inner, CallDescriptor* desc) { |
261 Zone zone(inner->GetIsolate()->allocator()); | 261 Zone zone(inner->GetIsolate()->allocator(), ZONE_NAME); |
262 int param_count = static_cast<int>(desc->ParameterCount()); | 262 int param_count = static_cast<int>(desc->ParameterCount()); |
263 GraphAndBuilders caller(&zone); | 263 GraphAndBuilders caller(&zone); |
264 { | 264 { |
265 GraphAndBuilders& b = caller; | 265 GraphAndBuilders& b = caller; |
266 Node* start = b.graph()->NewNode(b.common()->Start(param_count + 3)); | 266 Node* start = b.graph()->NewNode(b.common()->Start(param_count + 3)); |
267 b.graph()->SetStart(start); | 267 b.graph()->SetStart(start); |
268 Node* target = b.graph()->NewNode(b.common()->HeapConstant(inner)); | 268 Node* target = b.graph()->NewNode(b.common()->HeapConstant(inner)); |
269 | 269 |
270 // Add arguments to the call. | 270 // Add arguments to the call. |
271 Node** args = zone.NewArray<Node*>(param_count + 3); | 271 Node** args = zone.NewArray<Node*>(param_count + 3); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 void (*build)(CallDescriptor*, RawMachineAssembler&), | 417 void (*build)(CallDescriptor*, RawMachineAssembler&), |
418 CType (*compute)(CallDescriptor*, CType* inputs), | 418 CType (*compute)(CallDescriptor*, CType* inputs), |
419 int seed = 1) { | 419 int seed = 1) { |
420 int num_params = ParamCount(desc); | 420 int num_params = ParamCount(desc); |
421 CHECK_LE(num_params, kMaxParamCount); | 421 CHECK_LE(num_params, kMaxParamCount); |
422 Isolate* isolate = CcTest::InitIsolateOnce(); | 422 Isolate* isolate = CcTest::InitIsolateOnce(); |
423 HandleScope scope(isolate); | 423 HandleScope scope(isolate); |
424 Handle<Code> inner = Handle<Code>::null(); | 424 Handle<Code> inner = Handle<Code>::null(); |
425 { | 425 { |
426 // Build the graph for the computation. | 426 // Build the graph for the computation. |
427 Zone zone(isolate->allocator()); | 427 Zone zone(isolate->allocator(), ZONE_NAME); |
428 Graph graph(&zone); | 428 Graph graph(&zone); |
429 RawMachineAssembler raw(isolate, &graph, desc); | 429 RawMachineAssembler raw(isolate, &graph, desc); |
430 build(desc, raw); | 430 build(desc, raw); |
431 inner = CompileGraph("Compute", desc, &graph, raw.Export()); | 431 inner = CompileGraph("Compute", desc, &graph, raw.Export()); |
432 } | 432 } |
433 | 433 |
434 CSignature0<int32_t> csig; | 434 CSignature0<int32_t> csig; |
435 ArgsBuffer<CType> io(num_params, seed); | 435 ArgsBuffer<CType> io(num_params, seed); |
436 | 436 |
437 { | 437 { |
438 // constant mode. | 438 // constant mode. |
439 Handle<Code> wrapper = Handle<Code>::null(); | 439 Handle<Code> wrapper = Handle<Code>::null(); |
440 { | 440 { |
441 // Wrap the above code with a callable function that passes constants. | 441 // Wrap the above code with a callable function that passes constants. |
442 Zone zone(isolate->allocator()); | 442 Zone zone(isolate->allocator(), ZONE_NAME); |
443 Graph graph(&zone); | 443 Graph graph(&zone); |
444 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); | 444 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); |
445 RawMachineAssembler raw(isolate, &graph, cdesc); | 445 RawMachineAssembler raw(isolate, &graph, cdesc); |
446 Node* target = raw.HeapConstant(inner); | 446 Node* target = raw.HeapConstant(inner); |
447 Node** args = zone.NewArray<Node*>(num_params); | 447 Node** args = zone.NewArray<Node*>(num_params); |
448 for (int i = 0; i < num_params; i++) { | 448 for (int i = 0; i < num_params; i++) { |
449 args[i] = io.MakeConstant(raw, io.input[i]); | 449 args[i] = io.MakeConstant(raw, io.input[i]); |
450 } | 450 } |
451 | 451 |
452 Node* call = raw.CallN(desc, target, args); | 452 Node* call = raw.CallN(desc, target, args); |
(...skipping 11 matching lines...) Expand all Loading... |
464 int32_t check_seed = runnable.Call(); | 464 int32_t check_seed = runnable.Call(); |
465 CHECK_EQ(seed, check_seed); | 465 CHECK_EQ(seed, check_seed); |
466 CHECK_EQ(expected, io.output); | 466 CHECK_EQ(expected, io.output); |
467 } | 467 } |
468 | 468 |
469 { | 469 { |
470 // buffer mode. | 470 // buffer mode. |
471 Handle<Code> wrapper = Handle<Code>::null(); | 471 Handle<Code> wrapper = Handle<Code>::null(); |
472 { | 472 { |
473 // Wrap the above code with a callable function that loads from {input}. | 473 // Wrap the above code with a callable function that loads from {input}. |
474 Zone zone(isolate->allocator()); | 474 Zone zone(isolate->allocator(), ZONE_NAME); |
475 Graph graph(&zone); | 475 Graph graph(&zone); |
476 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); | 476 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); |
477 RawMachineAssembler raw(isolate, &graph, cdesc); | 477 RawMachineAssembler raw(isolate, &graph, cdesc); |
478 Node* base = raw.PointerConstant(io.input); | 478 Node* base = raw.PointerConstant(io.input); |
479 Node* target = raw.HeapConstant(inner); | 479 Node* target = raw.HeapConstant(inner); |
480 Node** args = zone.NewArray<Node*>(kMaxParamCount); | 480 Node** args = zone.NewArray<Node*>(kMaxParamCount); |
481 for (int i = 0; i < num_params; i++) { | 481 for (int i = 0; i < num_params; i++) { |
482 args[i] = io.LoadInput(raw, base, i); | 482 args[i] = io.LoadInput(raw, base, i); |
483 } | 483 } |
484 | 484 |
(...skipping 17 matching lines...) Expand all Loading... |
502 } | 502 } |
503 } | 503 } |
504 }; | 504 }; |
505 | 505 |
506 } // namespace | 506 } // namespace |
507 | 507 |
508 | 508 |
509 static void TestInt32Sub(CallDescriptor* desc) { | 509 static void TestInt32Sub(CallDescriptor* desc) { |
510 Isolate* isolate = CcTest::InitIsolateOnce(); | 510 Isolate* isolate = CcTest::InitIsolateOnce(); |
511 HandleScope scope(isolate); | 511 HandleScope scope(isolate); |
512 Zone zone(isolate->allocator()); | 512 Zone zone(isolate->allocator(), ZONE_NAME); |
513 GraphAndBuilders inner(&zone); | 513 GraphAndBuilders inner(&zone); |
514 { | 514 { |
515 // Build the add function. | 515 // Build the add function. |
516 GraphAndBuilders& b = inner; | 516 GraphAndBuilders& b = inner; |
517 Node* start = b.graph()->NewNode(b.common()->Start(5)); | 517 Node* start = b.graph()->NewNode(b.common()->Start(5)); |
518 b.graph()->SetStart(start); | 518 b.graph()->SetStart(start); |
519 Node* p0 = b.graph()->NewNode(b.common()->Parameter(0), start); | 519 Node* p0 = b.graph()->NewNode(b.common()->Parameter(0), start); |
520 Node* p1 = b.graph()->NewNode(b.common()->Parameter(1), start); | 520 Node* p1 = b.graph()->NewNode(b.common()->Parameter(1), start); |
521 Node* add = b.graph()->NewNode(b.machine()->Int32Sub(), p0, p1); | 521 Node* add = b.graph()->NewNode(b.machine()->Int32Sub(), p0, p1); |
522 Node* ret = b.graph()->NewNode(b.common()->Return(), add, start, start); | 522 Node* ret = b.graph()->NewNode(b.common()->Return(), add, start, start); |
(...skipping 19 matching lines...) Expand all Loading... |
542 | 542 |
543 static void CopyTwentyInt32(CallDescriptor* desc) { | 543 static void CopyTwentyInt32(CallDescriptor* desc) { |
544 const int kNumParams = 20; | 544 const int kNumParams = 20; |
545 int32_t input[kNumParams]; | 545 int32_t input[kNumParams]; |
546 int32_t output[kNumParams]; | 546 int32_t output[kNumParams]; |
547 Isolate* isolate = CcTest::InitIsolateOnce(); | 547 Isolate* isolate = CcTest::InitIsolateOnce(); |
548 HandleScope scope(isolate); | 548 HandleScope scope(isolate); |
549 Handle<Code> inner = Handle<Code>::null(); | 549 Handle<Code> inner = Handle<Code>::null(); |
550 { | 550 { |
551 // Writes all parameters into the output buffer. | 551 // Writes all parameters into the output buffer. |
552 Zone zone(isolate->allocator()); | 552 Zone zone(isolate->allocator(), ZONE_NAME); |
553 Graph graph(&zone); | 553 Graph graph(&zone); |
554 RawMachineAssembler raw(isolate, &graph, desc); | 554 RawMachineAssembler raw(isolate, &graph, desc); |
555 Node* base = raw.PointerConstant(output); | 555 Node* base = raw.PointerConstant(output); |
556 for (int i = 0; i < kNumParams; i++) { | 556 for (int i = 0; i < kNumParams; i++) { |
557 Node* offset = raw.Int32Constant(i * sizeof(int32_t)); | 557 Node* offset = raw.Int32Constant(i * sizeof(int32_t)); |
558 raw.Store(MachineRepresentation::kWord32, base, offset, raw.Parameter(i), | 558 raw.Store(MachineRepresentation::kWord32, base, offset, raw.Parameter(i), |
559 kNoWriteBarrier); | 559 kNoWriteBarrier); |
560 } | 560 } |
561 raw.Return(raw.Int32Constant(42)); | 561 raw.Return(raw.Int32Constant(42)); |
562 inner = CompileGraph("CopyTwentyInt32", desc, &graph, raw.Export()); | 562 inner = CompileGraph("CopyTwentyInt32", desc, &graph, raw.Export()); |
563 } | 563 } |
564 | 564 |
565 CSignature0<int32_t> csig; | 565 CSignature0<int32_t> csig; |
566 Handle<Code> wrapper = Handle<Code>::null(); | 566 Handle<Code> wrapper = Handle<Code>::null(); |
567 { | 567 { |
568 // Loads parameters from the input buffer and calls the above code. | 568 // Loads parameters from the input buffer and calls the above code. |
569 Zone zone(isolate->allocator()); | 569 Zone zone(isolate->allocator(), ZONE_NAME); |
570 Graph graph(&zone); | 570 Graph graph(&zone); |
571 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); | 571 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); |
572 RawMachineAssembler raw(isolate, &graph, cdesc); | 572 RawMachineAssembler raw(isolate, &graph, cdesc); |
573 Node* base = raw.PointerConstant(input); | 573 Node* base = raw.PointerConstant(input); |
574 Node* target = raw.HeapConstant(inner); | 574 Node* target = raw.HeapConstant(inner); |
575 Node** args = zone.NewArray<Node*>(kNumParams); | 575 Node** args = zone.NewArray<Node*>(kNumParams); |
576 for (int i = 0; i < kNumParams; i++) { | 576 for (int i = 0; i < kNumParams; i++) { |
577 Node* offset = raw.Int32Constant(i * sizeof(int32_t)); | 577 Node* offset = raw.Int32Constant(i * sizeof(int32_t)); |
578 args[i] = raw.Load(MachineType::Int32(), base, offset); | 578 args[i] = raw.Load(MachineType::Int32(), base, offset); |
579 } | 579 } |
(...skipping 19 matching lines...) Expand all Loading... |
599 for (int j = 0; j < kNumParams; j++) { | 599 for (int j = 0; j < kNumParams; j++) { |
600 CHECK_EQ(input[j], output[j]); | 600 CHECK_EQ(input[j], output[j]); |
601 } | 601 } |
602 } | 602 } |
603 } | 603 } |
604 | 604 |
605 | 605 |
606 static void Test_RunInt32SubWithRet(int retreg) { | 606 static void Test_RunInt32SubWithRet(int retreg) { |
607 Int32Signature sig(2); | 607 Int32Signature sig(2); |
608 v8::internal::AccountingAllocator allocator; | 608 v8::internal::AccountingAllocator allocator; |
609 Zone zone(&allocator); | 609 Zone zone(&allocator, ZONE_NAME); |
610 RegisterPairs pairs; | 610 RegisterPairs pairs; |
611 while (pairs.More()) { | 611 while (pairs.More()) { |
612 int parray[2]; | 612 int parray[2]; |
613 int rarray[] = {retreg}; | 613 int rarray[] = {retreg}; |
614 pairs.Next(&parray[0], &parray[1], false); | 614 pairs.Next(&parray[0], &parray[1], false); |
615 Allocator params(parray, 2, nullptr, 0); | 615 Allocator params(parray, 2, nullptr, 0); |
616 Allocator rets(rarray, 1, nullptr, 0); | 616 Allocator rets(rarray, 1, nullptr, 0); |
617 RegisterConfig config(params, rets); | 617 RegisterConfig config(params, rets); |
618 CallDescriptor* desc = config.Create(&zone, &sig); | 618 CallDescriptor* desc = config.Create(&zone, &sig); |
619 TestInt32Sub(desc); | 619 TestInt32Sub(desc); |
(...skipping 30 matching lines...) Expand all Loading... |
650 TEST_INT32_SUB_WITH_RET(17) | 650 TEST_INT32_SUB_WITH_RET(17) |
651 TEST_INT32_SUB_WITH_RET(18) | 651 TEST_INT32_SUB_WITH_RET(18) |
652 TEST_INT32_SUB_WITH_RET(19) | 652 TEST_INT32_SUB_WITH_RET(19) |
653 | 653 |
654 | 654 |
655 TEST(Run_Int32Sub_all_allocatable_single) { | 655 TEST(Run_Int32Sub_all_allocatable_single) { |
656 Int32Signature sig(2); | 656 Int32Signature sig(2); |
657 RegisterPairs pairs; | 657 RegisterPairs pairs; |
658 while (pairs.More()) { | 658 while (pairs.More()) { |
659 v8::internal::AccountingAllocator allocator; | 659 v8::internal::AccountingAllocator allocator; |
660 Zone zone(&allocator); | 660 Zone zone(&allocator, ZONE_NAME); |
661 int parray[1]; | 661 int parray[1]; |
662 int rarray[1]; | 662 int rarray[1]; |
663 pairs.Next(&rarray[0], &parray[0], true); | 663 pairs.Next(&rarray[0], &parray[0], true); |
664 Allocator params(parray, 1, nullptr, 0); | 664 Allocator params(parray, 1, nullptr, 0); |
665 Allocator rets(rarray, 1, nullptr, 0); | 665 Allocator rets(rarray, 1, nullptr, 0); |
666 RegisterConfig config(params, rets); | 666 RegisterConfig config(params, rets); |
667 CallDescriptor* desc = config.Create(&zone, &sig); | 667 CallDescriptor* desc = config.Create(&zone, &sig); |
668 TestInt32Sub(desc); | 668 TestInt32Sub(desc); |
669 } | 669 } |
670 } | 670 } |
671 | 671 |
672 | 672 |
673 TEST(Run_CopyTwentyInt32_all_allocatable_pairs) { | 673 TEST(Run_CopyTwentyInt32_all_allocatable_pairs) { |
674 Int32Signature sig(20); | 674 Int32Signature sig(20); |
675 RegisterPairs pairs; | 675 RegisterPairs pairs; |
676 while (pairs.More()) { | 676 while (pairs.More()) { |
677 v8::internal::AccountingAllocator allocator; | 677 v8::internal::AccountingAllocator allocator; |
678 Zone zone(&allocator); | 678 Zone zone(&allocator, ZONE_NAME); |
679 int parray[2]; | 679 int parray[2]; |
680 int rarray[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; | 680 int rarray[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; |
681 pairs.Next(&parray[0], &parray[1], false); | 681 pairs.Next(&parray[0], &parray[1], false); |
682 Allocator params(parray, 2, nullptr, 0); | 682 Allocator params(parray, 2, nullptr, 0); |
683 Allocator rets(rarray, 1, nullptr, 0); | 683 Allocator rets(rarray, 1, nullptr, 0); |
684 RegisterConfig config(params, rets); | 684 RegisterConfig config(params, rets); |
685 CallDescriptor* desc = config.Create(&zone, &sig); | 685 CallDescriptor* desc = config.Create(&zone, &sig); |
686 CopyTwentyInt32(desc); | 686 CopyTwentyInt32(desc); |
687 } | 687 } |
688 } | 688 } |
(...skipping 30 matching lines...) Expand all Loading... |
719 } | 719 } |
720 return static_cast<int32_t>(result); | 720 return static_cast<int32_t>(result); |
721 } | 721 } |
722 | 722 |
723 | 723 |
724 static void Test_Int32_WeightedSum_of_size(int count) { | 724 static void Test_Int32_WeightedSum_of_size(int count) { |
725 Int32Signature sig(count); | 725 Int32Signature sig(count); |
726 for (int p0 = 0; p0 < Register::kNumRegisters; p0++) { | 726 for (int p0 = 0; p0 < Register::kNumRegisters; p0++) { |
727 if (GetRegConfig()->IsAllocatableGeneralCode(p0)) { | 727 if (GetRegConfig()->IsAllocatableGeneralCode(p0)) { |
728 v8::internal::AccountingAllocator allocator; | 728 v8::internal::AccountingAllocator allocator; |
729 Zone zone(&allocator); | 729 Zone zone(&allocator, ZONE_NAME); |
730 | 730 |
731 int parray[] = {p0}; | 731 int parray[] = {p0}; |
732 int rarray[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; | 732 int rarray[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; |
733 Allocator params(parray, 1, nullptr, 0); | 733 Allocator params(parray, 1, nullptr, 0); |
734 Allocator rets(rarray, 1, nullptr, 0); | 734 Allocator rets(rarray, 1, nullptr, 0); |
735 RegisterConfig config(params, rets); | 735 RegisterConfig config(params, rets); |
736 CallDescriptor* desc = config.Create(&zone, &sig); | 736 CallDescriptor* desc = config.Create(&zone, &sig); |
737 Run_Computation<int32_t>(desc, Build_Int32_WeightedSum, | 737 Run_Computation<int32_t>(desc, Build_Int32_WeightedSum, |
738 Compute_Int32_WeightedSum, 257 + count); | 738 Compute_Int32_WeightedSum, 257 + count); |
739 } | 739 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 | 782 |
783 template <int which> | 783 template <int which> |
784 void Test_Int32_Select() { | 784 void Test_Int32_Select() { |
785 int parray[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; | 785 int parray[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; |
786 int rarray[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; | 786 int rarray[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; |
787 Allocator params(parray, 1, nullptr, 0); | 787 Allocator params(parray, 1, nullptr, 0); |
788 Allocator rets(rarray, 1, nullptr, 0); | 788 Allocator rets(rarray, 1, nullptr, 0); |
789 RegisterConfig config(params, rets); | 789 RegisterConfig config(params, rets); |
790 | 790 |
791 v8::internal::AccountingAllocator allocator; | 791 v8::internal::AccountingAllocator allocator; |
792 Zone zone(&allocator); | 792 Zone zone(&allocator, ZONE_NAME); |
793 | 793 |
794 for (int i = which + 1; i <= 64; i++) { | 794 for (int i = which + 1; i <= 64; i++) { |
795 Int32Signature sig(i); | 795 Int32Signature sig(i); |
796 CallDescriptor* desc = config.Create(&zone, &sig); | 796 CallDescriptor* desc = config.Create(&zone, &sig); |
797 RunSelect<int32_t, which>(desc); | 797 RunSelect<int32_t, which>(desc); |
798 } | 798 } |
799 } | 799 } |
800 | 800 |
801 | 801 |
802 // Separate tests for parallelization. | 802 // Separate tests for parallelization. |
(...skipping 18 matching lines...) Expand all Loading... |
821 | 821 |
822 TEST(Int64Select_registers) { | 822 TEST(Int64Select_registers) { |
823 if (GetRegConfig()->num_allocatable_general_registers() < 2) return; | 823 if (GetRegConfig()->num_allocatable_general_registers() < 2) return; |
824 if (kPointerSize < 8) return; // TODO(titzer): int64 on 32-bit platforms | 824 if (kPointerSize < 8) return; // TODO(titzer): int64 on 32-bit platforms |
825 | 825 |
826 int rarray[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; | 826 int rarray[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; |
827 ArgsBuffer<int64_t>::Sig sig(2); | 827 ArgsBuffer<int64_t>::Sig sig(2); |
828 | 828 |
829 RegisterPairs pairs; | 829 RegisterPairs pairs; |
830 v8::internal::AccountingAllocator allocator; | 830 v8::internal::AccountingAllocator allocator; |
831 Zone zone(&allocator); | 831 Zone zone(&allocator, ZONE_NAME); |
832 while (pairs.More()) { | 832 while (pairs.More()) { |
833 int parray[2]; | 833 int parray[2]; |
834 pairs.Next(&parray[0], &parray[1], false); | 834 pairs.Next(&parray[0], &parray[1], false); |
835 Allocator params(parray, 2, nullptr, 0); | 835 Allocator params(parray, 2, nullptr, 0); |
836 Allocator rets(rarray, 1, nullptr, 0); | 836 Allocator rets(rarray, 1, nullptr, 0); |
837 RegisterConfig config(params, rets); | 837 RegisterConfig config(params, rets); |
838 | 838 |
839 CallDescriptor* desc = config.Create(&zone, &sig); | 839 CallDescriptor* desc = config.Create(&zone, &sig); |
840 RunSelect<int64_t, 0>(desc); | 840 RunSelect<int64_t, 0>(desc); |
841 RunSelect<int64_t, 1>(desc); | 841 RunSelect<int64_t, 1>(desc); |
842 } | 842 } |
843 } | 843 } |
844 | 844 |
845 | 845 |
846 TEST(Float32Select_registers) { | 846 TEST(Float32Select_registers) { |
847 if (GetRegConfig()->num_allocatable_double_registers() < 2) { | 847 if (GetRegConfig()->num_allocatable_double_registers() < 2) { |
848 return; | 848 return; |
849 } | 849 } |
850 | 850 |
851 int rarray[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; | 851 int rarray[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; |
852 ArgsBuffer<float32>::Sig sig(2); | 852 ArgsBuffer<float32>::Sig sig(2); |
853 | 853 |
854 Float32RegisterPairs pairs; | 854 Float32RegisterPairs pairs; |
855 v8::internal::AccountingAllocator allocator; | 855 v8::internal::AccountingAllocator allocator; |
856 Zone zone(&allocator); | 856 Zone zone(&allocator, ZONE_NAME); |
857 while (pairs.More()) { | 857 while (pairs.More()) { |
858 int parray[2]; | 858 int parray[2]; |
859 pairs.Next(&parray[0], &parray[1], false); | 859 pairs.Next(&parray[0], &parray[1], false); |
860 Allocator params(nullptr, 0, parray, 2); | 860 Allocator params(nullptr, 0, parray, 2); |
861 Allocator rets(nullptr, 0, rarray, 1); | 861 Allocator rets(nullptr, 0, rarray, 1); |
862 RegisterConfig config(params, rets); | 862 RegisterConfig config(params, rets); |
863 | 863 |
864 CallDescriptor* desc = config.Create(&zone, &sig); | 864 CallDescriptor* desc = config.Create(&zone, &sig); |
865 RunSelect<float32, 0>(desc); | 865 RunSelect<float32, 0>(desc); |
866 RunSelect<float32, 1>(desc); | 866 RunSelect<float32, 1>(desc); |
867 } | 867 } |
868 } | 868 } |
869 | 869 |
870 | 870 |
871 TEST(Float64Select_registers) { | 871 TEST(Float64Select_registers) { |
872 if (GetRegConfig()->num_allocatable_double_registers() < 2) return; | 872 if (GetRegConfig()->num_allocatable_double_registers() < 2) return; |
873 if (GetRegConfig()->num_allocatable_general_registers() < 2) return; | 873 if (GetRegConfig()->num_allocatable_general_registers() < 2) return; |
874 int rarray[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; | 874 int rarray[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; |
875 ArgsBuffer<float64>::Sig sig(2); | 875 ArgsBuffer<float64>::Sig sig(2); |
876 | 876 |
877 Float64RegisterPairs pairs; | 877 Float64RegisterPairs pairs; |
878 v8::internal::AccountingAllocator allocator; | 878 v8::internal::AccountingAllocator allocator; |
879 Zone zone(&allocator); | 879 Zone zone(&allocator, ZONE_NAME); |
880 while (pairs.More()) { | 880 while (pairs.More()) { |
881 int parray[2]; | 881 int parray[2]; |
882 pairs.Next(&parray[0], &parray[1], false); | 882 pairs.Next(&parray[0], &parray[1], false); |
883 Allocator params(nullptr, 0, parray, 2); | 883 Allocator params(nullptr, 0, parray, 2); |
884 Allocator rets(nullptr, 0, rarray, 1); | 884 Allocator rets(nullptr, 0, rarray, 1); |
885 RegisterConfig config(params, rets); | 885 RegisterConfig config(params, rets); |
886 | 886 |
887 CallDescriptor* desc = config.Create(&zone, &sig); | 887 CallDescriptor* desc = config.Create(&zone, &sig); |
888 RunSelect<float64, 0>(desc); | 888 RunSelect<float64, 0>(desc); |
889 RunSelect<float64, 1>(desc); | 889 RunSelect<float64, 1>(desc); |
890 } | 890 } |
891 } | 891 } |
892 | 892 |
893 | 893 |
894 TEST(Float32Select_stack_params_return_reg) { | 894 TEST(Float32Select_stack_params_return_reg) { |
895 int rarray[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; | 895 int rarray[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; |
896 Allocator params(nullptr, 0, nullptr, 0); | 896 Allocator params(nullptr, 0, nullptr, 0); |
897 Allocator rets(nullptr, 0, rarray, 1); | 897 Allocator rets(nullptr, 0, rarray, 1); |
898 RegisterConfig config(params, rets); | 898 RegisterConfig config(params, rets); |
899 | 899 |
900 v8::internal::AccountingAllocator allocator; | 900 v8::internal::AccountingAllocator allocator; |
901 Zone zone(&allocator); | 901 Zone zone(&allocator, ZONE_NAME); |
902 for (int count = 1; count < 6; count++) { | 902 for (int count = 1; count < 6; count++) { |
903 ArgsBuffer<float32>::Sig sig(count); | 903 ArgsBuffer<float32>::Sig sig(count); |
904 CallDescriptor* desc = config.Create(&zone, &sig); | 904 CallDescriptor* desc = config.Create(&zone, &sig); |
905 RunSelect<float32, 0>(desc); | 905 RunSelect<float32, 0>(desc); |
906 RunSelect<float32, 1>(desc); | 906 RunSelect<float32, 1>(desc); |
907 RunSelect<float32, 2>(desc); | 907 RunSelect<float32, 2>(desc); |
908 RunSelect<float32, 3>(desc); | 908 RunSelect<float32, 3>(desc); |
909 RunSelect<float32, 4>(desc); | 909 RunSelect<float32, 4>(desc); |
910 RunSelect<float32, 5>(desc); | 910 RunSelect<float32, 5>(desc); |
911 } | 911 } |
912 } | 912 } |
913 | 913 |
914 | 914 |
915 TEST(Float64Select_stack_params_return_reg) { | 915 TEST(Float64Select_stack_params_return_reg) { |
916 int rarray[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; | 916 int rarray[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; |
917 Allocator params(nullptr, 0, nullptr, 0); | 917 Allocator params(nullptr, 0, nullptr, 0); |
918 Allocator rets(nullptr, 0, rarray, 1); | 918 Allocator rets(nullptr, 0, rarray, 1); |
919 RegisterConfig config(params, rets); | 919 RegisterConfig config(params, rets); |
920 | 920 |
921 v8::internal::AccountingAllocator allocator; | 921 v8::internal::AccountingAllocator allocator; |
922 Zone zone(&allocator); | 922 Zone zone(&allocator, ZONE_NAME); |
923 for (int count = 1; count < 6; count++) { | 923 for (int count = 1; count < 6; count++) { |
924 ArgsBuffer<float64>::Sig sig(count); | 924 ArgsBuffer<float64>::Sig sig(count); |
925 CallDescriptor* desc = config.Create(&zone, &sig); | 925 CallDescriptor* desc = config.Create(&zone, &sig); |
926 RunSelect<float64, 0>(desc); | 926 RunSelect<float64, 0>(desc); |
927 RunSelect<float64, 1>(desc); | 927 RunSelect<float64, 1>(desc); |
928 RunSelect<float64, 2>(desc); | 928 RunSelect<float64, 2>(desc); |
929 RunSelect<float64, 3>(desc); | 929 RunSelect<float64, 3>(desc); |
930 RunSelect<float64, 4>(desc); | 930 RunSelect<float64, 4>(desc); |
931 RunSelect<float64, 5>(desc); | 931 RunSelect<float64, 5>(desc); |
932 } | 932 } |
933 } | 933 } |
934 | 934 |
935 | 935 |
936 template <typename CType, int which> | 936 template <typename CType, int which> |
937 static void Build_Select_With_Call(CallDescriptor* desc, | 937 static void Build_Select_With_Call(CallDescriptor* desc, |
938 RawMachineAssembler& raw) { | 938 RawMachineAssembler& raw) { |
939 Handle<Code> inner = Handle<Code>::null(); | 939 Handle<Code> inner = Handle<Code>::null(); |
940 int num_params = ParamCount(desc); | 940 int num_params = ParamCount(desc); |
941 CHECK_LE(num_params, kMaxParamCount); | 941 CHECK_LE(num_params, kMaxParamCount); |
942 { | 942 { |
943 Isolate* isolate = CcTest::InitIsolateOnce(); | 943 Isolate* isolate = CcTest::InitIsolateOnce(); |
944 // Build the actual select. | 944 // Build the actual select. |
945 Zone zone(isolate->allocator()); | 945 Zone zone(isolate->allocator(), ZONE_NAME); |
946 Graph graph(&zone); | 946 Graph graph(&zone); |
947 RawMachineAssembler raw(isolate, &graph, desc); | 947 RawMachineAssembler raw(isolate, &graph, desc); |
948 raw.Return(raw.Parameter(which)); | 948 raw.Return(raw.Parameter(which)); |
949 inner = CompileGraph("Select-indirection", desc, &graph, raw.Export()); | 949 inner = CompileGraph("Select-indirection", desc, &graph, raw.Export()); |
950 CHECK(!inner.is_null()); | 950 CHECK(!inner.is_null()); |
951 CHECK(inner->IsCode()); | 951 CHECK(inner->IsCode()); |
952 } | 952 } |
953 | 953 |
954 { | 954 { |
955 // Build a call to the function that does the select. | 955 // Build a call to the function that does the select. |
956 Node* target = raw.HeapConstant(inner); | 956 Node* target = raw.HeapConstant(inner); |
957 Node** args = raw.zone()->NewArray<Node*>(num_params); | 957 Node** args = raw.zone()->NewArray<Node*>(num_params); |
958 for (int i = 0; i < num_params; i++) { | 958 for (int i = 0; i < num_params; i++) { |
959 args[i] = raw.Parameter(i); | 959 args[i] = raw.Parameter(i); |
960 } | 960 } |
961 | 961 |
962 Node* call = raw.CallN(desc, target, args); | 962 Node* call = raw.CallN(desc, target, args); |
963 raw.Return(call); | 963 raw.Return(call); |
964 } | 964 } |
965 } | 965 } |
966 | 966 |
967 | 967 |
968 TEST(Float64StackParamsToStackParams) { | 968 TEST(Float64StackParamsToStackParams) { |
969 int rarray[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; | 969 int rarray[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; |
970 Allocator params(nullptr, 0, nullptr, 0); | 970 Allocator params(nullptr, 0, nullptr, 0); |
971 Allocator rets(nullptr, 0, rarray, 1); | 971 Allocator rets(nullptr, 0, rarray, 1); |
972 | 972 |
973 v8::internal::AccountingAllocator allocator; | 973 v8::internal::AccountingAllocator allocator; |
974 Zone zone(&allocator); | 974 Zone zone(&allocator, ZONE_NAME); |
975 ArgsBuffer<float64>::Sig sig(2); | 975 ArgsBuffer<float64>::Sig sig(2); |
976 RegisterConfig config(params, rets); | 976 RegisterConfig config(params, rets); |
977 CallDescriptor* desc = config.Create(&zone, &sig); | 977 CallDescriptor* desc = config.Create(&zone, &sig); |
978 | 978 |
979 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>, | 979 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>, |
980 Compute_Select<float64, 0>, 1098); | 980 Compute_Select<float64, 0>, 1098); |
981 | 981 |
982 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 1>, | 982 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 1>, |
983 Compute_Select<float64, 1>, 1099); | 983 Compute_Select<float64, 1>, 1099); |
984 } | 984 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 int rarray_gp[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; | 1019 int rarray_gp[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; |
1020 int parray_fp[] = {GetRegConfig()->GetAllocatableDoubleCode(0), | 1020 int parray_fp[] = {GetRegConfig()->GetAllocatableDoubleCode(0), |
1021 GetRegConfig()->GetAllocatableDoubleCode(1)}; | 1021 GetRegConfig()->GetAllocatableDoubleCode(1)}; |
1022 int rarray_fp[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; | 1022 int rarray_fp[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; |
1023 Allocator palloc(parray_gp, 2, parray_fp, 2); | 1023 Allocator palloc(parray_gp, 2, parray_fp, 2); |
1024 Allocator ralloc(rarray_gp, 1, rarray_fp, 1); | 1024 Allocator ralloc(rarray_gp, 1, rarray_fp, 1); |
1025 RegisterConfig config(palloc, ralloc); | 1025 RegisterConfig config(palloc, ralloc); |
1026 | 1026 |
1027 for (int which = 0; which < num_params; which++) { | 1027 for (int which = 0; which < num_params; which++) { |
1028 v8::internal::AccountingAllocator allocator; | 1028 v8::internal::AccountingAllocator allocator; |
1029 Zone zone(&allocator); | 1029 Zone zone(&allocator, ZONE_NAME); |
1030 HandleScope scope(isolate); | 1030 HandleScope scope(isolate); |
1031 MachineSignature::Builder builder(&zone, 1, num_params); | 1031 MachineSignature::Builder builder(&zone, 1, num_params); |
1032 builder.AddReturn(params[which]); | 1032 builder.AddReturn(params[which]); |
1033 for (int j = 0; j < num_params; j++) builder.AddParam(params[j]); | 1033 for (int j = 0; j < num_params; j++) builder.AddParam(params[j]); |
1034 MachineSignature* sig = builder.Build(); | 1034 MachineSignature* sig = builder.Build(); |
1035 CallDescriptor* desc = config.Create(&zone, sig); | 1035 CallDescriptor* desc = config.Create(&zone, sig); |
1036 | 1036 |
1037 Handle<Code> select; | 1037 Handle<Code> select; |
1038 { | 1038 { |
1039 // build the select. | 1039 // build the select. |
1040 Zone zone(&allocator); | 1040 Zone zone(&allocator, ZONE_NAME); |
1041 Graph graph(&zone); | 1041 Graph graph(&zone); |
1042 RawMachineAssembler raw(isolate, &graph, desc); | 1042 RawMachineAssembler raw(isolate, &graph, desc); |
1043 raw.Return(raw.Parameter(which)); | 1043 raw.Return(raw.Parameter(which)); |
1044 select = CompileGraph("Compute", desc, &graph, raw.Export()); | 1044 select = CompileGraph("Compute", desc, &graph, raw.Export()); |
1045 } | 1045 } |
1046 | 1046 |
1047 { | 1047 { |
1048 // call the select. | 1048 // call the select. |
1049 Handle<Code> wrapper = Handle<Code>::null(); | 1049 Handle<Code> wrapper = Handle<Code>::null(); |
1050 int32_t expected_ret; | 1050 int32_t expected_ret; |
1051 char bytes[kDoubleSize]; | 1051 char bytes[kDoubleSize]; |
1052 V8_ALIGNED(8) char output[kDoubleSize]; | 1052 V8_ALIGNED(8) char output[kDoubleSize]; |
1053 int expected_size = 0; | 1053 int expected_size = 0; |
1054 CSignature0<int32_t> csig; | 1054 CSignature0<int32_t> csig; |
1055 { | 1055 { |
1056 // Wrap the select code with a callable function that passes constants. | 1056 // Wrap the select code with a callable function that passes constants. |
1057 Zone zone(&allocator); | 1057 Zone zone(&allocator, ZONE_NAME); |
1058 Graph graph(&zone); | 1058 Graph graph(&zone); |
1059 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); | 1059 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); |
1060 RawMachineAssembler raw(isolate, &graph, cdesc); | 1060 RawMachineAssembler raw(isolate, &graph, cdesc); |
1061 Node* target = raw.HeapConstant(select); | 1061 Node* target = raw.HeapConstant(select); |
1062 Node** args = zone.NewArray<Node*>(num_params); | 1062 Node** args = zone.NewArray<Node*>(num_params); |
1063 int64_t constant = 0x0102030405060708; | 1063 int64_t constant = 0x0102030405060708; |
1064 for (int i = 0; i < num_params; i++) { | 1064 for (int i = 0; i < num_params; i++) { |
1065 MachineType param_type = sig->GetParam(i); | 1065 MachineType param_type = sig->GetParam(i); |
1066 Node* konst = nullptr; | 1066 Node* konst = nullptr; |
1067 if (param_type == MachineType::Int32()) { | 1067 if (param_type == MachineType::Int32()) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 int parray_gp[] = {GetRegConfig()->GetAllocatableGeneralCode(0), | 1128 int parray_gp[] = {GetRegConfig()->GetAllocatableGeneralCode(0), |
1129 GetRegConfig()->GetAllocatableGeneralCode(1)}; | 1129 GetRegConfig()->GetAllocatableGeneralCode(1)}; |
1130 int rarray_gp[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; | 1130 int rarray_gp[] = {GetRegConfig()->GetAllocatableGeneralCode(0)}; |
1131 int parray_fp[] = {GetRegConfig()->GetAllocatableDoubleCode(0), | 1131 int parray_fp[] = {GetRegConfig()->GetAllocatableDoubleCode(0), |
1132 GetRegConfig()->GetAllocatableDoubleCode(1)}; | 1132 GetRegConfig()->GetAllocatableDoubleCode(1)}; |
1133 int rarray_fp[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; | 1133 int rarray_fp[] = {GetRegConfig()->GetAllocatableDoubleCode(0)}; |
1134 Allocator palloc(parray_gp, 2, parray_fp, 2); | 1134 Allocator palloc(parray_gp, 2, parray_fp, 2); |
1135 Allocator ralloc(rarray_gp, 1, rarray_fp, 1); | 1135 Allocator ralloc(rarray_gp, 1, rarray_fp, 1); |
1136 RegisterConfig config(palloc, ralloc); | 1136 RegisterConfig config(palloc, ralloc); |
1137 | 1137 |
1138 Zone zone(isolate->allocator()); | 1138 Zone zone(isolate->allocator(), ZONE_NAME); |
1139 HandleScope scope(isolate); | 1139 HandleScope scope(isolate); |
1140 MachineSignature::Builder builder(&zone, 1, 12); | 1140 MachineSignature::Builder builder(&zone, 1, 12); |
1141 builder.AddReturn(MachineType::Int32()); | 1141 builder.AddReturn(MachineType::Int32()); |
1142 for (int i = 0; i < 10; i++) { | 1142 for (int i = 0; i < 10; i++) { |
1143 builder.AddParam(MachineType::Int32()); | 1143 builder.AddParam(MachineType::Int32()); |
1144 } | 1144 } |
1145 builder.AddParam(slot_type); | 1145 builder.AddParam(slot_type); |
1146 builder.AddParam(MachineType::Pointer()); | 1146 builder.AddParam(MachineType::Pointer()); |
1147 MachineSignature* sig = builder.Build(); | 1147 MachineSignature* sig = builder.Build(); |
1148 CallDescriptor* desc = config.Create(&zone, sig); | 1148 CallDescriptor* desc = config.Create(&zone, sig); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 TestStackSlot(MachineType::Float32(), magic); | 1192 TestStackSlot(MachineType::Float32(), magic); |
1193 } | 1193 } |
1194 | 1194 |
1195 TEST(RunStackSlotFloat64) { | 1195 TEST(RunStackSlotFloat64) { |
1196 double magic = 3456.375; | 1196 double magic = 3456.375; |
1197 TestStackSlot(MachineType::Float64(), magic); | 1197 TestStackSlot(MachineType::Float64(), magic); |
1198 } | 1198 } |
1199 } // namespace compiler | 1199 } // namespace compiler |
1200 } // namespace internal | 1200 } // namespace internal |
1201 } // namespace v8 | 1201 } // namespace v8 |
OLD | NEW |