From: ageay Date: Thu, 16 Dec 2010 13:47:53 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: RELIQUAT_6x_15112010^0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3d19c98835f8717758521d90e539704daee8c825;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx index ee7116fd2..479b5c78e 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx @@ -23,6 +23,14 @@ #include #include +#ifdef _POSIX_MAPPED_FILES +#include +#else +#ifdef WNT +#include +#endif +#endif + const char *INTERP_KERNEL::AsmX86::OPS[NB_OF_OPS]={"mov","push","pop","fld","faddp","fsubp","fmulp","fdivp","fcos","fsin","fabs","fchs","fsqrt","sub","add","ret","leave","movsd","fst"}; std::vector INTERP_KERNEL::AsmX86::convertIntoMachineLangage(const std::vector& asmb) const throw(INTERP_KERNEL::Exception) @@ -33,11 +41,20 @@ std::vector INTERP_KERNEL::AsmX86::convertIntoMachineLangage(const std::ve return ret; } -char *INTERP_KERNEL::AsmX86::convertMachineLangageInBasic(const std::vector& ml, int& lgth) const +char *INTERP_KERNEL::AsmX86::copyToExecMemZone(const std::vector& ml, unsigned& offset) const { - lgth=ml.size(); - char *ret=new char[lgth]; - std::copy(ml.begin(),ml.end(),ret); + char *ret=0; + int lgth=ml.size(); +#ifdef _POSIX_MAPPED_FILES + ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0); +#else +#ifdef WNT + HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL); + ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth); +#endif +#endif + if(ret) + std::copy(ml.begin(),ml.end(),ret); return ret; } diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx index 11b8733e5..fd7bc9afc 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx @@ -32,7 +32,7 @@ namespace INTERP_KERNEL { public: std::vector convertIntoMachineLangage(const std::vector& asmb) const throw(INTERP_KERNEL::Exception); - char *convertMachineLangageInBasic(const std::vector& ml, int& lgth) const; + char *copyToExecMemZone(const std::vector& ml, unsigned& offset) const; private: void convertOneInstructionInML(const std::string& inst, std::vector& ml) const throw(INTERP_KERNEL::Exception); private: diff --git a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx index 0b29d67f7..1f6b497b5 100644 --- a/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx +++ b/src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx @@ -28,14 +28,6 @@ #include #include -#ifdef _POSIX_MAPPED_FILES -#include -#else -#ifdef WNT -#include -#endif -#endif - using namespace INTERP_KERNEL; const char LeafExprVar::END_OF_RECOGNIZED_VAR[]="Vec"; @@ -719,21 +711,8 @@ char *ExprParser::compileX86() const for(std::vector::const_iterator iter=output.begin();iter!=output.end();iter++) std::cout << std::hex << (int)((unsigned char)(*iter)) << " "; std::cout << std::endl; - int lgth; - char *lm=asmb.convertMachineLangageInBasic(output,lgth); - char *ret=0; -#ifdef _POSIX_MAPPED_FILES - ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0); -#else -#ifdef WNT - HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL); - ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth); -#endif -#endif - if(ret) - std::copy(lm,lm+lgth,ret); - delete [] lm; - return ret; + unsigned offset; + return asmb.copyToExecMemZone(output,offset); } char *ExprParser::compileX86_64() const @@ -757,21 +736,8 @@ char *ExprParser::compileX86_64() const for(std::vector::const_iterator iter=output.begin();iter!=output.end();iter++) std::cout << std::hex << (int)((unsigned char)(*iter)) << " "; std::cout << std::endl; - int lgth; - char *lm=asmb.convertMachineLangageInBasic(output,lgth); - char *ret=0; -#ifdef _POSIX_MAPPED_FILES - ret=(char *)mmap(0,lgth,PROT_EXEC | PROT_WRITE,MAP_ANONYMOUS | MAP_PRIVATE,-1,0); -#else -#ifdef WNT - HANDLE h=CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,lgth,NULL); - ret=(char *)MapViewOfFile(h,FILE_MAP_EXECUTE | FILE_MAP_READ | FILE_MAP_WRITE,0,0,lgth); -#endif -#endif - if(ret) - std::copy(lm,lm+lgth,ret); - delete [] lm; - return ret; + unsigned offset; + return asmb.copyToExecMemZone(output,offset); } void ExprParser::compileX86LowLev(std::vector& ass) const