fix after merge, rename runVMKIT by enableJIT, enable completion on names, add disabl...
Antoine ELIAS [Mon, 30 Sep 2013 17:44:50 +0000 (19:44 +0200)]
23 files changed:
scilab/modules/core/Makefile.am
scilab/modules/core/includes/core_gw.hxx
scilab/modules/core/includes/tasks.hxx
scilab/modules/core/includes/vmkit.hxx [moved from scilab/modules/core/includes/vmkit.h with 96% similarity]
scilab/modules/core/sci_gateway/cpp/core_gw.cpp
scilab/modules/core/src/cpp/InitScilab.cpp
scilab/modules/core/src/cpp/scilab.cpp
scilab/modules/core/src/cpp/tasks.cpp
scilab/modules/core/src/cpp/vmkit.cpp
scilab/modules/functions_manager/includes/module_declaration.hxx
scilab/modules/functions_manager/src/cpp/funcmanager.cpp
scilab/modules/jit/Makefile.am
scilab/modules/jit/includes/JITvisitor.hxx
scilab/modules/jit/includes/dynlib_jit_gw.h [new file with mode: 0644]
scilab/modules/jit/includes/jit_gw.hxx [new file with mode: 0644]
scilab/modules/jit/includes/vmkit_core.h [deleted file]
scilab/modules/jit/jit_gww.hxx [new file with mode: 0644]
scilab/modules/jit/sci_gateway/cpp/jit_gw.cpp [new file with mode: 0644]
scilab/modules/jit/sci_gateway/cpp/sci_disableJIT.cpp [new file with mode: 0644]
scilab/modules/jit/sci_gateway/cpp/sci_enableJIT.cpp [new file with mode: 0644]
scilab/modules/jit/sci_gateway/cpp/sci_isJIT.cpp [moved from scilab/modules/jit/sci_gateway/cpp/sci_runVMKit.cpp with 70% similarity]
scilab/modules/system_env/includes/configvariable.hxx
scilab/modules/system_env/src/cpp/configvariable.cpp

index 6215e90..70df408 100644 (file)
@@ -136,13 +136,11 @@ endif
 GATEWAY_C_SOURCES = \
        sci_gateway/c/gw_core.c \
        sci_gateway/c/gw_user.c \
+       sci_gateway/c/gw_user2.c \
        sci_gateway/c/sci_type.c \
        sci_gateway/c/sci_getdebuginfo.c \
-       sci_gateway/c/gw_user2.c \
-       sci_gateway/c/sci_getvariablesonstack.c \
-       sci_gateway/c/sci_readgateway.c \
-       sci_gateway/c/sci_comp.c
-
+       sci_gateway/c/sci_readgateway.c
+       
 GATEWAY_FORTRAN_SOURCES =  \
 sci_gateway/fortran/where.f
 
index a40bb51..c2afe2a 100644 (file)
@@ -57,6 +57,5 @@ CPP_GATEWAY_PROTOTYPE(sci_mode);
 CPP_GATEWAY_PROTOTYPE(sci_typename);
 CPP_GATEWAY_PROTOTYPE(sci_where);
 CPP_GATEWAY_PROTOTYPE(sci_getmemory);
-CPP_GATEWAY_PROTOTYPE(sci_runVMKit);
 
 #endif /* __CORE_GW_HXX__ */
index 5ac5ec8..482e59b 100644 (file)
@@ -48,7 +48,7 @@ void printAstTask(ast::Exp *tree, bool timed);
 **
 ** Execute the stored AST.
 */
-void execAstTask(ast::Exp *tree, bool timed, bool ASTtimed, bool execVerbose, bool ASTrunVMKit);
+void execAstTask(ast::Exp *tree, bool timed, bool ASTtimed, bool execVerbose, bool execJIT);
 
 /*
 ** Exec Tree with original visitor ( without template )
similarity index 96%
rename from scilab/modules/core/includes/vmkit.h
rename to scilab/modules/core/includes/vmkit.hxx
index acd8167..c739115 100644 (file)
  *
  */
 
