| 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 Handle<Code> WrapWithCFunction(Handle<Code> inner, CallDescriptor* desc) { | 261 Handle<Code> WrapWithCFunction(Handle<Code> inner, CallDescriptor* desc) { |
| 262 Zone zone; | 262 Zone zone; |
| 263 MachineSignature* msig = | 263 MachineSignature* msig = |
| 264 const_cast<MachineSignature*>(desc->GetMachineSignature()); | 264 const_cast<MachineSignature*>(desc->GetMachineSignature()); |
| 265 int param_count = static_cast<int>(msig->parameter_count()); | 265 int param_count = static_cast<int>(msig->parameter_count()); |
| 266 GraphAndBuilders caller(&zone); | 266 GraphAndBuilders caller(&zone); |
| 267 { | 267 { |
| 268 GraphAndBuilders& b = caller; | 268 GraphAndBuilders& b = caller; |
| 269 Node* start = b.graph()->NewNode(b.common()->Start(param_count + 3)); | 269 Node* start = b.graph()->NewNode(b.common()->Start(param_count + 3)); |
| 270 b.graph()->SetStart(start); | 270 b.graph()->SetStart(start); |
| 271 Unique<HeapObject> unique = Unique<HeapObject>::CreateUninitialized(inner); | 271 Node* target = b.graph()->NewNode(b.common()->HeapConstant(inner)); |
| 272 Node* target = b.graph()->NewNode(b.common()->HeapConstant(unique)); | |
| 273 | 272 |
| 274 // Add arguments to the call. | 273 // Add arguments to the call. |
| 275 Node** args = zone.NewArray<Node*>(param_count + 3); | 274 Node** args = zone.NewArray<Node*>(param_count + 3); |
| 276 int index = 0; | 275 int index = 0; |
| 277 args[index++] = target; | 276 args[index++] = target; |
| 278 for (int i = 0; i < param_count; i++) { | 277 for (int i = 0; i < param_count; i++) { |
| 279 args[index] = b.graph()->NewNode(b.common()->Parameter(i), start); | 278 args[index] = b.graph()->NewNode(b.common()->Parameter(i), start); |
| 280 index++; | 279 index++; |
| 281 } | 280 } |
| 282 args[index++] = start; // effect. | 281 args[index++] = start; // effect. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 | 437 |
| 439 { | 438 { |
| 440 // constant mode. | 439 // constant mode. |
| 441 Handle<Code> wrapper = Handle<Code>::null(); | 440 Handle<Code> wrapper = Handle<Code>::null(); |
| 442 { | 441 { |
| 443 // Wrap the above code with a callable function that passes constants. | 442 // Wrap the above code with a callable function that passes constants. |
| 444 Zone zone; | 443 Zone zone; |
| 445 Graph graph(&zone); | 444 Graph graph(&zone); |
| 446 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); | 445 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); |
| 447 RawMachineAssembler raw(isolate, &graph, cdesc); | 446 RawMachineAssembler raw(isolate, &graph, cdesc); |
| 448 Unique<HeapObject> unique = | 447 Node* target = raw.HeapConstant(inner); |
| 449 Unique<HeapObject>::CreateUninitialized(inner); | |
| 450 Node* target = raw.HeapConstant(unique); | |
| 451 Node** args = zone.NewArray<Node*>(num_params); | 448 Node** args = zone.NewArray<Node*>(num_params); |
| 452 for (int i = 0; i < num_params; i++) { | 449 for (int i = 0; i < num_params; i++) { |
| 453 args[i] = io.MakeConstant(raw, io.input[i]); | 450 args[i] = io.MakeConstant(raw, io.input[i]); |
| 454 } | 451 } |
| 455 | 452 |
| 456 Node* call = raw.CallN(desc, target, args); | 453 Node* call = raw.CallN(desc, target, args); |
| 457 Node* store = io.StoreOutput(raw, call); | 454 Node* store = io.StoreOutput(raw, call); |
| 458 USE(store); | 455 USE(store); |
| 459 raw.Return(raw.Int32Constant(seed)); | 456 raw.Return(raw.Int32Constant(seed)); |
| 460 wrapper = | 457 wrapper = |
| (...skipping 12 matching lines...) Expand all Loading... |
| 473 { | 470 { |
| 474 // buffer mode. | 471 // buffer mode. |
| 475 Handle<Code> wrapper = Handle<Code>::null(); | 472 Handle<Code> wrapper = Handle<Code>::null(); |
| 476 { | 473 { |
| 477 // Wrap the above code with a callable function that loads from {input}. | 474 // Wrap the above code with a callable function that loads from {input}. |
| 478 Zone zone; | 475 Zone zone; |
| 479 Graph graph(&zone); | 476 Graph graph(&zone); |
| 480 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); | 477 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); |
| 481 RawMachineAssembler raw(isolate, &graph, cdesc); | 478 RawMachineAssembler raw(isolate, &graph, cdesc); |
| 482 Node* base = raw.PointerConstant(io.input); | 479 Node* base = raw.PointerConstant(io.input); |
| 483 Unique<HeapObject> unique = | 480 Node* target = raw.HeapConstant(inner); |
| 484 Unique<HeapObject>::CreateUninitialized(inner); | |
| 485 Node* target = raw.HeapConstant(unique); | |
| 486 Node** args = zone.NewArray<Node*>(kMaxParamCount); | 481 Node** args = zone.NewArray<Node*>(kMaxParamCount); |
| 487 for (int i = 0; i < num_params; i++) { | 482 for (int i = 0; i < num_params; i++) { |
| 488 args[i] = io.LoadInput(raw, base, i); | 483 args[i] = io.LoadInput(raw, base, i); |
| 489 } | 484 } |
| 490 | 485 |
| 491 Node* call = raw.CallN(desc, target, args); | 486 Node* call = raw.CallN(desc, target, args); |
| 492 Node* store = io.StoreOutput(raw, call); | 487 Node* store = io.StoreOutput(raw, call); |
| 493 USE(store); | 488 USE(store); |
| 494 raw.Return(raw.Int32Constant(seed)); | 489 raw.Return(raw.Int32Constant(seed)); |
| 495 wrapper = CompileGraph("Compute-wrapper", cdesc, &graph, raw.Export()); | 490 wrapper = CompileGraph("Compute-wrapper", cdesc, &graph, raw.Export()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 | 567 |
| 573 CSignature0<int32_t> csig; | 568 CSignature0<int32_t> csig; |
| 574 Handle<Code> wrapper = Handle<Code>::null(); | 569 Handle<Code> wrapper = Handle<Code>::null(); |
| 575 { | 570 { |
| 576 // Loads parameters from the input buffer and calls the above code. | 571 // Loads parameters from the input buffer and calls the above code. |
| 577 Zone zone; | 572 Zone zone; |
| 578 Graph graph(&zone); | 573 Graph graph(&zone); |
| 579 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); | 574 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); |
| 580 RawMachineAssembler raw(isolate, &graph, cdesc); | 575 RawMachineAssembler raw(isolate, &graph, cdesc); |
| 581 Node* base = raw.PointerConstant(input); | 576 Node* base = raw.PointerConstant(input); |
| 582 Unique<HeapObject> unique = Unique<HeapObject>::CreateUninitialized(inner); | 577 Node* target = raw.HeapConstant(inner); |
| 583 Node* target = raw.HeapConstant(unique); | |
| 584 Node** args = zone.NewArray<Node*>(kNumParams); | 578 Node** args = zone.NewArray<Node*>(kNumParams); |
| 585 for (int i = 0; i < kNumParams; i++) { | 579 for (int i = 0; i < kNumParams; i++) { |
| 586 Node* offset = raw.Int32Constant(i * sizeof(int32_t)); | 580 Node* offset = raw.Int32Constant(i * sizeof(int32_t)); |
| 587 args[i] = raw.Load(kMachInt32, base, offset); | 581 args[i] = raw.Load(kMachInt32, base, offset); |
| 588 } | 582 } |
| 589 | 583 |
| 590 Node* call = raw.CallN(desc, target, args); | 584 Node* call = raw.CallN(desc, target, args); |
| 591 raw.Return(call); | 585 raw.Return(call); |
| 592 wrapper = | 586 wrapper = |
| 593 CompileGraph("CopyTwentyInt32-wrapper", cdesc, &graph, raw.Export()); | 587 CompileGraph("CopyTwentyInt32-wrapper", cdesc, &graph, raw.Export()); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 Graph graph(&zone); | 940 Graph graph(&zone); |
| 947 RawMachineAssembler raw(isolate, &graph, desc); | 941 RawMachineAssembler raw(isolate, &graph, desc); |
| 948 raw.Return(raw.Parameter(which)); | 942 raw.Return(raw.Parameter(which)); |
| 949 inner = CompileGraph("Select-indirection", desc, &graph, raw.Export()); | 943 inner = CompileGraph("Select-indirection", desc, &graph, raw.Export()); |
| 950 CHECK(!inner.is_null()); | 944 CHECK(!inner.is_null()); |
| 951 CHECK(inner->IsCode()); | 945 CHECK(inner->IsCode()); |
| 952 } | 946 } |
| 953 | 947 |
| 954 { | 948 { |
| 955 // Build a call to the function that does the select. | 949 // Build a call to the function that does the select. |
| 956 Unique<HeapObject> unique = Unique<HeapObject>::CreateUninitialized(inner); | 950 Node* target = raw.HeapConstant(inner); |
| 957 Node* target = raw.HeapConstant(unique); | |
| 958 Node** args = raw.zone()->NewArray<Node*>(num_params); | 951 Node** args = raw.zone()->NewArray<Node*>(num_params); |
| 959 for (int i = 0; i < num_params; i++) { | 952 for (int i = 0; i < num_params; i++) { |
| 960 args[i] = raw.Parameter(i); | 953 args[i] = raw.Parameter(i); |
| 961 } | 954 } |
| 962 | 955 |
| 963 Node* call = raw.CallN(desc, target, args); | 956 Node* call = raw.CallN(desc, target, args); |
| 964 raw.Return(call); | 957 raw.Return(call); |
| 965 } | 958 } |
| 966 } | 959 } |
| 967 | 960 |
| 968 | 961 |
| 969 TEST(Float64StackParamsToStackParams) { | 962 TEST(Float64StackParamsToStackParams) { |
| 970 if (DISABLE_NATIVE_STACK_PARAMS) return; | 963 if (DISABLE_NATIVE_STACK_PARAMS) return; |
| 971 | 964 |
| 972 int rarray[] = {0}; | 965 int rarray[] = {0}; |
| 973 Allocator params(nullptr, 0, nullptr, 0); | 966 Allocator params(nullptr, 0, nullptr, 0); |
| 974 Allocator rets(nullptr, 0, rarray, 1); | 967 Allocator rets(nullptr, 0, rarray, 1); |
| 975 | 968 |
| 976 Zone zone; | 969 Zone zone; |
| 977 ArgsBuffer<float64>::Sig sig(2); | 970 ArgsBuffer<float64>::Sig sig(2); |
| 978 RegisterConfig config(params, rets); | 971 RegisterConfig config(params, rets); |
| 979 CallDescriptor* desc = config.Create(&zone, &sig); | 972 CallDescriptor* desc = config.Create(&zone, &sig); |
| 980 | 973 |
| 981 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>, | 974 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 0>, |
| 982 Compute_Select<float64, 0>, 1098); | 975 Compute_Select<float64, 0>, 1098); |
| 983 | 976 |
| 984 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 1>, | 977 Run_Computation<float64>(desc, Build_Select_With_Call<float64, 1>, |
| 985 Compute_Select<float64, 1>, 1099); | 978 Compute_Select<float64, 1>, 1099); |
| 986 } | 979 } |
| OLD | NEW |