Skip to content

Instantly share code, notes, and snippets.

@ziz

ziz/emcc-0-ll.js Secret

Created January 3, 2012 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziz/93358b0ae60cb27fb293 to your computer and use it in GitHub Desktop.
Save ziz/93358b0ae60cb27fb293 to your computer and use it in GitHub Desktop.
; ModuleID = '/var/folders/3l/kh8mjcln3s90hm6q5pswr6mc0000gn/T/tmpozZcPT/src.cpp.o.bc'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"
target triple = "i386-apple-macosx10.7.2"
%struct.anon = type { %union.PyGC_Head*, %union.PyGC_Head*, i32 }
%union.PyGC_Head = type { x86_fp80 }
%struct.gc_generation = type { %union.PyGC_Head, i32, i32 }
@.str = private unnamed_addr constant [27 x i8] c"*%d,%d,%d,%d,%d,%d,%d,%d*\0A\00", align 1 ; [#uses=1 type=[27 x i8]*]
@.str1 = private unnamed_addr constant [12 x i8] c"*%d,%d,%d*\0A\00", align 1 ; [#uses=1 type=[12 x i8]*]
@.str2 = private unnamed_addr constant [6 x i8] c"*%d*\0A\00", align 1 ; [#uses=1 type=[6 x i8]*]
@.str3 = private unnamed_addr constant [10 x i8] c"%d:%d,%d\0A\00", align 1 ; [#uses=1 type=[10 x i8]*]
@_ZL11generations = internal global <{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }> <{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } { { %struct.anon, [4 x i8] } { %struct.anon { %union.PyGC_Head* getelementptr inbounds ([3 x %struct.gc_generation]* bitcast (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to [3 x %struct.gc_generation]*), i32 0, i32 0, i32 0), %union.PyGC_Head* getelementptr inbounds ([3 x %struct.gc_generation]* bitcast (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to [3 x %struct.gc_generation]*), i32 0, i32 0, i32 0), i32 0 }, [4 x i8] undef }, i32 700, i32 0, [8 x i8] undef }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } { { %struct.anon, [4 x i8] } { %struct.anon { %union.PyGC_Head* bitcast (i8* getelementptr (i8* bitcast (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to i8*), i64 32) to %union.PyGC_Head*), %union.PyGC_Head* bitcast (i8* getelementptr (i8* bitcast (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to i8*), i64 32) to %union.PyGC_Head*), i32 0 }, [4 x i8] undef }, i32 10, i32 0, [8 x i8] undef }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } { { %struct.anon, [4 x i8] } { %struct.anon { %union.PyGC_Head* bitcast (i8* getelementptr (i8* bitcast (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to i8*), i64 64) to %union.PyGC_Head*), %union.PyGC_Head* bitcast (i8* getelementptr (i8* bitcast (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to i8*), i64 64) to %union.PyGC_Head*), i32 0 }, [4 x i8] undef }, i32 10, i32 0, [8 x i8] undef } }>, align 16 ; [#uses=4 type=<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>*]
; [#uses=0]
define i32 @main() ssp {
%1 = alloca i32, align 4 ; [#uses=2 type=i32*]
%n = alloca %struct.gc_generation*, align 4 ; [#uses=9 type=%struct.gc_generation**]
%x1 = alloca i32, align 4 ; [#uses=2 type=i32*]
%x2 = alloca i32, align 4 ; [#uses=2 type=i32*]
%i = alloca i32, align 4 ; [#uses=6 type=i32*]
%list = alloca %union.PyGC_Head*, align 4 ; [#uses=5 type=%union.PyGC_Head**]
store i32 0, i32* %1
call void @llvm.dbg.declare(metadata !{%struct.gc_generation** %n}, metadata !36), !dbg !39 ; [debug line = 34:28] [debug variable = n]
store %struct.gc_generation* null, %struct.gc_generation** %n, align 4, !dbg !40 ; [debug line = 34:36]
%2 = load %struct.gc_generation** %n, align 4, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%3 = getelementptr inbounds %struct.gc_generation* %2, i32 0, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%4 = ptrtoint %struct.gc_generation* %3 to i32, !dbg !41 ; [#uses=1 type=i32] [debug line = 35:13]
%5 = load %struct.gc_generation** %n, align 4, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%6 = getelementptr inbounds %struct.gc_generation* %5, i32 0, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%7 = getelementptr inbounds %struct.gc_generation* %6, i32 0, i32 0, !dbg !41 ; [#uses=1 type=%union.PyGC_Head*] [debug line = 35:13]
%8 = ptrtoint %union.PyGC_Head* %7 to i32, !dbg !41 ; [#uses=1 type=i32] [debug line = 35:13]
%9 = load %struct.gc_generation** %n, align 4, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%10 = getelementptr inbounds %struct.gc_generation* %9, i32 0, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%11 = getelementptr inbounds %struct.gc_generation* %10, i32 0, i32 0, !dbg !41 ; [#uses=1 type=%union.PyGC_Head*] [debug line = 35:13]
%12 = bitcast %union.PyGC_Head* %11 to %struct.anon*, !dbg !41 ; [#uses=1 type=%struct.anon*] [debug line = 35:13]
%13 = getelementptr inbounds %struct.anon* %12, i32 0, i32 0, !dbg !41 ; [#uses=1 type=%union.PyGC_Head**] [debug line = 35:13]
%14 = ptrtoint %union.PyGC_Head** %13 to i32, !dbg !41 ; [#uses=1 type=i32] [debug line = 35:13]
%15 = load %struct.gc_generation** %n, align 4, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%16 = getelementptr inbounds %struct.gc_generation* %15, i32 0, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%17 = getelementptr inbounds %struct.gc_generation* %16, i32 0, i32 0, !dbg !41 ; [#uses=1 type=%union.PyGC_Head*] [debug line = 35:13]
%18 = bitcast %union.PyGC_Head* %17 to %struct.anon*, !dbg !41 ; [#uses=1 type=%struct.anon*] [debug line = 35:13]
%19 = getelementptr inbounds %struct.anon* %18, i32 0, i32 1, !dbg !41 ; [#uses=1 type=%union.PyGC_Head**] [debug line = 35:13]
%20 = ptrtoint %union.PyGC_Head** %19 to i32, !dbg !41 ; [#uses=1 type=i32] [debug line = 35:13]
%21 = load %struct.gc_generation** %n, align 4, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%22 = getelementptr inbounds %struct.gc_generation* %21, i32 0, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%23 = getelementptr inbounds %struct.gc_generation* %22, i32 0, i32 0, !dbg !41 ; [#uses=1 type=%union.PyGC_Head*] [debug line = 35:13]
%24 = bitcast %union.PyGC_Head* %23 to %struct.anon*, !dbg !41 ; [#uses=1 type=%struct.anon*] [debug line = 35:13]
%25 = getelementptr inbounds %struct.anon* %24, i32 0, i32 2, !dbg !41 ; [#uses=1 type=i32*] [debug line = 35:13]
%26 = ptrtoint i32* %25 to i32, !dbg !41 ; [#uses=1 type=i32] [debug line = 35:13]
%27 = load %struct.gc_generation** %n, align 4, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%28 = getelementptr inbounds %struct.gc_generation* %27, i32 0, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%29 = getelementptr inbounds %struct.gc_generation* %28, i32 0, i32 1, !dbg !41 ; [#uses=1 type=i32*] [debug line = 35:13]
%30 = ptrtoint i32* %29 to i32, !dbg !41 ; [#uses=1 type=i32] [debug line = 35:13]
%31 = load %struct.gc_generation** %n, align 4, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%32 = getelementptr inbounds %struct.gc_generation* %31, i32 0, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%33 = getelementptr inbounds %struct.gc_generation* %32, i32 0, i32 2, !dbg !41 ; [#uses=1 type=i32*] [debug line = 35:13]
%34 = ptrtoint i32* %33 to i32, !dbg !41 ; [#uses=1 type=i32] [debug line = 35:13]
%35 = load %struct.gc_generation** %n, align 4, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%36 = getelementptr inbounds %struct.gc_generation* %35, i32 1, !dbg !41 ; [#uses=1 type=%struct.gc_generation*] [debug line = 35:13]
%37 = ptrtoint %struct.gc_generation* %36 to i32, !dbg !41 ; [#uses=1 type=i32] [debug line = 35:13]
%38 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([27 x i8]* @.str, i32 0, i32 0), i32 %4, i32 %8, i32 %14, i32 %20, i32 %26, i32 %30, i32 %34, i32 %37), !dbg !41 ; [#uses=0 type=i32] [debug line = 35:13]
%39 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([12 x i8]* @.str1, i32 0, i32 0), i32 1, i32 zext (i1 icmp eq (i32 ptrtoint (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to i32), i32 ptrtoint (%union.PyGC_Head** getelementptr inbounds (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations, i32 0, i32 0, i32 0, i32 0, i32 1) to i32)) to i32), i32 zext (i1 icmp eq (i32 ptrtoint (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to i32), i32 ptrtoint (%struct.gc_generation* getelementptr inbounds ([3 x %struct.gc_generation]* bitcast (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to [3 x %struct.gc_generation]*), i32 0, i32 1) to i32)) to i32)), !dbg !42 ; [#uses=0 type=i32] [debug line = 43:13]
call void @llvm.dbg.declare(metadata !{i32* %x1}, metadata !43), !dbg !44 ; [debug line = 51:17] [debug variable = x1]
store i32 ptrtoint (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to i32), i32* %x1, align 4, !dbg !45 ; [debug line = 51:44]
call void @llvm.dbg.declare(metadata !{i32* %x2}, metadata !46), !dbg !47 ; [debug line = 52:17] [debug variable = x2]
store i32 ptrtoint (%struct.gc_generation* getelementptr inbounds ([3 x %struct.gc_generation]* bitcast (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to [3 x %struct.gc_generation]*), i32 0, i32 1) to i32), i32* %x2, align 4, !dbg !48 ; [debug line = 52:44]
%40 = load i32* %x1, align 4, !dbg !49 ; [#uses=1 type=i32] [debug line = 53:13]
%41 = load i32* %x2, align 4, !dbg !49 ; [#uses=1 type=i32] [debug line = 53:13]
%42 = icmp eq i32 %40, %41, !dbg !49 ; [#uses=1 type=i1] [debug line = 53:13]
%43 = zext i1 %42 to i32, !dbg !49 ; [#uses=1 type=i32] [debug line = 53:13]
%44 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str2, i32 0, i32 0), i32 %43), !dbg !49 ; [#uses=0 type=i32] [debug line = 53:13]
call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !50), !dbg !52 ; [debug line = 54:22] [debug variable = i]
store i32 0, i32* %i, align 4, !dbg !53 ; [debug line = 54:27]
br label %45, !dbg !53 ; [debug line = 54:27]
; <label>:45 ; preds = %72, %0
%46 = load i32* %i, align 4, !dbg !53 ; [#uses=1 type=i32] [debug line = 54:27]
%47 = icmp slt i32 %46, 3, !dbg !53 ; [#uses=1 type=i1] [debug line = 54:27]
br i1 %47, label %48, label %75, !dbg !53 ; [debug line = 54:27]
; <label>:48 ; preds = %45
call void @llvm.dbg.declare(metadata !{%union.PyGC_Head** %list}, metadata !54), !dbg !56 ; [debug line = 55:26] [debug variable = list]
%49 = load i32* %i, align 4, !dbg !57 ; [#uses=1 type=i32] [debug line = 55:44]
%50 = getelementptr inbounds [3 x %struct.gc_generation]* bitcast (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to [3 x %struct.gc_generation]*), i32 0, i32 %49, !dbg !57 ; [#uses=1 type=%struct.gc_generation*] [debug line = 55:44]
%51 = getelementptr inbounds %struct.gc_generation* %50, i32 0, i32 0, !dbg !57 ; [#uses=1 type=%union.PyGC_Head*] [debug line = 55:44]
store %union.PyGC_Head* %51, %union.PyGC_Head** %list, align 4, !dbg !57 ; [debug line = 55:44]
%52 = load i32* %i, align 4, !dbg !58 ; [#uses=1 type=i32] [debug line = 56:15]
%53 = load %union.PyGC_Head** %list, align 4, !dbg !58 ; [#uses=1 type=%union.PyGC_Head*] [debug line = 56:15]
%54 = ptrtoint %union.PyGC_Head* %53 to i32, !dbg !58 ; [#uses=1 type=i32] [debug line = 56:15]
%55 = load %union.PyGC_Head** %list, align 4, !dbg !58 ; [#uses=1 type=%union.PyGC_Head*] [debug line = 56:15]
%56 = bitcast %union.PyGC_Head* %55 to %struct.anon*, !dbg !58 ; [#uses=1 type=%struct.anon*] [debug line = 56:15]
%57 = getelementptr inbounds %struct.anon* %56, i32 0, i32 1, !dbg !58 ; [#uses=1 type=%union.PyGC_Head**] [debug line = 56:15]
%58 = load %union.PyGC_Head** %57, align 4, !dbg !58 ; [#uses=1 type=%union.PyGC_Head*] [debug line = 56:15]
%59 = ptrtoint %union.PyGC_Head* %58 to i32, !dbg !58 ; [#uses=1 type=i32] [debug line = 56:15]
%60 = icmp eq i32 %54, %59, !dbg !58 ; [#uses=1 type=i1] [debug line = 56:15]
%61 = zext i1 %60 to i32, !dbg !58 ; [#uses=1 type=i32] [debug line = 56:15]
%62 = load %union.PyGC_Head** %list, align 4, !dbg !58 ; [#uses=1 type=%union.PyGC_Head*] [debug line = 56:15]
%63 = ptrtoint %union.PyGC_Head* %62 to i32, !dbg !58 ; [#uses=1 type=i32] [debug line = 56:15]
%64 = load %union.PyGC_Head** %list, align 4, !dbg !58 ; [#uses=1 type=%union.PyGC_Head*] [debug line = 56:15]
%65 = bitcast %union.PyGC_Head* %64 to %struct.anon*, !dbg !58 ; [#uses=1 type=%struct.anon*] [debug line = 56:15]
%66 = getelementptr inbounds %struct.anon* %65, i32 0, i32 0, !dbg !58 ; [#uses=1 type=%union.PyGC_Head**] [debug line = 56:15]
%67 = load %union.PyGC_Head** %66, align 4, !dbg !58 ; [#uses=1 type=%union.PyGC_Head*] [debug line = 56:15]
%68 = ptrtoint %union.PyGC_Head* %67 to i32, !dbg !58 ; [#uses=1 type=i32] [debug line = 56:15]
%69 = icmp eq i32 %63, %68, !dbg !58 ; [#uses=1 type=i1] [debug line = 56:15]
%70 = zext i1 %69 to i32, !dbg !58 ; [#uses=1 type=i32] [debug line = 56:15]
%71 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([10 x i8]* @.str3, i32 0, i32 0), i32 %52, i32 %61, i32 %70), !dbg !58 ; [#uses=0 type=i32] [debug line = 56:15]
br label %72, !dbg !59 ; [debug line = 57:13]
; <label>:72 ; preds = %48
%73 = load i32* %i, align 4, !dbg !60 ; [#uses=1 type=i32] [debug line = 54:50]
%74 = add nsw i32 %73, 1, !dbg !60 ; [#uses=1 type=i32] [debug line = 54:50]
store i32 %74, i32* %i, align 4, !dbg !60 ; [debug line = 54:50]
br label %45, !dbg !60 ; [debug line = 54:50]
; <label>:75 ; preds = %45
%76 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([12 x i8]* @.str1, i32 0, i32 0), i32 16, i32 32, i32 sub (i32 ptrtoint (%union.PyGC_Head* getelementptr inbounds ([3 x %struct.gc_generation]* bitcast (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to [3 x %struct.gc_generation]*), i32 0, i32 2, i32 0) to i32), i32 ptrtoint (%union.PyGC_Head* getelementptr inbounds ([3 x %struct.gc_generation]* bitcast (<{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations to [3 x %struct.gc_generation]*), i32 0, i32 1, i32 0) to i32))), !dbg !61 ; [#uses=0 type=i32] [debug line = 58:13]
%77 = load i32* %1, !dbg !62 ; [#uses=1 type=i32] [debug line = 59:11]
ret i32 %77, !dbg !62 ; [debug line = 59:11]
}
; [#uses=5]
declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
; [#uses=5]
declare i32 @printf(i8*, ...)
!llvm.dbg.cu = !{!0}
!0 = metadata !{i32 720913, i32 0, i32 4, metadata !"/tmp/foo/emscripten_test_default_B49mFr/src.cpp", metadata !"/private/tmp/foo/emscripten_test_default_B49mFr", metadata !"clang version 3.0 (trunk 139974)", i1 true, i1 false, metadata !"", i32 0, metadata !1, metadata !1, metadata !3, metadata !12} ; [ DW_TAG_compile_unit ]
!1 = metadata !{metadata !2}
!2 = metadata !{i32 0}
!3 = metadata !{metadata !4}
!4 = metadata !{metadata !5}
!5 = metadata !{i32 720942, i32 0, metadata !6, metadata !"main", metadata !"main", metadata !"", metadata !6, i32 33, metadata !7, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 false, i32 ()* @main, null, null, metadata !10} ; [ DW_TAG_subprogram ]
!6 = metadata !{i32 720937, metadata !"/tmp/foo/emscripten_test_default_B49mFr/src.cpp", metadata !"/private/tmp/foo/emscripten_test_default_B49mFr", null} ; [ DW_TAG_file_type ]
!7 = metadata !{i32 720917, i32 0, metadata !"", i32 0, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !8, i32 0, i32 0} ; [ DW_TAG_subroutine_type ]
!8 = metadata !{metadata !9}
!9 = metadata !{i32 720932, null, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
!10 = metadata !{metadata !11}
!11 = metadata !{i32 720932} ; [ DW_TAG_base_type ]
!12 = metadata !{metadata !13}
!13 = metadata !{metadata !14}
!14 = metadata !{i32 720948, i32 0, null, metadata !"generations", metadata !"generations", metadata !"_ZL11generations", metadata !6, i32 25, metadata !15, i32 1, i32 1, <{ { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] }, { { %struct.anon, [4 x i8] }, i32, i32, [8 x i8] } }>* @_ZL11generations} ; [ DW_TAG_variable ]
!15 = metadata !{i32 720897, null, metadata !"", null, i32 0, i64 768, i64 128, i32 0, i32 0, metadata !16, metadata !34, i32 0, i32 0} ; [ DW_TAG_array_type ]
!16 = metadata !{i32 720898, null, metadata !"gc_generation", metadata !6, i32 14, i64 256, i64 128, i32 0, i32 0, null, metadata !17, i32 0, null, null} ; [ DW_TAG_class_type ]
!17 = metadata !{metadata !18, metadata !32, metadata !33}
!18 = metadata !{i32 720909, metadata !16, metadata !"head", metadata !6, i32 15, i64 128, i64 128, i64 0, i32 0, metadata !19} ; [ DW_TAG_member ]
!19 = metadata !{i32 720919, null, metadata !"PyGC_Head", metadata !6, i32 5, i64 128, i64 128, i64 0, i32 0, i32 0, metadata !20, i32 0, i32 0} ; [ DW_TAG_union_type ]
!20 = metadata !{metadata !21, metadata !30}
!21 = metadata !{i32 720909, metadata !19, metadata !"gc", metadata !6, i32 10, i64 96, i64 32, i64 0, i32 0, metadata !22} ; [ DW_TAG_member ]
!22 = metadata !{i32 720898, metadata !19, metadata !"", metadata !6, i32 6, i64 96, i64 32, i32 0, i32 0, null, metadata !23, i32 0, null, null} ; [ DW_TAG_class_type ]
!23 = metadata !{metadata !24, metadata !26, metadata !27}
!24 = metadata !{i32 720909, metadata !22, metadata !"gc_next", metadata !6, i32 7, i64 32, i64 32, i64 0, i32 0, metadata !25} ; [ DW_TAG_member ]
!25 = metadata !{i32 720911, null, metadata !"", null, i32 0, i64 32, i64 32, i64 0, i32 0, metadata !19} ; [ DW_TAG_pointer_type ]
!26 = metadata !{i32 720909, metadata !22, metadata !"gc_prev", metadata !6, i32 8, i64 32, i64 32, i64 32, i32 0, metadata !25} ; [ DW_TAG_member ]
!27 = metadata !{i32 720909, metadata !22, metadata !"gc_refs", metadata !6, i32 9, i64 32, i64 32, i64 64, i32 0, metadata !28} ; [ DW_TAG_member ]
!28 = metadata !{i32 720918, null, metadata !"size_t", metadata !6, i32 35, i64 0, i64 0, i64 0, i32 0, metadata !29} ; [ DW_TAG_typedef ]
!29 = metadata !{i32 720932, null, metadata !"long unsigned int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 7} ; [ DW_TAG_base_type ]
!30 = metadata !{i32 720909, metadata !19, metadata !"dummy", metadata !6, i32 11, i64 128, i64 128, i64 0, i32 0, metadata !31} ; [ DW_TAG_member ]
!31 = metadata !{i32 720932, null, metadata !"long double", null, i32 0, i64 128, i64 128, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ]
!32 = metadata !{i32 720909, metadata !16, metadata !"threshold", metadata !6, i32 16, i64 32, i64 32, i64 128, i32 0, metadata !9} ; [ DW_TAG_member ]
!33 = metadata !{i32 720909, metadata !16, metadata !"count", metadata !6, i32 17, i64 32, i64 32, i64 160, i32 0, metadata !9} ; [ DW_TAG_member ]
!34 = metadata !{metadata !35}
!35 = metadata !{i32 720929, i64 0, i64 2} ; [ DW_TAG_subrange_type ]
!36 = metadata !{i32 721152, metadata !37, metadata !"n", metadata !6, i32 34, metadata !38, i32 0, i32 0} ; [ DW_TAG_auto_variable ]
!37 = metadata !{i32 720907, metadata !5, i32 33, i32 11, metadata !6, i32 0} ; [ DW_TAG_lexical_block ]
!38 = metadata !{i32 720911, null, metadata !"", null, i32 0, i64 32, i64 32, i64 0, i32 0, metadata !16} ; [ DW_TAG_pointer_type ]
!39 = metadata !{i32 34, i32 28, metadata !37, null}
!40 = metadata !{i32 34, i32 36, metadata !37, null}
!41 = metadata !{i32 35, i32 13, metadata !37, null}
!42 = metadata !{i32 43, i32 13, metadata !37, null}
!43 = metadata !{i32 721152, metadata !37, metadata !"x1", metadata !6, i32 51, metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ]
!44 = metadata !{i32 51, i32 17, metadata !37, null}
!45 = metadata !{i32 51, i32 44, metadata !37, null}
!46 = metadata !{i32 721152, metadata !37, metadata !"x2", metadata !6, i32 52, metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ]
!47 = metadata !{i32 52, i32 17, metadata !37, null}
!48 = metadata !{i32 52, i32 44, metadata !37, null}
!49 = metadata !{i32 53, i32 13, metadata !37, null}
!50 = metadata !{i32 721152, metadata !51, metadata !"i", metadata !6, i32 54, metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ]
!51 = metadata !{i32 720907, metadata !37, i32 54, i32 13, metadata !6, i32 1} ; [ DW_TAG_lexical_block ]
!52 = metadata !{i32 54, i32 22, metadata !51, null}
!53 = metadata !{i32 54, i32 27, metadata !51, null}
!54 = metadata !{i32 721152, metadata !55, metadata !"list", metadata !6, i32 55, metadata !25, i32 0, i32 0} ; [ DW_TAG_auto_variable ]
!55 = metadata !{i32 720907, metadata !51, i32 54, i32 55, metadata !6, i32 2} ; [ DW_TAG_lexical_block ]
!56 = metadata !{i32 55, i32 26, metadata !55, null}
!57 = metadata !{i32 55, i32 44, metadata !55, null}
!58 = metadata !{i32 56, i32 15, metadata !55, null}
!59 = metadata !{i32 57, i32 13, metadata !55, null}
!60 = metadata !{i32 54, i32 50, metadata !51, null}
!61 = metadata !{i32 58, i32 13, metadata !37, null}
!62 = metadata !{i32 59, i32 11, metadata !37, null}
// Note: Some Emscripten settings will significantly limit the speed of the generated code.
// Note: Some Emscripten settings may limit the speed of the generated code.
// TODO: " u s e s t r i c t ";
// *** Environment setup code ***
var arguments_ = [];
var ENVIRONMENT_IS_NODE = typeof process === 'object';
var ENVIRONMENT_IS_WEB = typeof window === 'object';
var ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
if (ENVIRONMENT_IS_NODE) {
// Expose functionality in the same simple way that the shells work
print = function(x) {
process['stdout'].write(x + '\n');
};
printErr = function(x) {
process['stderr'].write(x + '\n');
};
var nodeFS = require('fs');
read = function(filename) {
var ret = nodeFS['readFileSync'](filename).toString();
if (!ret && filename[0] != '/') {
filename = __dirname.split('/').slice(0, -1).join('/') + '/src/' + filename;
ret = nodeFS['readFileSync'](filename).toString();
}
return ret;
};
arguments_ = process['argv'].slice(2);
} else if (ENVIRONMENT_IS_SHELL) {
// Polyfill over SpiderMonkey/V8 differences
if (!this['read']) {
read = function(f) { snarf(f) };
}
if (!this['arguments']) {
arguments_ = scriptArgs;
} else {
arguments_ = arguments;
}
} else if (ENVIRONMENT_IS_WEB) {
print = printErr = function(x) {
console.log(x);
};
read = function(url) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, false);
xhr.send(null);
return xhr.responseText;
};
if (this['arguments']) {
arguments_ = arguments;
}
} else if (ENVIRONMENT_IS_WORKER) {
// We can do very little here...
load = importScripts;
} else {
throw 'Unknown runtime environment. Where are we?';
}
function globalEval(x) {
eval.call(null, x);
}
if (typeof load == 'undefined' && typeof read != 'undefined') {
load = function(f) {
globalEval(read(f));
};
}
if (typeof printErr === 'undefined') {
printErr = function(){};
}
if (typeof print === 'undefined') {
print = printErr;
}
// *** Environment setup code ***
try {
this['Module'] = Module;
} catch(e) {
this['Module'] = Module = {};
}
if (!Module.arguments) {
Module.arguments = arguments_;
}
if (Module.print) {
print = Module.print;
}
// === Auto-generated preamble library stuff ===
//========================================
// Runtime code shared with compiler
//========================================
var Runtime = {
stackSave: function () {
return STACKTOP;
},
stackRestore: function (stackTop) {
STACKTOP = stackTop;
},
forceAlign: function (target, quantum) {
quantum = quantum || 4;
if (isNumber(target) && isNumber(quantum)) {
return Math.ceil(target/quantum)*quantum;
} else {
return 'Math.ceil((' + target + ')/' + quantum + ')*' + quantum;
}
},
isNumberType: function (type) {
return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES;
},
isPointerType: function isPointerType(type) {
return type[type.length-1] == '*';
},
isStructType: function isStructType(type) {
if (isPointerType(type)) return false;
if (/^\[\d+\ x\ (.*)\]/.test(type)) return true; // [15 x ?] blocks. Like structs
if (/<?{ [^}]* }>?/.test(type)) return true; // { i32, i8 } etc. - anonymous struct types
// See comment in isStructPointerType()
return type[0] == '%';
},
INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0},
FLOAT_TYPES: {"float":0,"double":0},
or64: function (x, y) {
var l = (x | 0) | (y | 0);
var h = (Math.round(x / 4294967296) | Math.round(y / 4294967296)) * 4294967296;
return l + h;
},
and64: function (x, y) {
var l = (x | 0) & (y | 0);
var h = (Math.round(x / 4294967296) & Math.round(y / 4294967296)) * 4294967296;
return l + h;
},
xor64: function (x, y) {
var l = (x | 0) ^ (y | 0);
var h = (Math.round(x / 4294967296) ^ Math.round(y / 4294967296)) * 4294967296;
return l + h;
},
getNativeTypeSize: function (type, quantumSize) {
if (Runtime.QUANTUM_SIZE == 1) return 1;
var size = {
'%i1': 1,
'%i8': 1,
'%i16': 2,
'%i32': 4,
'%i64': 8,
"%float": 4,
"%double": 8
}['%'+type]; // add '%' since float and double confuse Closure compiler as keys, and also spidermonkey as a compiler will remove 's from '_i8' etc
if (!size && type[type.length-1] == '*') {
size = Runtime.QUANTUM_SIZE; // A pointer
}
return size;
},
getNativeFieldSize: function (type) {
return Math.max(Runtime.getNativeTypeSize(type), Runtime.QUANTUM_SIZE);
},
dedup: function dedup(items, ident) {
var seen = {};
if (ident) {
return items.filter(function(item) {
if (seen[item[ident]]) return false;
seen[item[ident]] = true;
return true;
});
} else {
return items.filter(function(item) {
if (seen[item]) return false;
seen[item] = true;
return true;
});
}
},
set: function set() {
var args = typeof arguments[0] === 'object' ? arguments[0] : arguments;
var ret = {};
for (var i = 0; i < args.length; i++) {
ret[args[i]] = 0;
}
return ret;
},
calculateStructAlignment: function calculateStructAlignment(type) {
type.flatSize = 0;
type.alignSize = 0;
var diffs = [];
var prev = -1;
type.flatIndexes = type.fields.map(function(field) {
var size, alignSize;
if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) {
size = Runtime.getNativeTypeSize(field); // pack char; char; in structs, also char[X]s.
alignSize = size;
} else if (Runtime.isStructType(field)) {
size = Types.types[field].flatSize;
alignSize = Types.types[field].alignSize;
} else {
throw 'Unclear type in struct: ' + field + ', in ' + type.name_ + ' :: ' + dump(Types.types[type.name_]);
}
alignSize = type.packed ? 1 : Math.min(alignSize, Runtime.QUANTUM_SIZE);
type.alignSize = Math.max(type.alignSize, alignSize);
var curr = Runtime.alignMemory(type.flatSize, alignSize); // if necessary, place this on aligned memory
type.flatSize = curr + size;
if (prev >= 0) {
diffs.push(curr-prev);
}
prev = curr;
return curr;
});
type.flatSize = Runtime.alignMemory(type.flatSize, type.alignSize);
if (diffs.length == 0) {
type.flatFactor = type.flatSize;
} else if (Runtime.dedup(diffs).length == 1) {
type.flatFactor = diffs[0];
}
type.needsFlattening = (type.flatFactor != 1);
return type.flatIndexes;
},
generateStructInfo: function (struct, typeName, offset) {
var type, alignment;
if (typeName) {
offset = offset || 0;
type = (typeof Types === 'undefined' ? Runtime.typeInfo : Types.types)[typeName];
if (!type) return null;
if (!struct) struct = (typeof Types === 'undefined' ? Runtime : Types).structMetadata[typeName.replace(/.*\./, '')];
if (!struct) return null;
assert(type.fields.length === struct.length, 'Number of named fields must match the type for ' + typeName + '. Perhaps due to inheritance, which is not supported yet?');
alignment = type.flatIndexes;
} else {
var type = { fields: struct.map(function(item) { return item[0] }) };
alignment = Runtime.calculateStructAlignment(type);
}
var ret = {
__size__: type.flatSize
};
if (typeName) {
struct.forEach(function(item, i) {
if (typeof item === 'string') {
ret[item] = alignment[i] + offset;
} else {
// embedded struct
var key;
for (var k in item) key = k;
ret[key] = Runtime.generateStructInfo(item[key], type.fields[i], alignment[i]);
}
});
} else {
struct.forEach(function(item, i) {
ret[item[1]] = alignment[i];
});
}
return ret;
},
stackAlloc: function stackAlloc(size) { var ret = STACKTOP; STACKTOP += size;STACKTOP = Math.ceil((STACKTOP)/4)*4;; assert(STACKTOP < STACK_ROOT + STACK_MAX, "Ran out of stack"); return ret; },
staticAlloc: function staticAlloc(size) { var ret = STATICTOP; STATICTOP += size;STATICTOP = Math.ceil((STATICTOP)/4)*4;; if (STATICTOP >= TOTAL_MEMORY) enlargeMemory();; return ret; },
alignMemory: function alignMemory(size,quantum) { var ret = size = Math.ceil((size)/(quantum ? quantum : 4))*(quantum ? quantum : 4);; return ret; },
QUANTUM_SIZE: 4,
__dummy__: 0
}
var CorrectionsMonitor = {
MAX_ALLOWED: 0, // XXX
corrections: 0,
sigs: {},
note: function(type, succeed, sig) {
if (!succeed) {
this.corrections++;
if (this.corrections >= this.MAX_ALLOWED) abort('\n\nToo many corrections!');
}
},
print: function() {
var items = [];
for (var sig in this.sigs) {
items.push({
sig: sig,
fails: this.sigs[sig][0],
succeeds: this.sigs[sig][1],
total: this.sigs[sig][0] + this.sigs[sig][1]
});
}
items.sort(function(x, y) { return y.total - x.total; });
for (var i = 0; i < items.length; i++) {
var item = items[i];
print(item.sig + ' : ' + item.total + ' hits, %' + (Math.ceil(100*item.fails/item.total)) + ' failures');
}
}
};
//========================================
// Runtime essentials
//========================================
var __globalConstructor__ = function globalConstructor() {
};
var __THREW__ = false; // Used in checking for thrown exceptions.
var __ATEXIT__ = [];
var ABORT = false;
var undef = 0;
// tempInt is used for 32-bit signed values or smaller. tempBigInt is used
// for 32-bit unsigned values or more than 32 bits. TODO: audit all uses of tempInt
var tempValue, tempInt, tempBigInt, tempInt2, tempBigInt2, tempPair, tempBigIntI, tempBigIntR, tempBigIntS, tempBigIntP, tempBigIntD;
var tempI64, tempI64b;
var tempDoubleBuffer = new ArrayBuffer(8);
var tempDoubleI32 = new Int32Array(tempDoubleBuffer);
var tempDoubleF64 = new Float64Array(tempDoubleBuffer);
function abort(text) {
print(text + ':\n' + (new Error).stack);
ABORT = true;
throw "Assertion: " + text;
}
function assert(condition, text) {
if (!condition) {
abort('Assertion failed: ' + text);
}
}
// Sets a value in memory in a dynamic way at run-time. Uses the
// type data. This is the same as makeSetValue, except that
// makeSetValue is done at compile-time and generates the needed
// code then, whereas this function picks the right code at
// run-time.
function setValue(ptr, value, type, noSafe) {
type = type || 'i8';
if (type[type.length-1] === '*') type = 'i32'; // pointers are 32-bit
switch(type) {
case 'i1': HEAP8[(ptr)]=value; break;
case 'i8': HEAP8[(ptr)]=value; break;
case 'i16': HEAP16[((ptr)>>1)]=value; break;
case 'i32': HEAP32[((ptr)>>2)]=value; break;
case 'i64': (HEAP32[((ptr)>>2)]=value[0],HEAP32[((ptr+4)>>2)]=value[1]); break;
case 'float': HEAPF32[((ptr)>>2)]=value; break;
case 'double': (tempDoubleF64[0]=value,HEAP32[((ptr)>>2)]=tempDoubleI32[0],HEAP32[((ptr+4)>>2)]=tempDoubleI32[1]); break;
default: abort('invalid type for setValue: ' + type);
}
}
Module['setValue'] = setValue;
// Parallel to setValue.
function getValue(ptr, type, noSafe) {
type = type || 'i8';
if (type[type.length-1] === '*') type = 'i32'; // pointers are 32-bit
switch(type) {
case 'i1': return HEAP8[(ptr)];
case 'i8': return HEAP8[(ptr)];
case 'i16': return HEAP16[((ptr)>>1)];
case 'i32': return HEAP32[((ptr)>>2)];
case 'i64': return [HEAPU32[((ptr)>>2)],HEAPU32[((ptr+4)>>2)]];
case 'float': return HEAPF32[((ptr)>>2)];
case 'double': return (tempDoubleI32[0]=HEAP32[((ptr)>>2)],tempDoubleI32[1]=HEAP32[((ptr+4)>>2)],tempDoubleF64[0]);
default: abort('invalid type for setValue: ' + type);
}
return null;
}
Module['getValue'] = getValue;
// Allocates memory for some data and initializes it properly.
var ALLOC_NORMAL = 0; // Tries to use _malloc()
var ALLOC_STACK = 1; // Lives for the duration of the current function call
var ALLOC_STATIC = 2; // Cannot be freed
Module['ALLOC_NORMAL'] = ALLOC_NORMAL;
Module['ALLOC_STACK'] = ALLOC_STACK;
Module['ALLOC_STATIC'] = ALLOC_STATIC;
function allocate(slab, types, allocator) {
var zeroinit, size;
if (typeof slab === 'number') {
zeroinit = true;
size = slab;
} else {
zeroinit = false;
size = slab.length;
}
var singleType = typeof types === 'string' ? types : null;
var ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc][allocator === undefined ? ALLOC_STATIC : allocator](Math.max(size, singleType ? 1 : types.length));
var i = 0, type;
while (i < size) {
var curr = zeroinit ? 0 : slab[i];
if (typeof curr === 'function') {
curr = Runtime.getFunctionIndex(curr);
}
type = singleType || types[i];
if (type === 0) {
i++;
continue;
}
assert(type, 'Must know what type to store in allocate!');
if (type == 'i64') type = 'i32'; // special case: we have one i32 here, and one i32 later
setValue(ret+i, curr, type);
i += Runtime.getNativeTypeSize(type);
}
return ret;
}
Module['allocate'] = allocate;
function Pointer_stringify(ptr) {
var ret = "";
var i = 0;
var t;
var nullByte = String.fromCharCode(0);
while (1) {
t = String.fromCharCode(HEAPU8[(ptr+i)]);
if (t == nullByte) { break; } else {}
ret += t;
i += 1;
}
return ret;
}
Module['Pointer_stringify'] = Pointer_stringify;
function Array_stringify(array) {
var ret = "";
for (var i = 0; i < array.length; i++) {
ret += String.fromCharCode(array[i]);
}
return ret;
}
Module['Array_stringify'] = Array_stringify;
// Memory management
var FUNCTION_TABLE; // XXX: In theory the indexes here can be equal to pointers to stacked or malloced memory. Such comparisons should
// be false, but can turn out true. We should probably set the top bit to prevent such issues.
var PAGE_SIZE = 4096;
function alignMemoryPage(x) {
return Math.ceil(x/PAGE_SIZE)*PAGE_SIZE;
}
var HEAP;
var HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32;
var STACK_ROOT, STACKTOP, STACK_MAX;
var STATICTOP;
function enlargeMemory() {
// TOTAL_MEMORY is the current size of the actual array, and STATICTOP is the new top.
printErr('Warning: Enlarging memory arrays, this is not fast! ' + [STATICTOP, TOTAL_MEMORY]);
assert(STATICTOP >= TOTAL_MEMORY);
assert(TOTAL_MEMORY > 4); // So the loop below will not be infinite
while (TOTAL_MEMORY <= STATICTOP) { // Simple heuristic. Override enlargeMemory() if your program has something more optimal for it
TOTAL_MEMORY = alignMemoryPage(TOTAL_MEMORY*1.25);
}
var oldHEAP8 = HEAP8;
var buffer = new ArrayBuffer(TOTAL_MEMORY);
HEAP8 = new Int8Array(buffer);
HEAP16 = new Int16Array(buffer);
HEAP32 = new Int32Array(buffer);
HEAPU8 = new Uint8Array(buffer);
HEAPU16 = new Uint16Array(buffer);
HEAPU32 = new Uint32Array(buffer);
HEAPF32 = new Float32Array(buffer);
HEAP8.set(oldHEAP8);
}
var TOTAL_MEMORY = Module['TOTAL_MEMORY'] || 10485760;
var FAST_MEMORY = Module['FAST_MEMORY'] || 2097152;
// Initialize the runtime's memory
// check for full engine support (use string 'subarray' to avoid closure compiler confusion)
assert(!!Int32Array && !!Float64Array && !!(new Int32Array(1)['subarray']) && !!(new Int32Array(1)['set']),
'Cannot fallback to non-typed array case: Code is too specialized');
var buffer = new ArrayBuffer(TOTAL_MEMORY);
HEAP8 = new Int8Array(buffer);
HEAP16 = new Int16Array(buffer);
HEAP32 = new Int32Array(buffer);
HEAPU8 = new Uint8Array(buffer);
HEAPU16 = new Uint16Array(buffer);
HEAPU32 = new Uint32Array(buffer);
HEAPF32 = new Float32Array(buffer);
// Endianness check (note: assumes compiler arch was little-endian)
HEAP32[0] = 255;
assert(HEAPU8[0] === 255 && HEAPU8[3] === 0, 'Typed arrays 2 must be run on a little-endian system');
var base = intArrayFromString('(null)'); // So printing %s of NULL gives '(null)'
// Also this ensures we leave 0 as an invalid address, 'NULL'
STATICTOP = base.length;
for (var i = 0; i < base.length; i++) {
HEAP8[(i)]=base[i]
}
Module['HEAP'] = HEAP;
Module['HEAP8'] = HEAP8;
Module['HEAP16'] = HEAP16;
Module['HEAP32'] = HEAP32;
Module['HEAPU8'] = HEAPU8;
Module['HEAPU16'] = HEAPU16;
Module['HEAPU32'] = HEAPU32;
Module['HEAPF32'] = HEAPF32;
STACK_ROOT = STACKTOP = alignMemoryPage(10);
var TOTAL_STACK = 1024*1024; // XXX: Changing this value can lead to bad perf on v8!
STACK_MAX = STACK_ROOT + TOTAL_STACK;
STATICTOP = alignMemoryPage(STACK_MAX);
function __shutdownRuntime__() {
while(__ATEXIT__.length > 0) {
var atexit = __ATEXIT__.pop();
var func = atexit.func;
if (typeof func === 'number') {
func = FUNCTION_TABLE[func];
}
func(atexit.arg === undefined ? null : atexit.arg);
}
// allow browser to GC, set heaps to null?
// Print summary of correction activity
CorrectionsMonitor.print();
}
// Copies a list of num items on the HEAP into a
// a normal JavaScript array of numbers
function Array_copy(ptr, num) {
return Array.prototype.slice.call(HEAP8.subarray(ptr, ptr+num)); // Make a normal array out of the typed 'view'
// Consider making a typed array here, for speed?
return HEAP.slice(ptr, ptr+num);
}
Module['Array_copy'] = Array_copy;
function String_len(ptr) {
var i = 0;
while (HEAP8[(ptr+i)]) i++; // Note: should be |!= 0|, technically. But this helps catch bugs with undefineds
return i;
}
Module['String_len'] = String_len;
// Copies a C-style string, terminated by a zero, from the HEAP into
// a normal JavaScript array of numbers
function String_copy(ptr, addZero) {
var len = String_len(ptr);
if (addZero) len++;
var ret = Array_copy(ptr, len);
if (addZero) ret[len-1] = 0;
return ret;
}
Module['String_copy'] = String_copy;
// Tools
// This processes a JS string into a C-line array of numbers, 0-terminated.
// For LLVM-originating strings, see parser.js:parseLLVMString function
function intArrayFromString(stringy, dontAddNull) {
var ret = [];
var t;
var i = 0;
while (i < stringy.length) {
var chr = stringy.charCodeAt(i);
if (chr > 0xFF) {
assert(false, 'Character code ' + chr + ' (' + stringy[i] + ') at offset ' + i + ' not in 0x00-0xFF.');
chr &= 0xFF;
}
ret.push(chr);
i = i + 1;
}
if (!dontAddNull) {
ret.push(0);
}
return ret;
}
Module['intArrayFromString'] = intArrayFromString;
function intArrayToString(array) {
var ret = [];
for (var i = 0; i < array.length; i++) {
var chr = array[i];
if (chr > 0xFF) {
assert(false, 'Character code ' + chr + ' (' + String.fromCharCode(chr) + ') at offset ' + i + ' not in 0x00-0xFF.');
chr &= 0xFF;
}
ret.push(String.fromCharCode(chr));
}
return ret.join('');
}
Module['intArrayToString'] = intArrayToString;
function unSign(value, bits, ignore, sig) {
if (value >= 0) {
return value;
}
return bits <= 32 ? 2*Math.abs(1 << (bits-1)) + value // Need some trickery, since if bits == 32, we are right at the limit of the bits JS uses in bitshifts
: Math.pow(2, bits) + value;
// TODO: clean up previous line
}
function reSign(value, bits, ignore, sig) {
if (value <= 0) {
return value;
}
var half = bits <= 32 ? Math.abs(1 << (bits-1)) // abs is needed if bits == 32
: Math.pow(2, bits-1);
if (value >= half && (bits <= 32 || value > half)) { // for huge values, we can hit the precision limit and always get true here. so don't do that
// but, in general there is no perfect solution here. With 64-bit ints, we get rounding and errors
// TODO: In i64 mode 1, resign the two parts separately and safely
value = -2*half + value; // Cannot bitshift half, as it may be at the limit of the bits JS uses in bitshifts
}
return value;
}
// === Body ===
undefined:166: Unclear type in struct: x86_fp80, in %union.PyGC_Head :: // {"intertype":"type","name_":"%union.PyGC_Head","fields":["x86_fp80"],"packed":fa
// lse,"lineNum":2,"flatSize":0,"alignSize":0}
'Unclear type in struct: ' + field + ', in ' + type.name_ + ' :: ' + dump(Typ
^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment