mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Yul interpreter: Smaller execution timeout for tests and additional test cases
This commit is contained in:
		
							parent
							
								
									088b694f0b
								
							
						
					
					
						commit
						e1b44500dd
					
				| @ -87,8 +87,8 @@ bool YulInterpreterTest::parse(ostream& _stream, string const& _linePrefix, bool | |||||||
| string YulInterpreterTest::interpret() | string YulInterpreterTest::interpret() | ||||||
| { | { | ||||||
| 	InterpreterState state; | 	InterpreterState state; | ||||||
| 	state.maxTraceSize = 10000; | 	state.maxTraceSize = 32; | ||||||
| 	state.maxSteps = 10000; | 	state.maxSteps = 512; | ||||||
| 	try | 	try | ||||||
| 	{ | 	{ | ||||||
| 		Interpreter::run(state, EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{}), *m_ast); | 		Interpreter::run(state, EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{}), *m_ast); | ||||||
|  | |||||||
							
								
								
									
										16
									
								
								test/libyul/yulInterpreterTests/bounded_recursion.yul
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								test/libyul/yulInterpreterTests/bounded_recursion.yul
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | |||||||
|  | { | ||||||
|  |   function f(x) -> y { | ||||||
|  |     if lt(x, 150) { | ||||||
|  |       y := f(add(x, 1)) | ||||||
|  |     } | ||||||
|  |     if eq(x, 150) { | ||||||
|  |       y := x | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   mstore(0, f(0)) | ||||||
|  | } | ||||||
|  | // ---- | ||||||
|  | // Trace: | ||||||
|  | // Memory dump: | ||||||
|  | //      0: 0000000000000000000000000000000000000000000000000000000000000096 | ||||||
|  | // Storage dump: | ||||||
							
								
								
									
										11
									
								
								test/libyul/yulInterpreterTests/infinite_recursion.yul
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								test/libyul/yulInterpreterTests/infinite_recursion.yul
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,11 @@ | |||||||
|  | { | ||||||
|  |   function f() { | ||||||
|  |     f() | ||||||
|  |   } | ||||||
|  |   f() | ||||||
|  | } | ||||||
|  | // ---- | ||||||
|  | // Trace: | ||||||
|  | //   Interpreter execution step limit reached. | ||||||
|  | // Memory dump: | ||||||
|  | // Storage dump: | ||||||
| @ -0,0 +1,44 @@ | |||||||
|  | { | ||||||
|  |   function f() { | ||||||
|  |     log0(0x0, 0x0) | ||||||
|  |     f() | ||||||
|  |   } | ||||||
|  |   f() | ||||||
|  | } | ||||||
|  | // ---- | ||||||
|  | // Trace: | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   LOG0(0, 0) | ||||||
|  | //   Trace size limit reached. | ||||||
|  | // Memory dump: | ||||||
|  | // Storage dump: | ||||||
| @ -104,12 +104,18 @@ DEFINE_PROTO_FUZZER(Program const& _input) | |||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	stack.optimize(); | 	stack.optimize(); | ||||||
| 	yulFuzzerUtil::interpret( | 	termReason = yulFuzzerUtil::interpret( | ||||||
| 		os2, | 		os2, | ||||||
| 		stack.parserResult()->code, | 		stack.parserResult()->code, | ||||||
| 		EVMDialect::strictAssemblyForEVMObjects(version) | 		EVMDialect::strictAssemblyForEVMObjects(version) | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
|  | 	if ( | ||||||
|  | 		termReason == yulFuzzerUtil::TerminationReason::StepLimitReached || | ||||||
|  | 		termReason == yulFuzzerUtil::TerminationReason::TraceLimitReached | ||||||
|  | 	) | ||||||
|  | 		return; | ||||||
|  | 
 | ||||||
| 	bool isTraceEq = (os1.str() == os2.str()); | 	bool isTraceEq = (os1.str() == os2.str()); | ||||||
| 	yulAssert(isTraceEq, "Interpreted traces for optimized and unoptimized code differ."); | 	yulAssert(isTraceEq, "Interpreted traces for optimized and unoptimized code differ."); | ||||||
| 	return; | 	return; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user