Skip to content

Commit

Permalink
test garbage collector
Browse files Browse the repository at this point in the history
  • Loading branch information
anhnguyen1618 committed Feb 14, 2019
1 parent 60302d7 commit 1aa68ec
Show file tree
Hide file tree
Showing 68 changed files with 3,948 additions and 923 deletions.
Binary file modified bin/compiler
Binary file not shown.
14 changes: 7 additions & 7 deletions llvm_byte_code/test/array_of_nil.tig-opt.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ source_filename = "Tiger jit"
@3 = private unnamed_addr constant [49 x i8] c"test/array_of_nil.tig::18.26: Array out of bound\00"
@4 = private unnamed_addr constant [53 x i8] c"test/array_of_nil.tig::21.18: Nil pointer exception!\00"

declare i32 @tig_nillable(i8*) local_unnamed_addr
declare i32 @tig_nillable(i8*) local_unnamed_addr gc "ocaml"

declare void @tig_check_array_bound(i8*, i32, i8*) local_unnamed_addr
declare void @tig_check_array_bound(i8*, i32, i8*) local_unnamed_addr gc "ocaml"

declare void @tig_check_null_pointer(i8*, i8*) local_unnamed_addr
declare void @tig_check_null_pointer(i8*, i8*) local_unnamed_addr gc "ocaml"

declare void @assert_equal_int(i32, i32) local_unnamed_addr
declare void @assert_equal_int(i32, i32) local_unnamed_addr gc "ocaml"

