mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 07:32:23 -07:00
promote content scope to base layer, rename as 'access'; generalize based just on list of scope refcounts, + optional cvs; eliminate c_scope; replace dasm_scope with access as well
This commit is contained in:
@@ -130,3 +130,58 @@ tctx_read_srcloc(char **file_name, U64 *line_number)
|
||||
*file_name = tctx->file_name;
|
||||
*line_number = tctx->line_number;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Touch Scope Functions
|
||||
|
||||
internal Access *
|
||||
access_open(void)
|
||||
{
|
||||
if(tctx_thread_local->access_arena == 0)
|
||||
{
|
||||
tctx_thread_local->access_arena = arena_alloc();
|
||||
}
|
||||
Access *access = tctx_thread_local->free_access;
|
||||
if(access != 0)
|
||||
{
|
||||
SLLStackPop(tctx_thread_local->free_access);
|
||||
}
|
||||
else
|
||||
{
|
||||
access = push_array_no_zero(tctx_thread_local->access_arena, Access, 1);
|
||||
}
|
||||
MemoryZeroStruct(access);
|
||||
return access;
|
||||
}
|
||||
|
||||
internal void
|
||||
access_close(Access *access)
|
||||
{
|
||||
for(Touch *touch = access->top_touch, *next = 0; touch != 0; touch = next)
|
||||
{
|
||||
next = touch->next;
|
||||
ins_atomic_u64_dec_eval(touch->touch_count);
|
||||
if(touch->cv.u64[0] != 0) { cond_var_broadcast(touch->cv); }
|
||||
SLLStackPush(tctx_thread_local->free_touch, touch);
|
||||
}
|
||||
SLLStackPush(tctx_thread_local->free_access, access);
|
||||
}
|
||||
|
||||
internal void
|
||||
access_touch(Access *access, U64 *touch_count, CondVar cv)
|
||||
{
|
||||
ins_atomic_u64_inc_eval(touch_count);
|
||||
Touch *touch = tctx_thread_local->free_touch;
|
||||
if(touch != 0)
|
||||
{
|
||||
SLLStackPop(tctx_thread_local->free_touch);
|
||||
}
|
||||
else
|
||||
{
|
||||
touch = push_array_no_zero(tctx_thread_local->access_arena, Touch, 1);
|
||||
}
|
||||
MemoryZeroStruct(touch);
|
||||
SLLStackPush(access->top_touch, touch);
|
||||
touch->cv = cv;
|
||||
touch->touch_count = touch_count;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,24 @@ struct LaneCtx
|
||||
Barrier barrier;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Access Scopes
|
||||
|
||||
typedef struct Touch Touch;
|
||||
struct Touch
|
||||
{
|
||||
Touch *next;
|
||||
U64 *touch_count;
|
||||
CondVar cv;
|
||||
};
|
||||
|
||||
typedef struct Access Access;
|
||||
struct Access
|
||||
{
|
||||
Access *next;
|
||||
Touch *top_touch;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Base Per-Thread State Bundle
|
||||
|
||||
@@ -34,6 +52,11 @@ struct TCTX
|
||||
// rjf: source location info
|
||||
char *file_name;
|
||||
U64 line_number;
|
||||
|
||||
// rjf: accesses
|
||||
Arena *access_arena;
|
||||
Access *free_access;
|
||||
Touch *free_touch;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
@@ -69,4 +92,9 @@ internal void tctx_write_srcloc(char *file_name, U64 line_number);
|
||||
internal void tctx_read_srcloc(char **file_name, U64 *line_number);
|
||||
#define tctx_write_this_srcloc() tctx_write_srcloc(__FILE__, __LINE__)
|
||||
|
||||
//- rjf: access scopes
|
||||
internal Access *access_open(void);
|
||||
internal void access_close(Access *access);
|
||||
internal void access_touch(Access *access, U64 *touch_count, CondVar cv);
|
||||
|
||||
#endif // BASE_THREAD_CONTEXT_H
|
||||
|
||||
+40
-110
@@ -67,14 +67,14 @@ c_init(void)
|
||||
Arena *arena = arena_alloc();
|
||||
c_shared = push_array(arena, C_Shared, 1);
|
||||
c_shared->arena = arena;
|
||||
c_shared->slots_count = 4096;
|
||||
c_shared->stripes_count = Min(c_shared->slots_count, os_get_system_info()->logical_processor_count);
|
||||
c_shared->slots = push_array(arena, C_BlobSlot, c_shared->slots_count);
|
||||
c_shared->stripes = push_array(arena, C_Stripe, c_shared->stripes_count);
|
||||
c_shared->stripes_free_nodes = push_array(arena, C_BlobNode *, c_shared->stripes_count);
|
||||
for(U64 idx = 0; idx < c_shared->stripes_count; idx += 1)
|
||||
c_shared->blob_slots_count = 16384;
|
||||
c_shared->blob_stripes_count = Min(c_shared->blob_slots_count, os_get_system_info()->logical_processor_count);
|
||||
c_shared->blob_slots = push_array(arena, C_BlobSlot, c_shared->blob_slots_count);
|
||||
c_shared->blob_stripes = push_array(arena, C_Stripe, c_shared->blob_stripes_count);
|
||||
c_shared->blob_stripes_free_nodes = push_array(arena, C_BlobNode *, c_shared->blob_stripes_count);
|
||||
for(U64 idx = 0; idx < c_shared->blob_stripes_count; idx += 1)
|
||||
{
|
||||
C_Stripe *stripe = &c_shared->stripes[idx];
|
||||
C_Stripe *stripe = &c_shared->blob_stripes[idx];
|
||||
stripe->arena = arena_alloc();
|
||||
stripe->rw_mutex = rw_mutex_alloc();
|
||||
stripe->cv = cond_var_alloc();
|
||||
@@ -184,10 +184,10 @@ c_root_release(C_Root root)
|
||||
for(U64 history_idx = 0; history_idx < C_KEY_HASH_HISTORY_STRONG_REF_COUNT && history_idx < n->hash_history_gen; history_idx += 1)
|
||||
{
|
||||
U128 hash = n->hash_history[(n->hash_history_gen+history_idx)%ArrayCount(n->hash_history)];
|
||||
U64 hash_slot_idx = hash.u64[1]%c_shared->slots_count;
|
||||
U64 hash_stripe_idx = hash_slot_idx%c_shared->stripes_count;
|
||||
C_BlobSlot *hash_slot = &c_shared->slots[hash_slot_idx];
|
||||
C_Stripe *hash_stripe = &c_shared->stripes[hash_stripe_idx];
|
||||
U64 hash_slot_idx = hash.u64[1]%c_shared->blob_slots_count;
|
||||
U64 hash_stripe_idx = hash_slot_idx%c_shared->blob_stripes_count;
|
||||
C_BlobSlot *hash_slot = &c_shared->blob_slots[hash_slot_idx];
|
||||
C_Stripe *hash_stripe = &c_shared->blob_stripes[hash_stripe_idx];
|
||||
MutexScopeR(hash_stripe->rw_mutex)
|
||||
{
|
||||
for(C_BlobNode *n = hash_slot->first; n != 0; n = n->next)
|
||||
@@ -224,10 +224,10 @@ c_submit_data(C_Key key, Arena **data_arena, String8 data)
|
||||
C_KeySlot *key_slot = &c_shared->key_slots[key_slot_idx];
|
||||
C_Stripe *key_stripe = &c_shared->key_stripes[key_stripe_idx];
|
||||
U128 hash = c_hash_from_data(data);
|
||||
U64 slot_idx = hash.u64[1]%c_shared->slots_count;
|
||||
U64 stripe_idx = slot_idx%c_shared->stripes_count;
|
||||
C_BlobSlot *slot = &c_shared->slots[slot_idx];
|
||||
C_Stripe *stripe = &c_shared->stripes[stripe_idx];
|
||||
U64 slot_idx = hash.u64[1]%c_shared->blob_slots_count;
|
||||
U64 stripe_idx = slot_idx%c_shared->blob_stripes_count;
|
||||
C_BlobSlot *slot = &c_shared->blob_slots[slot_idx];
|
||||
C_Stripe *stripe = &c_shared->blob_stripes[stripe_idx];
|
||||
|
||||
//- rjf: commit data to cache - if already there, just bump key refcount
|
||||
ProfScope("commit data to cache - if already there, just bump key refcount") MutexScopeW(stripe->rw_mutex)
|
||||
@@ -243,10 +243,10 @@ c_submit_data(C_Key key, Arena **data_arena, String8 data)
|
||||
}
|
||||
if(existing_node == 0)
|
||||
{
|
||||
C_BlobNode *node = c_shared->stripes_free_nodes[stripe_idx];
|
||||
C_BlobNode *node = c_shared->blob_stripes_free_nodes[stripe_idx];
|
||||
if(node)
|
||||
{
|
||||
SLLStackPop(c_shared->stripes_free_nodes[stripe_idx]);
|
||||
SLLStackPop(c_shared->blob_stripes_free_nodes[stripe_idx]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -357,10 +357,10 @@ c_submit_data(C_Key key, Arena **data_arena, String8 data)
|
||||
ProfScope("decrement key ref count of expired hash")
|
||||
if(!u128_match(key_expired_hash, u128_zero()))
|
||||
{
|
||||
U64 old_hash_slot_idx = key_expired_hash.u64[1]%c_shared->slots_count;
|
||||
U64 old_hash_stripe_idx = old_hash_slot_idx%c_shared->stripes_count;
|
||||
C_BlobSlot *old_hash_slot = &c_shared->slots[old_hash_slot_idx];
|
||||
C_Stripe *old_hash_stripe = &c_shared->stripes[old_hash_stripe_idx];
|
||||
U64 old_hash_slot_idx = key_expired_hash.u64[1]%c_shared->blob_slots_count;
|
||||
U64 old_hash_stripe_idx = old_hash_slot_idx%c_shared->blob_stripes_count;
|
||||
C_BlobSlot *old_hash_slot = &c_shared->blob_slots[old_hash_slot_idx];
|
||||
C_Stripe *old_hash_stripe = &c_shared->blob_stripes[old_hash_stripe_idx];
|
||||
MutexScopeR(old_hash_stripe->rw_mutex)
|
||||
{
|
||||
for(C_BlobNode *n = old_hash_slot->first; n != 0; n = n->next)
|
||||
@@ -377,86 +377,16 @@ c_submit_data(C_Key key, Arena **data_arena, String8 data)
|
||||
return hash;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Scoped Access
|
||||
|
||||
internal C_Scope *
|
||||
c_scope_open(void)
|
||||
{
|
||||
if(c_tctx == 0)
|
||||
{
|
||||
Arena *arena = arena_alloc();
|
||||
c_tctx = push_array(arena, C_TCTX, 1);
|
||||
c_tctx->arena = arena;
|
||||
}
|
||||
C_Scope *scope = c_tctx->free_scope;
|
||||
if(scope)
|
||||
{
|
||||
SLLStackPop(c_tctx->free_scope);
|
||||
}
|
||||
else
|
||||
{
|
||||
scope = push_array_no_zero(c_tctx->arena, C_Scope, 1);
|
||||
}
|
||||
MemoryZeroStruct(scope);
|
||||
return scope;
|
||||
}
|
||||
|
||||
internal void
|
||||
c_scope_close(C_Scope *scope)
|
||||
{
|
||||
for(C_Touch *touch = scope->top_touch, *next = 0; touch != 0; touch = next)
|
||||
{
|
||||
U128 hash = touch->hash;
|
||||
next = touch->next;
|
||||
U64 slot_idx = hash.u64[1]%c_shared->slots_count;
|
||||
U64 stripe_idx = slot_idx%c_shared->stripes_count;
|
||||
C_BlobSlot *slot = &c_shared->slots[slot_idx];
|
||||
C_Stripe *stripe = &c_shared->stripes[stripe_idx];
|
||||
MutexScopeR(stripe->rw_mutex)
|
||||
{
|
||||
for(C_BlobNode *n = slot->first; n != 0; n = n->next)
|
||||
{
|
||||
if(u128_match(hash, n->hash))
|
||||
{
|
||||
ins_atomic_u64_dec_eval(&n->scope_ref_count);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SLLStackPush(c_tctx->free_touch, touch);
|
||||
}
|
||||
SLLStackPush(c_tctx->free_scope, scope);
|
||||
}
|
||||
|
||||
internal void
|
||||
c_scope_touch_node__stripe_r_guarded(C_Scope *scope, C_BlobNode *node)
|
||||
{
|
||||
C_Touch *touch = c_tctx->free_touch;
|
||||
ins_atomic_u64_inc_eval(&node->scope_ref_count);
|
||||
if(touch != 0)
|
||||
{
|
||||
SLLStackPop(c_tctx->free_touch);
|
||||
}
|
||||
else
|
||||
{
|
||||
touch = push_array_no_zero(c_tctx->arena, C_Touch, 1);
|
||||
}
|
||||
MemoryZeroStruct(touch);
|
||||
touch->hash = node->hash;
|
||||
SLLStackPush(scope->top_touch, touch);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Downstream Accesses
|
||||
|
||||
internal void
|
||||
c_hash_downstream_inc(U128 hash)
|
||||
{
|
||||
U64 slot_idx = hash.u64[1]%c_shared->slots_count;
|
||||
U64 stripe_idx = slot_idx%c_shared->stripes_count;
|
||||
C_BlobSlot *slot = &c_shared->slots[slot_idx];
|
||||
C_Stripe *stripe = &c_shared->stripes[stripe_idx];
|
||||
U64 slot_idx = hash.u64[1]%c_shared->blob_slots_count;
|
||||
U64 stripe_idx = slot_idx%c_shared->blob_stripes_count;
|
||||
C_BlobSlot *slot = &c_shared->blob_slots[slot_idx];
|
||||
C_Stripe *stripe = &c_shared->blob_stripes[stripe_idx];
|
||||
MutexScopeR(stripe->rw_mutex)
|
||||
{
|
||||
for(C_BlobNode *n = slot->first; n != 0; n = n->next)
|
||||
@@ -473,10 +403,10 @@ c_hash_downstream_inc(U128 hash)
|
||||
internal void
|
||||
c_hash_downstream_dec(U128 hash)
|
||||
{
|
||||
U64 slot_idx = hash.u64[1]%c_shared->slots_count;
|
||||
U64 stripe_idx = slot_idx%c_shared->stripes_count;
|
||||
C_BlobSlot *slot = &c_shared->slots[slot_idx];
|
||||
C_Stripe *stripe = &c_shared->stripes[stripe_idx];
|
||||
U64 slot_idx = hash.u64[1]%c_shared->blob_slots_count;
|
||||
U64 stripe_idx = slot_idx%c_shared->blob_stripes_count;
|
||||
C_BlobSlot *slot = &c_shared->blob_slots[slot_idx];
|
||||
C_Stripe *stripe = &c_shared->blob_stripes[stripe_idx];
|
||||
MutexScopeR(stripe->rw_mutex)
|
||||
{
|
||||
for(C_BlobNode *n = slot->first; n != 0; n = n->next)
|
||||
@@ -517,14 +447,14 @@ c_hash_from_key(C_Key key, U64 rewind_count)
|
||||
}
|
||||
|
||||
internal String8
|
||||
c_data_from_hash(C_Scope *scope, U128 hash)
|
||||
c_data_from_hash(Access *access, U128 hash)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
String8 result = {0};
|
||||
U64 slot_idx = hash.u64[1]%c_shared->slots_count;
|
||||
U64 stripe_idx = slot_idx%c_shared->stripes_count;
|
||||
C_BlobSlot *slot = &c_shared->slots[slot_idx];
|
||||
C_Stripe *stripe = &c_shared->stripes[stripe_idx];
|
||||
U64 slot_idx = hash.u64[1]%c_shared->blob_slots_count;
|
||||
U64 stripe_idx = slot_idx%c_shared->blob_stripes_count;
|
||||
C_BlobSlot *slot = &c_shared->blob_slots[slot_idx];
|
||||
C_Stripe *stripe = &c_shared->blob_stripes[stripe_idx];
|
||||
MutexScopeR(stripe->rw_mutex)
|
||||
{
|
||||
for(C_BlobNode *n = slot->first; n != 0; n = n->next)
|
||||
@@ -532,7 +462,7 @@ c_data_from_hash(C_Scope *scope, U128 hash)
|
||||
if(u128_match(n->hash, hash))
|
||||
{
|
||||
result = n->data;
|
||||
c_scope_touch_node__stripe_r_guarded(scope, n);
|
||||
access_touch(access, &n->scope_ref_count, stripe->cv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -548,12 +478,12 @@ internal void
|
||||
c_tick(void)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
Rng1U64 range = lane_range(c_shared->slots_count);
|
||||
Rng1U64 range = lane_range(c_shared->blob_slots_count);
|
||||
for EachInRange(slot_idx, range)
|
||||
{
|
||||
U64 stripe_idx = slot_idx%c_shared->stripes_count;
|
||||
C_BlobSlot *slot = &c_shared->slots[slot_idx];
|
||||
C_Stripe *stripe = &c_shared->stripes[stripe_idx];
|
||||
U64 stripe_idx = slot_idx%c_shared->blob_stripes_count;
|
||||
C_BlobSlot *slot = &c_shared->blob_slots[slot_idx];
|
||||
C_Stripe *stripe = &c_shared->blob_stripes[stripe_idx];
|
||||
B32 slot_has_work = 0;
|
||||
MutexScopeR(stripe->rw_mutex)
|
||||
{
|
||||
@@ -580,7 +510,7 @@ c_tick(void)
|
||||
if(key_ref_count == 0 && scope_ref_count == 0 && downstream_ref_count == 0)
|
||||
{
|
||||
DLLRemove(slot->first, slot->last, n);
|
||||
SLLStackPush(c_shared->stripes_free_nodes[stripe_idx], n);
|
||||
SLLStackPush(c_shared->blob_stripes_free_nodes[stripe_idx], n);
|
||||
if(n->arena != 0)
|
||||
{
|
||||
arena_release(n->arena);
|
||||
|
||||
+7
-43
@@ -155,34 +155,6 @@ struct C_Stripe
|
||||
CondVar cv;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Scoped Access
|
||||
|
||||
typedef struct C_Touch C_Touch;
|
||||
struct C_Touch
|
||||
{
|
||||
C_Touch *next;
|
||||
U128 hash;
|
||||
};
|
||||
|
||||
typedef struct C_Scope C_Scope;
|
||||
struct C_Scope
|
||||
{
|
||||
C_Scope *next;
|
||||
C_Touch *top_touch;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Thread Context
|
||||
|
||||
typedef struct C_TCTX C_TCTX;
|
||||
struct C_TCTX
|
||||
{
|
||||
Arena *arena;
|
||||
C_Scope *free_scope;
|
||||
C_Touch *free_touch;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Shared State
|
||||
|
||||
@@ -191,12 +163,12 @@ struct C_Shared
|
||||
{
|
||||
Arena *arena;
|
||||
|
||||
// rjf: main data cache
|
||||
U64 slots_count;
|
||||
U64 stripes_count;
|
||||
C_BlobSlot *slots;
|
||||
C_Stripe *stripes;
|
||||
C_BlobNode **stripes_free_nodes;
|
||||
// rjf: main data blob cache
|
||||
U64 blob_slots_count;
|
||||
U64 blob_stripes_count;
|
||||
C_BlobSlot *blob_slots;
|
||||
C_Stripe *blob_stripes;
|
||||
C_BlobNode **blob_stripes_free_nodes;
|
||||
|
||||
// rjf: key cache
|
||||
U64 key_slots_count;
|
||||
@@ -217,7 +189,6 @@ struct C_Shared
|
||||
////////////////////////////////
|
||||
//~ rjf: Globals
|
||||
|
||||
thread_static C_TCTX *c_tctx = 0;
|
||||
global C_Shared *c_shared = 0;
|
||||
|
||||
////////////////////////////////
|
||||
@@ -246,13 +217,6 @@ internal void c_root_release(C_Root root);
|
||||
|
||||
internal U128 c_submit_data(C_Key key, Arena **data_arena, String8 data);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Scoped Access
|
||||
|
||||
internal C_Scope *c_scope_open(void);
|
||||
internal void c_scope_close(C_Scope *scope);
|
||||
internal void c_scope_touch_node__stripe_r_guarded(C_Scope *scope, C_BlobNode *node);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Downstream Accesses
|
||||
|
||||
@@ -263,7 +227,7 @@ internal void c_hash_downstream_dec(U128 hash);
|
||||
//~ rjf: Cache Lookups
|
||||
|
||||
internal U128 c_hash_from_key(C_Key key, U64 rewind_count);
|
||||
internal String8 c_data_from_hash(C_Scope *scope, U128 hash);
|
||||
internal String8 c_data_from_hash(Access *access, U128 hash);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Tick
|
||||
|
||||
@@ -1851,7 +1851,7 @@ ctrl_process_memory_slice_from_vaddr_range(Arena *arena, CTRL_Handle process, Rn
|
||||
range.max <= 0x000FFFFFFFFFFFFFull)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
C_Scope *scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
CTRL_ProcessMemoryCache *cache = &ctrl_state->process_memory_cache;
|
||||
|
||||
//- rjf: unpack address range, prepare per-touched-page info
|
||||
@@ -1889,7 +1889,7 @@ ctrl_process_memory_slice_from_vaddr_range(Arena *arena, CTRL_Handle process, Rn
|
||||
for(U64 page_idx = 0; page_idx < page_count; page_idx += 1)
|
||||
{
|
||||
// rjf: read data for this page
|
||||
String8 data = c_data_from_hash(scope, page_hashes[page_idx]);
|
||||
String8 data = c_data_from_hash(access, page_hashes[page_idx]);
|
||||
Rng1U64 data_vaddr_range = r1u64(page_range.min + page_idx*page_size, page_range.min + page_idx*page_size+data.size);
|
||||
|
||||
// rjf: skip/chop bytes which are irrelevant for the actual requested read
|
||||
@@ -1925,7 +1925,7 @@ ctrl_process_memory_slice_from_vaddr_range(Arena *arena, CTRL_Handle process, Rn
|
||||
// fill out changed flags
|
||||
if(!u128_match(page_hashes[page_idx], page_last_hashes[page_idx])) ProfScope("hashes don't match; diff each byte")
|
||||
{
|
||||
String8 last_data = c_data_from_hash(scope, page_last_hashes[page_idx]);
|
||||
String8 last_data = c_data_from_hash(access, page_last_hashes[page_idx]);
|
||||
String8 in_range_last_data = last_data;
|
||||
if(page_idx == page_count-1 && data_vaddr_range.max > range.max)
|
||||
{
|
||||
@@ -1977,7 +1977,7 @@ ctrl_process_memory_slice_from_vaddr_range(Arena *arena, CTRL_Handle process, Rn
|
||||
}
|
||||
}
|
||||
|
||||
c_scope_close(scope);
|
||||
access_close(access);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
ProfEnd();
|
||||
|
||||
+10
-64
@@ -277,67 +277,11 @@ dasm_init(void)
|
||||
dasm_shared->req_arena = arena_alloc();
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Scoped Access
|
||||
|
||||
internal DASM_Scope *
|
||||
dasm_scope_open(void)
|
||||
{
|
||||
if(dasm_tctx == 0)
|
||||
{
|
||||
Arena *arena = arena_alloc();
|
||||
dasm_tctx = push_array(arena, DASM_TCTX, 1);
|
||||
dasm_tctx->arena = arena;
|
||||
}
|
||||
U64 base_pos = arena_pos(dasm_tctx->arena);
|
||||
DASM_Scope *scope = push_array(dasm_tctx->arena, DASM_Scope, 1);
|
||||
scope->base_pos = base_pos;
|
||||
return scope;
|
||||
}
|
||||
|
||||
internal void
|
||||
dasm_scope_close(DASM_Scope *scope)
|
||||
{
|
||||
for(DASM_Touch *t = scope->top_touch, *next = 0; t != 0; t = next)
|
||||
{
|
||||
next = t->next;
|
||||
U64 slot_idx = t->hash.u64[1]%dasm_shared->slots_count;
|
||||
U64 stripe_idx = slot_idx%dasm_shared->stripes_count;
|
||||
DASM_Slot *slot = &dasm_shared->slots[slot_idx];
|
||||
DASM_Stripe *stripe = &dasm_shared->stripes[stripe_idx];
|
||||
MutexScopeR(stripe->rw_mutex)
|
||||
{
|
||||
for(DASM_Node *n = slot->first; n != 0; n = n->next)
|
||||
{
|
||||
if(u128_match(t->hash, n->hash) && dasm_params_match(&t->params, &n->params))
|
||||
{
|
||||
ins_atomic_u64_dec_eval(&n->scope_ref_count);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
arena_pop_to(dasm_tctx->arena, scope->base_pos);
|
||||
}
|
||||
|
||||
internal void
|
||||
dasm_scope_touch_node__stripe_r_guarded(DASM_Scope *scope, DASM_Node *node)
|
||||
{
|
||||
DASM_Touch *touch = push_array(dasm_tctx->arena, DASM_Touch, 1);
|
||||
ins_atomic_u64_inc_eval(&node->scope_ref_count);
|
||||
ins_atomic_u64_eval_assign(&node->last_time_touched_us, os_now_microseconds());
|
||||
ins_atomic_u64_eval_assign(&node->last_user_clock_idx_touched, update_tick_idx());
|
||||
touch->hash = node->hash;
|
||||
MemoryCopyStruct(&touch->params, &node->params);
|
||||
touch->params.dbgi_key = di_key_copy(dasm_tctx->arena, &touch->params.dbgi_key);
|
||||
SLLStackPush(scope->top_touch, touch);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Cache Lookups
|
||||
|
||||
internal DASM_Info
|
||||
dasm_info_from_hash_params(DASM_Scope *scope, U128 hash, DASM_Params *params)
|
||||
dasm_info_from_hash_params(Access *access, U128 hash, DASM_Params *params)
|
||||
{
|
||||
DASM_Info info = {0};
|
||||
if(!u128_match(hash, u128_zero()))
|
||||
@@ -402,7 +346,9 @@ dasm_info_from_hash_params(DASM_Scope *scope, U128 hash, DASM_Params *params)
|
||||
// rjf: nonzero node, request if needed - touch & return results
|
||||
if(node != 0)
|
||||
{
|
||||
dasm_scope_touch_node__stripe_r_guarded(scope, node);
|
||||
ins_atomic_u64_eval_assign(&node->last_time_touched_us, os_now_microseconds());
|
||||
ins_atomic_u64_eval_assign(&node->last_user_clock_idx_touched, update_tick_idx());
|
||||
access_touch(access, &node->scope_ref_count, stripe->cv);
|
||||
MemoryCopyStruct(&info, &node->info);
|
||||
}
|
||||
}
|
||||
@@ -416,13 +362,13 @@ dasm_info_from_hash_params(DASM_Scope *scope, U128 hash, DASM_Params *params)
|
||||
}
|
||||
|
||||
internal DASM_Info
|
||||
dasm_info_from_key_params(DASM_Scope *scope, C_Key key, DASM_Params *params, U128 *hash_out)
|
||||
dasm_info_from_key_params(Access *access, C_Key key, DASM_Params *params, U128 *hash_out)
|
||||
{
|
||||
DASM_Info result = {0};
|
||||
for(U64 rewind_idx = 0; rewind_idx < C_KEY_HASH_HISTORY_COUNT; rewind_idx += 1)
|
||||
{
|
||||
U128 hash = c_hash_from_key(key, rewind_idx);
|
||||
result = dasm_info_from_hash_params(scope, hash, params);
|
||||
result = dasm_info_from_hash_params(access, hash, params);
|
||||
if(result.lines.count != 0)
|
||||
{
|
||||
if(hash_out)
|
||||
@@ -552,7 +498,7 @@ dasm_tick(void)
|
||||
break;
|
||||
}
|
||||
U64 req_idx = req_num-1;
|
||||
C_Scope *c_scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
DI_Scope *di_scope = di_scope_open();
|
||||
TXT_Scope *txt_scope = txt_scope_open();
|
||||
|
||||
@@ -562,7 +508,7 @@ dasm_tick(void)
|
||||
C_Root root = r->root;
|
||||
U128 hash = r->hash;
|
||||
DASM_Params params = r->params;
|
||||
String8 data = c_data_from_hash(c_scope, hash);
|
||||
String8 data = c_data_from_hash(access, hash);
|
||||
U64 change_gen = fs_change_gen();
|
||||
U64 slot_idx = hash.u64[1]%dasm_shared->slots_count;
|
||||
U64 stripe_idx = slot_idx%dasm_shared->stripes_count;
|
||||
@@ -655,7 +601,7 @@ dasm_tick(void)
|
||||
stale = (stale || u128_match(hash, u128_zero()));
|
||||
if(0 < line->line_num && line->line_num < text_info.lines_count)
|
||||
{
|
||||
String8 data = c_data_from_hash(c_scope, hash);
|
||||
String8 data = c_data_from_hash(access, hash);
|
||||
String8 line_text = str8_skip_chop_whitespace(str8_substr(data, text_info.lines_ranges[line->line_num-1]));
|
||||
if(line_text.size != 0)
|
||||
{
|
||||
@@ -786,7 +732,7 @@ dasm_tick(void)
|
||||
|
||||
txt_scope_close(txt_scope);
|
||||
di_scope_close(di_scope);
|
||||
c_scope_close(c_scope);
|
||||
access_close(access);
|
||||
}
|
||||
lane_sync();
|
||||
|
||||
|
||||
@@ -220,25 +220,6 @@ struct DASM_Stripe
|
||||
DASM_Node *free_node;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Scoped Access Types
|
||||
|
||||
typedef struct DASM_Touch DASM_Touch;
|
||||
struct DASM_Touch
|
||||
{
|
||||
DASM_Touch *next;
|
||||
U128 hash;
|
||||
DASM_Params params;
|
||||
};
|
||||
|
||||
typedef struct DASM_Scope DASM_Scope;
|
||||
struct DASM_Scope
|
||||
{
|
||||
DASM_Scope *next;
|
||||
DASM_Touch *top_touch;
|
||||
U64 base_pos;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Thread Context
|
||||
|
||||
@@ -307,18 +288,11 @@ internal U64 dasm_line_array_code_off_from_idx(DASM_LineArray *array, U64 idx);
|
||||
|
||||
internal void dasm_init(void);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Scoped Access
|
||||
|
||||
internal DASM_Scope *dasm_scope_open(void);
|
||||
internal void dasm_scope_close(DASM_Scope *scope);
|
||||
internal void dasm_scope_touch_node__stripe_r_guarded(DASM_Scope *scope, DASM_Node *node);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Cache Lookups
|
||||
|
||||
internal DASM_Info dasm_info_from_hash_params(DASM_Scope *scope, U128 hash, DASM_Params *params);
|
||||
internal DASM_Info dasm_info_from_key_params(DASM_Scope *scope, C_Key key, DASM_Params *params, U128 *hash_out);
|
||||
internal DASM_Info dasm_info_from_hash_params(Access *access, U128 hash, DASM_Params *params);
|
||||
internal DASM_Info dasm_info_from_key_params(Access *access, C_Key key, DASM_Params *params, U128 *hash_out);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Ticks
|
||||
|
||||
@@ -245,7 +245,7 @@ geo_u2x_dequeue_req(U128 *hash_out)
|
||||
ASYNC_WORK_DEF(geo_xfer_work)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
C_Scope *scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
|
||||
//- rjf: decode
|
||||
U128 hash = {0};
|
||||
@@ -275,7 +275,7 @@ ASYNC_WORK_DEF(geo_xfer_work)
|
||||
String8 data = {0};
|
||||
if(got_task)
|
||||
{
|
||||
data = c_data_from_hash(scope, hash);
|
||||
data = c_data_from_hash(access, hash);
|
||||
}
|
||||
|
||||
//- rjf: data -> buffer
|
||||
@@ -300,7 +300,7 @@ ASYNC_WORK_DEF(geo_xfer_work)
|
||||
}
|
||||
}
|
||||
|
||||
c_scope_close(scope);
|
||||
access_close(access);
|
||||
ProfEnd();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ mtx_mut_thread__entry_point(void *p)
|
||||
for(;;)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
C_Scope *c_scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
|
||||
//- rjf: get next op
|
||||
C_Key buffer_key = {0};
|
||||
@@ -107,7 +107,7 @@ mtx_mut_thread__entry_point(void *p)
|
||||
|
||||
//- rjf: get buffer's current data
|
||||
U128 hash = c_hash_from_key(buffer_key, 0);
|
||||
String8 data = c_data_from_hash(c_scope, hash);
|
||||
String8 data = c_data_from_hash(access, hash);
|
||||
|
||||
//- rjf: clamp op by data
|
||||
op.range.min = Min(op.range.min, data.size);
|
||||
@@ -137,7 +137,7 @@ mtx_mut_thread__entry_point(void *p)
|
||||
c_submit_data(buffer_key, &arena, new_data);
|
||||
}
|
||||
|
||||
c_scope_close(c_scope);
|
||||
access_close(access);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ ptg_builder_thread__entry_point(void *p)
|
||||
{
|
||||
for(;;)
|
||||
{
|
||||
C_Scope *scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
|
||||
//- rjf: get next key
|
||||
PTG_Key key = {0};
|
||||
@@ -214,7 +214,7 @@ ptg_builder_thread__entry_point(void *p)
|
||||
}
|
||||
}
|
||||
|
||||
c_scope_close(scope);
|
||||
access_close(access);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+29
-29
@@ -1750,9 +1750,9 @@ rd_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range)
|
||||
C_ID id = {space.u128};
|
||||
C_Key key = c_key_make(root, id);
|
||||
U128 hash = c_hash_from_key(key, 0);
|
||||
C_Scope *scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
{
|
||||
String8 data = c_data_from_hash(scope, hash);
|
||||
String8 data = c_data_from_hash(access, hash);
|
||||
Rng1U64 legal_range = r1u64(0, data.size);
|
||||
Rng1U64 read_range = intersect_1u64(range, legal_range);
|
||||
if(read_range.min < read_range.max)
|
||||
@@ -1761,7 +1761,7 @@ rd_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range)
|
||||
MemoryCopy(out, data.str + read_range.min, dim_1u64(read_range));
|
||||
}
|
||||
}
|
||||
c_scope_close(scope);
|
||||
access_close(access);
|
||||
}break;
|
||||
|
||||
//- rjf: file reads
|
||||
@@ -1783,9 +1783,9 @@ rd_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range)
|
||||
U128 hash = c_hash_from_key(key, 0);
|
||||
|
||||
// rjf: look up from hash store
|
||||
C_Scope *scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
{
|
||||
String8 data = c_data_from_hash(scope, hash);
|
||||
String8 data = c_data_from_hash(access, hash);
|
||||
Rng1U64 legal_range = r1u64(containing_range.min, containing_range.min + data.size);
|
||||
Rng1U64 read_range = intersect_1u64(range, legal_range);
|
||||
if(read_range.min < read_range.max)
|
||||
@@ -1794,7 +1794,7 @@ rd_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range)
|
||||
MemoryCopy(out, data.str + read_range.min - containing_range.min, dim_1u64(read_range));
|
||||
}
|
||||
}
|
||||
c_scope_close(scope);
|
||||
access_close(access);
|
||||
}break;
|
||||
|
||||
//- rjf: interior control entity reads (inside process address space or thread register block)
|
||||
@@ -2181,12 +2181,12 @@ rd_whole_range_from_eval_space(E_Space space)
|
||||
C_ID id = {space.u128};
|
||||
C_Key key = c_key_make(root, id);
|
||||
U128 hash = c_hash_from_key(key, 0);
|
||||
C_Scope *c_scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
{
|
||||
String8 data = c_data_from_hash(c_scope, hash);
|
||||
String8 data = c_data_from_hash(access, hash);
|
||||
result = r1u64(0, data.size);
|
||||
}
|
||||
c_scope_close(c_scope);
|
||||
access_close(access);
|
||||
}break;
|
||||
case E_SpaceKind_File:
|
||||
{
|
||||
@@ -2879,10 +2879,10 @@ rd_view_ui(Rng2F32 rect)
|
||||
B32 data_is_ready = 0;
|
||||
String8 new_view_name = {0};
|
||||
{
|
||||
C_Scope *c_scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
if(!u128_match(hash, u128_zero()))
|
||||
{
|
||||
String8 data = c_data_from_hash(c_scope, hash);
|
||||
String8 data = c_data_from_hash(access, hash);
|
||||
U64 num_utf8_bytes = 0;
|
||||
U64 num_unknown_bytes = 0;
|
||||
for(U64 idx = 0; idx < data.size && idx < range.max;)
|
||||
@@ -2911,7 +2911,7 @@ rd_view_ui(Rng2F32 rect)
|
||||
new_view_name = str8_lit("memory");
|
||||
}
|
||||
}
|
||||
c_scope_close(c_scope);
|
||||
access_close(access);
|
||||
}
|
||||
|
||||
// rjf: if we don't have a viewer, just use the memory viewer.
|
||||
@@ -5993,7 +5993,7 @@ rd_window_frame(void)
|
||||
//- rjf: @window_frame_part compute window's theme
|
||||
//
|
||||
{
|
||||
C_Scope *c_scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
|
||||
//- rjf: try to find theme settings from the project, then the user.
|
||||
RD_CfgList colors_cfgs = {0};
|
||||
@@ -6039,7 +6039,7 @@ rd_window_frame(void)
|
||||
}
|
||||
|
||||
//- rjf: map the theme config to the associated tree (either from a preset, or from a file)
|
||||
MD_Node *theme_tree = rd_theme_tree_from_name(scratch.arena, c_scope, theme_cfg->first->string);
|
||||
MD_Node *theme_tree = rd_theme_tree_from_name(scratch.arena, access, theme_cfg->first->string);
|
||||
if(colors_cfgs.count == 0 && theme_tree == &md_nil_node)
|
||||
{
|
||||
theme_tree = rd_state->theme_preset_trees[RD_ThemePreset_DefaultDark];
|
||||
@@ -6110,7 +6110,7 @@ rd_window_frame(void)
|
||||
}
|
||||
}
|
||||
|
||||
c_scope_close(c_scope);
|
||||
access_close(access);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
@@ -10205,7 +10205,7 @@ rd_set_autocomp_regs_(E_Eval dst_eval, RD_Regs *regs)
|
||||
//- rjf: colors
|
||||
|
||||
internal MD_Node *
|
||||
rd_theme_tree_from_name(Arena *arena, C_Scope *scope, String8 theme_name)
|
||||
rd_theme_tree_from_name(Arena *arena, Access *access, String8 theme_name)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
MD_Node *theme_tree = &md_nil_node;
|
||||
@@ -10228,7 +10228,7 @@ rd_theme_tree_from_name(Arena *arena, C_Scope *scope, String8 theme_name)
|
||||
endt_us = os_now_microseconds()+50000;
|
||||
}
|
||||
U128 hash = fs_hash_from_path_range(path, r1u64(0, max_U64), endt_us);
|
||||
String8 data = c_data_from_hash(scope, hash);
|
||||
String8 data = c_data_from_hash(access, hash);
|
||||
theme_tree = md_tree_from_string(arena, data);
|
||||
}
|
||||
}
|
||||
@@ -12459,10 +12459,10 @@ rd_frame(void)
|
||||
|
||||
//- rjf: add macro for output log
|
||||
{
|
||||
C_Scope *c_scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
C_Key key = d_state->output_log_key;
|
||||
U128 hash = c_hash_from_key(key, 0);
|
||||
String8 data = c_data_from_hash(c_scope, hash);
|
||||
String8 data = c_data_from_hash(access, hash);
|
||||
E_Space space = e_space_make(E_SpaceKind_HashStoreKey);
|
||||
space.u64_0 = key.root.u64[0];
|
||||
space.u128 = key.id.u128[0];
|
||||
@@ -12471,7 +12471,7 @@ rd_frame(void)
|
||||
expr->mode = E_Mode_Offset;
|
||||
expr->type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), data.size, 0);
|
||||
e_string2expr_map_insert(scratch.arena, macro_map, str8_lit("output"), expr);
|
||||
c_scope_close(c_scope);
|
||||
access_close(access);
|
||||
}
|
||||
|
||||
//- rjf: (DEBUG) add macro for cfg strings
|
||||
@@ -15936,10 +15936,10 @@ rd_frame(void)
|
||||
}break;
|
||||
case RD_CmdKind_AddThemeColor:
|
||||
{
|
||||
C_Scope *c_scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
RD_Cfg *parent = rd_cfg_from_id(rd_regs()->cfg);
|
||||
RD_Cfg *theme = rd_cfg_child_from_string_or_alloc(parent, str8_lit("theme"));
|
||||
MD_Node *theme_tree = rd_theme_tree_from_name(scratch.arena, c_scope, theme->first->string);
|
||||
MD_Node *theme_tree = rd_theme_tree_from_name(scratch.arena, access, theme->first->string);
|
||||
if(theme_tree == &md_nil_node)
|
||||
{
|
||||
rd_cfg_new_replace(theme, rd_theme_preset_display_string_table[RD_ThemePreset_DefaultDark]);
|
||||
@@ -15948,11 +15948,11 @@ rd_frame(void)
|
||||
rd_cfg_new(color, str8_lit("tags"));
|
||||
RD_Cfg *value = rd_cfg_new(color, str8_lit("value"));
|
||||
rd_cfg_new(value, str8_lit("0xffffffff"));
|
||||
c_scope_close(c_scope);
|
||||
access_close(access);
|
||||
}break;
|
||||
case RD_CmdKind_ForkTheme:
|
||||
{
|
||||
C_Scope *c_scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
RD_Cfg *parent = rd_cfg_from_id(rd_regs()->cfg);
|
||||
RD_CfgList colors = rd_cfg_child_list_from_string(scratch.arena, parent, str8_lit("theme_color"));
|
||||
for(RD_CfgNode *n = colors.first; n != 0; n = n->next)
|
||||
@@ -15961,7 +15961,7 @@ rd_frame(void)
|
||||
}
|
||||
RD_Cfg *theme_cfg = rd_cfg_child_from_string(parent, str8_lit("theme"));
|
||||
String8 theme_name = theme_cfg->first->string;
|
||||
MD_Node *theme_tree = rd_theme_tree_from_name(scratch.arena, c_scope, theme_name);
|
||||
MD_Node *theme_tree = rd_theme_tree_from_name(scratch.arena, access, theme_name);
|
||||
if(theme_tree == &md_nil_node)
|
||||
{
|
||||
theme_tree = rd_state->theme_preset_trees[RD_ThemePreset_DefaultDark];
|
||||
@@ -15978,7 +15978,7 @@ rd_frame(void)
|
||||
}
|
||||
}
|
||||
rd_cfg_release(theme_cfg);
|
||||
c_scope_close(c_scope);
|
||||
access_close(access);
|
||||
}break;
|
||||
case RD_CmdKind_SaveTheme:
|
||||
case RD_CmdKind_SaveAndSetTheme:
|
||||
@@ -16091,7 +16091,7 @@ rd_frame(void)
|
||||
case RD_CmdKind_GoToNameAtCursor:
|
||||
case RD_CmdKind_ToggleWatchExpressionAtCursor:
|
||||
{
|
||||
C_Scope *c_scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
TXT_Scope *txt_scope = txt_scope_open();
|
||||
RD_Regs *regs = rd_regs();
|
||||
C_Key text_key = regs->text_key;
|
||||
@@ -16099,7 +16099,7 @@ rd_frame(void)
|
||||
TxtRng range = txt_rng(regs->cursor, regs->mark);
|
||||
U128 hash = {0};
|
||||
TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, text_key, lang_kind, &hash);
|
||||
String8 data = c_data_from_hash(c_scope, hash);
|
||||
String8 data = c_data_from_hash(access, hash);
|
||||
Rng1U64 expr_off_range = {0};
|
||||
if(range.min.column != range.max.column)
|
||||
{
|
||||
@@ -16115,7 +16115,7 @@ rd_frame(void)
|
||||
RD_CmdKind_GoToName),
|
||||
.string = expr);
|
||||
txt_scope_close(txt_scope);
|
||||
c_scope_close(c_scope);
|
||||
access_close(access);
|
||||
}break;
|
||||
case RD_CmdKind_SetNextStatement:
|
||||
{
|
||||
|
||||
@@ -988,7 +988,7 @@ internal void rd_set_autocomp_regs_(E_Eval dst_eval, RD_Regs *regs);
|
||||
//~ rjf: Colors, Fonts, Config
|
||||
|
||||
//- rjf: colors
|
||||
internal MD_Node *rd_theme_tree_from_name(Arena *arena, C_Scope *scope, String8 theme_name);
|
||||
internal MD_Node *rd_theme_tree_from_name(Arena *arena, Access *access, String8 theme_name);
|
||||
internal Vec4F32 rd_rgba_from_code_color_slot(RD_CodeColorSlot slot);
|
||||
internal RD_CodeColorSlot rd_code_color_slot_from_txt_token_kind(TXT_TokenKind kind);
|
||||
internal RD_CodeColorSlot rd_code_color_slot_from_txt_token_kind_lookup_string(TXT_TokenKind kind, String8 string);
|
||||
|
||||
+13
-15
@@ -1944,8 +1944,8 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, str8_lit(" "));
|
||||
dr_fstrs_push_new(arena, &fstrs, ¶ms, name);
|
||||
{
|
||||
C_Scope *c_scope = c_scope_open();
|
||||
MD_Node *theme_tree = rd_theme_tree_from_name(scratch.arena, c_scope, name);
|
||||
Access *access = access_open();
|
||||
MD_Node *theme_tree = rd_theme_tree_from_name(scratch.arena, access, name);
|
||||
U64 color_idx = 0;
|
||||
for(MD_Node *n = theme_tree; color_idx < 4 && !md_node_is_nil(n); n = md_node_rec_depth_first_pre(n, theme_tree).next)
|
||||
{
|
||||
@@ -1973,7 +1973,7 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
|
||||
}
|
||||
}
|
||||
}
|
||||
c_scope_close(c_scope);
|
||||
access_close(access);
|
||||
}
|
||||
result.eval_fstrs = fstrs;
|
||||
}break;
|
||||
@@ -2025,7 +2025,7 @@ RD_VIEW_UI_FUNCTION_DEF(text)
|
||||
RD_CodeViewState *cv = rd_view_state(RD_CodeViewState);
|
||||
rd_code_view_init(cv);
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
C_Scope *c_scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
TXT_Scope *txt_scope = txt_scope_open();
|
||||
|
||||
//////////////////////////////
|
||||
@@ -2091,7 +2091,7 @@ RD_VIEW_UI_FUNCTION_DEF(text)
|
||||
}
|
||||
U128 hash = {0};
|
||||
TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, rd_regs()->text_key, rd_regs()->lang_kind, &hash);
|
||||
String8 data = c_data_from_hash(c_scope, hash);
|
||||
String8 data = c_data_from_hash(access, hash);
|
||||
B32 file_is_missing = (rd_regs()->file_path.size != 0 && os_properties_from_file_path(rd_regs()->file_path).modified == 0);
|
||||
B32 key_has_data = !u128_match(hash, u128_zero()) && info.lines_count;
|
||||
ProfEnd();
|
||||
@@ -2251,7 +2251,7 @@ RD_VIEW_UI_FUNCTION_DEF(text)
|
||||
rd_store_view_param_s64(str8_lit("mark_column"), rd_regs()->mark.column);
|
||||
|
||||
txt_scope_close(txt_scope);
|
||||
c_scope_close(c_scope);
|
||||
access_close(access);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
@@ -2291,8 +2291,7 @@ RD_VIEW_UI_FUNCTION_DEF(disasm)
|
||||
}
|
||||
RD_CodeViewState *cv = &dv->cv;
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
C_Scope *c_scope = c_scope_open();
|
||||
DASM_Scope *dasm_scope = dasm_scope_open();
|
||||
Access *access = access_open();
|
||||
TXT_Scope *txt_scope = txt_scope_open();
|
||||
|
||||
//////////////////////////////
|
||||
@@ -2410,12 +2409,12 @@ RD_VIEW_UI_FUNCTION_DEF(disasm)
|
||||
dasm_params.base_vaddr = base_vaddr;
|
||||
dasm_params.dbgi_key = dbgi_key;
|
||||
}
|
||||
DASM_Info dasm_info = dasm_info_from_key_params(dasm_scope, dasm_key, &dasm_params, &dasm_data_hash);
|
||||
DASM_Info dasm_info = dasm_info_from_key_params(access, dasm_key, &dasm_params, &dasm_data_hash);
|
||||
rd_regs()->text_key = dasm_info.text_key;
|
||||
rd_regs()->lang_kind = txt_lang_kind_from_arch(arch);
|
||||
U128 dasm_text_hash = {0};
|
||||
TXT_TextInfo dasm_text_info = txt_text_info_from_key_lang(txt_scope, rd_regs()->text_key, rd_regs()->lang_kind, &dasm_text_hash);
|
||||
String8 dasm_text_data = c_data_from_hash(c_scope, dasm_text_hash);
|
||||
String8 dasm_text_data = c_data_from_hash(access, dasm_text_hash);
|
||||
B32 has_disasm = (dasm_info.lines.count != 0 && dasm_text_info.lines_count != 0);
|
||||
B32 is_loading = (!has_disasm && dim_1u64(range) != 0 && eval.msgs.max_kind == E_MsgKind_Null && (space.kind != RD_EvalSpaceKind_CtrlEntity || space_entity != &ctrl_entity_nil));
|
||||
|
||||
@@ -2496,8 +2495,7 @@ RD_VIEW_UI_FUNCTION_DEF(disasm)
|
||||
dv->mark = rd_regs()->mark;
|
||||
|
||||
txt_scope_close(txt_scope);
|
||||
dasm_scope_close(dasm_scope);
|
||||
c_scope_close(c_scope);
|
||||
access_close(access);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
@@ -3826,7 +3824,7 @@ EV_EXPAND_RULE_INFO_FUNCTION_DEF(bitmap)
|
||||
RD_VIEW_UI_FUNCTION_DEF(bitmap)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
C_Scope *c_scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
TEX_Scope *tex_scope = tex_scope_open();
|
||||
|
||||
//////////////////////////////
|
||||
@@ -3878,7 +3876,7 @@ RD_VIEW_UI_FUNCTION_DEF(bitmap)
|
||||
TEX_Topology topology = tex_topology_make(dim, fmt);
|
||||
U128 data_hash = {0};
|
||||
R_Handle texture = tex_texture_from_key_topology(tex_scope, texture_key, topology, &data_hash);
|
||||
String8 data = c_data_from_hash(c_scope, data_hash);
|
||||
String8 data = c_data_from_hash(access, data_hash);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: equip loading info
|
||||
@@ -4031,8 +4029,8 @@ RD_VIEW_UI_FUNCTION_DEF(bitmap)
|
||||
rd_store_view_param_f32(str8_lit("x"), view_center_pos.x);
|
||||
rd_store_view_param_f32(str8_lit("y"), view_center_pos.y);
|
||||
|
||||
c_scope_close(c_scope);
|
||||
tex_scope_close(tex_scope);
|
||||
access_close(access);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
|
||||
@@ -2206,7 +2206,7 @@ ASYNC_WORK_DEF(txt_parse_work)
|
||||
U128 hash = {0};
|
||||
TXT_LangKind lang = TXT_LangKind_Null;
|
||||
txt_u2p_dequeue_req(&hash, &lang);
|
||||
C_Scope *scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
|
||||
//- rjf: unpack hash
|
||||
U64 slot_idx = hash.u64[1]%txt_shared->slots_count;
|
||||
@@ -2232,7 +2232,7 @@ ASYNC_WORK_DEF(txt_parse_work)
|
||||
String8 data = {0};
|
||||
if(got_task)
|
||||
{
|
||||
data = c_data_from_hash(scope, hash);
|
||||
data = c_data_from_hash(access, hash);
|
||||
}
|
||||
|
||||
//- rjf: data -> text info
|
||||
@@ -2500,7 +2500,7 @@ ASYNC_WORK_DEF(txt_parse_work)
|
||||
}
|
||||
}
|
||||
|
||||
c_scope_close(scope);
|
||||
access_close(access);
|
||||
ProfEnd();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ tex_u2x_dequeue_req(U128 *hash_out, TEX_Topology *top_out)
|
||||
ASYNC_WORK_DEF(tex_xfer_work)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
C_Scope *scope = c_scope_open();
|
||||
Access *access = access_open();
|
||||
|
||||
//- rjf: decode
|
||||
U128 hash = {0};
|
||||
@@ -297,7 +297,7 @@ ASYNC_WORK_DEF(tex_xfer_work)
|
||||
String8 data = {0};
|
||||
if(got_task)
|
||||
{
|
||||
data = c_data_from_hash(scope, hash);
|
||||
data = c_data_from_hash(access, hash);
|
||||
}
|
||||
|
||||
//- rjf: data * topology -> texture
|
||||
@@ -322,7 +322,7 @@ ASYNC_WORK_DEF(tex_xfer_work)
|
||||
}
|
||||
}
|
||||
|
||||
c_scope_close(scope);
|
||||
access_close(access);
|
||||
ProfEnd();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user