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;
output_str(file);
}
+ output_str("\n");
+
process_exit :: proc (status: i32) #foreign "host" "exit" ---
process_exit(1);
}
output_str(file);
}
+ output_str("\n");
+
proc_exit(1);
}
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;
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();
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);
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;