define i32 @main() local_unnamed_addr {
define i32 @main() local_unnamed_addr gc "ocaml" {
entry:
%frame_pointer = alloca { i32 }
%malloccall = tail call i8* @malloc(i32 ptrtoint ({ i32, i8* }* getelementptr ({ i32, i8* }, { i32, i8* }* null, i32 1) to i32))
Expand Down Expand Up @@ -140,15 +140,15 @@ end31: ; preds = %test29

declare noalias i8* @malloc(i32) local_unnamed_addr

define { i32, i8* }* @f({ i32 }*) local_unnamed_addr {
define { i32, i8* }* @f({ i32 }*) local_unnamed_addr gc "ocaml" {
entry:
%frame_pointer = alloca { { i32 }* }
%arg_address = getelementptr { { i32 }* }, { { i32 }* }* %frame_pointer, i32 0, i32 0
store { i32 }* %0, { i32 }** %arg_address
ret { i32, i8* }* null
}

define i32 @g({ i32 }*, { i32, i8* }*) local_unnamed_addr {
define i32 @g({ i32 }*, { i32, i8* }*) local_unnamed_addr gc "ocaml" {
entry:
%frame_pointer = alloca { { i32 }* }
%arg_address = getelementptr { { i32 }* }, { { i32 }* }* %frame_pointer, i32 0, i32 0
Expand Down
150 changes: 150 additions & 0 deletions llvm_byte_code/test/array_of_nil.tig-opt.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
.text
.file "Tiger jit"
.globl "camlLlvm_byte_code/test/array_of_nil__code_begin"
"camlLlvm_byte_code/test/array_of_nil__code_begin":
.data
.globl "camlLlvm_byte_code/test/array_of_nil__data_begin"
"camlLlvm_byte_code/test/array_of_nil__data_begin":
.text
.globl main # -- Begin function main
.p2align 4, 0x90
.type main,@function
Expand All @@ -25,14 +31,17 @@ main: # @main
.cfi_offset %r15, -16
movl $16, %edi
callq malloc
.Ltmp0:
movq %rax, %r14
movl $1, (%r14)
movq $0, 8(%r14)
leaq 8(%rsp), %rdi
callq f
.Ltmp1:
movq %rax, %rbx
movl $40, %edi
callq malloc
.Ltmp2:
movq %rax, %r12
xorl %eax, %eax
cmpl $4, %eax
Expand All @@ -47,11 +56,13 @@ main: # @main
.LBB0_3: # %end
movl $16, %edi
callq malloc
.Ltmp3:
movq %rax, %r15
movl $5, (%r15)
movq %r12, 8(%r15)
movl $40, %edi
callq malloc
.Ltmp4:
movq %rax, %rbx
xorl %eax, %eax
cmpl $4, %eax
Expand All @@ -66,11 +77,13 @@ main: # @main
.LBB0_6: # %end13
movl $16, %edi
callq malloc
.Ltmp5:
movq %rax, %r12
movl $5, (%r12)
movq %rbx, 8(%r12)
movl $40, %edi
callq malloc
.Ltmp6:
movq %rax, %rbx
xorl %eax, %eax
cmpl $4, %eax
Expand All @@ -85,61 +98,78 @@ main: # @main
.LBB0_9: # %end31
movl $16, %edi
callq malloc
.Ltmp7:
movq %rax, %r13
movl $5, (%r13)
movq %rbx, 8(%r13)
movl $1, %esi
movl $.L__unnamed_1, %edx
movq %r15, %rdi
callq tig_check_array_bound
.Ltmp8:
movq 8(%r15), %rax
movq 8(%rax), %rdi
callq tig_nillable
.Ltmp9:
movl $1, %esi
movl %eax, %edi
callq assert_equal_int
.Ltmp10:
movl $1, %esi
movl $.L__unnamed_2, %edx
movq %r12, %rdi
callq tig_check_array_bound
.Ltmp11:
movq 8(%r12), %rax
movq 8(%rax), %rdi
callq tig_nillable
.Ltmp12:
movl $1, %esi
movl %eax, %edi
callq assert_equal_int
.Ltmp13:
movl $1, %esi
movl $.L__unnamed_3, %edx
movq %r13, %rdi
callq tig_check_array_bound
.Ltmp14:
movq 8(%r13), %rax
movq 8(%rax), %rdi
callq tig_nillable
.Ltmp15:
movl $1, %esi
movl %eax, %edi
callq assert_equal_int
.Ltmp16:
leaq 8(%rsp), %rbx
xorl %esi, %esi
movq %rbx, %rdi
callq g
.Ltmp17:
xorl %esi, %esi
movl %eax, %edi
callq assert_equal_int
.Ltmp18:
movq %rbx, %rdi
movq %r14, %rsi
callq g
.Ltmp19:
movl $1, %esi
movl %eax, %edi
callq assert_equal_int
.Ltmp20:
movl $.L__unnamed_4, %esi
movq %r14, %rdi
callq tig_check_null_pointer
.Ltmp21:
movq 8(%r14), %rsi
movq %rbx, %rdi
callq g
.Ltmp22:
xorl %esi, %esi
movl %eax, %edi
callq assert_equal_int
.Ltmp23:
xorl %eax, %eax
addq $16, %rsp
popq %rbx
Expand Down Expand Up @@ -180,6 +210,7 @@ g: # @g
movq %rdi, 8(%rsp)
movq %rbx, %rdi
callq tig_nillable
.Ltmp24:
movl %eax, %ecx
xorl %eax, %eax
cmpl $1, %ecx
Expand All @@ -188,6 +219,7 @@ g: # @g
movl $.L__unnamed_5, %esi
movq %rbx, %rdi
callq tig_check_null_pointer
.Ltmp25:
movl (%rbx), %eax
.LBB2_2: # %merge
addq $16, %rsp
Expand Down Expand Up @@ -229,4 +261,122 @@ g: # @g
.size .L__unnamed_4, 53


.text
.globl "camlLlvm_byte_code/test/array_of_nil__code_end"
"camlLlvm_byte_code/test/array_of_nil__code_end":
.data
.globl "camlLlvm_byte_code/test/array_of_nil__data_end"
"camlLlvm_byte_code/test/array_of_nil__data_end":
.quad 0
.globl "camlLlvm_byte_code/test/array_of_nil__frametable"
"camlLlvm_byte_code/test/array_of_nil__frametable":
.short 26
.p2align 3
# live roots for main
.quad .Ltmp0
.short 56
.short 0
.p2align 3
.quad .Ltmp1
.short 56
.short 0
.p2align 3
.quad .Ltmp2
.short 56
.short 0
.p2align 3
.quad .Ltmp3
.short 56
.short 0
.p2align 3
.quad .Ltmp4
.short 56
.short 0
.p2align 3
.quad .Ltmp5
.short 56
.short 0
.p2align 3
.quad .Ltmp6
.short 56
.short 0
.p2align 3
.quad .Ltmp7
.short 56
.short 0
.p2align 3
.quad .Ltmp8
.short 56
.short 0
.p2align 3
.quad .Ltmp9
.short 56
.short 0
.p2align 3
.quad .Ltmp10
.short 56
.short 0
.p2align 3
.quad .Ltmp11
.short 56
.short 0
.p2align 3
.quad .Ltmp12
.short 56
.short 0
.p2align 3
.quad .Ltmp13
.short 56
.short 0
.p2align 3
.quad .Ltmp14
.short 56
.short 0
.p2align 3
.quad .Ltmp15
.short 56
.short 0
.p2align 3
.quad .Ltmp16
.short 56
.short 0
.p2align 3
.quad .Ltmp17
.short 56
.short 0
.p2align 3
.quad .Ltmp18
.short 56
.short 0
.p2align 3
.quad .Ltmp19
.short 56
.short 0
.p2align 3
.quad .Ltmp20
.short 56
.short 0
.p2align 3
.quad .Ltmp21
.short 56
.short 0
.p2align 3
.quad .Ltmp22
.short 56
.short 0
.p2align 3
.quad .Ltmp23
.short 56
.short 0
.p2align 3
# live roots for f
# live roots for g
.quad .Ltmp24
.short 24
.short 0
.p2align 3
.quad .Ltmp25
.short 24
.short 0
.p2align 3
.section ".note.GNU-stack","",@progbits
Loading

0 comments on commit 1aa68ec

Please sign in to comment.