Merge branch 'next/vere' into jo/khan-c3

This commit is contained in:
Jōshin 2022-01-25 08:50:45 -08:00
commit aebce8dbf5
No known key found for this signature in database
GPG Key ID: A8BE5A9A521639D0
5 changed files with 35 additions and 87 deletions

View File

@ -14,6 +14,12 @@ let
version = builtins.readFile "${src}/version";
# See https://github.com/urbit/urbit/issues/5561
oFlags =
if stdenv.hostPlatform.system == "aarch64-darwin"
then (if enableDebug then [ "-O0" "-g" ] else [ "-O3" ])
else [ (if enableDebug then "-O0" else "-O3") "-g" ];
in stdenv.mkDerivation {
inherit src version;
@ -59,8 +65,7 @@ in stdenv.mkDerivation {
then [ "--disable-shared" "--enable-static" ]
else [];
CFLAGS = [ (if enableDebug then "-O0" else "-O3") "-g" ]
++ lib.optionals (!enableDebug) [ "-Werror" ];
CFLAGS = oFlags ++ lib.optionals (!enableDebug) [ "-Werror" ];
MEMORY_DEBUG = enableDebug;
CPU_DEBUG = enableDebug;

2
pkg/urbit/configure vendored
View File

@ -88,7 +88,7 @@ case $(tr A-Z a-z <<< $cpu) in
x86_64)
defmacro U3_OS_ENDIAN_little 1
;;
aarch64)
arm64|aarch64)
defmacro U3_OS_ENDIAN_little 1
defmacro U3_CPU_aarch64 1
;;

View File

@ -74,11 +74,6 @@
c3_o
u3e_live(c3_o nuu_o, c3_c* dir_c);
/* u3e_dirty(): count dirty pages.
*/
c3_w
u3e_dirty(void);
/* u3e_yolo(): disable dirty page tracking, read/write whole loom.
*/
c3_o

View File

