diff --git a/3rd/ftb b/3rd/ftb
index d213320..9a26305 160000
--- a/3rd/ftb
+++ b/3rd/ftb
@@ -1 +1 @@
-Subproject commit d2133205a73c3ae3455e8cc3e0a910ce0aaae518
+Subproject commit 9a2630596564a0401d26adb70a96f14a3e8c19d1
diff --git a/build.bat b/build.bat
index ccba429..ff8e48a 100644
--- a/build.bat
+++ b/build.bat
@@ -7,7 +7,7 @@ set exeName=slime.exe
taskkill /F /IM %exeName% > NUL 2> NUL
echo ---------- Compiling ----------
-call ..\timecmd cl ^
+call cl ^
../src/main.cpp^
/I../3rd/ ^
/D_PROFILING /D_DEBUG ^
@@ -25,7 +25,7 @@ if %errorlevel% == 0 (
echo.
echo ---- Running Tests ----
echo.
- call timecmd slime.exe --run-tests
+ call slime.exe --run-tests
) else (
echo.
echo Fuckin' ell
diff --git a/profiler_vis/data.csv b/profiler_vis/data.csv
deleted file mode 100644
index e249edd..0000000
--- a/profiler_vis/data.csv
+++ /dev/null
@@ -1,149 +0,0 @@
-nconst,character,start,end
-nm0221046,Actor2,53000,237000
-nm0330687,Actor1,53000,237000
-nm0569501,Narrator,64000,237000
-nm0932891,Actor3,72000,237000
-nm3068638,Actor1 - Age 12,81000,237000
-nm2788212,Actor2 - Age 12,97000,237000
-nm1631269,Actor4,240000,424000
-nm0034309,Actor5,258000,424000
-nm1131557,Actor6,258000,424000
-nm0330687,Actor1,273000,424000
-nm0221046,Actor2,305000,424000
-nm0034309,Actor5,425000,558000
-nm0329622,Office Worker,427000,558000
-nm0330687,Actor1,427000,558000
-nm0932891,Actor3,427000,558000
-nm0381763,Actor7,433000,558000
-nm0803331,Usher,433000,558000
-nm0163988,Actor8,443000,558000
-nm0221046,Actor2,449000,558000
-nm0569501,Narrator,472000,558000
-nm0221046,Actor2,560000,647000
-nm0034309,Actor5,561000,647000
-nm0330687,Actor1,564000,647000
-nm0163988,Actor8,650000,813000
-nm0735538,Employee #1,650000,813000
-nm0330687,Actor1,652000,813000
-nm0006970,Actor9,654000,813000
-nm0803331,Usher,656000,813000
-nm0221046,Actor2,660000,813000
-nm0034309,Actor5,661000,813000
-nm0932891,Actor3,699000,813000
-nm0330687,Actor1,815000,1013000
-nm1131557,Actor6,815000,1013000
-nm0221046,Actor2,821000,1013000
-nm1631269,Actor4,865000,1013000
-nm0034309,Actor5,888000,1013000
-nm0034309,Actor5,1014000,1119000
-nm0330687,Actor1,1014000,1119000
-nm0221046,Actor2,1048000,1119000
-nm0330687,Actor1,1119000,1348000
-nm0034309,Actor5,1126000,1348000
-nm0221046,Actor2,1126000,1348000
-nm0006970,Actor9,1279000,1348000
-nm0330687,Actor1,1348000,1469000
-nm0221046,Actor2,1348000,1469000
-nm0034309,Actor5,1348000,1469000
-nm0221046/trivia,nt0447626,1377000,1469000
-nm0330687,Actor1,1470000,1619000
-nm0221046,Actor2,1471000,1619000
-nm1131557,Actor6,1547000,1619000
-nm0330687,Actor1,1622000,1839000
-nm0221046,Actor2,1627000,1839000
-nm2124215,Actor10,1752000,1839000
-nm0330687,Actor1,1839000,2006000
-nm0221046,Actor2,1839000,2006000
-nm0000148,Self,1910000,2006000
-nm0330687,Actor1,2008000,2066000
-nm0163988,Actor8,2019000,2066000
-nm1304328,New Secretary,2019000,2066000
-nm0034309,Actor5,2025000,2066000
-nm0221046,Actor2,2052000,2066000
-nm0034309,Actor5,2068000,2293000
-nm0221046,Actor2,2068000,2293000
-nm0330687,Actor1,2074000,2293000
-nm0221046,Actor2,2295000,2482000
-nm0330687,Actor1,2295000,2482000
-nm0569501,Narrator,2315000,2482000
-nm1131557,Actor6,2433000,2482000
-nm0034309,Actor5,2437000,2482000
-nm0330687,Actor1,2483000,2626000
-nm1631269,Actor4,2483000,2626000
-nm0330687/trivia,nt0127470,2539000,2626000
-nm0221046,Actor2,2557000,2626000
-nm0221046,Actor2,2630000,2853000
-nm0330687,Actor1,2630000,2853000
-nm1071303,Douche,2656000,2853000
-nm3300012,Girl on the Stairs,2835000,2853000
-nm0330687,Actor1,2853000,2984000
-nm0221046,Actor2,2861000,2984000
-nm0221046/trivia,nt0085270,2908000,2984000
-nm0221046,Actor2,2985000,3072000
-nm0330687,Actor1,2987000,3072000
-nm2622767,Actor11,3050000,3072000
-nm0330687,Actor1,3072000,3143000
-nm0221046,Actor2,3073000,3143000
-nm0221046,Actor2,3148000,3278000
-nm0330687,Actor1,3148000,3278000
-nm0897096,Actor12,3194000,3278000
-nm0533467,Actor13,3209000,3278000
-nm3505105,Actor14,3249000,3278000
-nm1304328,New Secretary,3279000,3406000
-nm0330687,Actor1,3282000,3406000
-nm0163988,Actor8,3289000,3406000
-nm0330687,Actor1,3410000,3625000
-nm0034309,Actor5,3413000,3625000
-nm0932891,Actor3,3414000,3625000
-nm0735538,Employee #1,3438000,3625000
-nm0006970,Actor9,3443000,3625000
-nm0381763,Actor7,3443000,3625000
-nm0281068,Actor15,3446000,3625000
-nm0221046,Actor2,3450000,3625000
-nm0715377,Bus Driver,3483000,3625000
-nm1036340,Actor16,3488000,3625000
-nm0330687,Actor1,3629000,3841000
-nm0034309,Actor5,3642000,3841000
-nm0221046,Actor2,3677000,3841000
-nm0006970,Actor9,3827000,3841000
-nm2306384,Minister,3827000,3841000
-nm3505110,Actor9's New Husband,3827000,3841000
-nm0221046,Actor2,3841000,3984000
-nm0006970,Actor9,3847000,3984000
-nm3505110,Actor9's New Husband,3847000,3984000
-nm0330687,Actor1,3851000,3984000
-nm3505106,Wedding Singer,3892000,3984000
-nm1131557,Actor6,3984000,4054000
-nm0034309,Actor5,3999000,4054000
-nm0163988,Actor8,4009000,4054000
-nm0330687,Actor1,4045000,4054000
-nm0330687,Actor1,4054000,4249000
-nm0569501,Narrator,4066000,4249000
-nm0221046,Actor2,4089000,4249000
-nm1656122,Partygoer,4134000,4249000
-nm1497668,Rooftop Guy #1,4168000,4249000
-nm3107009,Another Partygoer,4194000,4249000
-nm0330687,Actor1,4254000,4305000
-nm0330687,Actor1,4305000,4514000
-nm0034309,Actor5,4305000,4514000
-nm0381763,Actor7,4310000,4514000
-nm0281068,Actor10,4328000,4514000
-nm0803331,Usher,4328000,4514000
-nm0163988,Actor8,4334000,4514000
-nm0329622,Office Worker,4334000,4514000
-nm0330687/trivia,nt0127468,4362000,4514000
-nm0330687,Actor1,4516000,4740000
-nm1631269,Actor4,4520000,4740000
-nm1631269/trivia,nt0787786,4533000,4740000
-nm0221046,Actor2,4583000,4740000
-nm1071303,Douche,4593000,4740000
-nm0000163,Ben,4620000,4740000
-nm0001684,Elaine,4620000,4740000
-nm0330687,Actor1,4743000,4882000
-nm0330687/trivia,nt0920755,4751000,4882000
-nm0221046,Actor2,4851000,4882000
-nm0330687,Actor1,4885000,5228000
-nm0221046,Actor2,4907000,5228000
-nm0330687,Actor1,5230000,5426000
-nm0569501,Narrator,5240000,5426000
-nm1310368,Girl at interview,5263000,5426000
\ No newline at end of file
diff --git a/profiler_vis/main.py b/profiler_vis/main.py
deleted file mode 100644
index e16e16d..0000000
--- a/profiler_vis/main.py
+++ /dev/null
@@ -1,27 +0,0 @@
-import plotly.figure_factory as ff
-
-df = [
- {"Task": "call depth 4", "Start": 9321, "Finish": 9326},
- {"Task": "call depth 3", "Start": 9288, "Finish": 9311},
- {"Task": "call depth 2", "Start": 9126, "Finish": 9141},
- {"Task": "call depth 1", "Start": 9088, "Finish": 9099},
- {"Task": "call depth 0", "Start": 9076, "Finish": 9337},
- {"Task": "call depth 1", "Start": 9109, "Finish": 9179},
- {"Task": "call depth 1", "Start": 9194, "Finish": 9334},
- {"Task": "call depth 2", "Start": 9206, "Finish": 9231},
- {"Task": "call depth 2", "Start": 9237, "Finish": 9269},
- {"Task": "call depth 2", "Start": 9274, "Finish": 9331},
- {"Task": "call depth 3", "Start": 9255, "Finish": 9266},
- {"Task": "call depth 3", "Start": 9279, "Finish": 9284},
- {"Task": "call depth 4", "Start": 9299, "Finish": 9309},
- {"Task": "call depth 3", "Start": 9316, "Finish": 9329},
-]
-
-fig = ff.create_gantt(df, group_tasks=True, bar_width=0.4, width=1700, height=720)
-
-fig["data"][0].update(text="apply_arguments_to_function", hoverinfo="text+x+y")
-fig["data"][1].update(text="apply_arguments_to_function", hoverinfo="text+x+y")
-fig["data"][2].update(text="apply_arguments_to_function", hoverinfo="text+x+y")
-
-
-fig.show()
diff --git a/profiler_vis/report2tracing.py b/profiler_vis/report2tracing.py
new file mode 100644
index 0000000..0c5355d
--- /dev/null
+++ b/profiler_vis/report2tracing.py
@@ -0,0 +1,32 @@
+import json
+import csv
+import sys
+
+if len(sys.argv) == 1:
+ print("No file was provided")
+else:
+ trace_events = []
+ call_stack = []
+ with open(sys.argv[1], "r") as in_file:
+ csv_reader = csv.reader(in_file, delimiter=',')
+ for line in csv_reader:
+ if line[0] == "->":
+ call_stack.append(line)
+ elif line[0] == "<-":
+ call = call_stack.pop()
+ trace_events.append({
+ "pid": 1,
+ "tid": 1,
+ "ts" : int(call[1]),
+ "dur": int(line[1])-int(call[1]),
+ "ph" : "X",
+ "name": call[2],
+ "args": {
+ "file": f"({call[3]}:{call[4]})"
+ }
+ })
+ else:
+ print("invalid syntax")
+ break
+ with open("out.json", "w") as out_file:
+ out_file.write(json.dumps({"traceEvents": trace_events}, indent=4))
diff --git a/profiler_vis/test.py b/profiler_vis/test.py
deleted file mode 100644
index 544fa5e..0000000
--- a/profiler_vis/test.py
+++ /dev/null
@@ -1,88 +0,0 @@
-import pandas as pd
-import plotly.graph_objs as go
-
-call_depths = [0]
-datas = []
-
-def ensure_big_enough(list, idx, el):
- l = len(list)
- if (idx >= l):
- list.extend([el]*(idx-l+1))
-
-def incr_call_depth(thread):
- ensure_big_enough(call_depths, thread, 0)
- call_depths[thread] += 1
-
-def append_to_datas(thread, data):
- ensure_big_enough(datas, thread, [])
- datas[thread].append(data)
-
-with open("../src/profiler_reports/04.10.2019-13.29.21-140737348403048-profiler.report", "r") as file:
- for line in file:
- infos = line.split()
- if infos[1] == "->":
- incr_call_depth(thread)
- append_to_datas(thread, {
- "task": f"[T{thread}] - {'{:03d}'.format(call_depths[thread])}",
- "start": int(infos[5]),
- "end": None
- })
- elif infos[1] == "<-":
- call_depths[thread] -= 1
- for set in datas[thread][::-1]:
- if set["end"] == None:
- set["end"] = int(infos[2])
- break
- else:
- print("couldn't find task that finished")
- break
-
- else:
- print("neither -> nor <-")
-
-
-fig = go.Figure(
- layout = {
- 'barmode': 'stack',
- "dragmode" : "pan",
- }
-)
-
-flat_datas= [item for sublist in datas for item in sublist]
-# i = 1
-# df = flat_datas[:20]
-# for call in df:
-# name = call["task"]
-# start = call["start"]
-# end = call["end"]
-# duration = end,start
-# fig.add_bar(x=(i,duration),
-# y=(i,name),
-# base=(i,start),
-# orientation='h',
-# showlegend=False,
-# name=name,
-# hovertext=f"yes",
-# text=""
-# )
-# i += 1
-
-df = pd.DataFrame(flat_datas[:20])
-df['duration'] = df['end'] - df['start']
-
-for stackdepth, stackdepth_df in df.groupby('task'):
- params = {"x": stackdepth_df.duration,
- "y": stackdepth_df.task,
- "name": stackdepth,
- "base": stackdepth_df.start
- }
- print(params)
- fig.add_bar(**params,
- orientation='h',
- showlegend=False,
- hovertext=f"yes",
- text=""
- )
-
-
-fig.show(config={'scrollZoom': True})
diff --git a/profiler_vis/test.rkt b/profiler_vis/test.rkt
deleted file mode 100644
index 937eb8f..0000000
--- a/profiler_vis/test.rkt
+++ /dev/null
@@ -1,21 +0,0 @@
-#lang racket
-(require racket/gui mrlib/snip-canvas plot)
-
-(define ((make-current-value-renderer fn) snip event x y)
- (define overlays
- (and x y (eq? (send event get-event-type) 'motion)
- (list (vrule x #:style 'long-dash)
- (point-label (vector x (fn x)) #:anchor 'auto))))
- (send snip set-overlay-renderers overlays))
-
-(define (make-plot-snip width height)
- (define snip (plot-snip (function sin)
- #:x-min 0 #:x-max (* 2 pi) #:y-min -1.5 #:y-max 1.5
- #:width width #:height height))
- (send snip set-mouse-event-callback (make-current-value-renderer sin))
- snip)
-
-(define toplevel (new frame% [label "Plot"] [width 500] [height 200]))
-(define canvas (new snip-canvas% [parent toplevel] [make-snip make-plot-snip]))
-(send toplevel show #t)
-
diff --git a/profiler_vis/test.svg b/profiler_vis/test.svg
deleted file mode 100644
index 9aad194..0000000
--- a/profiler_vis/test.svg
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/profiler_vis/test2.py b/profiler_vis/test2.py
deleted file mode 100644
index 68dd466..0000000
--- a/profiler_vis/test2.py
+++ /dev/null
@@ -1,173 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8-unix -*-
-
-import datetime
-import gantt
-
-# Change font default
-gantt.define_font_attributes(fill='black',
- stroke='black',
- stroke_width=0,
- font_family="Verdana")
-
-# Add vacations for everyone
-gantt.add_vacations(datetime.date(2014, 12, 25))
-gantt.add_vacations(datetime.date(2015, 1, 1))
-gantt.add_vacations(datetime.date(2015, 1, 13))
-
-# Create two resources
-rANO = gantt.Resource('ANO')
-rJLS = gantt.Resource('JLS')
-
-# Add vacations for one lucky resource
-rANO.add_vacations(
- dfrom=datetime.date(2014, 12, 29),
- dto=datetime.date(2015, 1, 4)
-)
-rANO.add_vacations(
- dfrom=datetime.date(2015, 1, 6),
- dto=datetime.date(2015, 1, 8)
-)
-
-# Test if this resource is avalaible for some dates
-print(rANO.is_available(datetime.date(2015, 1, 5)))
-print(rANO.is_available(datetime.date(2015, 1, 8)))
-print(rANO.is_available(datetime.date(2015, 1, 6)))
-print(rANO.is_available(datetime.date(2015, 1, 2)))
-print(rANO.is_available(datetime.date(2015, 1, 1)))
-
-
-# Create some tasks
-t1 = gantt.Task(name='tache1',
- start=datetime.date(2014, 12, 25),
- duration=4,
- percent_done=44,
- resources=[rANO],
- color="#FF8080")
-t2 = gantt.Task(name='tache2',
- start=datetime.date(2014, 12, 28),
- duration=6,
- resources=[rJLS])
-t7 = gantt.Task(name='tache7',
- start=datetime.date(2014, 12, 28),
- duration=5,
- percent_done=50)
-t3 = gantt.Task(name='tache3',
- start=datetime.date(2014, 12, 25),
- duration=4,
- depends_of=[t1, t7, t2],
- resources=[rJLS])
-t4 = gantt.Task(name='tache4',
- start=datetime.date(2015, 1, 1),
- duration=4,
- depends_of=t1,
- resources=[rJLS])
-t5 = gantt.Task(name='tache5',
- start=datetime.date(2014, 12, 23),
- duration=3)
-t6 = gantt.Task(name='tache6',
- start=datetime.date(2014, 12, 25),
- duration=4,
- depends_of=t7,
- resources=[rANO])
-t8 = gantt.Task(name='tache8',
- start=datetime.date(2014, 12, 25),
- duration=4,
- depends_of=t7,
- resources=[rANO, rJLS])
-
-
-# Create a project
-p1 = gantt.Project(name='Projet 1')
-
-# Add tasks to this project
-p1.add_task(t1)
-p1.add_task(t7)
-p1.add_task(t2)
-p1.add_task(t3)
-p1.add_task(t5)
-p1.add_task(t8)
-
-
-
-# Create another project
-p2 = gantt.Project(name='Projet 2', color='#FFFF40')
-
-# Add tasks to this project
-p2.add_task(t2)
-p2.add_task(t4)
-
-
-# Create another project
-p = gantt.Project(name='Gantt')
-# wich contains the first two projects
-# and a single task
-p.add_task(p1)
-p.add_task(p2)
-p.add_task(t6)
-
-
-
-# Test cases for milestones
-# Create another project
-ptcm = gantt.Project(name='Test case for milestones')
-
-tcm11 = gantt.Task(name='tcm11',
- start=datetime.date(2014, 12, 25),
- duration=4)
-tcm12 = gantt.Task(name='tcm12',
- start=datetime.date(2014, 12, 26),
- duration=5)
-ms1 = gantt.Milestone(name=' ',
- depends_of=[tcm11, tcm12])
-tcm21 = gantt.Task(name='tcm21',
- start=datetime.date(2014, 12, 30),
- duration=4,
- depends_of=[ms1])
-tcm22 = gantt.Task(name='tcm22',
- start=datetime.date(2014, 12, 30),
- duration=6,
- depends_of=[ms1])
-ms2 = gantt.Milestone(name='MS2',
- depends_of=[ms1, tcm21, tcm22])
-tcm31 = gantt.Task(name='tcm31',
- start=datetime.date(2014, 12, 30),
- duration=6,
- depends_of=[ms2])
-ms3 = gantt.Milestone(name='MS3', depends_of=[ms1])
-
-
-ptcm.add_task(tcm11)
-ptcm.add_task(tcm12)
-ptcm.add_task(ms1)
-ptcm.add_task(tcm21)
-ptcm.add_task(tcm22)
-ptcm.add_task(ms2)
-ptcm.add_task(tcm31)
-ptcm.add_task(ms3)
-
-
-p.add_task(ptcm)
-
-##########################$ MAKE DRAW ###############
-p.make_svg_for_tasks(filename='test_full.svg',
- today=datetime.date(2014, 12, 31),
- start=datetime.date(2014, 8, 22),
- end=datetime.date(2015, 1, 14))
-p.make_svg_for_tasks(filename='test_full2.svg',
- today=datetime.date(2014, 12, 31))
-p.make_svg_for_tasks(filename='test.svg',
- today=datetime.date(2014, 12, 31),
- start=datetime.date(2015, 1, 3),
- end=datetime.date(2015, 1, 6))
-p1.make_svg_for_tasks(filename='test_p1.svg',
- today=datetime.date(2014, 12, 31))
-p2.make_svg_for_tasks(filename='test_p2.svg',
- today=datetime.date(2014, 12, 31))
-p.make_svg_for_resources(filename='test_resources.svg',
- today=datetime.date(2014, 12, 31),
- resources=[rANO, rJLS])
-p.make_svg_for_tasks(filename='test_weekly.svg',
- today=datetime.date(2014, 12, 31),
- scale=gantt.DRAW_WITH_WEEKLY_SCALE)
-##########################$ /MAKE DRAW ###############
diff --git a/profiler_vis/test_full.svg b/profiler_vis/test_full.svg
deleted file mode 100644
index 02552d3..0000000
--- a/profiler_vis/test_full.svg
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/profiler_vis/test_full2.svg b/profiler_vis/test_full2.svg
deleted file mode 100644
index 8021b42..0000000
--- a/profiler_vis/test_full2.svg
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/profiler_vis/test_p1.svg b/profiler_vis/test_p1.svg
deleted file mode 100644
index c963ba2..0000000
--- a/profiler_vis/test_p1.svg
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/profiler_vis/test_p2.svg b/profiler_vis/test_p2.svg
deleted file mode 100644
index d049b37..0000000
--- a/profiler_vis/test_p2.svg
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/profiler_vis/test_resources.svg b/profiler_vis/test_resources.svg
deleted file mode 100644
index 62e1569..0000000
--- a/profiler_vis/test_resources.svg
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/profiler_vis/test_weekly.svg b/profiler_vis/test_weekly.svg
deleted file mode 100644
index 5b56c66..0000000
--- a/profiler_vis/test_weekly.svg
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
\ No newline at end of file
diff --git a/src/built_ins.cpp b/src/built_ins.cpp
index 36395a2..34c3f6c 100644
--- a/src/built_ins.cpp
+++ b/src/built_ins.cpp
@@ -46,6 +46,7 @@ proc add_to_load_path(const char* path) -> void {
}
proc built_in_load(String* file_name) -> Lisp_Object* {
+ profile_this();
char* file_content;
char fullpath[4096];
sprintf(fullpath, "%s", Memory::get_c_str(file_name));
@@ -89,6 +90,7 @@ proc built_in_load(String* file_name) -> Lisp_Object* {
}
proc built_in_import(String* file_name) -> Lisp_Object* {
+ profile_this();
Environment* new_env;
new_env = Memory::file_to_env_map.get_object(Memory::get_c_str(file_name));
@@ -114,12 +116,15 @@ proc built_in_import(String* file_name) -> Lisp_Object* {
}
proc load_built_ins_into_environment() -> void* {
+ profile_this();
String* file_name_built_ins = Memory::create_string(__FILE__);
define((helper), "") {
+ profile_with_name("(helper)");
return Memory::create_lisp_object_number(101);
};
define((test (:k (helper))), "") {
+ profile_with_name("(test)");
fetch(k);
return k;
};
@@ -127,6 +132,7 @@ proc load_built_ins_into_environment() -> void* {
"Takes 0 or more arguments and returns =t= if all arguments are equal "
"and =()= otherwise.")
{
+ profile_with_name("(=)");
fetch(args);
if (args == Memory::nil)
@@ -143,6 +149,7 @@ proc load_built_ins_into_environment() -> void* {
};
define((> . args), "TODO")
{
+ profile_with_name("(>)");
fetch(args);
double last_number = strtod("Inf", NULL);
@@ -157,6 +164,7 @@ proc load_built_ins_into_environment() -> void* {
};
define((>= . args), "TODO")
{
+ profile_with_name("(>=)");
fetch(args);
double last_number = strtod("Inf", NULL);
@@ -171,6 +179,7 @@ proc load_built_ins_into_environment() -> void* {
};
define((< . args), "TODO")
{
+ profile_with_name("(<)");
fetch(args);
double last_number = strtod("-Inf", NULL);
@@ -185,6 +194,7 @@ proc load_built_ins_into_environment() -> void* {
};
define((<= . args), "TODO")
{
+ profile_with_name("(<=)");
fetch(args);
double last_number = strtod("-Inf", NULL);
@@ -199,6 +209,7 @@ proc load_built_ins_into_environment() -> void* {
};
define((+ . args), "TODO")
{
+ profile_with_name("(+)");
fetch(args);
double sum = 0;
@@ -211,6 +222,7 @@ proc load_built_ins_into_environment() -> void* {
};
define((- . args), "TODO")
{
+ profile_with_name("(-)");
fetch(args);
if (args == Memory::nil)
return Memory::create_lisp_object_number(0);
@@ -232,6 +244,7 @@ proc load_built_ins_into_environment() -> void* {
};
define((* . args), "TODO")
{
+ profile_with_name("(*)");
fetch(args);
if (args == Memory::nil) {
return Memory::create_lisp_object_number(1);
@@ -248,6 +261,7 @@ proc load_built_ins_into_environment() -> void* {
};
define((/ . args), "TODO")
{
+ profile_with_name("(/)");
fetch(args);
if (args == Memory::nil) {
@@ -266,6 +280,7 @@ proc load_built_ins_into_environment() -> void* {
return Memory::create_lisp_object_number(quotient);
};
define((** a b), "TODO") {
+ profile_with_name("(**)");
fetch(a, b);
try assert_type(a, Lisp_Object_Type::Number);
try assert_type(b, Lisp_Object_Type::Number);
@@ -273,6 +288,7 @@ proc load_built_ins_into_environment() -> void* {
b->value.number));
};
define((% a b), "TODO") {
+ profile_with_name("(%)");
fetch(a, b);
try assert_type(a, Lisp_Object_Type::Number);
try assert_type(b, Lisp_Object_Type::Number);
@@ -280,6 +296,7 @@ proc load_built_ins_into_environment() -> void* {
(int)b->value.number);
};
define((get-random-between a b), "TODO") {
+ profile_with_name("(get-random-between)");
fetch(a, b);
try assert_type(a, Lisp_Object_Type::Number);
try assert_type(b, Lisp_Object_Type::Number);
@@ -293,6 +310,7 @@ proc load_built_ins_into_environment() -> void* {
return Memory::create_lisp_object_number(x);
};
define_special((bound? var), "TODO") {
+ profile_with_name("(bound?)");
fetch(var);
try assert_type(var, Lisp_Object_Type::Symbol);
@@ -305,6 +323,7 @@ proc load_built_ins_into_environment() -> void* {
return Memory::nil;
};
define((assert test), "TODO") {
+ profile_with_name("(assert)");
fetch(test);
if (is_truthy(test))
@@ -314,6 +333,7 @@ proc load_built_ins_into_environment() -> void* {
return nullptr;
};
define_special((define-syntax form (:doc "") . body), "TODO") {
+ profile_with_name("(define-syntax)");
fetch(form, doc, body);
try assert_type(doc, Lisp_Object_Type::String);
@@ -350,6 +370,7 @@ proc load_built_ins_into_environment() -> void* {
return Memory::nil;
};
define_special((define definee (:doc "") . body), "TODO") {
+ profile_with_name("(define)");
fetch(definee, doc, body);
// print_hm(get_current_environment()->hm);
@@ -405,6 +426,7 @@ proc load_built_ins_into_environment() -> void* {
return Memory::nil;
};
define((mutate target source), "TODO") {
+ profile_with_name("(mutate)");
fetch(target, source);
if (target == Memory::nil ||
@@ -427,11 +449,13 @@ proc load_built_ins_into_environment() -> void* {
return target;
};
define((vector-length v), "TODO") {
+ profile_with_name("(vector-length)");
fetch(v);
try assert_type(v, Lisp_Object_Type::Vector);
return Memory::create_lisp_object_number((double)v->value.vector.length);
};
define((vector-ref vec idx), "TODO") {
+ profile_with_name("(vector-ref)");
fetch(vec, idx);
try assert_type(vec, Lisp_Object_Type::Vector);
@@ -445,6 +469,7 @@ proc load_built_ins_into_environment() -> void* {
return vec->value.vector.data+int_idx;
};
define((vector-set! vec idx val), "TODO") {
+ profile_with_name("(vector-set!)");
fetch(vec, idx, val);
try assert_type(vec, Lisp_Object_Type::Vector);
@@ -460,6 +485,7 @@ proc load_built_ins_into_environment() -> void* {
return val;
};
define_special((set! sym val), "TODO") {
+ profile_with_name("(set!)");
fetch(sym, val);
try assert_type(sym, Lisp_Object_Type::Symbol);
@@ -473,14 +499,13 @@ proc load_built_ins_into_environment() -> void* {
push_environment(target_env);
- {
- define_symbol(sym, val);
- }
+ define_symbol(sym, val);
pop_environment();
return val;
};
define((set-car! target source), "TODO") {
+ profile_with_name("(set-car!)");
fetch(target, source);
try assert_type(target, Lisp_Object_Type::Pair);
@@ -489,6 +514,7 @@ proc load_built_ins_into_environment() -> void* {
return source;
};
define((set-cdr! target source), "TODO") {
+ profile_with_name("(set-cdr!)");
fetch(target, source);
try assert_type(target, Lisp_Object_Type::Pair);
@@ -497,6 +523,7 @@ proc load_built_ins_into_environment() -> void* {
return source;
};
define_special((if test then_part else_part), "TODO") {
+ profile_with_name("(if)");
fetch(test, then_part, else_part);
bool truthy;
@@ -511,10 +538,12 @@ proc load_built_ins_into_environment() -> void* {
return result;
};
define_special((quote datum), "TODO") {
+ profile_with_name("(quote)");
fetch(datum);
return datum;
};
define_special((quasiquote expr), "TODO") {
+ profile_with_name("(quasiquote)");
fetch(expr);
Lisp_Object* quasiquote_sym = Memory::get_or_create_lisp_object_symbol("quasiquote");
Lisp_Object* unquote_sym = Memory::get_or_create_lisp_object_symbol("unquote");
@@ -615,6 +644,7 @@ proc load_built_ins_into_environment() -> void* {
return expr;
};
define_special((and . args), "TODO") {
+ profile_with_name("(and)");
fetch(args);
bool result = true;
in_caller_env {
@@ -627,6 +657,7 @@ proc load_built_ins_into_environment() -> void* {
return Memory::t;
};
define_special((or . args), "TODO") {
+ profile_with_name("(or)");
fetch(args);
bool result = false;
in_caller_env {
@@ -639,6 +670,7 @@ proc load_built_ins_into_environment() -> void* {
return Memory::nil;
};
define_special((not test), "TODO") {
+ profile_with_name("(not)");
fetch(test);
bool truthy;
in_caller_env {
@@ -673,6 +705,7 @@ proc load_built_ins_into_environment() -> void* {
// // });
define_special((lambda args . body), "TODO") {
+ profile_with_name("(lambda)");
fetch(args, body);
// creating new lisp object and setting type
@@ -688,6 +721,7 @@ proc load_built_ins_into_environment() -> void* {
return func;
};
define((apply fun args), "TODO") {
+ profile_with_name("(apply)");
fetch(fun, args);
Lisp_Object* result;
@@ -696,6 +730,7 @@ proc load_built_ins_into_environment() -> void* {
return result;
};
define((eval expr), "TODO") {
+ profile_with_name("(eval)");
fetch(expr);
Lisp_Object* result;
@@ -706,6 +741,7 @@ proc load_built_ins_into_environment() -> void* {
return result;
};
define_special((begin . args), "TODO") {
+ profile_with_name("(begin)");
fetch(args);
Lisp_Object* result = Memory::nil;
in_caller_env {
@@ -716,10 +752,12 @@ proc load_built_ins_into_environment() -> void* {
return result;
};
define((list . args), "TODO") {
+ profile_with_name("(list)");
fetch(args);
return args;
};
define((hash-map . args), "TODO") {
+ profile_with_name("(hash-map)");
fetch(args);
Lisp_Object* ret;
try ret = Memory::create_lisp_object_hash_map();
@@ -732,6 +770,7 @@ proc load_built_ins_into_environment() -> void* {
return ret;
};
define((hash-map-get hm key), "TODO") {
+ profile_with_name("(hash-map-get)");
fetch(hm, key);
try assert_type(hm, Lisp_Object_Type::HashMap);
@@ -742,18 +781,21 @@ proc load_built_ins_into_environment() -> void* {
return ret;
};
define((hash-map-set! hm key value), "TODO") {
+ profile_with_name("(hash-map-set!)");
fetch(hm, key, value);
try assert_type(hm, Lisp_Object_Type::HashMap);
hm->value.hashMap->set_object(key, value);
return Memory::nil;
};
define((hash-map-delete! hm key), "TODO") {
+ profile_with_name("(hash-map-delete!)");
fetch(hm, key);
try assert_type(hm, Lisp_Object_Type::HashMap);
hm->value.hashMap->delete_object(key);
return Memory::nil;
};
define((vector . args), "TODO") {
+ profile_with_name("(vector)");
fetch(args);
Lisp_Object* ret;
int length = list_length(args);
@@ -761,6 +803,7 @@ proc load_built_ins_into_environment() -> void* {
return ret;
};
define((pair car cdr), "TODO") {
+ profile_with_name("(pair)");
fetch(car, cdr);
Lisp_Object* ret;
@@ -768,6 +811,7 @@ proc load_built_ins_into_environment() -> void* {
return ret;
};
define((first seq), "TODO") {
+ profile_with_name("(first)");
fetch(seq);
if (seq == Memory::nil)
return Memory::nil;
@@ -775,6 +819,7 @@ proc load_built_ins_into_environment() -> void* {
return seq->value.pair.first;
};
define((rest seq), "TODO") {
+ profile_with_name("(rest)");
fetch(seq);
if (seq == Memory::nil)
return Memory::nil;
@@ -782,17 +827,20 @@ proc load_built_ins_into_environment() -> void* {
return seq->value.pair.rest;
};
define((set-type! node new_type), "TODO") {
+ profile_with_name("(set-type!)");
fetch(node, new_type);
try assert_type(new_type, Lisp_Object_Type::Keyword);
node->userType = new_type;
return node;
};
define((delete-type! n), "TODO") {
+ profile_with_name("(delete-type!)");
fetch(n);
n->userType = nullptr;
return Memory::t;
};
define((type n), "TODO") {
+ profile_with_name("(type)");
fetch(n);
if (n->userType) {
@@ -828,6 +876,7 @@ proc load_built_ins_into_environment() -> void* {
return Memory::get_or_create_lisp_object_keyword("unknown");
};
define((mem-reset), "TODO") {
+ profile_with_name("(mem-reset)");
Memory::reset();
return Memory::nil;
};
@@ -837,6 +886,7 @@ proc load_built_ins_into_environment() -> void* {
// object. Otherwise (define k :doc "hallo" :keyword) would modify
// the global keyword
define_special((info n), "TODO") {
+ profile_with_name("(info)");
fetch(n);
print(n);
@@ -908,6 +958,7 @@ proc load_built_ins_into_environment() -> void* {
return Memory::nil;
};
define((show n), "TODO") {
+ profile_with_name("(show)");
fetch(n);
try assert_type(n, Lisp_Object_Type::Function);
@@ -920,11 +971,13 @@ proc load_built_ins_into_environment() -> void* {
return Memory::nil;
};
define((addr-of var), "TODO") {
+ profile_with_name("(addr-of-var)");
fetch(var);
return Memory::create_lisp_object_number(
(float)((u64)&(var)));
};
define((generate-docs file_name), "TODO") {
+ profile_with_name("(generate-docs)");
fetch(file_name);
try assert_type(file_name, Lisp_Object_Type::String);
in_caller_env {
@@ -933,6 +986,7 @@ proc load_built_ins_into_environment() -> void* {
return Memory::t;
};
define((print (:sep " ") (:end "\n") . things), "TODO") {
+ profile_with_name("(print)");
fetch(sep, end, things);
if (things != Memory::nil) {
@@ -948,6 +1002,7 @@ proc load_built_ins_into_environment() -> void* {
return Memory::nil;
};
define((read (:prompt ">")), "TODO") {
+ profile_with_name("(read)");
fetch(prompt);
print(prompt);
@@ -960,21 +1015,25 @@ proc load_built_ins_into_environment() -> void* {
return Memory::create_lisp_object_string(strLine);
};
define((exit (:code 0)), "TODO") {
+ profile_with_name("(exit)");
fetch(code);
try assert_type(code, Lisp_Object_Type::Number);
exit((int)code->value.number);
};
define((break), "TODO") {
+ profile_with_name("(break)");
in_caller_env {
print_environment(get_current_environment());
}
return Memory::nil;
};
define((memstat), "TODO") {
+ profile_with_name("(memstat)");
Memory::print_status();
return Memory::nil;
};
define_special((mytry try_part catch_part), "TODO") {
+ profile_with_name("(mytry)");
fetch(try_part, catch_part);
Lisp_Object* result;
@@ -993,6 +1052,7 @@ proc load_built_ins_into_environment() -> void* {
return result;
};
define((load file), "TODO") {
+ profile_with_name("(load)");
fetch(file);
try assert_type(file, Lisp_Object_Type::String);
@@ -1003,6 +1063,7 @@ proc load_built_ins_into_environment() -> void* {
return result;
};
define((import f), "TODO") {
+ profile_with_name("(import)");
fetch(f);
try assert_type(f, Lisp_Object_Type::String);
@@ -1014,12 +1075,14 @@ proc load_built_ins_into_environment() -> void* {
return Memory::t;
};
define((copy obj), "TODO") {
+ profile_with_name("(copy)");
fetch(obj);
// TODO(Felix): if we are copying string nodes, then
// shouldn't the string itself also get copied??
return Memory::copy_lisp_object(obj);
};
define((error type message), "TODO") {
+ profile_with_name("(error)");
fetch(type, message);
// TODO(Felix): make the error function useful
try assert_type(type, Lisp_Object_Type::Keyword);
@@ -1034,11 +1097,13 @@ proc load_built_ins_into_environment() -> void* {
return nullptr;
};
define((symbol->keyword sym), "TODO") {
+ profile_with_name("(symbol->keyword)");
fetch(sym);
try assert_type(sym, Lisp_Object_Type::Symbol);
return Memory::get_or_create_lisp_object_keyword(sym->value.symbol);
};
define((string->symbol str), "TODO") {
+ profile_with_name("(string->symbol)");
fetch(str);
// TODO(Felix): do some sanity checks on the string. For
// example, numbers are not valid symbols.
@@ -1048,6 +1113,7 @@ proc load_built_ins_into_environment() -> void* {
Memory::duplicate_string(str->value.string));
};
define((symbol->string sym), "TODO") {
+ profile_with_name("(symbol->string)");
fetch(sym);
try assert_type(sym, Lisp_Object_Type::Symbol);
@@ -1055,6 +1121,7 @@ proc load_built_ins_into_environment() -> void* {
Memory::duplicate_string(sym->value.symbol));
};
define((concat-strings . strings), "TODO") {
+ profile_with_name("(concat-strings)");
fetch(strings);
int resulting_string_len = 0;
@@ -1076,3 +1143,4 @@ proc load_built_ins_into_environment() -> void* {
};
return nullptr;
}
+
diff --git a/src/eval.cpp b/src/eval.cpp
index cf49e01..a08a3a0 100644
--- a/src/eval.cpp
+++ b/src/eval.cpp
@@ -3,7 +3,7 @@ proc create_extended_environment_for_function_application(
Lisp_Object* function,
bool should_evaluate) -> Environment*
{
- profile_this;
+ profile_this();
bool is_c_function = Memory::get_type(function) == Lisp_Object_Type::CFunction;
Environment* new_env;
Lisp_Object* arguments = unevaluated_arguments;
@@ -226,7 +226,7 @@ proc create_extended_environment_for_function_application(
}
proc apply_arguments_to_function(Lisp_Object* arguments, Lisp_Object* function, bool should_evaluate_args) -> Lisp_Object* {
- profile_this;
+ profile_this();
Environment* new_env;
Lisp_Object* result;
@@ -236,10 +236,12 @@ proc apply_arguments_to_function(Lisp_Object* arguments, Lisp_Object* function,
pop_environment();
};
- // if c function:
+
if (Memory::get_type(function) == Lisp_Object_Type::CFunction)
+ // if c function:
try result = function->value.cFunction->body();
- else // if lisp function
+ else
+ // if lisp function
try result = eval_expr(function->value.function->body);
return result;
@@ -357,7 +359,7 @@ proc copy_scl(Source_Code_Location*) -> Source_Code_Location* {
}
proc eval_arguments(Lisp_Object* arguments) -> Lisp_Object* {
- profile_this;
+ profile_this();
// int my_out_arguments_length = 0;
if (arguments == Memory::nil) {
// *(out_arguments_length) = 0;
@@ -393,7 +395,7 @@ proc eval_arguments(Lisp_Object* arguments) -> Lisp_Object* {
}
proc eval_expr(Lisp_Object* node) -> Lisp_Object* {
- profile_this;
+ profile_this();
using namespace Globals::Current_Execution;
call_stack.append(node);
diff --git a/src/gc.cpp b/src/gc.cpp
index f56c84b..5a892de 100644
--- a/src/gc.cpp
+++ b/src/gc.cpp
@@ -76,7 +76,7 @@ namespace GC {
}
proc garbage_collect() -> void {
- profile_this;
+ profile_this();
++current_mark;
for (auto it : protected_environments) maybe_mark(it);
diff --git a/src/io.cpp b/src/io.cpp
index 5847ecc..a1e9649 100644
--- a/src/io.cpp
+++ b/src/io.cpp
@@ -120,6 +120,7 @@ proc unescape_string(char* in) -> int {
}
proc read_entire_file(char* filename) -> char* {
+ profile_this();
char *fileContent = nullptr;
FILE *fp = fopen(filename, "r");
if (fp) {
diff --git a/src/memory.cpp b/src/memory.cpp
index bb327d6..6314443 100644
--- a/src/memory.cpp
+++ b/src/memory.cpp
@@ -161,6 +161,7 @@ namespace Memory {
}
proc init(int sms) -> void {
+ profile_this();
char* exe_path = get_exe_dir();
// don't free exe path because it will be used until end of time
add_to_load_path(exe_path);
@@ -192,8 +193,9 @@ namespace Memory {
}
proc reset() -> void {
- free_spots_in_string_memory.next_index = 0;
+ profile_this();
+ free_spots_in_string_memory.next_index = 0;
global_symbol_table.~Hash_Map();
global_keyword_table.~Hash_Map();
diff --git a/src/parse2.cpp b/src/parse2.cpp
index 1ce6494..f89e369 100644
--- a/src/parse2.cpp
+++ b/src/parse2.cpp
@@ -201,6 +201,7 @@ namespace Parser {
}
proc parse_atom(char* text, int* index_in_text) -> Lisp_Object* {
+ profile_this();
Lisp_Object* ret;
// numbers
if ((text[*index_in_text] <= 57 && // if number
@@ -231,7 +232,7 @@ namespace Parser {
proc parse_list(char* text, int* index_in_text) -> Lisp_Object* {
-
+ profile_this();
if (text[*index_in_text] != '(') {
create_parsing_error("a list cannot be parsed here");
return nullptr;
@@ -338,6 +339,7 @@ namespace Parser {
}
proc parse_expression(char* text, int* index_in_text) -> Lisp_Object* {
+ profile_this();
Lisp_Object* ret;
eat_until_code(text, index_in_text);
try ret = maybe_expand_short_form(text, index_in_text);
@@ -372,6 +374,7 @@ namespace Parser {
proc parse_program(String* file_name, char* text) -> Array_List* {
+ profile_this();
parser_file = file_name;
parser_line = 1;
parser_col = 0;