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

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

Issue 2304553002: Include only stuff you need, part 6: Fix cctest.h. (Closed)
Patch Set: Created 4 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
« no previous file with comments | « test/cctest/cctest.cc ('k') | test/cctest/compiler/function-tester.cc » ('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_FUNCTION_TESTER_H_ 5 #ifndef V8_CCTEST_COMPILER_FUNCTION_TESTER_H_
6 #define V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ 6 #define V8_CCTEST_COMPILER_FUNCTION_TESTER_H_
7 7
8 #include "src/handles.h" 8 #include "src/handles.h"
9 #include "test/cctest/cctest.h" 9 #include "test/cctest/cctest.h"
10 10
(...skipping 25 matching lines...) Expand all
36 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b); 36 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b);
37 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b, 37 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b,
38 Handle<Object> c); 38 Handle<Object> c);
39 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b, Handle<Object> c, 39 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b, Handle<Object> c,
40 Handle<Object> d); 40 Handle<Object> d);
41 41
42 void CheckThrows(Handle<Object> a, Handle<Object> b); 42 void CheckThrows(Handle<Object> a, Handle<Object> b);
43 v8::Local<v8::Message> CheckThrowsReturnMessage(Handle<Object> a, 43 v8::Local<v8::Message> CheckThrowsReturnMessage(Handle<Object> a,
44 Handle<Object> b); 44 Handle<Object> b);
45 void CheckCall(Handle<Object> expected, Handle<Object> a, Handle<Object> b, 45 void CheckCall(Handle<Object> expected, Handle<Object> a, Handle<Object> b,
46 Handle<Object> c, Handle<Object> d) { 46 Handle<Object> c, Handle<Object> d);
47 Handle<Object> result = Call(a, b, c, d).ToHandleChecked();
48 CHECK(expected->SameValue(*result));
49 }
50 47
51 void CheckCall(Handle<Object> expected, Handle<Object> a, Handle<Object> b, 48 void CheckCall(Handle<Object> expected, Handle<Object> a, Handle<Object> b,
52 Handle<Object> c) { 49 Handle<Object> c) {
53 return CheckCall(expected, a, b, c, undefined()); 50 return CheckCall(expected, a, b, c, undefined());
54 } 51 }
55 52
56 void CheckCall(Handle<Object> expected, Handle<Object> a, Handle<Object> b) { 53 void CheckCall(Handle<Object> expected, Handle<Object> a, Handle<Object> b) {
57 return CheckCall(expected, a, b, undefined()); 54 return CheckCall(expected, a, b, undefined());
58 } 55 }
59 56
(...skipping 29 matching lines...) Expand all
89 void CheckFalse(Handle<Object> a) { CheckCall(false_value(), a); } 86 void CheckFalse(Handle<Object> a) { CheckCall(false_value(), a); }
90 87
91 void CheckFalse(Handle<Object> a, Handle<Object> b) { 88 void CheckFalse(Handle<Object> a, Handle<Object> b) {
92 CheckCall(false_value(), a, b); 89 CheckCall(false_value(), a, b);
93 } 90 }
94 91
95 void CheckFalse(double a, double b) { 92 void CheckFalse(double a, double b) {
96 CheckCall(false_value(), Val(a), Val(b)); 93 CheckCall(false_value(), Val(a), Val(b));
97 } 94 }
98 95
99 Handle<JSFunction> NewFunction(const char* source) { 96 Handle<JSFunction> NewFunction(const char* source);
100 return Handle<JSFunction>::cast(v8::Utils::OpenHandle( 97 Handle<JSObject> NewObject(const char* source);
101 *v8::Local<v8::Function>::Cast(CompileRun(source))));
102 }
103
104 Handle<JSObject> NewObject(const char* source) {
105 return Handle<JSObject>::cast(v8::Utils::OpenHandle(
106 *v8::Local<v8::Object>::Cast(CompileRun(source))));
107 }
108 98
109 Handle<String> Val(const char* string); 99 Handle<String> Val(const char* string);
110 Handle<Object> Val(double value); 100 Handle<Object> Val(double value);
111 Handle<Object> infinity(); 101 Handle<Object> infinity();
112 Handle<Object> minus_infinity(); 102 Handle<Object> minus_infinity();
113 Handle<Object> nan(); 103 Handle<Object> nan();
114 Handle<Object> undefined(); 104 Handle<Object> undefined();
115 Handle<Object> null(); 105 Handle<Object> null();
116 Handle<Object> true_value(); 106 Handle<Object> true_value();
117 Handle<Object> false_value(); 107 Handle<Object> false_value();
118 108
119 static Handle<JSFunction> ForMachineGraph(Graph* graph, int param_count) { 109 static Handle<JSFunction> ForMachineGraph(Graph* graph, int param_count);
120 JSFunction* p = NULL;
121 { // because of the implicit handle scope of FunctionTester.
122 FunctionTester f(graph, param_count);
123 p = *f.function;
124 }
125 return Handle<JSFunction>(p); // allocated in outer handle scope.
126 }
127 110
128 private: 111 private:
129 uint32_t flags_; 112 uint32_t flags_;
130 113
131 Handle<JSFunction> Compile(Handle<JSFunction> function); 114 Handle<JSFunction> Compile(Handle<JSFunction> function);
132 std::string BuildFunction(int param_count) { 115 std::string BuildFunction(int param_count) {
133 std::string function_string = "(function("; 116 std::string function_string = "(function(";
134 if (param_count > 0) { 117 if (param_count > 0) {
135 function_string += 'a'; 118 function_string += 'a';
136 for (int i = 1; i < param_count; i++) { 119 for (int i = 1; i < param_count; i++) {
137 function_string += ','; 120 function_string += ',';
138 function_string += static_cast<char>('a' + i); 121 function_string += static_cast<char>('a' + i);
139 } 122 }
140 } 123 }
141 function_string += "){})"; 124 function_string += "){})";
142 return function_string; 125 return function_string;
143 } 126 }
144 127
145 // Compile the given machine graph instead of the source of the function 128 // Compile the given machine graph instead of the source of the function
146 // and replace the JSFunction's code with the result. 129 // and replace the JSFunction's code with the result.
147 Handle<JSFunction> CompileGraph(Graph* graph); 130 Handle<JSFunction> CompileGraph(Graph* graph);
148 }; 131 };
149 } // namespace compiler 132 } // namespace compiler
150 } // namespace internal 133 } // namespace internal
151 } // namespace v8 134 } // namespace v8
152 135
153 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ 136 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_
OLDNEW
« no previous file with comments | « test/cctest/cctest.cc ('k') | test/cctest/compiler/function-tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698