@ -123,13 +123,13 @@ u3e_fault(void* adr_v, c3_i ser_i)
c3_w* adr_w = (c3_w*) adr_v;
if ( (adr_w < u3_Loom) || (adr_w >= (u3_Loom + u3a_words)) ) {
fprintf(stderr, "address %p out of loom!\r\n", adr_v);
fprintf(stderr, "address %p out of loom!\r\n", adr_w);
fprintf(stderr, "loom: [%p : %p)\r\n", u3_Loom, u3_Loom + u3a_words);
c3_assert(0);
return 0;
}
else {
c3_w off_w = (adr_w - u3_Loom);
c3_w off_w = u3a_outa(adr_w);
c3_w pag_w = off_w >> u3a_page;
c3_w blk_w = (pag_w >> 5);
c3_w bit_w = (pag_w & 31);
@ -471,62 +471,6 @@ _ce_patch_save_page(u3_ce_patch* pat_u,
return pgc_w;
}
/* _ce_patch_junk_page(): mark a page as junk.
*/
static void
_ce_patch_junk_page(u3_ce_patch* pat_u,
c3_w pag_w)
{
c3_w blk_w = (pag_w >> 5);
c3_w bit_w = (pag_w & 31);
// u3l_log("protect b: page %d\r\n", pag_w);
if ( -1 == mprotect(u3_Loom + (pag_w << u3a_page),
(1 << (u3a_page + 2)),
PROT_READ) )
{
c3_assert(0);
}
u3P.dit_w[blk_w] &= ~(1 << bit_w);
}
/* u3e_dirty(): count dirty pages.
*/
c3_w
u3e_dirty(void)
{
c3_w pgs_w = 0;
c3_w nor_w = 0;
c3_w sou_w = 0;
/* Calculate number of saved pages, north and south.
*/
{
c3_w nwr_w, swu_w;
u3m_water(&nwr_w, &swu_w);
nor_w = (nwr_w + ((1 << u3a_page) - 1)) >> u3a_page;
sou_w = (swu_w + ((1 << u3a_page) - 1)) >> u3a_page;
}
// u3K.nor_w = nor_w;
// u3K.sou_w = sou_w;
/* Count dirty pages.
*/
{
c3_w i_w;
for ( i_w = 0; i_w < nor_w; i_w++ ) {
pgs_w = _ce_patch_count_page(i_w, pgs_w);
}
for ( i_w = 0; i_w < sou_w; i_w++ ) {
pgs_w = _ce_patch_count_page((u3a_pages - (i_w + 1)), pgs_w);
}
}
return pgs_w;
}
/* _ce_patch_compose(): make and write current patch.
*/
static u3_ce_patch*
@ -583,9 +527,6 @@ _ce_patch_compose(void)
for ( i_w = 0; i_w < sou_w; i_w++ ) {
pgc_w = _ce_patch_save_page(pat_u, (u3a_pages - (i_w + 1)), pgc_w);
}
for ( i_w = nor_w; i_w < (u3a_pages - sou_w); i_w++ ) {
_ce_patch_junk_page(pat_u, i_w);
}
pat_u->con_u->nor_w = nor_w;
pat_u->con_u->sou_w = sou_w;
@ -710,23 +651,30 @@ _ce_image_blit(u3e_image* img_u,
c3_w* ptr_w,
c3_ws stp_ws)
{
if ( 0 == img_u->pgs_w ) {
return;
}
c3_w i_w;
c3_w siz_w = 1 << (u3a_page + 2);
lseek(img_u->fid_i, 0, SEEK_SET);
for ( i_w=0; i_w < img_u->pgs_w; i_w++ ) {
if ( -1 == read(img_u->fid_i, ptr_w, (1 << (u3a_page + 2))) ) {
for ( i_w = 0; i_w < img_u->pgs_w; i_w++ ) {
if ( -1 == read(img_u->fid_i, ptr_w, siz_w) ) {
fprintf(stderr, "loom: image blit read: %s\r\n", strerror(errno));
c3_assert(0);
}
#if 0
{
c3_w off_w = (ptr_w - u3_Loom);
c3_w pag_w = (off_w >> u3a_page);
u3l_log("blit: page %d, mug %x\r\n", pag_w,
u3r_mug_words(ptr_w, (1 << u3a_page)));
if ( 0 != mprotect(ptr_w, siz_w, PROT_READ) ) {
fprintf(stderr, "loom: live mprotect: %s\r\n", strerror(errno));
c3_assert(0);
}
#endif
c3_w pag_w = u3a_outa(ptr_w) >> u3a_page;
c3_w blk_w = pag_w >> 5;
c3_w bit_w = pag_w & 31;
u3P.dit_w[blk_w] &= ~(1 << bit_w);
ptr_w += stp_ws;
}
}
@ -976,17 +924,16 @@ u3e_live(c3_o nuu_o, c3_c* dir_c)
(u3_Loom + (1 << u3a_bits) - (1 << u3a_page)),
-(1 << u3a_page));
if ( 0 != mprotect((void *)u3_Loom, u3a_bytes, PROT_READ) ) {
u3l_log("loom: live mprotect: %s\r\n", strerror(errno));
c3_assert(0);
}
u3l_log("boot: protected loom\r\n");
}
/* If the images were empty, we are logically booting.
/* If the images were empty, we are logically booting. By default, we mark
** all pages as dirty, which enables us to track only home road pages by
** marking those as clean when they're mapped into memory from the
** snapshot on a future boot for which the images are not empty.
*/
if ( (0 == u3P.nor_u.pgs_w) && (0 == u3P.sou_u.pgs_w) ) {
u3e_foul();
u3l_log("live: logical boot\r\n");
nuu_o = c3y;
}
@ -1018,5 +965,5 @@ u3e_yolo(void)
void
u3e_foul(void)
{
memset((void*)u3P.dit_w, 0xff, u3a_pages >> 3);
memset((void*)u3P.dit_w, 0xff, sizeof(u3P.dit_w));
}

View File

@ -751,10 +751,11 @@ u3_disk_init(c3_c* pax_c, u3_disk_cb cb_u)
// "[..] on 64-bit there is no penalty for making this huge (say 1TB)."
//
{
const size_t siz_i =
#if (defined(U3_CPU_aarch64) && defined(U3_OS_linux)) || defined(U3_OS_mingw)
const size_t siz_i = 64424509440;
0xf00000000;
#else
const size_t siz_i = 1099511627776;
0x10000000000;
#endif
if ( 0 == (log_u->mdb_u = u3_lmdb_init(log_c, siz_i)) ) {