| 1 | module scheme |
| 2 | |
| 3 | import arena |
| 4 | import reader |
| 5 | |
| 6 | fn test_diagnostic_procedural_allocation_breakdown() { |
| 7 | mut vm := new() |
| 8 | vm.eval('(define-syntax pass (lambda (stx) (syntax-case stx () ((_ e) (syntax e)))))') or { panic(err) } |
| 9 | doc := reader.read_all('(pass 1)') or { panic(err) } |
| 10 | mut code := vm.new_code(doc, vm.next_context(), unsafe { nil }, '') |
| 11 | mut builder := Builder{ code: code, function: &Function{ code: code } } |
| 12 | transformer := (vm.syntax.entries['pass'] or { panic('missing pass') }).transformer |
| 13 | mut scratch := arena.new(chunk_size: 4096) |
| 14 | scratch.push() |
| 15 | mut origins := SyntaxInputOrigins{ storage: scratch } |
| 16 | scratch.pop() |
| 17 | mut region := arena.new(chunk_size: 1048576) |
| 18 | region.push() |
| 19 | a := region.used() |
| 20 | context := builder.capture_syntax_lookup_context() or { panic(err) } |
| 21 | b := region.used() |
| 22 | input := builder.procedural_input(doc.forms[0], mut origins) or { panic(err) } |
| 23 | c := region.used() |
| 24 | output := vm.call(transformer.procedure, [input]) or { panic(err) } |
| 25 | d := region.used() |
| 26 | _ := builder.hydrate_procedural_output(output, (syntax_object_ref(input) or { panic(err) }).data, &origins, doc.forms[0]) or { panic(err) } |
| 27 | e := region.used() |
| 28 | assert context.globals.len >= 540 |
| 29 | assert (syntax_to_datum(output) or { panic(err) }).as_integer() or { panic(err) } == 1 |
| 30 | region.pop() |
| 31 | println('context=${b - a} input=${c - b} call=${d - c} hydrate=${e - d}') |
| 32 | scratch.free() |
| 33 | region.free() |
| 34 | } |
| 35 | |