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

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

Issue 530783002: Convert Linkage to use MachineSignature. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase. Created 6 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 | Annotate | Revision Log
« 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/pipeline.h" 10 #include "src/compiler/pipeline.h"
11 #include "src/compiler/raw-machine-assembler.h" 11 #include "src/compiler/raw-machine-assembler.h"
12 #include "src/compiler/structured-machine-assembler.h" 12 #include "src/compiler/structured-machine-assembler.h"
13 #include "src/simulator.h" 13 #include "src/simulator.h"
14 #include "test/cctest/compiler/call-tester.h" 14 #include "test/cctest/compiler/call-tester.h"
15 15
16 namespace v8 { 16 namespace v8 {
17 namespace internal { 17 namespace internal {
18 namespace compiler { 18 namespace compiler {
19 19
20 template <typename MachineAssembler> 20 template <typename MachineAssembler>
21 class MachineAssemblerTester : public HandleAndZoneScope, 21 class MachineAssemblerTester : public HandleAndZoneScope,
22 public CallHelper, 22 public CallHelper,
23 public MachineAssembler { 23 public MachineAssembler {
24 public: 24 public:
25 MachineAssemblerTester(MachineType return_type, MachineType p0, 25 MachineAssemblerTester(MachineType return_type, MachineType p0,
26 MachineType p1, MachineType p2, MachineType p3, 26 MachineType p1, MachineType p2, MachineType p3,
27 MachineType p4) 27 MachineType p4)
28 : HandleAndZoneScope(), 28 : HandleAndZoneScope(),
29 CallHelper(main_isolate()), 29 CallHelper(
30 MachineAssembler(new (main_zone()) Graph(main_zone()), 30 main_isolate(),
31 ToCallDescriptorBuilder(main_zone(), return_type, p0, 31 MakeMachineSignature(main_zone(), return_type, p0, p1, p2, p3, p4)),
32 p1, p2, p3, p4), 32 MachineAssembler(
33 kMachPtr) {} 33 new (main_zone()) Graph(main_zone()),
34 MakeMachineSignature(main_zone(), return_type, p0, p1, p2, p3, p4),
35 kMachPtr) {}
34 36
35 Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) { 37 Node* LoadFromPointer(void* address, MachineType rep, int32_t offset = 0) {
36 return this->Load(rep, this->PointerConstant(address), 38 return this->Load(rep, this->PointerConstant(address),
37 this->Int32Constant(offset)); 39 this->Int32Constant(offset));
38 } 40 }
39 41
40 void StoreToPointer(void* address, MachineType rep, Node* node) { 42 void StoreToPointer(void* address, MachineType rep, Node* node) {
41 this->Store(rep, this->PointerConstant(address), node); 43 this->Store(rep, this->PointerConstant(address), node);
42 } 44 }
43 45
44 Node* StringConstant(const char* string) { 46 Node* StringConstant(const char* string) {
45 return this->HeapConstant( 47 return this->HeapConstant(
46 this->isolate()->factory()->InternalizeUtf8String(string)); 48 this->isolate()->factory()->InternalizeUtf8String(string));
47 } 49 }
48 50
49 void CheckNumber(double expected, Object* number) { 51 void CheckNumber(double expected, Object* number) {
50 CHECK(this->isolate()->factory()->NewNumber(expected)->SameValue(number)); 52 CHECK(this->isolate()->factory()->NewNumber(expected)->SameValue(number));
51 } 53 }
52 54
53 void CheckString(const char* expected, Object* string) { 55 void CheckString(const char* expected, Object* string) {
54 CHECK( 56 CHECK(
55 this->isolate()->factory()->InternalizeUtf8String(expected)->SameValue( 57 this->isolate()->factory()->InternalizeUtf8String(expected)->SameValue(
56 string)); 58 string));
57 } 59 }
58 60
59 void GenerateCode() { Generate(); } 61 void GenerateCode() { Generate(); }
60 62
61 protected: 63 protected:
62 virtual void VerifyParameters(int parameter_count,
63 MachineType* parameter_types) {
64 CHECK_EQ(this->parameter_count(), parameter_count);
65 const MachineType* expected_types = this->parameter_types();
66 for (int i = 0; i < parameter_count; i++) {
67 CHECK_EQ(expected_types[i], parameter_types[i]);
68 }
69 }
70
71 virtual byte* Generate() { 64 virtual byte* Generate() {
72 if (code_.is_null()) { 65 if (code_.is_null()) {
73 Schedule* schedule = this->Export(); 66 Schedule* schedule = this->Export();
74 CallDescriptor* call_descriptor = this->call_descriptor(); 67 CallDescriptor* call_descriptor = this->call_descriptor();
75 Graph* graph = this->graph(); 68 Graph* graph = this->graph();
76 CompilationInfo info(graph->zone()->isolate(), graph->zone()); 69 CompilationInfo info(graph->zone()->isolate(), graph->zone());
77 Linkage linkage(&info, call_descriptor); 70 Linkage linkage(&info, call_descriptor);
78 Pipeline pipeline(&info); 71 Pipeline pipeline(&info);
79 code_ = pipeline.GenerateCodeForMachineGraph(&linkage, graph, schedule); 72 code_ = pipeline.GenerateCodeForMachineGraph(&linkage, graph, schedule);
80 } 73 }
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 347
355 void Run(RawMachineAssemblerTester<int32_t>* m); 348 void Run(RawMachineAssemblerTester<int32_t>* m);
356 void RunLeft(RawMachineAssemblerTester<int32_t>* m); 349 void RunLeft(RawMachineAssemblerTester<int32_t>* m);
357 void RunRight(RawMachineAssemblerTester<int32_t>* m); 350 void RunRight(RawMachineAssemblerTester<int32_t>* m);
358 }; 351 };
359 } // namespace compiler 352 } // namespace compiler
360 } // namespace internal 353 } // namespace internal
361 } // namespace v8 354 } // namespace v8
362 355
363 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ 356 #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