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

Unified Diff: test/cctest/compiler/function-tester.h

Issue 1475953002: [stubs] A new approach to TF stubs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Win64 build Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/compiler/test-code-stub-assembler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/function-tester.h
diff --git a/test/cctest/compiler/function-tester.h b/test/cctest/compiler/function-tester.h
index 9911f1340d2643d2fcf34969505e027c1a929899..2fcd35398ce29a28b7070ade4dc3e5c25f4c6319 100644
--- a/test/cctest/compiler/function-tester.h
+++ b/test/cctest/compiler/function-tester.h
@@ -35,18 +35,30 @@ class FunctionTester : public InitializedHandleScope {
CHECK_EQ(0u, flags_ & ~supported_flags);
}
- // TODO(turbofan): generalize FunctionTester to work with N arguments. Now, it
- // can handle up to four.
- explicit FunctionTester(Graph* graph)
+ FunctionTester(Graph* graph, int param_count)
: isolate(main_isolate()),
- function(NewFunction("(function(a,b,c,d){})")),
+ function(NewFunction(BuildFunction(param_count).c_str())),
flags_(0) {
CompileGraph(graph);
}
+ FunctionTester(const CallInterfaceDescriptor& descriptor, Handle<Code> code)
+ : isolate(main_isolate()),
+ function(
+ (FLAG_allow_natives_syntax = true,
+ NewFunction(BuildFunctionFromDescriptor(descriptor).c_str()))),
+ flags_(0) {
+ Compile(function);
+ function->ReplaceCode(*code);
+ }
+
Isolate* isolate;
Handle<JSFunction> function;
+ MaybeHandle<Object> Call() {
+ return Execution::Call(isolate, function, undefined(), 0, nullptr);
+ }
+
MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b) {
Handle<Object> args[] = {a, b};
return Execution::Call(isolate, function, undefined(), 2, args);
@@ -180,10 +192,10 @@ class FunctionTester : public InitializedHandleScope {
return function;
}
- static Handle<JSFunction> ForMachineGraph(Graph* graph) {
+ static Handle<JSFunction> ForMachineGraph(Graph* graph, int param_count) {
JSFunction* p = NULL;
{ // because of the implicit handle scope of FunctionTester.
- FunctionTester f(graph);
+ FunctionTester f(graph, param_count);
p = *f.function;
}
return Handle<JSFunction>(p); // allocated in outer handle scope.
@@ -192,6 +204,25 @@ class FunctionTester : public InitializedHandleScope {
private:
uint32_t flags_;
+ std::string BuildFunction(int param_count) {
+ std::string function_string = "(function(";
+ if (param_count > 0) {
+ char next = 'a';
+ function_string += next;
+ while (param_count-- > 0) {
+ function_string += ',';
+ function_string += ++next;
+ }
+ }
+ function_string += "){})";
+ return function_string;
+ }
+
+ std::string BuildFunctionFromDescriptor(
+ const CallInterfaceDescriptor& descriptor) {
+ return BuildFunction(descriptor.GetParameterCount());
+ }
+
// Compile the given machine graph instead of the source of the function
// and replace the JSFunction's code with the result.
Handle<JSFunction> CompileGraph(Graph* graph) {
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/compiler/test-code-stub-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698