]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message *** V6_2_BR RELIQUAT_6x_15112010 V6_2_0 V6_2_0a2 V6_2_0rc1
authorageay <ageay>
Thu, 16 Dec 2010 13:47:53 +0000 (13:47 +0000)
committerageay <ageay>
Thu, 16 Dec 2010 13:47:53 +0000 (13:47 +0000)
src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.cxx
src/INTERP_KERNEL/ExprEval/InterpKernelAsmX86.hxx
src/INTERP_KERNEL/ExprEval/InterpKernelExprParser.cxx

index ee7116fd2e32d62a3196951cc9c0a62a8fea25a5..479b5c78ec8c201e50fbc57b3c36efdf5aee2f41 100644 (file)
 #include <sstream>
 #include <algorithm>
 
+#ifdef _POSIX_MAPPED_FILES
+#include <sys/mman.h>
+#else
+#ifdef WNT
+#include <windows.h>
+#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<char> INTERP_KERNEL::AsmX86::convertIntoMachineLangage(const std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception)
@@ -33,11 +41,20 @@ std::vector<char> INTERP_KERNEL::AsmX86::convertIntoMachineLangage(const std::ve
   return ret;
 }
 
-char *INTERP_KERNEL::AsmX86::convertMachineLangageInBasic(const std::vector<char>& ml, int& lgth) const
+char *INTERP_KERNEL::AsmX86::copyToExecMemZone(const std::vector<char>& 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;
 }
 
index 11b8733e5040701355a8d6237167d728ea36345c..fd7bc9afc840417159687d4451c1d85ed96120d5 100644 (file)
@@ -32,7 +32,7 @@ namespace INTERP_KERNEL
   {
   public:
     std::vector<char> convertIntoMachineLangage(const std::vector<std::string>& asmb) const throw(INTERP_KERNEL::Exception);
-    char *convertMachineLangageInBasic(const std::vector<char>& ml, int& lgth) const;
+    char *copyToExecMemZone(const std::vector<char>& ml, unsigned& offset) const;
   private:
     void convertOneInstructionInML(const std::string& inst, std::vector<char>& ml) const throw(INTERP_KERNEL::Exception);
   private:
index 0b29d67f72f04f3f18d82c8499a3844e3310a189..1f6b497b5fd10c7aee297bc290d57b9ba6ce5a6b 100644 (file)
 #include <iostream>
 #include <algorithm>
 
-#ifdef _POSIX_MAPPED_FILES
-#include <sys/mman.h>
-#else
-#ifdef WNT
-#include <windows.h>
-#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<char>::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<char>::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<std::string>& ass) const