Skip to content

Commit 3011d41

Browse files
committed
memory_maps: hoist the TLS check out of the compartment loop in ia2_all_threads_metadata_find_addr
1 parent 6d24d3e commit 3011d41

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

runtime/libia2/memory_maps.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,16 @@ struct ia2_addr_location ia2_all_threads_metadata_find_addr(struct ia2_all_threa
6161
}
6262
for (size_t thread = 0; thread < this->num_threads; thread++) {
6363
const pid_t tid = this->tids[thread];
64+
const struct ia2_thread_metadata *const thread_metadata = &this->thread_metadata[thread];
65+
66+
if (addr == thread_metadata->tls_addr_compartment1_first || addr == thread_metadata->tls_addr_compartment1_second) {
67+
location.name = "tls";
68+
location.thread_metadata = thread_metadata;
69+
location.compartment = 1;
70+
goto unlock;
71+
}
72+
6473
for (int compartment = 0; compartment < IA2_MAX_COMPARTMENTS; compartment++) {
65-
const struct ia2_thread_metadata *const thread_metadata = &this->thread_metadata[thread];
6674
if (addr == thread_metadata->stack_addrs[compartment]) {
6775
location.name = "stack";
6876
location.thread_metadata = thread_metadata;
@@ -75,12 +83,6 @@ struct ia2_addr_location ia2_all_threads_metadata_find_addr(struct ia2_all_threa
7583
location.compartment = compartment;
7684
goto unlock;
7785
}
78-
if (addr == thread_metadata->tls_addr_compartment1_first || addr == thread_metadata->tls_addr_compartment1_second) {
79-
location.name = "tls";
80-
location.thread_metadata = thread_metadata;
81-
location.compartment = 1;
82-
goto unlock;
83-
}
8486
}
8587
}
8688

0 commit comments

Comments
 (0)