| 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/v8.h" | 8 #include "src/v8.h" |
| 9 #include "test/cctest/cctest.h" | 9 #include "test/cctest/cctest.h" |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 function((FLAG_allow_natives_syntax = true, NewFunction(source))), | 33 function((FLAG_allow_natives_syntax = true, NewFunction(source))), |
| 34 flags_(flags) { | 34 flags_(flags) { |
| 35 Compile(function); | 35 Compile(function); |
| 36 const uint32_t supported_flags = CompilationInfo::kContextSpecializing | | 36 const uint32_t supported_flags = CompilationInfo::kContextSpecializing | |
| 37 CompilationInfo::kBuiltinInliningEnabled | | 37 CompilationInfo::kBuiltinInliningEnabled | |
| 38 CompilationInfo::kInliningEnabled | | 38 CompilationInfo::kInliningEnabled | |
| 39 CompilationInfo::kTypingEnabled; | 39 CompilationInfo::kTypingEnabled; |
| 40 CHECK_EQ(0u, flags_ & ~supported_flags); | 40 CHECK_EQ(0u, flags_ & ~supported_flags); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // TODO(turbofan): generalize FunctionTester to work with N arguments. Now, it |
| 44 // can handle up to four. |
| 43 explicit FunctionTester(Graph* graph) | 45 explicit FunctionTester(Graph* graph) |
| 44 : isolate(main_isolate()), | 46 : isolate(main_isolate()), |
| 45 function(NewFunction("(function(a,b){})")), | 47 function(NewFunction("(function(a,b,c,d){})")), |
| 46 flags_(0) { | 48 flags_(0) { |
| 47 CompileGraph(graph); | 49 CompileGraph(graph); |
| 48 } | 50 } |
| 49 | 51 |
| 50 Isolate* isolate; | 52 Isolate* isolate; |
| 51 Handle<JSFunction> function; | 53 Handle<JSFunction> function; |
| 52 | 54 |
| 53 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b) { | 55 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b) { |
| 54 Handle<Object> args[] = {a, b}; | 56 Handle<Object> args[] = {a, b}; |
| 55 return Execution::Call(isolate, function, undefined(), 2, args, false); | 57 return Execution::Call(isolate, function, undefined(), 2, args, false); |
| 56 } | 58 } |
| 57 | 59 |
| 60 MaybeHandle<Object> Call(Handle<Object> a, Handle<Object> b, Handle<Object> c, |
| 61 Handle<Object> d) { |
| 62 Handle<Object> args[] = {a, b, c, d}; |
| 63 return Execution::Call(isolate, function, undefined(), 4, args, false); |
| 64 } |
| 65 |
| 58 void CheckThrows(Handle<Object> a, Handle<Object> b) { | 66 void CheckThrows(Handle<Object> a, Handle<Object> b) { |
| 59 TryCatch try_catch; | 67 TryCatch try_catch; |
| 60 MaybeHandle<Object> no_result = Call(a, b); | 68 MaybeHandle<Object> no_result = Call(a, b); |
| 61 CHECK(isolate->has_pending_exception()); | 69 CHECK(isolate->has_pending_exception()); |
| 62 CHECK(try_catch.HasCaught()); | 70 CHECK(try_catch.HasCaught()); |
| 63 CHECK(no_result.is_null()); | 71 CHECK(no_result.is_null()); |
| 64 isolate->OptionalRescheduleException(true); | 72 isolate->OptionalRescheduleException(true); |
| 65 } | 73 } |
| 66 | 74 |
| 67 v8::Handle<v8::Message> CheckThrowsReturnMessage(Handle<Object> a, | 75 v8::Handle<v8::Message> CheckThrowsReturnMessage(Handle<Object> a, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 CHECK(!code.is_null()); | 230 CHECK(!code.is_null()); |
| 223 function->ReplaceCode(*code); | 231 function->ReplaceCode(*code); |
| 224 return function; | 232 return function; |
| 225 } | 233 } |
| 226 }; | 234 }; |
| 227 } | 235 } |
| 228 } | 236 } |
| 229 } // namespace v8::internal::compiler | 237 } // namespace v8::internal::compiler |
| 230 | 238 |
| 231 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ | 239 #endif // V8_CCTEST_COMPILER_FUNCTION_TESTER_H_ |
| OLD | NEW |