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/machine-type.h" | 8 #include "src/compiler/machine-type.h" |
9 #include "src/compiler/raw-machine-assembler.h" | 9 #include "src/compiler/raw-machine-assembler.h" |
10 | 10 |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 Handle<Code> wrapper = Handle<Code>::null(); | 440 Handle<Code> wrapper = Handle<Code>::null(); |
441 { | 441 { |
442 // Wrap the above code with a callable function that passes constants. | 442 // Wrap the above code with a callable function that passes constants. |
443 Zone zone; | 443 Zone zone; |
444 Graph graph(&zone); | 444 Graph graph(&zone); |
445 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); | 445 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); |
446 RawMachineAssembler raw(isolate, &graph, cdesc); | 446 RawMachineAssembler raw(isolate, &graph, cdesc); |
447 Unique<HeapObject> unique = | 447 Unique<HeapObject> unique = |
448 Unique<HeapObject>::CreateUninitialized(inner); | 448 Unique<HeapObject>::CreateUninitialized(inner); |
449 Node* target = raw.HeapConstant(unique); | 449 Node* target = raw.HeapConstant(unique); |
450 Node** args = zone.NewArray<Node*>(kMaxParamCount); | 450 Node** args = zone.NewArray<Node*>(num_params); |
451 for (int i = 0; i < num_params; i++) { | 451 for (int i = 0; i < num_params; i++) { |
452 args[i] = io.MakeConstant(raw, io.input[i]); | 452 args[i] = io.MakeConstant(raw, io.input[i]); |
453 } | 453 } |
454 | 454 |
455 Node* call = raw.CallN(desc, target, args); | 455 Node* call = raw.CallN(desc, target, args); |
456 Node* store = io.StoreOutput(raw, call); | 456 Node* store = io.StoreOutput(raw, call); |
457 USE(store); | 457 USE(store); |
458 raw.Return(raw.Int32Constant(seed)); | 458 raw.Return(raw.Int32Constant(seed)); |
459 wrapper = | 459 wrapper = |
460 CompileGraph("Compute-wrapper-const", cdesc, &graph, raw.Export()); | 460 CompileGraph("Compute-wrapper-const", cdesc, &graph, raw.Export()); |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 ArgsBuffer<float64>::Sig sig(count); | 923 ArgsBuffer<float64>::Sig sig(count); |
924 CallDescriptor* desc = config.Create(&zone, &sig); | 924 CallDescriptor* desc = config.Create(&zone, &sig); |
925 RunSelect<float64, 0>(desc); | 925 RunSelect<float64, 0>(desc); |
926 RunSelect<float64, 1>(desc); | 926 RunSelect<float64, 1>(desc); |
927 RunSelect<float64, 2>(desc); | 927 RunSelect<float64, 2>(desc); |
928 RunSelect<float64, 3>(desc); | 928 RunSelect<float64, 3>(desc); |
929 RunSelect<float64, 4>(desc); | 929 RunSelect<float64, 4>(desc); |
930 RunSelect<float64, 5>(desc); | 930 RunSelect<float64, 5>(desc); |
931 } | 931 } |
932 } | 932 } |
| 933 |
| 934 |
| 935 template <typename CType, int which> |
| 936 static void Build_Select_With_Call(CallDescriptor* desc, |
| 937 RawMachineAssembler& raw) { |
| 938 Handle<Code> inner = Handle<Code>::null(); |
| 939 int num_params = ParamCount(desc); |
| 940 CHECK_LE(num_params, kMaxParamCount); |
| 941 { |
| 942 Isolate* isolate = CcTest::InitIsolateOnce(); |
| 943 // Build the actual select. |
| 944 Zone zone; |
| 945 Graph graph(&zone); |
| 946 RawMachineAssembler raw(isolate, &graph, desc); |
| 947 raw.Return(raw.Parameter(which)); |
| 948 inner = CompileGraph("Select-indirection", desc, &graph, raw.Export()); |
| 949 CHECK(!inner.is_null()); |
| 950 CHECK(inner->IsCode()); |
| 951 } |
| 952 |
| 953 { |
| 954 // Build a call to the function that does the select. |
| 955 Unique<HeapObject> unique = Unique<HeapObject>::CreateUninitialized(inner); |
| 956 Node* target = raw.HeapConstant(unique); |
| 957 Node** args = raw.zone()->NewArray<Node*>(num_params); |
| 958 for (int i = 0; i < num_params; i++) { |
| 959 args[i] = raw.Parameter(i); |
| 960 } |
| 961 |
| 962 Node* call = raw.CallN(desc, target, args); |
| 963 raw.Return(call); |
| 964 } |
| 965 } |
| 966 |
| 967 |
| 968 TEST(Float64StackParamsToStackParams) { |
| 969 if (DISABLE_NATIVE_STACK_PARAMS) return; |
| 970 |
| 971 int rarray[] = {0}; |
| 972 Allocator params(nullptr, 0, nullptr, 0); |
| 973 Allocator rets(nullptr, 0, rarray, 1); |
| 974 |
| 975 Zone zone; |
| 976 ArgsBuffer<float64>::Sig sig(2); |
| 977 RegisterConfig config(params, rets); |
| 978 CallDescriptor* desc = config.Create(&zone, &sig); |
| 979 |
| 980 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>, |
| 981 Compute_Select<float64, 0>, 1098); |
| 982 |
| 983 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 1>, |
| 984 Compute_Select<float64, 1>, 1099); |
| 985 } |
OLD | NEW |