small bug fix; fixed timing on windows
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 3 Feb 2021 19:48:30 +0000 (13:48 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Wed, 3 Feb 2021 19:48:30 +0000 (13:48 -0600)
bin/onyx
core/memory.onyx
core/sys/js.onyx
core/sys/wasi.onyx
include/bh.h
onyx.exe
src/onyxclone.c

index dd26dece3b4043f70d2ac9a162a47005d9a25cc0..d7b1484a24c599b37f944fd5a7b36a16f96078f7 100755 (executable)
Binary files a/bin/onyx and b/bin/onyx differ
index 3ec079524c09252c3eab6975ffe0b4eafe455696..838acb585feec9dc4fe5a7fe7f3dc62874e179db 100644 (file)
@@ -1,11 +1,20 @@
 package core.memory
 
+// This will be replaced / augmented with a memory_copy intrinsic
+// when that is added to the compiler. There would be an easy flag
+// to control if this implementation is used, or the intrinsic. The
+// only case where this implementation should be used is in legacy
+// systems where the memory_copy instruction is not available.
+// However, it might be worth switching to an intrinsic completely
+// and having the intrinsic know whether or not to output the instruction
+// or an inlined version of this procedure.
 copy :: (dst_: rawptr, src_: rawptr, len: u32) {
     dst := cast(^u8) dst_;
     src := cast(^u8) src_;
     for i: 0 .. len do dst[i] = src[i];
 }
 
+// The same thing goes for this procedure too.
 set :: (start: rawptr, length: u32, value: u8) {
     s := cast(^u8) start;
     for i: 0 .. length do s[i] = value;
index f9b223c99978d794233fdbc43076e38047ed301a..4c6ea40da71ea840c7324ccf0d0c636071730050 100644 (file)
@@ -14,6 +14,8 @@ assert_handler :: (msg: str, file: str) {
         output_str(file);
     }
 
+    output_str("\n");
+
     process_exit :: proc (status: i32) #foreign "host" "exit" ---
     process_exit(1);
 }
index 6fc9122d9d14a783066d48be3c15845aa5fc10fa..c347c45abb23ab7c7c6b66f049bdf5cfb432e674 100644 (file)
@@ -25,6 +25,8 @@ assert_handler :: (msg: str, file: str) {
         output_str(file);
     }
 
+    output_str("\n");
+
     proc_exit(1);
 }
 
index f75dd1cfea125f34bcdfa7f8689f2e0394724f07..127e74ad9aabd027bc02e75fcc891400bedcc685 100644 (file)
@@ -2391,7 +2391,9 @@ void bh_imap_clear(bh_imap* imap) {
 
 u64 bh_time_curr() {
 #if defined(_BH_WINDOWS)
-    return clock();
+    LARGE_INTEGER result;
+    QueryPerformanceCounter(&result);
+    return (u64) result.QuadPart;
 
 #elif defined(_BH_LINUX)
     struct timespec spec;
@@ -2411,7 +2413,13 @@ u64 bh_time_curr() {
 u64 bh_time_duration(u64 old) {
 #if defined(_BH_WINDOWS)
     u64 curr = bh_time_curr();
-    return (u64) (((f64) (curr - old)) / CLOCKS_PER_SEC);
+    u64 duration = curr - old;
+    
+    LARGE_INTEGER freq;
+    QueryPerformanceFrequency(&freq);
+    duration *= 1000;
+    duration /= freq.QuadPart;
+    return duration;
 
 #elif defined(_BH_LINUX)
     u64 curr = bh_time_curr();
index c19b02d97a8a44e804c46c2d6c1e7dc3f4e256a7..1506e5e5613a039d8212ca73cd302de78252e67a 100644 (file)
Binary files a/onyx.exe and b/onyx.exe differ
index 07d8d678f63afe4c0fb967200bd8ccfc7ae5ca8e..15ba968ff20423789fd88f789d137187ec0d8842 100644 (file)
@@ -76,6 +76,7 @@ static inline i32 ast_kind_to_size(AstNode* node) {
         case Ast_Kind_Field_Access: return sizeof(AstFieldAccess);
         case Ast_Kind_Pipe: return sizeof(AstBinaryOp);
         case Ast_Kind_Range_Literal: return sizeof(AstRangeLiteral);
+        case Ast_Kind_Method_Call: return sizeof(AstBinaryOp);
         case Ast_Kind_Size_Of: return sizeof(AstSizeOf);
         case Ast_Kind_Align_Of: return sizeof(AstAlignOf);
         case Ast_Kind_File_Contents: return sizeof(AstFileContents);
@@ -131,6 +132,8 @@ AstNode* ast_clone(bh_allocator a, void* n) {
 
        switch ((u16) node->kind) {
                case Ast_Kind_Binary_Op:
+        case Ast_Kind_Pipe:
+        case Ast_Kind_Method_Call:
                        ((AstBinaryOp *) nn)->left  = (AstTyped *) ast_clone(a, ((AstBinaryOp *) node)->left);
                        ((AstBinaryOp *) nn)->right = (AstTyped *) ast_clone(a, ((AstBinaryOp *) node)->right);
                        break;