mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 03:42:44 +00:00 
			
		
		
		
	 a02b9983f9
			
		
	
	
		a02b9983f9
		
	
	
	
	
		
			
			This prevents stack overflows when calling infinite/deep recursive
functions, e.g.:
    const f = () => f(); f();
    JSON.stringify({}, () => ({ foo: "bar" }));
    new Proxy({}, { get: (_, __, p) => p.foo }).foo;
The VM caches a StackInfo object to not slow down function calls
considerably. VM::push_call_frame() will throw an exception if
necessary (plain Error with "RuntimeError" as its .name).
		
	
			
		
			
				
	
	
		
			21 lines
		
	
	
	
		
			610 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
	
		
			610 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| test("infinite recursion", () => {
 | |
|     function infiniteRecursion() {
 | |
|         infiniteRecursion();
 | |
|     }
 | |
| 
 | |
|     try {
 | |
|         infiniteRecursion();
 | |
|     } catch (e) {
 | |
|         expect(e).toBeInstanceOf(Error);
 | |
|         expect(e.name).toBe("RuntimeError");
 | |
|         expect(e.message).toBe("Call stack size limit exceeded");
 | |
|     }
 | |
| 
 | |
|     expect(() => {
 | |
|         JSON.stringify({}, () => ({ foo: "bar" }));
 | |
|     }).toThrowWithMessage(Error, "Call stack size limit exceeded");
 | |
| 
 | |
|     expect(() => {
 | |
|         new Proxy({}, { get: (_, __, p) => p.foo }).foo;
 | |
|     }).toThrowWithMessage(Error, "Call stack size limit exceeded");
 | |
| });
 |