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

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

Issue 1314473007: [turbofan] Remove usage of Unique<T> from graph. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased and fixed. Created 5 years, 3 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/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
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
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
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
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
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
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 char bytes[kDoubleSize]; 1041 char bytes[kDoubleSize];
1049 char output[kDoubleSize]; 1042 char output[kDoubleSize];
1050 int expected_size = 0; 1043 int expected_size = 0;
1051 CSignature0<int32_t> csig; 1044 CSignature0<int32_t> csig;
1052 { 1045 {
1053 // Wrap the select code with a callable function that passes constants. 1046 // Wrap the select code with a callable function that passes constants.
1054 Zone zone; 1047 Zone zone;
1055 Graph graph(&zone); 1048 Graph graph(&zone);
1056 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig); 1049 CallDescriptor* cdesc = Linkage::GetSimplifiedCDescriptor(&zone, &csig);
1057 RawMachineAssembler raw(isolate, &graph, cdesc); 1050 RawMachineAssembler raw(isolate, &graph, cdesc);
1058 Unique<HeapObject> unique = 1051 Node* target = raw.HeapConstant(select);
1059 Unique<HeapObject>::CreateUninitialized(select);
1060 Node* target = raw.HeapConstant(unique);
1061 Node** args = zone.NewArray<Node*>(num_params); 1052 Node** args = zone.NewArray<Node*>(num_params);
1062 int64_t constant = 0x0102030405060708; 1053 int64_t constant = 0x0102030405060708;
1063 for (int i = 0; i < num_params; i++) { 1054 for (int i = 0; i < num_params; i++) {
1064 MachineType param_type = sig->GetParam(i); 1055 MachineType param_type = sig->GetParam(i);
1065 Node* konst = nullptr; 1056 Node* konst = nullptr;
1066 if (param_type == kMachInt32) { 1057 if (param_type == kMachInt32) {
1067 int32_t value[] = {static_cast<int32_t>(constant)}; 1058 int32_t value[] = {static_cast<int32_t>(constant)};
1068 konst = raw.Int32Constant(value[0]); 1059 konst = raw.Int32Constant(value[0]);
1069 if (i == which) memcpy(bytes, value, expected_size = 4); 1060 if (i == which) memcpy(bytes, value, expected_size = 4);
1070 } 1061 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 } 1096 }
1106 } 1097 }
1107 } 1098 }
1108 } 1099 }
1109 1100
1110 1101
1111 TEST(MixedParams_0) { MixedParamTest(0); } 1102 TEST(MixedParams_0) { MixedParamTest(0); }
1112 TEST(MixedParams_1) { MixedParamTest(1); } 1103 TEST(MixedParams_1) { MixedParamTest(1); }
1113 TEST(MixedParams_2) { MixedParamTest(2); } 1104 TEST(MixedParams_2) { MixedParamTest(2); }
1114 TEST(MixedParams_3) { MixedParamTest(3); } 1105 TEST(MixedParams_3) { MixedParamTest(3); }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-representation-change.cc ('k') | test/cctest/compiler/test-run-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698