|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* |
|
7 * GC related routines |
|
8 * |
|
9 */ |
|
10 #include "primpl.h" |
|
11 |
|
12 PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) |
|
13 { |
|
14 CONTEXTRECORD context; |
|
15 context.ContextFlags = CONTEXT_INTEGER; |
|
16 |
|
17 if (_PR_IS_NATIVE_THREAD(t)) { |
|
18 context.ContextFlags |= CONTEXT_CONTROL; |
|
19 if (QueryThreadContext(t->md.handle, CONTEXT_CONTROL, &context)) { |
|
20 t->md.gcContext[0] = context.ctx_RegEax; |
|
21 t->md.gcContext[1] = context.ctx_RegEbx; |
|
22 t->md.gcContext[2] = context.ctx_RegEcx; |
|
23 t->md.gcContext[3] = context.ctx_RegEdx; |
|
24 t->md.gcContext[4] = context.ctx_RegEsi; |
|
25 t->md.gcContext[5] = context.ctx_RegEdi; |
|
26 t->md.gcContext[6] = context.ctx_RegEsp; |
|
27 t->md.gcContext[7] = context.ctx_RegEbp; |
|
28 *np = PR_NUM_GCREGS; |
|
29 } else { |
|
30 PR_ASSERT(0);/* XXX */ |
|
31 } |
|
32 } |
|
33 return (PRWord *)&t->md.gcContext; |
|
34 } |
|
35 |
|
36 /* This function is not used right now, but is left as a reference. |
|
37 * If you ever need to get the fiberID from the currently running fiber, |
|
38 * this is it. |
|
39 */ |
|
40 void * |
|
41 GetMyFiberID() |
|
42 { |
|
43 void *fiberData = 0; |
|
44 |
|
45 /* A pointer to our tib entry is found at FS:[18] |
|
46 * At offset 10h is the fiberData pointer. The context of the |
|
47 * fiber is stored in there. |
|
48 */ |
|
49 #ifdef HAVE_ASM |
|
50 __asm { |
|
51 mov EDX, FS:[18h] |
|
52 mov EAX, DWORD PTR [EDX+10h] |
|
53 mov [fiberData], EAX |
|
54 } |
|
55 #endif |
|
56 |
|
57 return fiberData; |
|
58 } |