| OLD | NEW |
| 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/ast/ast-numbering.h" | 8 #include "src/ast/ast-numbering.h" |
| 9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 CHECK_EQ(0u, flags_ & ~supported_flags); | 35 CHECK_EQ(0u, flags_ & ~supported_flags); |
| 36 } | 36 } |
| 37 | 37 |
| 38 FunctionTester(Graph* graph, int param_count) | 38 FunctionTester(Graph* graph, int param_count) |
| 39 : isolate(main_isolate()), | 39 : isolate(main_isolate()), |
| 40 function(NewFunction(BuildFunction(param_count).c_str())), | 40 function(NewFunction(BuildFunction(param_count).c_str())), |
| 41 flags_(0) { | 41 flags_(0) { |
| 42 CompileGraph(graph); | 42 CompileGraph(graph); |
| 43 } | 43 } |
| 44 | 44 |
| 45 FunctionTester(int param_count, Handle<Code> code) |
| 46 : isolate(main_isolate()), |
| 47 function(NewFunction(BuildFunction(param_count).c_str())), |
| 48 flags_(0) { |
| 49 Compile(function); |
| 50 function->ReplaceCode(*code); |
| 51 } |
| 52 |
| 45 FunctionTester(const CallInterfaceDescriptor& descriptor, Handle<Code> code) | 53 FunctionTester(const CallInterfaceDescriptor& descriptor, Handle<Code> code) |
| 46 : isolate(main_isolate()), | 54 : isolate(main_isolate()), |
| 47 function( | 55 function( |
| 48 (FLAG_allow_natives_syntax = true, | 56 (FLAG_allow_natives_syntax = true, |
| 49 NewFunction(BuildFunctionFromDescriptor(descriptor).c_str()))), | 57 NewFunction(BuildFunctionFromDescriptor(descriptor).c_str()))), |
| 50 flags_(0) { | 58 flags_(0) { |
| 51 Compile(function); | 59 Compile(function); |
| 52 function->ReplaceCode(*code); | 60 function->ReplaceCode(*code); |
| 53 } | 61 } |
| 54 | 62 |
| 55 Isolate* isolate; | 63 Isolate* isolate; |
| 56 Handle<JSFunction> function; | 64 Handle<JSFunction> function; |
| 57 | 65 |
| 58 MaybeHandle<Object> Call() { | 66 MaybeHandle<Object> Call() { |
| 59 return Execution::Call(isolate, function, undefined(), 0, nullptr); | 67 return Execution::Call(isolate, function, undefined(), 0, nullptr); |
| 60 } | 68 } |
| 61 | 69 |
| 62 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b) { | 70 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b) { |
| 63 Handle<Object> args[] = {a, b}; | 71 Handle<Object> args[] = {a, b}; |
| 64 return Execution::Call(isolate, function, undefined(), 2, args); | 72 return Execution::Call(isolate, function, undefined(), 2, args); |
| 65 } | 73 } |
| 66 | 74 |
| 75 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b, |
| 76 Handle<Object> c) { |
| 77 Handle<Object> args[] = {a, b, c}; |
| 78 return Execution::Call(isolate, function, undefined(), 3, args); |
| 79 } |
| 80 |
| 67 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b, Handle<Object> c, | 81 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b, Handle<Object> c, |
| 68 Handle<Object> d) { | 82 Handle<Object> d) { |
| 69 Handle<Object> args[] = {a, b, c, d}; | 83 Handle<Object> args[] = {a, b, c, d}; |
| 70 return Execution::Call(isolate, function, undefined(), 4, args); | 84 return Execution::Call(isolate, function, undefined(), 4, args); |
| 71 } | 85 } |
| 72 | 86 |
| 73 void CheckThrows(Handle<Object> a, Handle<Object> b) { | 87 void CheckThrows(Handle<Object> a, Handle<Object> b) { |
| 74 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); | 88 TryCatch try_catch(reinterpret_cast<v8::Isolate*>(isolate)); |
| 75 MaybeHandle<Object> no_result = Call(a, b); | 89 MaybeHandle<Object> no_result = Call(a, b); |
| 76 CHECK(isolate->has_pending_exception()); | 90 CHECK(isolate->has_pending_exception()); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 CHECK(!code.is_null()); | 252 CHECK(!code.is_null()); |
| 239 function->ReplaceCode(*code); | 253 function->ReplaceCode(*code); |
| 240 return function; | 254 return function; |
| 241 } | 255 } |
| 242 }; | 256 }; |
| 243 } // namespace compiler | 257 } // namespace compiler |
| 244 } // namespace internal | 258 } // namespace internal |
| 245 } // namespace v8 | 259 } // namespace v8 |
| 246 | 260 |
| 247 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 261 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
| OLD | NEW |