Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(629)

Side by Side Diff: test/cctest/compiler/test-run-native-calls.cc

Issue 1847543002: Expose a lower bound of malloc'd memory via heap statistics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 if (FLAG_print_opt_code) { 263 if (FLAG_print_opt_code) {
264 OFStream os(stdout); 264 OFStream os(stdout);
265 code->Disassemble(name, os); 265 code->Disassemble(name, os);
266 } 266 }
267 #endif 267 #endif
268 return code; 268 return code;
269 } 269 }
270 270
271 271
272 Handle<Code> WrapWithCFunction(Handle<Code> inner, CallDescriptor* desc) { 272 Handle<Code> WrapWithCFunction(Handle<Code> inner, CallDescriptor* desc) {
273 Zone zone; 273 ZoneForTesting zone;
274 MachineSignature* msig = 274 MachineSignature* msig =
275 const_cast<MachineSignature*>(desc->GetMachineSignature()); 275 const_cast<MachineSignature*>(desc->GetMachineSignature());
276 int param_count = static_cast<int>(msig->parameter_count()); 276 int param_count = static_cast<int>(msig->parameter_count());
277 GraphAndBuilders caller(&zone); 277 GraphAndBuilders caller(&zone);
278 { 278 {
279 GraphAndBuilders& b = caller; 279 GraphAndBuilders& b = caller;
280 Node* start = b.graph()->NewNode(b.common()->Start(param_count + 3)); 280 Node* start = b.graph()->NewNode(b.common()->Start(param_count + 3));
281 b.graph()->SetStart(start); 281 b.graph()->SetStart(start);
282 Node* target = b.graph()->NewNode(b.common()->HeapConstant(inner)); 282 Node* target = b.graph()->NewNode(b.common()->HeapConstant(inner));
283 283
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 void (*build)(CallDescriptor*, RawMachineAssembler&), 430 void (*build)(CallDescriptor*, RawMachineAssembler&),
431 CType (*compute)(CallDescriptor*, CType* inputs), 431 CType (*compute)(CallDescriptor*, CType* inputs),
432 int seed = 1) { 432 int seed = 1) {
433 int num_params = ParamCount(desc); 433 int num_params = ParamCount(desc);
434 CHECK_LE(num_params, kMaxParamCount); 434 CHECK_LE(num_params, kMaxParamCount);
435 Isolate* isolate = CcTest::InitIsolateOnce(); 435 Isolate* isolate = CcTest::InitIsolateOnce();
436 HandleScope scope(isolate); 436 HandleScope scope(isolate);
437 Handle<Code> inner = Handle<Code>::null(); 437 Handle<Code> inner = Handle<Code>::null();
438 { 438 {
439 // Build the graph for the computation. 439 // Build the graph for the computation.
440 Zone zone; 440 ZoneForTesting zone;
441 Graph graph(&zone); 441 Graph graph(&zone);
442 RawMachineAssembler raw(isolate, &graph, desc); 442 RawMachineAssembler raw(isolate, &graph, desc);
443 build(desc, raw); 443 build(desc, raw);
444 inner = CompileGraph("Compute", desc, &graph, raw.Export()); 444 inner = CompileGraph("Compute", desc, &graph, raw.Export());
445 } 445 }
446 446
447 CSignature0<int32_t> csig; 447 CSignature0<int32_t> csig;
448 ArgsBuffer<CType> io(num_params, seed); 448 ArgsBuffer<CType> io(num_params, seed);
449 449
450 { 450 {
451 // constant mode. 451 // constant mode.
452 Handle<Code> wrapper = Handle<Code>::null(); 452 Handle<Code> wrapper = Handle<Code>::null();
453 { 453 {
454 // Wrap the above code with a callable function that passes constants. 454 // Wrap the above code with a callable function that passes constants.
455 Zone zone; 455 ZoneForTesting zone;
456 Graph graph(&zone); 456 Graph graph(&zone);
457 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); 457 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
458 RawMachineAssembler raw(isolate, &graph, cdesc); 458 RawMachineAssembler raw(isolate, &graph, cdesc);
459 Node* target = raw.HeapConstant(inner); 459 Node* target = raw.HeapConstant(inner);
460 Node** args = zone.NewArray<Node*>(num_params); 460 Node** args = zone.NewArray<Node*>(num_params);
461 for (int i = 0; i < num_params; i++) { 461 for (int i = 0; i < num_params; i++) {
462 args[i] = io.MakeConstant(raw, io.input[i]); 462 args[i] = io.MakeConstant(raw, io.input[i]);
463 } 463 }
464 464
465 Node* call = raw.CallN(desc, target, args); 465 Node* call = raw.CallN(desc, target, args);
(...skipping 11 matching lines...) Expand all
477 int32_t check_seed = runnable.Call(); 477 int32_t check_seed = runnable.Call();
478 CHECK_EQ(seed, check_seed); 478 CHECK_EQ(seed, check_seed);
479 CHECK_EQ(expected, io.output); 479 CHECK_EQ(expected, io.output);
480 } 480 }
481 481
482 { 482 {
483 // buffer mode. 483 // buffer mode.
484 Handle<Code> wrapper = Handle<Code>::null(); 484 Handle<Code> wrapper = Handle<Code>::null();
485 { 485 {
486 // Wrap the above code with a callable function that loads from {input}. 486 // Wrap the above code with a callable function that loads from {input}.
487 Zone zone; 487 ZoneForTesting zone;
488 Graph graph(&zone); 488 Graph graph(&zone);
489 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); 489 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
490 RawMachineAssembler raw(isolate, &graph, cdesc); 490 RawMachineAssembler raw(isolate, &graph, cdesc);
491 Node* base = raw.PointerConstant(io.input); 491 Node* base = raw.PointerConstant(io.input);
492 Node* target = raw.HeapConstant(inner); 492 Node* target = raw.HeapConstant(inner);
493 Node** args = zone.NewArray<Node*>(kMaxParamCount); 493 Node** args = zone.NewArray<Node*>(kMaxParamCount);
494 for (int i = 0; i < num_params; i++) { 494 for (int i = 0; i < num_params; i++) {
495 args[i] = io.LoadInput(raw, base, i); 495 args[i] = io.LoadInput(raw, base, i);
496 } 496 }
497 497
(...skipping 17 matching lines...) Expand all
515 } 515 }
516 } 516 }
517 }; 517 };
518 518
519 } // namespace 519 } // namespace
520 520
521 521
522 static void TestInt32Sub(CallDescriptor* desc) { 522 static void TestInt32Sub(CallDescriptor* desc) {
523 Isolate* isolate = CcTest::InitIsolateOnce(); 523 Isolate* isolate = CcTest::InitIsolateOnce();
524 HandleScope scope(isolate); 524 HandleScope scope(isolate);
525 Zone zone; 525 ZoneForTesting zone;
526 GraphAndBuilders inner(&zone); 526 GraphAndBuilders inner(&zone);
527 { 527 {
528 // Build the add function. 528 // Build the add function.
529 GraphAndBuilders& b = inner; 529 GraphAndBuilders& b = inner;
530 Node* start = b.graph()->NewNode(b.common()->Start(5)); 530 Node* start = b.graph()->NewNode(b.common()->Start(5));
531 b.graph()->SetStart(start); 531 b.graph()->SetStart(start);
532 Node* p0 = b.graph()->NewNode(b.common()->Parameter(0), start); 532 Node* p0 = b.graph()->NewNode(b.common()->Parameter(0), start);
533 Node* p1 = b.graph()->NewNode(b.common()->Parameter(1), start); 533 Node* p1 = b.graph()->NewNode(b.common()->Parameter(1), start);
534 Node* add = b.graph()->NewNode(b.machine()->Int32Sub(), p0, p1); 534 Node* add = b.graph()->NewNode(b.machine()->Int32Sub(), p0, p1);
535 Node* ret = b.graph()->NewNode(b.common()->Return(), add, start, start); 535 Node* ret = b.graph()->NewNode(b.common()->Return(), add, start, start);
(...skipping 20 matching lines...) Expand all
556 556
557 static void CopyTwentyInt32(CallDescriptor* desc) { 557 static void CopyTwentyInt32(CallDescriptor* desc) {
558 const int kNumParams = 20; 558 const int kNumParams = 20;
559 int32_t input[kNumParams]; 559 int32_t input[kNumParams];
560 int32_t output[kNumParams]; 560 int32_t output[kNumParams];
561 Isolate* isolate = CcTest::InitIsolateOnce(); 561 Isolate* isolate = CcTest::InitIsolateOnce();
562 HandleScope scope(isolate); 562 HandleScope scope(isolate);
563 Handle<Code> inner = Handle<Code>::null(); 563 Handle<Code> inner = Handle<Code>::null();
564 { 564 {
565 // Writes all parameters into the output buffer. 565 // Writes all parameters into the output buffer.
566 Zone zone; 566 ZoneForTesting zone;
567 Graph graph(&zone); 567 Graph graph(&zone);
568 RawMachineAssembler raw(isolate, &graph, desc); 568 RawMachineAssembler raw(isolate, &graph, desc);
569 Node* base = raw.PointerConstant(output); 569 Node* base = raw.PointerConstant(output);
570 for (int i = 0; i < kNumParams; i++) { 570 for (int i = 0; i < kNumParams; i++) {
571 Node* offset = raw.Int32Constant(i * sizeof(int32_t)); 571 Node* offset = raw.Int32Constant(i * sizeof(int32_t));
572 raw.Store(MachineRepresentation::kWord32, base, offset, raw.Parameter(i), 572 raw.Store(MachineRepresentation::kWord32, base, offset, raw.Parameter(i),
573 kNoWriteBarrier); 573 kNoWriteBarrier);
574 } 574 }
575 raw.Return(raw.Int32Constant(42)); 575 raw.Return(raw.Int32Constant(42));
576 inner = CompileGraph("CopyTwentyInt32", desc, &graph, raw.Export()); 576 inner = CompileGraph("CopyTwentyInt32", desc, &graph, raw.Export());
577 } 577 }
578 578
579 CSignature0<int32_t> csig; 579 CSignature0<int32_t> csig;
580 Handle<Code> wrapper = Handle<Code>::null(); 580 Handle<Code> wrapper = Handle<Code>::null();
581 { 581 {
582 // Loads parameters from the input buffer and calls the above code. 582 // Loads parameters from the input buffer and calls the above code.
583 Zone zone; 583 ZoneForTesting zone;
584 Graph graph(&zone); 584 Graph graph(&zone);
585 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); 585 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
586 RawMachineAssembler raw(isolate, &graph, cdesc); 586 RawMachineAssembler raw(isolate, &graph, cdesc);
587 Node* base = raw.PointerConstant(input); 587 Node* base = raw.PointerConstant(input);
588 Node* target = raw.HeapConstant(inner); 588 Node* target = raw.HeapConstant(inner);
589 Node** args = zone.NewArray<Node*>(kNumParams); 589 Node** args = zone.NewArray<Node*>(kNumParams);
590 for (int i = 0; i < kNumParams; i++) { 590 for (int i = 0; i < kNumParams; i++) {
591 Node* offset = raw.Int32Constant(i * sizeof(int32_t)); 591 Node* offset = raw.Int32Constant(i * sizeof(int32_t));
592 args[i] = raw.Load(MachineType::Int32(), base, offset); 592 args[i] = raw.Load(MachineType::Int32(), base, offset);
593 } 593 }
(...skipping 18 matching lines...) Expand all
612 612
613 for (int j = 0; j < kNumParams; j++) { 613 for (int j = 0; j < kNumParams; j++) {
614 CHECK_EQ(input[j], output[j]); 614 CHECK_EQ(input[j], output[j]);
615 } 615 }
616 } 616 }
617 } 617 }
618 618
619 619
620 static void Test_RunInt32SubWithRet(int retreg) { 620 static void Test_RunInt32SubWithRet(int retreg) {
621 Int32Signature sig(2); 621 Int32Signature sig(2);
622 Zone zone; 622 ZoneForTesting zone;
623 RegisterPairs pairs; 623 RegisterPairs pairs;
624 while (pairs.More()) { 624 while (pairs.More()) {
625 int parray[2]; 625 int parray[2];
626 int rarray[] = {retreg}; 626 int rarray[] = {retreg};
627 pairs.Next(&parray[0], &parray[1], false); 627 pairs.Next(&parray[0], &parray[1], false);
628 Allocator params(parray, 2, nullptr, 0); 628 Allocator params(parray, 2, nullptr, 0);
629 Allocator rets(rarray, 1, nullptr, 0); 629 Allocator rets(rarray, 1, nullptr, 0);
630 RegisterConfig config(params, rets); 630 RegisterConfig config(params, rets);
631 CallDescriptor* desc = config.Create(&zone, &sig); 631 CallDescriptor* desc = config.Create(&zone, &sig);
632 TestInt32Sub(desc); 632 TestInt32Sub(desc);
(...skipping 30 matching lines...) Expand all
663 TEST_INT32_SUB_WITH_RET(16) 663 TEST_INT32_SUB_WITH_RET(16)
664 TEST_INT32_SUB_WITH_RET(17) 664 TEST_INT32_SUB_WITH_RET(17)
665 TEST_INT32_SUB_WITH_RET(18) 665 TEST_INT32_SUB_WITH_RET(18)
666 TEST_INT32_SUB_WITH_RET(19) 666 TEST_INT32_SUB_WITH_RET(19)
667 667
668 668
669 TEST(Run_Int32Sub_all_allocatable_single) { 669 TEST(Run_Int32Sub_all_allocatable_single) {
670 Int32Signature sig(2); 670 Int32Signature sig(2);
671 RegisterPairs pairs; 671 RegisterPairs pairs;
672 while (pairs.More()) { 672 while (pairs.More()) {
673 Zone zone; 673 ZoneForTesting zone;
674 int parray[1]; 674 int parray[1];
675 int rarray[1]; 675 int rarray[1];
676 pairs.Next(&rarray[0], &parray[0], true); 676 pairs.Next(&rarray[0], &parray[0], true);
677 Allocator params(parray, 1, nullptr, 0); 677 Allocator params(parray, 1, nullptr, 0);
678 Allocator rets(rarray, 1, nullptr, 0); 678 Allocator rets(rarray, 1, nullptr, 0);
679 RegisterConfig config(params, rets); 679 RegisterConfig config(params, rets);
680 CallDescriptor* desc = config.Create(&zone, &sig); 680 CallDescriptor* desc = config.Create(&zone, &sig);
681 TestInt32Sub(desc); 681 TestInt32Sub(desc);
682 } 682 }
683 } 683 }
684 684
685 685
686 TEST(Run_CopyTwentyInt32_all_allocatable_pairs) { 686 TEST(Run_CopyTwentyInt32_all_allocatable_pairs) {
687 Int32Signature sig(20); 687 Int32Signature sig(20);
688 RegisterPairs pairs; 688 RegisterPairs pairs;
689 while (pairs.More()) { 689 while (pairs.More()) {
690 Zone zone; 690 ZoneForTesting zone;
691 int parray[2]; 691 int parray[2];
692 int rarray[] = { 692 int rarray[] = {
693 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 693 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
694 ->GetAllocatableGeneralCode(0)}; 694 ->GetAllocatableGeneralCode(0)};
695 pairs.Next(&parray[0], &parray[1], false); 695 pairs.Next(&parray[0], &parray[1], false);
696 Allocator params(parray, 2, nullptr, 0); 696 Allocator params(parray, 2, nullptr, 0);
697 Allocator rets(rarray, 1, nullptr, 0); 697 Allocator rets(rarray, 1, nullptr, 0);
698 RegisterConfig config(params, rets); 698 RegisterConfig config(params, rets);
699 CallDescriptor* desc = config.Create(&zone, &sig); 699 CallDescriptor* desc = config.Create(&zone, &sig);
700 CopyTwentyInt32(desc); 700 CopyTwentyInt32(desc);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 result += static_cast<uint32_t>(input[i]) * coeff[i]; 732 result += static_cast<uint32_t>(input[i]) * coeff[i];
733 } 733 }
734 return static_cast<int32_t>(result); 734 return static_cast<int32_t>(result);
735 } 735 }
736 736
737 737
738 static void Test_Int32_WeightedSum_of_size(int count) { 738 static void Test_Int32_WeightedSum_of_size(int count) {
739 Int32Signature sig(count); 739 Int32Signature sig(count);
740 for (int p0 = 0; p0 < Register::kNumRegisters; p0++) { 740 for (int p0 = 0; p0 < Register::kNumRegisters; p0++) {
741 if (Register::from_code(p0).IsAllocatable()) { 741 if (Register::from_code(p0).IsAllocatable()) {
742 Zone zone; 742 ZoneForTesting zone;
743 743
744 int parray[] = {p0}; 744 int parray[] = {p0};
745 int rarray[] = { 745 int rarray[] = {
746 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 746 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
747 ->GetAllocatableGeneralCode(0)}; 747 ->GetAllocatableGeneralCode(0)};
748 Allocator params(parray, 1, nullptr, 0); 748 Allocator params(parray, 1, nullptr, 0);
749 Allocator rets(rarray, 1, nullptr, 0); 749 Allocator rets(rarray, 1, nullptr, 0);
750 RegisterConfig config(params, rets); 750 RegisterConfig config(params, rets);
751 CallDescriptor* desc = config.Create(&zone, &sig); 751 CallDescriptor* desc = config.Create(&zone, &sig);
752 Run_Computation<int32_t>(desc, Build_Int32_WeightedSum, 752 Run_Computation<int32_t>(desc, Build_Int32_WeightedSum,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 int parray[] = { 800 int parray[] = {
801 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 801 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
802 ->GetAllocatableGeneralCode(0)}; 802 ->GetAllocatableGeneralCode(0)};
803 int rarray[] = { 803 int rarray[] = {
804 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 804 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
805 ->GetAllocatableGeneralCode(0)}; 805 ->GetAllocatableGeneralCode(0)};
806 Allocator params(parray, 1, nullptr, 0); 806 Allocator params(parray, 1, nullptr, 0);
807 Allocator rets(rarray, 1, nullptr, 0); 807 Allocator rets(rarray, 1, nullptr, 0);
808 RegisterConfig config(params, rets); 808 RegisterConfig config(params, rets);
809 809
810 Zone zone; 810 ZoneForTesting zone;
811 811
812 for (int i = which + 1; i <= 64; i++) { 812 for (int i = which + 1; i <= 64; i++) {
813 Int32Signature sig(i); 813 Int32Signature sig(i);
814 CallDescriptor* desc = config.Create(&zone, &sig); 814 CallDescriptor* desc = config.Create(&zone, &sig);
815 RunSelect<int32_t, which>(desc); 815 RunSelect<int32_t, which>(desc);
816 } 816 }
817 } 817 }
818 818
819 819
820 // Separate tests for parallelization. 820 // Separate tests for parallelization.
(...skipping 21 matching lines...) Expand all
842 ->num_allocatable_general_registers() < 2) 842 ->num_allocatable_general_registers() < 2)
843 return; 843 return;
844 if (kPointerSize < 8) return; // TODO(titzer): int64 on 32-bit platforms 844 if (kPointerSize < 8) return; // TODO(titzer): int64 on 32-bit platforms
845 845
846 int rarray[] = { 846 int rarray[] = {
847 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 847 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
848 ->GetAllocatableGeneralCode(0)}; 848 ->GetAllocatableGeneralCode(0)};
849 ArgsBuffer<int64_t>::Sig sig(2); 849 ArgsBuffer<int64_t>::Sig sig(2);
850 850
851 RegisterPairs pairs; 851 RegisterPairs pairs;
852 Zone zone; 852 ZoneForTesting zone;
853 while (pairs.More()) { 853 while (pairs.More()) {
854 int parray[2]; 854 int parray[2];
855 pairs.Next(&parray[0], &parray[1], false); 855 pairs.Next(&parray[0], &parray[1], false);
856 Allocator params(parray, 2, nullptr, 0); 856 Allocator params(parray, 2, nullptr, 0);
857 Allocator rets(rarray, 1, nullptr, 0); 857 Allocator rets(rarray, 1, nullptr, 0);
858 RegisterConfig config(params, rets); 858 RegisterConfig config(params, rets);
859 859
860 CallDescriptor* desc = config.Create(&zone, &sig); 860 CallDescriptor* desc = config.Create(&zone, &sig);
861 RunSelect<int64_t, 0>(desc); 861 RunSelect<int64_t, 0>(desc);
862 RunSelect<int64_t, 1>(desc); 862 RunSelect<int64_t, 1>(desc);
863 } 863 }
864 } 864 }
865 865
866 866
867 TEST(Float32Select_registers) { 867 TEST(Float32Select_registers) {
868 if (RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 868 if (RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
869 ->num_allocatable_double_registers() < 2) { 869 ->num_allocatable_double_registers() < 2) {
870 return; 870 return;
871 } 871 }
872 872
873 int rarray[] = { 873 int rarray[] = {
874 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 874 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
875 ->GetAllocatableDoubleCode(0)}; 875 ->GetAllocatableDoubleCode(0)};
876 ArgsBuffer<float32>::Sig sig(2); 876 ArgsBuffer<float32>::Sig sig(2);
877 877
878 Float32RegisterPairs pairs; 878 Float32RegisterPairs pairs;
879 Zone zone; 879 ZoneForTesting zone;
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<float32, 0>(desc); 888 RunSelect<float32, 0>(desc);
889 RunSelect<float32, 1>(desc); 889 RunSelect<float32, 1>(desc);
890 } 890 }
891 } 891 }
892 892
893 893
894 TEST(Float64Select_registers) { 894 TEST(Float64Select_registers) {
895 if (RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 895 if (RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
896 ->num_allocatable_double_registers() < 2) 896 ->num_allocatable_double_registers() < 2)
897 return; 897 return;
898 if (RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 898 if (RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
899 ->num_allocatable_general_registers() < 2) 899 ->num_allocatable_general_registers() < 2)
900 return; 900 return;
901 int rarray[] = { 901 int rarray[] = {
902 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 902 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
903 ->GetAllocatableDoubleCode(0)}; 903 ->GetAllocatableDoubleCode(0)};
904 ArgsBuffer<float64>::Sig sig(2); 904 ArgsBuffer<float64>::Sig sig(2);
905 905
906 Float64RegisterPairs pairs; 906 Float64RegisterPairs pairs;
907 Zone zone; 907 ZoneForTesting zone;
908 while (pairs.More()) { 908 while (pairs.More()) {
909 int parray[2]; 909 int parray[2];
910 pairs.Next(&parray[0], &parray[1], false); 910 pairs.Next(&parray[0], &parray[1], false);
911 Allocator params(nullptr, 0, parray, 2); 911 Allocator params(nullptr, 0, parray, 2);
912 Allocator rets(nullptr, 0, rarray, 1); 912 Allocator rets(nullptr, 0, rarray, 1);
913 RegisterConfig config(params, rets); 913 RegisterConfig config(params, rets);
914 914
915 CallDescriptor* desc = config.Create(&zone, &sig); 915 CallDescriptor* desc = config.Create(&zone, &sig);
916 RunSelect<float64, 0>(desc); 916 RunSelect<float64, 0>(desc);
917 RunSelect<float64, 1>(desc); 917 RunSelect<float64, 1>(desc);
918 } 918 }
919 } 919 }
920 920
921 921
922 TEST(Float32Select_stack_params_return_reg) { 922 TEST(Float32Select_stack_params_return_reg) {
923 int rarray[] = { 923 int rarray[] = {
924 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 924 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
925 ->GetAllocatableDoubleCode(0)}; 925 ->GetAllocatableDoubleCode(0)};
926 Allocator params(nullptr, 0, nullptr, 0); 926 Allocator params(nullptr, 0, nullptr, 0);
927 Allocator rets(nullptr, 0, rarray, 1); 927 Allocator rets(nullptr, 0, rarray, 1);
928 RegisterConfig config(params, rets); 928 RegisterConfig config(params, rets);
929 929
930 Zone zone; 930 ZoneForTesting zone;
931 for (int count = 1; count < 6; count++) { 931 for (int count = 1; count < 6; count++) {
932 ArgsBuffer<float32>::Sig sig(count); 932 ArgsBuffer<float32>::Sig sig(count);
933 CallDescriptor* desc = config.Create(&zone, &sig); 933 CallDescriptor* desc = config.Create(&zone, &sig);
934 RunSelect<float32, 0>(desc); 934 RunSelect<float32, 0>(desc);
935 RunSelect<float32, 1>(desc); 935 RunSelect<float32, 1>(desc);
936 RunSelect<float32, 2>(desc); 936 RunSelect<float32, 2>(desc);
937 RunSelect<float32, 3>(desc); 937 RunSelect<float32, 3>(desc);
938 RunSelect<float32, 4>(desc); 938 RunSelect<float32, 4>(desc);
939 RunSelect<float32, 5>(desc); 939 RunSelect<float32, 5>(desc);
940 } 940 }
941 } 941 }
942 942
943 943
944 TEST(Float64Select_stack_params_return_reg) { 944 TEST(Float64Select_stack_params_return_reg) {
945 int rarray[] = { 945 int rarray[] = {
946 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 946 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
947 ->GetAllocatableDoubleCode(0)}; 947 ->GetAllocatableDoubleCode(0)};
948 Allocator params(nullptr, 0, nullptr, 0); 948 Allocator params(nullptr, 0, nullptr, 0);
949 Allocator rets(nullptr, 0, rarray, 1); 949 Allocator rets(nullptr, 0, rarray, 1);
950 RegisterConfig config(params, rets); 950 RegisterConfig config(params, rets);
951 951
952 Zone zone; 952 ZoneForTesting zone;
953 for (int count = 1; count < 6; count++) { 953 for (int count = 1; count < 6; count++) {
954 ArgsBuffer<float64>::Sig sig(count); 954 ArgsBuffer<float64>::Sig sig(count);
955 CallDescriptor* desc = config.Create(&zone, &sig); 955 CallDescriptor* desc = config.Create(&zone, &sig);
956 RunSelect<float64, 0>(desc); 956 RunSelect<float64, 0>(desc);
957 RunSelect<float64, 1>(desc); 957 RunSelect<float64, 1>(desc);
958 RunSelect<float64, 2>(desc); 958 RunSelect<float64, 2>(desc);
959 RunSelect<float64, 3>(desc); 959 RunSelect<float64, 3>(desc);
960 RunSelect<float64, 4>(desc); 960 RunSelect<float64, 4>(desc);
961 RunSelect<float64, 5>(desc); 961 RunSelect<float64, 5>(desc);
962 } 962 }
963 } 963 }
964 964
965 965
966 template <typename CType, int which> 966 template <typename CType, int which>
967 static void Build_Select_With_Call(CallDescriptor* desc, 967 static void Build_Select_With_Call(CallDescriptor* desc,
968 RawMachineAssembler& raw) { 968 RawMachineAssembler& raw) {
969 Handle<Code> inner = Handle<Code>::null(); 969 Handle<Code> inner = Handle<Code>::null();
970 int num_params = ParamCount(desc); 970 int num_params = ParamCount(desc);
971 CHECK_LE(num_params, kMaxParamCount); 971 CHECK_LE(num_params, kMaxParamCount);
972 { 972 {
973 Isolate* isolate = CcTest::InitIsolateOnce(); 973 Isolate* isolate = CcTest::InitIsolateOnce();
974 // Build the actual select. 974 // Build the actual select.
975 Zone zone; 975 ZoneForTesting zone;
976 Graph graph(&zone); 976 Graph graph(&zone);
977 RawMachineAssembler raw(isolate, &graph, desc); 977 RawMachineAssembler raw(isolate, &graph, desc);
978 raw.Return(raw.Parameter(which)); 978 raw.Return(raw.Parameter(which));
979 inner = CompileGraph("Select-indirection", desc, &graph, raw.Export()); 979 inner = CompileGraph("Select-indirection", desc, &graph, raw.Export());
980 CHECK(!inner.is_null()); 980 CHECK(!inner.is_null());
981 CHECK(inner->IsCode()); 981 CHECK(inner->IsCode());
982 } 982 }
983 983
984 { 984 {
985 // Build a call to the function that does the select. 985 // Build a call to the function that does the select.
986 Node* target = raw.HeapConstant(inner); 986 Node* target = raw.HeapConstant(inner);
987 Node** args = raw.zone()->NewArray<Node*>(num_params); 987 Node** args = raw.zone()->NewArray<Node*>(num_params);
988 for (int i = 0; i < num_params; i++) { 988 for (int i = 0; i < num_params; i++) {
989 args[i] = raw.Parameter(i); 989 args[i] = raw.Parameter(i);
990 } 990 }
991 991
992 Node* call = raw.CallN(desc, target, args); 992 Node* call = raw.CallN(desc, target, args);
993 raw.Return(call); 993 raw.Return(call);
994 } 994 }
995 } 995 }
996 996
997 997
998 TEST(Float64StackParamsToStackParams) { 998 TEST(Float64StackParamsToStackParams) {
999 int rarray[] = { 999 int rarray[] = {
1000 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 1000 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
1001 ->GetAllocatableDoubleCode(0)}; 1001 ->GetAllocatableDoubleCode(0)};
1002 Allocator params(nullptr, 0, nullptr, 0); 1002 Allocator params(nullptr, 0, nullptr, 0);
1003 Allocator rets(nullptr, 0, rarray, 1); 1003 Allocator rets(nullptr, 0, rarray, 1);
1004 1004
1005 Zone zone; 1005 ZoneForTesting zone;
1006 ArgsBuffer<float64>::Sig sig(2); 1006 ArgsBuffer<float64>::Sig sig(2);
1007 RegisterConfig config(params, rets); 1007 RegisterConfig config(params, rets);
1008 CallDescriptor* desc = config.Create(&zone, &sig); 1008 CallDescriptor* desc = config.Create(&zone, &sig);
1009 1009
1010 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>, 1010 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>,
1011 Compute_Select<float64, 0>, 1098); 1011 Compute_Select<float64, 0>, 1098);
1012 1012
1013 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 1>, 1013 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 1>,
1014 Compute_Select<float64, 1>, 1099); 1014 Compute_Select<float64, 1>, 1099);
1015 } 1015 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 1061 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
1062 ->GetAllocatableDoubleCode(1)}; 1062 ->GetAllocatableDoubleCode(1)};
1063 int rarray_fp[] = { 1063 int rarray_fp[] = {
1064 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 1064 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
1065 ->GetAllocatableDoubleCode(0)}; 1065 ->GetAllocatableDoubleCode(0)};
1066 Allocator palloc(parray_gp, 2, parray_fp, 2); 1066 Allocator palloc(parray_gp, 2, parray_fp, 2);
1067 Allocator ralloc(rarray_gp, 1, rarray_fp, 1); 1067 Allocator ralloc(rarray_gp, 1, rarray_fp, 1);
1068 RegisterConfig config(palloc, ralloc); 1068 RegisterConfig config(palloc, ralloc);
1069 1069
1070 for (int which = 0; which < num_params; which++) { 1070 for (int which = 0; which < num_params; which++) {
1071 Zone zone; 1071 ZoneForTesting zone;
1072 HandleScope scope(isolate); 1072 HandleScope scope(isolate);
1073 MachineSignature::Builder builder(&zone, 1, num_params); 1073 MachineSignature::Builder builder(&zone, 1, num_params);
1074 builder.AddReturn(params[which]); 1074 builder.AddReturn(params[which]);
1075 for (int j = 0; j < num_params; j++) builder.AddParam(params[j]); 1075 for (int j = 0; j < num_params; j++) builder.AddParam(params[j]);
1076 MachineSignature* sig = builder.Build(); 1076 MachineSignature* sig = builder.Build();
1077 CallDescriptor* desc = config.Create(&zone, sig); 1077 CallDescriptor* desc = config.Create(&zone, sig);
1078 1078
1079 Handle<Code> select; 1079 Handle<Code> select;
1080 { 1080 {
1081 // build the select. 1081 // build the select.
1082 Zone zone; 1082 ZoneForTesting zone;
1083 Graph graph(&zone); 1083 Graph graph(&zone);
1084 RawMachineAssembler raw(isolate, &graph, desc); 1084 RawMachineAssembler raw(isolate, &graph, desc);
1085 raw.Return(raw.Parameter(which)); 1085 raw.Return(raw.Parameter(which));
1086 select = CompileGraph("Compute", desc, &graph, raw.Export()); 1086 select = CompileGraph("Compute", desc, &graph, raw.Export());
1087 } 1087 }
1088 1088
1089 { 1089 {
1090 // call the select. 1090 // call the select.
1091 Handle<Code> wrapper = Handle<Code>::null(); 1091 Handle<Code> wrapper = Handle<Code>::null();
1092 int32_t expected_ret; 1092 int32_t expected_ret;
1093 char bytes[kDoubleSize]; 1093 char bytes[kDoubleSize];
1094 V8_ALIGNED(8) char output[kDoubleSize]; 1094 V8_ALIGNED(8) char output[kDoubleSize];
1095 int expected_size = 0; 1095 int expected_size = 0;
1096 CSignature0<int32_t> csig; 1096 CSignature0<int32_t> csig;
1097 { 1097 {
1098 // Wrap the select code with a callable function that passes constants. 1098 // Wrap the select code with a callable function that passes constants.
1099 Zone zone; 1099 ZoneForTesting zone;
1100 Graph graph(&zone); 1100 Graph graph(&zone);
1101 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); 1101 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
1102 RawMachineAssembler raw(isolate, &graph, cdesc); 1102 RawMachineAssembler raw(isolate, &graph, cdesc);
1103 Node* target = raw.HeapConstant(select); 1103 Node* target = raw.HeapConstant(select);
1104 Node** args = zone.NewArray<Node*>(num_params); 1104 Node** args = zone.NewArray<Node*>(num_params);
1105 int64_t constant = 0x0102030405060708; 1105 int64_t constant = 0x0102030405060708;
1106 for (int i = 0; i < num_params; i++) { 1106 for (int i = 0; i < num_params; i++) {
1107 MachineType param_type = sig->GetParam(i); 1107 MachineType param_type = sig->GetParam(i);
1108 Node* konst = nullptr; 1108 Node* konst = nullptr;
1109 if (param_type == MachineType::Int32()) { 1109 if (param_type == MachineType::Int32()) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 ->GetAllocatableDoubleCode(0), 1182 ->GetAllocatableDoubleCode(0),
1183 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 1183 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
1184 ->GetAllocatableDoubleCode(1)}; 1184 ->GetAllocatableDoubleCode(1)};
1185 int rarray_fp[] = { 1185 int rarray_fp[] = {
1186 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN) 1186 RegisterConfiguration::ArchDefault(RegisterConfiguration::TURBOFAN)
1187 ->GetAllocatableDoubleCode(0)}; 1187 ->GetAllocatableDoubleCode(0)};
1188 Allocator palloc(parray_gp, 2, parray_fp, 2); 1188 Allocator palloc(parray_gp, 2, parray_fp, 2);
1189 Allocator ralloc(rarray_gp, 1, rarray_fp, 1); 1189 Allocator ralloc(rarray_gp, 1, rarray_fp, 1);
1190 RegisterConfig config(palloc, ralloc); 1190 RegisterConfig config(palloc, ralloc);
1191 1191
1192 Zone zone; 1192 ZoneForTesting zone;
1193 HandleScope scope(isolate); 1193 HandleScope scope(isolate);
1194 MachineSignature::Builder builder(&zone, 1, 12); 1194 MachineSignature::Builder builder(&zone, 1, 12);
1195 builder.AddReturn(MachineType::Int32()); 1195 builder.AddReturn(MachineType::Int32());
1196 for (int i = 0; i < 10; i++) { 1196 for (int i = 0; i < 10; i++) {
1197 builder.AddParam(MachineType::Int32()); 1197 builder.AddParam(MachineType::Int32());
1198 } 1198 }
1199 builder.AddParam(slot_type); 1199 builder.AddParam(slot_type);
1200 builder.AddParam(MachineType::Pointer()); 1200 builder.AddParam(MachineType::Pointer());
1201 MachineSignature* sig = builder.Build(); 1201 MachineSignature* sig = builder.Build();
1202 CallDescriptor* desc = config.Create(&zone, sig); 1202 CallDescriptor* desc = config.Create(&zone, sig);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 TestStackSlot(MachineType::Float32(), magic); 1246 TestStackSlot(MachineType::Float32(), magic);
1247 } 1247 }
1248 1248
1249 TEST(RunStackSlotFloat64) { 1249 TEST(RunStackSlotFloat64) {
1250 double magic = 3456.375; 1250 double magic = 3456.375;
1251 TestStackSlot(MachineType::Float64(), magic); 1251 TestStackSlot(MachineType::Float64(), magic);
1252 } 1252 }
1253 } // namespace compiler 1253 } // namespace compiler
1254 } // namespace internal 1254 } // namespace internal
1255 } // namespace v8 1255 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698