+extern "C" {
+    #include "machine.h"
+    #include "InitScilab.h"
+}
+
 #include "MutatorThread.h"
 #include "vmkit/System.h"
 #include "vmkit/Locks.h"
 #include "vmkit/Thread.h"
 #include "vmkit/VirtualMachine.h"
-#include "InitScilab.h"
 
 
 namespace VMKitScilab
@@ -26,6 +30,7 @@ class ScilabThread : public vmkit::MutatorThread
 {
 private:
     ScilabEngineInfo* pSEI;
+    int ret;
 
 public:
     void setArgs(ScilabEngineInfo* _pSEI);
index 2e9f2ac..14ab867 100644 (file)
@@ -56,6 +56,5 @@ int CoreModule::Load()
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"mode", &sci_mode, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"where", &sci_where, MODULE_NAME));
     symbol::Context::getInstance()->addFunction(Function::createFunction(L"getmemory", &sci_getmemory, MODULE_NAME));
-    symbol::Context::getInstance()->addFunction(Function::createFunction(L"runVMKit", &sci_runVMKit, MODULE_NAME));
     return 1;
 }
index 49c442f..080e526 100644 (file)
@@ -74,8 +74,6 @@ extern "C"
     extern BOOL isItTheDisabledLib(void);
 }
 
-extern bool ASTrunVMKit;
-
 static void Add_i(void);
 static void Add_pi(void);
 static void Add_eps(void);
