From 1a261f016322de0f7517421cb7f659e12d8fc19e Mon Sep 17 00:00:00 2001 From: "fur%netscape.com" Date: Sat, 27 Feb 1999 01:53:18 +0000 Subject: [PATCH] Separated x86Win32_Support.cpp into an OS-independent part x86GenStub.cpp and x86Stub.cpp which is Win32-only. git-svn-id: svn://10.0.0.236/trunk@22279 18797224-902f-48f8-a5cc-f745e15eee43 --- .../{x86Win32_Support.cpp => x86GenStub.cpp} | 59 ++++------------- .../Compiler/CodeGenerator/md/x86/x86Stub.cpp | 65 +++++++++++++++++++ .../winbuild/electricalfire.dsp | 27 ++++---- 3 files changed, 94 insertions(+), 57 deletions(-) rename mozilla/ef/Compiler/CodeGenerator/md/x86/{x86Win32_Support.cpp => x86GenStub.cpp} (76%) create mode 100644 mozilla/ef/Compiler/CodeGenerator/md/x86/x86Stub.cpp diff --git a/mozilla/ef/Compiler/CodeGenerator/md/x86/x86Win32_Support.cpp b/mozilla/ef/Compiler/CodeGenerator/md/x86/x86GenStub.cpp similarity index 76% rename from mozilla/ef/Compiler/CodeGenerator/md/x86/x86Win32_Support.cpp rename to mozilla/ef/Compiler/CodeGenerator/md/x86/x86GenStub.cpp index 52720de44d4..d6dd9e1a8b6 100644 --- a/mozilla/ef/Compiler/CodeGenerator/md/x86/x86Win32_Support.cpp +++ b/mozilla/ef/Compiler/CodeGenerator/md/x86/x86GenStub.cpp @@ -27,56 +27,14 @@ #include "Fundamentals.h" #include "MemoryAccess.h" +PR_BEGIN_EXTERN_C +extern void staticCompileStub(); +PR_END_EXTERN_C void* JNIenv = 0; extern ClassWorld world; -static void __declspec( naked ) -staticCompileStub() -{ - _asm - { - // eax contains the cache entry. - - // make frame - push ebp - mov ebp,esp - - /* Even though ESI and EDI are non-volatile (callee-saved) registers, we need to - preserve them here in case an exception is thrown. The exception-handling - code expects to encounter this specially-prepared stack "guard" frame when - unwinding the stack. See x86ExceptionHandler.cpp. */ - push edi - push esi - push ebx - - // call compileAndBackPatchMethod with args - // third argument is not used - push [esp + 16] // second argument -- return address - push eax // first argument -- cacheEntry - call compileAndBackPatchMethod - - // remove frame - mov esp,ebp - pop ebp - - // jump to the compiled method - jmp eax - } -} - -#ifdef DEBUG -// Pointer to the instruction after the call (used by exception handler to check -// I wanted to use: -// void* compileStubReEntryPoint = (void*) ((Uint8*)staticCompileStub + 17); -// but MSDev appears to have a bug, in that compileStubReEntryPoint will be set == (void*)staticCompileStub -// which is clearly wrong. -void* compileStubAddress = (void*)staticCompileStub; -// void* compileStubReEntryPoint = (Uint8*)compileStubAddress + 15; // Correct address ? -void* compileStubReEntryPoint = NULL; -#endif // DEBUG - void * generateNativeStub(NativeCodeCache& inCache, const CacheEntry& inCacheEntry, void *nativeFunction) { @@ -144,3 +102,14 @@ backPatchMethod(void* inMethodAddress, void* inLastPC, void* /*inUserDefined*/) return (inMethodAddress); } + +#ifdef DEBUG +// Pointer to the instruction after the call (used by exception handler to sanity-check stack) +// I wanted to use: +// void* compileStubReEntryPoint = (void*) ((Uint8*)staticCompileStub + xx); +// but MSDev appears to have a bug, in that compileStubReEntryPoint will be set == (void*)staticCompileStub +// which is clearly wrong. +void* compileStubAddress = (void*)staticCompileStub; +// void* compileStubReEntryPoint = (Uint8*)compileStubAddress + 15; // Correct address ? +void* compileStubReEntryPoint = (void*)NULL; +#endif // DEBUG diff --git a/mozilla/ef/Compiler/CodeGenerator/md/x86/x86Stub.cpp b/mozilla/ef/Compiler/CodeGenerator/md/x86/x86Stub.cpp new file mode 100644 index 00000000000..89de72518f7 --- /dev/null +++ b/mozilla/ef/Compiler/CodeGenerator/md/x86/x86Stub.cpp @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef WIN32 + #error "This is a Win32-only file" +#endif + +#include "NativeCodeCache.h" + +/* Calls to a Java method are routed to this routine, which arranges for + compilation of the method, backpatching of any involved 'call' instruction, + and resumption of execution in the compiled method. */ + +PR_BEGIN_EXTERN_C +void __declspec( naked ) +staticCompileStub() +{ + _asm + { + // eax contains the cache entry. + + // make frame + push ebp + mov ebp,esp + + /* Even though ESI and EDI are non-volatile (callee-saved) registers, we need to + preserve them here in case an exception is thrown. The exception-handling + code expects to encounter this specially-prepared stack "guard" frame when + unwinding the stack. See x86ExceptionHandler.cpp. */ + push edi + push esi + push ebx + + // call compileAndBackPatchMethod with args + // third argument is not used + push [esp + 16] // second argument -- return address + push eax // first argument -- cacheEntry + call compileAndBackPatchMethod + + // <== compileStubReEntryPoint should point here (the instruction after the call) + + // remove frame + mov esp,ebp + pop ebp + + // jump to the compiled method + jmp eax + } +} +PR_END_EXTERN_C diff --git a/mozilla/ef/Driver/StandAloneJava/winbuild/electricalfire.dsp b/mozilla/ef/Driver/StandAloneJava/winbuild/electricalfire.dsp index 3b93db86639..4e1611543d9 100644 --- a/mozilla/ef/Driver/StandAloneJava/winbuild/electricalfire.dsp +++ b/mozilla/ef/Driver/StandAloneJava/winbuild/electricalfire.dsp @@ -768,10 +768,10 @@ InputName=x86 BuildCmds= \ $(NSTOOLS)\perl5\perl ..\..\..\tools\nad\nad.pl $(InputPath)\ - ..\..\..\Compiler\PrimitiveGraph\PrimitiveOperations\ - genfiles\PrimitiveOperations.h genfiles\PrimitiveOperations.cpp\ - genfiles\$(InputName).nad.burg.h | Burg\Release\burg -I >\ - genfiles\$(InputName).nad.burg.cpp + ..\..\..\Compiler\PrimitiveGraph\PrimitiveOperations\ + genfiles\PrimitiveOperations.h genfiles\PrimitiveOperations.cpp\ + genfiles\$(InputName).nad.burg.h | Burg\Release\burg -I >\ + genfiles\$(InputName).nad.burg.cpp "genfiles\$(InputName).nad.burg.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" $(BuildCmds) @@ -794,10 +794,10 @@ InputName=x86 BuildCmds= \ $(MOZ_TOOLS)\perl5\perl ..\..\..\tools\nad\nad.pl $(InputPath)\ - ..\..\..\Compiler\PrimitiveGraph\PrimitiveOperations\ - genfiles\PrimitiveOperations.h genfiles\PrimitiveOperations.cpp\ - genfiles\$(InputName).nad.burg.h | Burg\Debug\burg -I >\ - genfiles\$(InputName).nad.burg.cpp + ..\..\..\Compiler\PrimitiveGraph\PrimitiveOperations\ + genfiles\PrimitiveOperations.h genfiles\PrimitiveOperations.cpp\ + genfiles\$(InputName).nad.burg.h | Burg\Debug\burg -I >\ + genfiles\$(InputName).nad.burg.cpp "genfiles\$(InputName).nad.burg.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" $(BuildCmds) @@ -847,6 +847,10 @@ SOURCE=..\..\..\Compiler\CodeGenerator\md\x86\x86Formatter.h # End Source File # Begin Source File +SOURCE=..\..\..\Compiler\CodeGenerator\md\x86\x86GenStub.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\Compiler\CodeGenerator\md\x86\x86Instruction.cpp # End Source File # Begin Source File @@ -867,8 +871,7 @@ SOURCE=..\..\..\Compiler\CodeGenerator\md\x86\x86StdCall.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Compiler\CodeGenerator\md\x86\x86Win32_Support.cpp -# SUBTRACT CPP /O +SOURCE=..\..\..\Compiler\CodeGenerator\md\x86\x86Stub.cpp # End Source File # End Group # Begin Group "generic" @@ -1083,8 +1086,8 @@ InputName=PrimitiveOperations BuildCmds= \ $(MOZ_TOOLS)\perl5\perl -I"..\..\..\Tools\PrimitiveOperations"\ - ..\..\..\Tools\PrimitiveOperations\MakePrimOp.pl $(InputPath)\ - genfiles\$(InputName).h genfiles\$(InputName).cpp + ..\..\..\Tools\PrimitiveOperations\MakePrimOp.pl $(InputPath)\ + genfiles\$(InputName).h genfiles\$(InputName).cpp "genfiles\$(InputName).h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" $(BuildCmds)