From: Brendan Hansen Date: Wed, 3 Feb 2021 19:48:30 +0000 (-0600) Subject: small bug fix; fixed timing on windows X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=0b6dbbcec8ce876b21f1185b94ff8216c22b9457;p=onyx.git small bug fix; fixed timing on windows --- diff --git a/bin/onyx b/bin/onyx index dd26dece..d7b1484a 100755 Binary files a/bin/onyx and b/bin/onyx differ diff --git a/core/memory.onyx b/core/memory.onyx index 3ec07952..838acb58 100644 --- a/core/memory.onyx +++ b/core/memory.onyx @@ -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; diff --git a/core/sys/js.onyx b/core/sys/js.onyx index f9b223c9..4c6ea40d 100644 --- a/core/sys/js.onyx +++ b/core/sys/js.onyx @@ -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); } diff --git a/core/sys/wasi.onyx b/core/sys/wasi.onyx index 6fc9122d..c347c45a 100644 --- a/core/sys/wasi.onyx +++ b/core/sys/wasi.onyx @@ -25,6 +25,8 @@ assert_handler :: (msg: str, file: str) { output_str(file); } + output_str("\n"); + proc_exit(1); } diff --git a/include/bh.h b/include/bh.h index f75dd1cf..127e74ad 100644 --- a/include/bh.h +++ b/include/bh.h @@ -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(); diff --git a/onyx.exe b/onyx.exe index c19b02d9..1506e5e5 100644 Binary files a/onyx.exe and b/onyx.exe differ diff --git a/src/onyxclone.c b/src/onyxclone.c index 07d8d678..15ba968f 100644 --- a/src/onyxclone.c +++ b/src/onyxclone.c @@ -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;