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

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: Merge with ToT 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
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..4f35b981e7fd974b91866aed387a3253ec52de67 100644
--- a/test/cctest/compiler/function-tester.h
+++ b/test/cctest/compiler/function-tester.h
@@ -37,16 +37,30 @@ class FunctionTester : public InitializedHandleScope {
// TODO(turbofan): generalize FunctionTester to work with N arguments. Now, it
Michael Starzinger 2015/12/01 18:06:53 I think your change pretty much addresses this TOD
danno 2015/12/02 07:00:19 Done.
// can handle up to four.
- explicit FunctionTester(Graph* graph)
+ explicit FunctionTester(Graph* graph, int param_count)
Michael Starzinger 2015/12/01 18:06:53 nit: No longer needs to be marked "explicit".
danno 2015/12/02 07:00:19 Done.
: isolate(main_isolate()),
- function(NewFunction("(function(a,b,c,d){})")),
+ function(NewFunction(BuildFunction(param_count).c_str())),
flags_(0) {
CompileGraph(graph);
}
+ explicit FunctionTester(const CallInterfaceDescriptor& descriptor,
Michael Starzinger 2015/12/01 18:06:53 nit: Doesn't need to be marked "explicit".
danno 2015/12/02 07:00:19 Done.
+ Handle<Code> code)
+ : isolate(main_isolate()),
+ function(
+ (FLAG_allow_natives_syntax = true,
+ NewFunction(BuildFunctionFromDescriptor(descriptor).c_str()))) {
+ 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 +194,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 +206,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) {

Powered by Google App Engine
This is Rietveld 408576698