michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * GC related routines michael@0: * michael@0: */ michael@0: #include "primpl.h" michael@0: michael@0: PRWord *_MD_HomeGCRegisters(PRThread *t, int isCurrent, int *np) michael@0: { michael@0: CONTEXTRECORD context; michael@0: context.ContextFlags = CONTEXT_INTEGER; michael@0: michael@0: if (_PR_IS_NATIVE_THREAD(t)) { michael@0: context.ContextFlags |= CONTEXT_CONTROL; michael@0: if (QueryThreadContext(t->md.handle, CONTEXT_CONTROL, &context)) { michael@0: t->md.gcContext[0] = context.ctx_RegEax; michael@0: t->md.gcContext[1] = context.ctx_RegEbx; michael@0: t->md.gcContext[2] = context.ctx_RegEcx; michael@0: t->md.gcContext[3] = context.ctx_RegEdx; michael@0: t->md.gcContext[4] = context.ctx_RegEsi; michael@0: t->md.gcContext[5] = context.ctx_RegEdi; michael@0: t->md.gcContext[6] = context.ctx_RegEsp; michael@0: t->md.gcContext[7] = context.ctx_RegEbp; michael@0: *np = PR_NUM_GCREGS; michael@0: } else { michael@0: PR_ASSERT(0);/* XXX */ michael@0: } michael@0: } michael@0: return (PRWord *)&t->md.gcContext; michael@0: } michael@0: michael@0: /* This function is not used right now, but is left as a reference. michael@0: * If you ever need to get the fiberID from the currently running fiber, michael@0: * this is it. michael@0: */ michael@0: void * michael@0: GetMyFiberID() michael@0: { michael@0: void *fiberData = 0; michael@0: michael@0: /* A pointer to our tib entry is found at FS:[18] michael@0: * At offset 10h is the fiberData pointer. The context of the michael@0: * fiber is stored in there. michael@0: */ michael@0: #ifdef HAVE_ASM michael@0: __asm { michael@0: mov EDX, FS:[18h] michael@0: mov EAX, DWORD PTR [EDX+10h] michael@0: mov [fiberData], EAX michael@0: } michael@0: #endif michael@0: michael@0: return fiberData; michael@0: }