mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-10-31 13:20:59 +00:00 
			
		
		
		
	 bd6750aaa5
			
		
	
	
		bd6750aaa5
		
	
	
	
	
		
			
			...when Array.prototype and Object.prototype are intact.
If `internal_set()` is called on an array exotic object with a numeric
PropertyKey, and:
- the prototype chain has not been modified (i.e., there are no getters
  or setters for indexed properties), and
- the array is not the target of a Proxy object,
then we can directly store the value in the receiver's indexed
properties, without checking whether it already exists somewhere in the
prototype chain.
1.7x improvement on the following program:
```js
function f() {
    let a = [];
    let i = 0;
    while (i < 10_000_000) {
        a.push(i);
        i++;
    }
}
f();
```
		
	
			
		
			
				
	
	
		
			26 lines
		
	
	
	
		
			685 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
	
		
			685 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| test("proxy traps should be invoked in the correct order", () => {
 | |
|     var log = [];
 | |
|     var target = [];
 | |
|     var proxy = new Proxy(
 | |
|         target,
 | |
|         new Proxy(
 | |
|             {},
 | |
|             {
 | |
|                 get(t, pk, r) {
 | |
|                     log.push(pk);
 | |
|                 },
 | |
|             }
 | |
|         )
 | |
|     );
 | |
|     proxy.push(1);
 | |
| 
 | |
|     expect(log.length, 8);
 | |
|     expect(log[0]).toBe("get");
 | |
|     expect(log[1]).toBe("get");
 | |
|     expect(log[2]).toBe("set");
 | |
|     expect(log[3]).toBe("getOwnPropertyDescriptor");
 | |
|     expect(log[4]).toBe("defineProperty");
 | |
|     expect(log[5]).toBe("set");
 | |
|     expect(log[6]).toBe("getOwnPropertyDescriptor");
 | |
|     expect(log[7]).toBe("defineProperty");
 | |
| });
 |