Skip to content

Commit

Permalink
ast,cgen: remove instrumentation for the cached ident lookup, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Aug 23, 2024
1 parent 20da195 commit 150b4b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
25 changes: 4 additions & 21 deletions vlib/v/ast/str.v
Original file line number Diff line number Diff line change
Expand Up @@ -394,16 +394,6 @@ __global nested_expr_str_calls = i64(0)
// too big values, risk stack overflow in `${expr}` (which uses `expr.str()`) calls
const max_nested_expr_str_calls = 300

__global expr_str_ident_calls = i64(0)
__global expr_str_ident_calls_consts = i64(0)
__global expr_str_ident_calls_normal = i64(0)

pub fn dump_counters() {
dump(expr_str_ident_calls)
dump(expr_str_ident_calls_consts)
dump(expr_str_ident_calls_normal)
}

// string representation of expr
pub fn (x &Expr) str() string {
str_calls := stdatomic.add_i64(&nested_expr_str_calls, 1)
Expand Down Expand Up @@ -525,29 +515,22 @@ pub fn (x &Expr) str() string {
return 'spawn ${x.call_expr}'
}
Ident {
expr_str_ident_calls++
if x.cached_name != '' {
return x.cached_name
}
if obj := x.scope.find('${x.mod}.${x.name}') {
expr_str_ident_calls_consts++
if obj is ConstField && x.mod != 'main' {
last_mod := x.mod.all_after_last('.')
res := '${last_mod}.${x.name}'
// println('px: ${voidptr(px)} | res: $res')
unsafe {
x.cached_name = res
x.cached_name = '${last_mod}.${x.name}'
}
return res
return x.cached_name
}
}
expr_str_ident_calls_normal++
res := x.name.clone()
// println('px: ${voidptr(px)} | res: $res')
unsafe {
x.cached_name = res
x.cached_name = x.name.clone()
}
return res
return x.cached_name
}
IfExpr {
mut parts := []string{}
Expand Down
1 change: 0 additions & 1 deletion vlib/v/gen/c/cgen.v
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ struct GlobalConstDef {
}

pub fn gen(files []&ast.File, mut table ast.Table, pref_ &pref.Preferences) (string, string, string, []int) {
defer { ast.dump_counters() }
mut module_built := ''
if pref_.build_mode == .build_module {
for file in files {
Expand Down

0 comments on commit 150b4b2

Please sign in to comment.