Separated x86Win32_Support.cpp into an OS-independent part x86GenStub.cpp and

x86Stub.cpp which is Win32-only.
This commit is contained in:
fur%netscape.com 1999-02-27 01:53:18 +00:00
parent 5abf681e81
commit c9523edadb
3 changed files with 94 additions and 57 deletions

View File

@ -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

View File

@ -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

View File

@ -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<none>
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)