@@ -402,7 +400,7 @@ static Parser::ControlStatus processCommand(ScilabEngineInfo* _pSEI)
             {
                 //before calling YaspReader, try to call %onprompt function
                 callOnPrompt();
-                execAstTask(parser->getTree(), _pSEI->iTimed != 0, _pSEI->iAstTimed != 0, _pSEI->iExecVerbose != 0, ASTrunVMKit);
+                execAstTask(parser->getTree(), _pSEI->iTimed != 0, _pSEI->iAstTimed != 0, _pSEI->iExecVerbose != 0, ConfigVariable::isJIT());
             }
 
             /*
index 65aaa10..c115661 100644 (file)
@@ -35,7 +35,7 @@ extern "C"
 #include "scilabWrite.hxx"
 
 #if defined(VMKIT_ENABLED)
-#include <vmkit_core.h>
+#include "vmkit.hxx"
 #endif
 
 #define INTERACTIVE     -1
@@ -84,8 +84,6 @@ static int get_option(const int argc, char *argv[], ScilabEngineInfo* _pSEI)
     bool execFile = false;
     bool parseFile = false;
 
-    bool ASTrunVMKit = false;
-
     for (i = 1; i < argc; ++i)
     {
         if (!strcmp("--parse-trace", argv[i]))
@@ -152,10 +150,7 @@ static int get_option(const int argc, char *argv[], ScilabEngineInfo* _pSEI)
             if (argc >= i)
             {
                 _pSEI->pstLang = argv[i];
-/*                //before calling YaspReader, try to call %onprompt function
-                callOnPrompt();
-                execAstTask(parser->getTree(), timed, ASTtimed, execVerbose, ASTrunVMKit);
-*/            }
+            }
         }
         else if (!strcmp("-nw", argv[i]))
         {
@@ -271,7 +266,7 @@ int main(int argc, char *argv[])
     setScilabInputMethod(&getCmdLine);
     setScilabOutputMethod(&TermPrintf);
 
-#if defined(VMKIT_ENABLED)
+#ifdef VMKIT_ENABLED
     vmkit::CompiledFrames** frametables;
     vmkit::BumpPtrAllocator Allocator;
 
@@ -284,6 +279,7 @@ int main(int argc, char *argv[])
     return vm->getret();
 
 #else
+    #pragma message "VMKIT Disable"
     StartScilabEngine(pSEI);
     iRet = RunScilabEngine(pSEI);
     StopScilabEngine(pSEI);
index 54a6f25..9cf9083 100644 (file)
 
 Timer _timer;
 
-// Defined at modules/core/src/cpp/scilab.cpp
-extern bool ASTrunVMKit;
-
-//#define DEBUG
-
 /*
 ** Parse
 **
@@ -159,7 +154,7 @@ void printAstTask(ast::Exp *tree, bool timed)
 **
 ** Execute the stored AST.
 */
-void execAstTask(ast::Exp* tree, bool timed, bool ASTtimed, bool execVerbose, bool ASTrunVMKit)
+void execAstTask(ast::Exp* tree, bool timed, bool ASTtimed, bool execVerbose, bool execJIT)
 {
     if (tree == NULL)
     {
@@ -187,7 +182,7 @@ void execAstTask(ast::Exp* tree, bool timed, bool ASTtimed, bool execVerbose, bo
         exec = new ast::ExecVisitor();
     }
 
-    if (ASTrunVMKit)
+    if (execJIT)
     {
         ast::JITVisitor *jitExec;
 
@@ -253,7 +248,7 @@ void execScilabStartTask(void)
         return;
     }
 
-    execAstTask(parse.getTree(), false, false, false, ASTrunVMKit);
+    execAstTask(parse.getTree(), false, false, false, ConfigVariable::isJIT());
 }
 
 /*
@@ -275,7 +270,7 @@ void execScilabQuitTask(void)
         return;
     }
 
-    execAstTask(parse.getTree(), false, false, false, ASTrunVMKit);
+    execAstTask(parse.getTree(), false, false, false, ConfigVariable::isJIT());
 }
 
 
index 34e6ba6..e47e7a5 100644 (file)
  *
  */
 
-#if defined(VMKIT_ENABLED)
+#include "vmkit.hxx"
+
+#ifdef VMKIT_ENABLED
+
+
 namespace VMKitScilab
 {
 void ScilabThread::setArgs(ScilabEngineInfo* _pSEI)
@@ -23,7 +27,7 @@ void ScilabThread::setret(int ret)
     this->ret = ret;
 }
 
-int ScilabThread::getArgs()
+ScilabEngineInfo* ScilabThread::getArgs()
 {
     return pSEI;
 }
@@ -45,7 +49,9 @@ ScilabVM* ScilabThread::vm()
 
 void ScilabThread::execute()
 {
-    setret(StartScilabEngine(getargc(), getargv(), getiFileIndex(), getiLangIndex()));
+    StartScilabEngine(pSEI);
+    setret(RunScilabEngine(pSEI));
+    StopScilabEngine(pSEI);
 }
 
 void ScilabVM::mainStart(ScilabThread* thread)
@@ -63,7 +69,7 @@ void ScilabVM::mainStart(ScilabThread* thread)
 
 void ScilabVM::runApplication(ScilabEngineInfo* _pSEI)
 {
-    VMKitScilab::ScilabThread * mainThread = new VMKitScilab::ScilabThread(this);
+    ScilabThread * mainThread = new ScilabThread(this);
 
     mainThread->setArgs(_pSEI);
 
index e4fa858..5ea6fad 100644 (file)
@@ -49,4 +49,5 @@
 #include "../../polynomials/includes/polynomials_gw.hxx"
 #include "../../data_structures/includes/data_structures_gw.hxx"
 #include "../../completion/includes/completion_gw.hxx"
+#include "../../jit/includes/jit_gw.hxx"
 #endif /* !__MODULE_DECLARATION_HXX__ */
index acefb57..29e2cb9 100644 (file)
@@ -30,6 +30,7 @@
 #include "module_declaration.hxx"
 #include "parser.hxx"
 #include "execvisitor.hxx"
+#include "machine.h"
 
 extern "C"
 {
@@ -338,6 +339,10 @@ bool FuncManager::CreateModuleList(void)
 #ifdef _MSC_VER
     m_ModuleMap.insert(pair<wstring, GW_MOD>(L"windows_tools", &WindowsToolsModule::Load));
 #endif
+
+#ifdef VMKIT_ENABLED
+    m_ModuleMap.insert(pair<wstring, GW_MOD>(L"jit", &JITModule::Load));
+#endif
     return true;
 }
 
index f47d78a..eea4cef 100644 (file)
@@ -16,7 +16,10 @@ JIT_CPP_SOURCES = \
        src/cpp/jitter.cpp
 
 GATEWAY_CPP_SOURCES =   \
-sci_gateway/cpp/sci_runVMKit.cpp
+       sci_gateway/cpp/jit_gw.cpp \
+    sci_gateway/cpp/sci_enableJIT.cpp \
+    sci_gateway/cpp/sci_disableJIT.cpp \
+    sci_gateway/cpp/sci_isJIT.cpp
 
 libscijit_la_CPPFLAGS = \
        -Iincludes \
index 7ad86fe..3267a77 100644 (file)
@@ -72,7 +72,7 @@ extern "C" {
 #include "llvm/ExecutionEngine/JIT.h"
 #include "llvm/PassManager.h"
 #include "llvm/IR/DataLayout.h"
-#include "vmkit_core.h"
+//#include "vmkit_core.h"
 
 #undef WHITE
 #undef Max
diff --git a/scilab/modules/jit/includes/dynlib_jit_gw.h b/scilab/modules/jit/includes/dynlib_jit_gw.h
new file mode 100644 (file)
index 0000000..c5b9259
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) Scilab Enterprises - 2013 - Antoine ELIAS
+*
+* This file must be used under the terms of the CeCILL.
+* This source file is licensed as described in the file COPYING, which
+* you should have received as part of this distribution.  The terms
+* are also available at
+* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+
+/*--------------------------------------------------------------------------*/
+#ifndef __DYNLIB_JIT_GW_H__
+#define __DYNLIB_JIT_GW_H__
+
+#ifdef _MSC_VER
+#ifdef JIT_GW_EXPORTS
+#define JIT_GW_IMPEXP __declspec(dllexport)
+#else
+#define JIT_GW_IMPEXP __declspec(dllimport)
+#endif
+#else
+#define JIT_GW_IMPEXP
+#endif
+
+#endif /* __DYNLIB_JIT_GW_H__ */
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/jit/includes/jit_gw.hxx b/scilab/modules/jit/includes/jit_gw.hxx
new file mode 100644 (file)
index 0000000..4fe66e9
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ *  Copyright (C) 2010-2011 - DIGITEO - Bruno JOFRET
+ *
+ *  This file must be used under the terms of the CeCILL.
+ *  This source file is licensed as described in the file COPYING, which
+ *  you should have received as part of this distribution.  The terms
+ *  are also available at
+ *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef __JIT_GW_HXX__
+#define __JIT_GW_HXX__
+
+
+#include "dynlib_jit_gw.h"
+
+#include "cpp_gateway_prototype.hxx"
+
+class JITModule
+{
+private :
+    JITModule() {};
+    ~JITModule() {};
+
+public :
+    JIT_GW_IMPEXP static int Load();
+};
+
+CPP_GATEWAY_PROTOTYPE(sci_enableJIT);
+CPP_GATEWAY_PROTOTYPE(sci_disableJIT);
+CPP_GATEWAY_PROTOTYPE(sci_isJIT);
+
+#endif /* !__JIT_GW_HXX__ */
diff --git a/scilab/modules/jit/includes/vmkit_core.h b/scilab/modules/jit/includes/vmkit_core.h
deleted file mode 100644 (file)
index 0af011c..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-#include "MutatorThread.h"
-#include "vmkit/System.h"
-#include "vmkit/Locks.h"
-#include "vmkit/Thread.h"
-#include "vmkit/VirtualMachine.h"
-
-namespace VMKitScilab
-{
-class ScilabVM;
-
-class ScilabThread : public vmkit::MutatorThread
-{
-private:
-    int argc, iFileIndex, iLangIndex, ret;
-    char **argv;
-
-public:
-    void setArgs(int argc, char** argv, int iFileIndex, int iLangIndex);
-    void setret(int ret);
-    int getargc();
-    int getiFileIndex();
-    int getiLangIndex();
-    char **getargv();
-    int getret();
-
-    ScilabThread (ScilabVM* vm);
-    ScilabVM* vm();
-    void execute();
-};
-
-class ScilabVM : public vmkit::VirtualMachine
-{
-private:
-    int ret;
-
-public:
-    vmkit::BumpPtrAllocator Alloc;
-    vmkit::CompiledFrames **frames;
-
-    ScilabVM (vmkit::BumpPtrAllocator& Alloc, vmkit::CompiledFrames** frames) : VirtualMachine(Alloc, frames) {}
-    ~ScilabVM() {}
-
-    virtual void startCollection() {}
-    virtual void endCollection() {}
-    virtual void scanWeakReferencesQueue(word_t closure) {}
-    virtual void scanSoftReferencesQueue(word_t closure) {}
-    virtual void scanPhantomReferencesQueue(word_t closure) {}
-    virtual void scanFinalizationQueue(word_t closure) {}
-    virtual void addFinalizationCandidate(gc* obj) {}
-    virtual void finalizeObject(gc* res) {}
-    virtual void traceObject(gc* obj, word_t closure) {}
-    virtual void setType(gc* header, void* type) {}
-    virtual void setType(void* header, void* type) {}
-    virtual void* getType(gc* obj) {}
-    virtual size_t getObjectSize(gc* obj) {}
-    virtual const char* getObjectTypeName(gc* obj) {}
-    virtual bool isCorruptedType(gc* header) {}
-    virtual void printMethod(vmkit::FrameInfo* FI, word_t ip, word_t addr) {}
-    virtual void invokeEnqueueReference(gc* res) {}
-    virtual void clearObjectReferent(gc* ref) {}
-    virtual gc** getObjectReferentPtr(gc* _obj) {}
-    virtual void setObjectReferent(gc* _obj, gc* val) {}
-
-    virtual void runApplication(int argc, char** argv) {}
-
-    virtual void runApplication(int argc, char**  argv, int iFileIndex, int iLangIndex);
-
-    virtual void nullPointerException() {}
-    virtual void stackOverflowError() {}
-
-    static void mainStart(ScilabThread* thread);
-    int getret();
-    void setret(int ret);
-};
-}
diff --git a/scilab/modules/jit/jit_gww.hxx b/scilab/modules/jit/jit_gww.hxx
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/scilab/modules/jit/sci_gateway/cpp/jit_gw.cpp b/scilab/modules/jit/sci_gateway/cpp/jit_gw.cpp
new file mode 100644 (file)
index 0000000..ed8c81f
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+*  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+*  Copyright (C) 2008-2008 - DIGITEO - Antoine ELIAS
+*
+*  This file must be used under the terms of the CeCILL.
+*  This source file is licensed as described in the file COPYING, which
+*  you should have received as part of this distribution.  The terms
+*  are also available at
+*  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+*
+*/
+
+#include "jit_gw.hxx"
+#include "context.hxx"
+
+#define MODULE_NAME L"core"
+
+using namespace types;
+
+int JITModule::Load()
+{
+    symbol::Context::getInstance()->addFunction(Function::createFunction(L"enableJIT", &sci_enableJIT, MODULE_NAME));
+    symbol::Context::getInstance()->addFunction(Function::createFunction(L"disableJIT", &sci_disableJIT, MODULE_NAME));
+    return 1;
+}
diff --git a/scilab/modules/jit/sci_gateway/cpp/sci_disableJIT.cpp b/scilab/modules/jit/sci_gateway/cpp/sci_disableJIT.cpp
new file mode 100644 (file)
index 0000000..9a8e4fa
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013-2013 - LIP6 - Peter Senna Tschudin
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+#include "funcmanager.hxx"
+#include "jit_gw.hxx"
+#include "configvariable.hxx"
+#include "function.hxx"
+extern "C"
+{
+#include "sciprint.h"
+#include "localization.h"
+}
+
+/*--------------------------------------------------------------------------*/
+using namespace types;
+/*--------------------------------------------------------------------------*/
+Function::ReturnValue sci_disableJIT(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    sciprint(_("Disable JIT\n"));
+
+    ConfigVariable::disableJIT();
+
+    return Function::OK;
+}
+/*--------------------------------------------------------------------------*/
diff --git a/scilab/modules/jit/sci_gateway/cpp/sci_enableJIT.cpp b/scilab/modules/jit/sci_gateway/cpp/sci_enableJIT.cpp
new file mode 100644 (file)
index 0000000..85d8b44
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2013-2013 - LIP6 - Peter Senna Tschudin
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution.  The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+#include "funcmanager.hxx"
+#include "jit_gw.hxx"
+#include "configvariable.hxx"
+#include "function.hxx"
+
+extern "C"
+{
+#include "sciprint.h"
+#include "localization.h"
+}
+
+/*--------------------------------------------------------------------------*/
+using namespace types;
+/*--------------------------------------------------------------------------*/
+Function::ReturnValue sci_enableJIT(types::typed_list &in, int _iRetCount, types::typed_list &out)
+{
+    sciprint(_("Enable JIT\n"));
+
+    ConfigVariable::enableJIT();
+
+    return Function::OK;
+}
+/*--------------------------------------------------------------------------*/
 #include "funcmanager.hxx"
 #include "context.hxx"
 #include "core_gw.hxx"
-#include "string.hxx"
+#include "bool.hxx"
+#include "configvariable.hxx"
 
 extern "C"
 {
 #include "sci_mode.h"
-#include "Scierror.h"
+#include "sciprint.h"
 #include "localization.h"
 #include "sci_mode.h"
 #include "os_strdup.h"
 }
 
-// Defined at modules/core/src/cpp/scilab.cpp
-extern bool ASTrunVMKit;
-
 /*--------------------------------------------------------------------------*/
-
 using namespace types;
-
-Function::ReturnValue sci_runVMKit(types::typed_list &in, int _iRetCount, types::typed_list &out)
+/*--------------------------------------------------------------------------*/
+Function::ReturnValue sci_isJIT(types::typed_list &in, int _iRetCount, types::typed_list &out)
 {
-    Scierror(999, _("Coming soon...\n"));
-
-    ASTrunVMKit = true;
+    bool isJIT = ConfigVariable::isJIT();
+    
+    out.push_back(new Bool(isJIT ? 1 : 0));
 
     return Function::OK;
 }
index a693cac..ffedc2d 100644 (file)
@@ -351,6 +351,15 @@ public :
     static void where_end();
     static std::list< std::pair<int, std::wstring> >& getWhere();
 
+
+    //JIT
+private :
+    static bool m_bJIT;
+public :
+    static void enableJIT();
+    static void disableJIT();
+    static bool isJIT();
+
 };
 
 #endif /* !__CONFIGVARIABLE_HXX__ */
index bf46c79..dc76e6c 100644 (file)
@@ -991,3 +991,29 @@ std::list< std::pair<int, std::wstring> >& ConfigVariable::getWhere()
 /*
 ** \}
 */
+
+/*
+** JIT
+** \{
+*/
+
+bool ConfigVariable::m_bJIT = false;
+
+void ConfigVariable::enableJIT()
+{
+    m_bJIT = true;
+}
+
+void ConfigVariable::disableJIT()
+{
+    m_bJIT = false;
+}
+
+bool ConfigVariable::isJIT()
+{
+    return m_bJIT;
+}
+
+/*
+** \}
+*/