mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 11:32:43 +00:00 
			
		
		
		
	UserspaceEmulator: Make big malloc block lookup O(1) as well
By passing the Region& to the auditing functions, we know exactly which block we are hitting. This allows us to track big mallocations the same way we already do chunked ones. This gets rid of the O(n) scan in find_mallocation() for allocations larger than the maximum malloc chunk size. :^)
This commit is contained in:
		
							parent
							
								
									8d9dd4c518
								
							
						
					
					
						commit
						e1f617950e
					
				
					 4 changed files with 57 additions and 55 deletions
				
			
		|  | @ -75,7 +75,7 @@ ValueWithShadow<u8> MmapRegion::read8(FlatPtr offset) | |||
| 
 | ||||
|     if (is_malloc_block()) { | ||||
|         if (auto* tracer = Emulator::the().malloc_tracer()) | ||||
|             tracer->audit_read(base() + offset, 1); | ||||
|             tracer->audit_read(*this, base() + offset, 1); | ||||
|     } | ||||
| 
 | ||||
|     ASSERT(offset < size()); | ||||
|  | @ -92,7 +92,7 @@ ValueWithShadow<u16> MmapRegion::read16(u32 offset) | |||
| 
 | ||||
|     if (is_malloc_block()) { | ||||
|         if (auto* tracer = Emulator::the().malloc_tracer()) | ||||
|             tracer->audit_read(base() + offset, 2); | ||||
|             tracer->audit_read(*this, base() + offset, 2); | ||||
|     } | ||||
| 
 | ||||
|     ASSERT(offset + 1 < size()); | ||||
|  | @ -109,7 +109,7 @@ ValueWithShadow<u32> MmapRegion::read32(u32 offset) | |||
| 
 | ||||
|     if (is_malloc_block()) { | ||||
|         if (auto* tracer = Emulator::the().malloc_tracer()) | ||||
|             tracer->audit_read(base() + offset, 4); | ||||
|             tracer->audit_read(*this, base() + offset, 4); | ||||
|     } | ||||
| 
 | ||||
|     ASSERT(offset + 3 < size()); | ||||
|  | @ -126,7 +126,7 @@ ValueWithShadow<u64> MmapRegion::read64(u32 offset) | |||
| 
 | ||||
|     if (is_malloc_block()) { | ||||
|         if (auto* tracer = Emulator::the().malloc_tracer()) | ||||
|             tracer->audit_read(base() + offset, 8); | ||||
|             tracer->audit_read(*this, base() + offset, 8); | ||||
|     } | ||||
| 
 | ||||
|     ASSERT(offset + 7 < size()); | ||||
|  | @ -143,7 +143,7 @@ void MmapRegion::write8(u32 offset, ValueWithShadow<u8> value) | |||
| 
 | ||||
|     if (is_malloc_block()) { | ||||
|         if (auto* tracer = Emulator::the().malloc_tracer()) | ||||
|             tracer->audit_write(base() + offset, 1); | ||||
|             tracer->audit_write(*this, base() + offset, 1); | ||||
|     } | ||||
| 
 | ||||
|     ASSERT(offset < size()); | ||||
|  | @ -161,7 +161,7 @@ void MmapRegion::write16(u32 offset, ValueWithShadow<u16> value) | |||
| 
 | ||||
|     if (is_malloc_block()) { | ||||
|         if (auto* tracer = Emulator::the().malloc_tracer()) | ||||
|             tracer->audit_write(base() + offset, 2); | ||||
|             tracer->audit_write(*this, base() + offset, 2); | ||||
|     } | ||||
| 
 | ||||
|     ASSERT(offset + 1 < size()); | ||||
|  | @ -179,7 +179,7 @@ void MmapRegion::write32(u32 offset, ValueWithShadow<u32> value) | |||
| 
 | ||||
|     if (is_malloc_block()) { | ||||
|         if (auto* tracer = Emulator::the().malloc_tracer()) | ||||
|             tracer->audit_write(base() + offset, 4); | ||||
|             tracer->audit_write(*this, base() + offset, 4); | ||||
|     } | ||||
| 
 | ||||
|     ASSERT(offset + 3 < size()); | ||||
|  | @ -198,7 +198,7 @@ void MmapRegion::write64(u32 offset, ValueWithShadow<u64> value) | |||
| 
 | ||||
|     if (is_malloc_block()) { | ||||
|         if (auto* tracer = Emulator::the().malloc_tracer()) | ||||
|             tracer->audit_write(base() + offset, 8); | ||||
|             tracer->audit_write(*this, base() + offset, 8); | ||||
|     } | ||||
| 
 | ||||
|     ASSERT(offset + 7 < size()); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling