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

Side by Side Diff: test/cctest/compiler/codegen-tester.h

Issue 1146173005: [test] Refactor call-tester to use c-signature.h. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « test/cctest/compiler/call-tester.h ('k') | test/cctest/compiler/graph-builder-tester.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #ifndef V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ 5 #ifndef V8_CCTEST_COMPILER_CODEGEN_TESTER_H_
6 #define V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ 6 #define V8_CCTEST_COMPILER_CODEGEN_TESTER_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/compiler/instruction-selector.h" 10 #include "src/compiler/instruction-selector.h"
(...skipping 12 matching lines...) Expand all
23 public RawMachineAssembler { 23 public RawMachineAssembler {
24 public: 24 public:
25 RawMachineAssemblerTester(MachineType p0 = kMachNone, 25 RawMachineAssemblerTester(MachineType p0 = kMachNone,
26 MachineType p1 = kMachNone, 26 MachineType p1 = kMachNone,
27 MachineType p2 = kMachNone, 27 MachineType p2 = kMachNone,
28 MachineType p3 = kMachNone, 28 MachineType p3 = kMachNone,
29 MachineType p4 = kMachNone) 29 MachineType p4 = kMachNone)
30 : HandleAndZoneScope(), 30 : HandleAndZoneScope(),
31 CallHelper<ReturnType>( 31 CallHelper<ReturnType>(
32 main_isolate(), 32 main_isolate(),
33 MakeMachineSignature(main_zone(), MachineTypeForC<ReturnType>(), p0, 33 CSignature::New(main_zone(), MachineTypeForC<ReturnType>(), p0, p1,
34 p1, p2, p3, p4)), 34 p2, p3, p4)),
35 RawMachineAssembler( 35 RawMachineAssembler(
36 main_isolate(), new (main_zone()) Graph(main_zone()), 36 main_isolate(), new (main_zone()) Graph(main_zone()),
37 MakeMachineSignature(main_zone(), MachineTypeForC<ReturnType>(), p0, 37 CSignature::New(main_zone(), MachineTypeForC<ReturnType>(), p0, p1,
38 p1, p2, p3, p4), 38 p2, p3, p4),
39 kMachPtr, InstructionSelector::SupportedMachineOperatorFlags()) {} 39 kMachPtr, InstructionSelector::SupportedMachineOperatorFlags()) {}
40 40
41 void CheckNumber(double expected, Object* number) { 41 void CheckNumber(double expected, Object* number) {
42 CHECK(this->isolate()->factory()->NewNumber(expected)->SameValue(number)); 42 CHECK(this->isolate()->factory()->NewNumber(expected)->SameValue(number));
43 } 43 }
44 44
45 void CheckString(const char* expected, Object* string) { 45 void CheckString(const char* expected, Object* string) {
46 CHECK( 46 CHECK(
47 this->isolate()->factory()->InternalizeUtf8String(expected)->SameValue( 47 this->isolate()->factory()->InternalizeUtf8String(expected)->SameValue(
48 string)); 48 string));
49 } 49 }
50 50
51 void GenerateCode() { Generate(); } 51 void GenerateCode() { Generate(); }
52 52
53 protected: 53 protected:
54 virtual byte* Generate() { 54 virtual byte* Generate() {
55 if (code_.is_null()) { 55 if (code_.is_null()) {
56 Schedule* schedule = this->Export(); 56 Schedule* schedule = this->Export();
57 CallDescriptor* call_descriptor = this->call_descriptor(); 57 CallDescriptor* call_descriptor = this->call_descriptor();
58 Graph* graph = this->graph(); 58 Graph* graph = this->graph();
59 code_ = Pipeline::GenerateCodeForTesting(this->isolate(), call_descriptor, 59 code_ = Pipeline::GenerateCodeForTesting(this->isolate(), call_descriptor,
60 graph, schedule); 60 graph, schedule);
61 } 61 }
62 return this->code_.ToHandleChecked()->entry(); 62 return this->code_.ToHandleChecked()->entry();
63 } 63 }
64 64
65 private: 65 private:
66 MaybeHandle<Code> code_; 66 MaybeHandle<Code> code_;
67
68 // TODO(titzer): factor me elsewhere.
69 static MachineSignature* MakeMachineSignature(
70 Zone* zone, MachineType return_type, MachineType p0 = kMachNone,
71 MachineType p1 = kMachNone, MachineType p2 = kMachNone,
72 MachineType p3 = kMachNone, MachineType p4 = kMachNone) {
73 // Count the number of parameters.
74 size_t param_count = 5;
75 MachineType types[] = {p0, p1, p2, p3, p4};
76 while (param_count > 0 && types[param_count - 1] == kMachNone)
77 param_count--;
78 size_t return_count = return_type == kMachNone ? 0 : 1;
79
80 // Build the machine signature.
81 MachineSignature::Builder builder(zone, return_count, param_count);
82 if (return_count > 0) builder.AddReturn(return_type);
83 for (size_t i = 0; i < param_count; i++) {
84 builder.AddParam(types[i]);
85 }
86 return builder.Build();
87 }
88 }; 67 };
89 68
90 69
91 static const bool USE_RESULT_BUFFER = true; 70 static const bool USE_RESULT_BUFFER = true;
92 static const bool USE_RETURN_REGISTER = false; 71 static const bool USE_RETURN_REGISTER = false;
93 static const int32_t CHECK_VALUE = 0x99BEEDCE; 72 static const int32_t CHECK_VALUE = 0x99BEEDCE;
94 73
95 74
96 // TODO(titzer): use the C-style calling convention, or any register-based 75 // TODO(titzer): use the C-style calling convention, or any register-based
97 // calling convention for binop tests. 76 // calling convention for binop tests.
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } else { 312 } else {
334 CHECK_EQ(x, y); 313 CHECK_EQ(x, y);
335 } 314 }
336 } 315 }
337 316
338 } // namespace compiler 317 } // namespace compiler
339 } // namespace internal 318 } // namespace internal
340 } // namespace v8 319 } // namespace v8
341 320
342 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ 321 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_
OLDNEW
« no previous file with comments | « test/cctest/compiler/call-tester.h ('k') | test/cctest/compiler/graph-builder-tester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698