(aligned_addr, max_distance, step_op)
| 395 | } |
| 396 | |
| 397 | function find_object_near(aligned_addr, max_distance, step_op) { |
| 398 | if (!step_op) { |
| 399 | const step = tagged_size(); |
| 400 | const prev = |
| 401 | find_object_near(aligned_addr, max_distance, x => x - step); |
| 402 | const next = |
| 403 | find_object_near(aligned_addr, max_distance, x => x + step); |
| 404 | |
| 405 | if (!prev) return next; |
| 406 | if (!next) return prev; |
| 407 | return (addr - prev <= next - addr) ? prev : next; |
| 408 | } |
| 409 | |
| 410 | let maybe_map_addr = poim(aligned_addr); |
| 411 | let iters = 0; |
| 412 | while (maybe_map_addr && iters < max_distance) { |
| 413 | if (is_map(maybe_map_addr)) { |
| 414 | return aligned_addr; |
| 415 | } |
| 416 | aligned_addr = step_op(aligned_addr); |
| 417 | maybe_map_addr = poim(aligned_addr); |
| 418 | iters++; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | function find_object_prev(addr, max_distance) { |
| 423 | if (!Number.isSafeInteger(int(addr))) return; |
no test coverage detected