Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: src/trusted/service_runtime/nacl_app_thread.c

Issue 12218089: Remove nacl_user[] array lookup from syscall code path on x86-64 and MIPS (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /* 7 /*
8 * NaCl Server Runtime user thread state. 8 * NaCl Server Runtime user thread state.
9 */ 9 */
10 10
(...skipping 21 matching lines...) Expand all
32 NaClSignalStackRegister(natp->signal_stack); 32 NaClSignalStackRegister(natp->signal_stack);
33 33
34 NaClLog(4, " natp = 0x%016"NACL_PRIxPTR"\n", (uintptr_t) natp); 34 NaClLog(4, " natp = 0x%016"NACL_PRIxPTR"\n", (uintptr_t) natp);
35 NaClLog(4, " prog_ctr = 0x%016"NACL_PRIxNACL_REG"\n", natp->user.prog_ctr); 35 NaClLog(4, " prog_ctr = 0x%016"NACL_PRIxNACL_REG"\n", natp->user.prog_ctr);
36 NaClLog(4, "stack_ptr = 0x%016"NACL_PRIxPTR"\n", 36 NaClLog(4, "stack_ptr = 0x%016"NACL_PRIxPTR"\n",
37 NaClGetThreadCtxSp(&natp->user)); 37 NaClGetThreadCtxSp(&natp->user));
38 38
39 thread_idx = NaClGetThreadIdx(natp); 39 thread_idx = NaClGetThreadIdx(natp);
40 CHECK(0 < thread_idx); 40 CHECK(0 < thread_idx);
41 CHECK(thread_idx < NACL_THREAD_MAX); 41 CHECK(thread_idx < NACL_THREAD_MAX);
42 NaClTlsSetIdx(thread_idx); 42 NaClTlsSetCurrentThread(natp);
43 nacl_user[thread_idx] = &natp->user; 43 nacl_user[thread_idx] = &natp->user;
44 #if NACL_WINDOWS 44 #if NACL_WINDOWS
45 nacl_thread_ids[thread_idx] = GetCurrentThreadId(); 45 nacl_thread_ids[thread_idx] = GetCurrentThreadId();
46 #endif 46 #endif
47 47
48 /* 48 /*
49 * We have to hold the threads_mu lock until after thread_num field 49 * We have to hold the threads_mu lock until after thread_num field
50 * in this thread has been initialized. All other threads can only 50 * in this thread has been initialized. All other threads can only
51 * find and examine this natp through the threads table, so the fact 51 * find and examine this natp through the threads table, so the fact
52 * that natp is not consistent (no thread_num) will not be visible. 52 * that natp is not consistent (no thread_num) will not be visible.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 thread_idx = NaClGetThreadIdx(natp); 116 thread_idx = NaClGetThreadIdx(natp);
117 /* 117 /*
118 * On x86-64 and ARM, clearing nacl_user entry ensures that we will 118 * On x86-64 and ARM, clearing nacl_user entry ensures that we will
119 * fault if another syscall is made with this thread_idx. In 119 * fault if another syscall is made with this thread_idx. In
120 * particular, thread_idx 0 is never used. 120 * particular, thread_idx 0 is never used.
121 */ 121 */
122 nacl_user[thread_idx] = NULL; 122 nacl_user[thread_idx] = NULL;
123 #if NACL_WINDOWS 123 #if NACL_WINDOWS
124 nacl_thread_ids[thread_idx] = 0; 124 nacl_thread_ids[thread_idx] = 0;
125 #endif 125 #endif
126 NaClTlsSetCurrentThread(NULL);
126 127
127 NaClLog(3, " removing thread from thread table\n"); 128 NaClLog(3, " removing thread from thread table\n");
128 /* Deallocate the ID natp->thread_num. */ 129 /* Deallocate the ID natp->thread_num. */
129 NaClRemoveThreadMu(nap, natp->thread_num); 130 NaClRemoveThreadMu(nap, natp->thread_num);
130 NaClLog(3, " unlocking thread\n"); 131 NaClLog(3, " unlocking thread\n");
131 NaClXMutexUnlock(&natp->mu); 132 NaClXMutexUnlock(&natp->mu);
132 NaClLog(3, " unlocking thread table\n"); 133 NaClLog(3, " unlocking thread table\n");
133 NaClXMutexUnlock(&nap->threads_mu); 134 NaClXMutexUnlock(&nap->threads_mu);
134 NaClLog(3, " unregistering signal stack\n"); 135 NaClLog(3, " unregistering signal stack\n");
135 NaClSignalStackUnregister(); 136 NaClSignalStackUnregister();
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 NaClThreadDtor(&natp->host_thread); 261 NaClThreadDtor(&natp->host_thread);
261 } 262 }
262 free(natp->suspended_registers); 263 free(natp->suspended_registers);
263 NaClMutexDtor(&natp->suspend_mu); 264 NaClMutexDtor(&natp->suspend_mu);
264 NaClSignalStackFree(natp->signal_stack); 265 NaClSignalStackFree(natp->signal_stack);
265 natp->signal_stack = NULL; 266 natp->signal_stack = NULL;
266 NaClTlsFree(natp); 267 NaClTlsFree(natp);
267 NaClMutexDtor(&natp->mu); 268 NaClMutexDtor(&natp->mu);
268 NaClAlignedFree(natp); 269 NaClAlignedFree(natp);
269 } 270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698