📄 main.h
字号:
/*0245*/#endif
/*0246*/
/*0247*//* This option can be used for turning on/off constant pool integrity
/*0248./ * checking. When turned on, the system checks that the given constant
/*0249./ * pool references point to appropriate constant pool entries at
/*0250./ * runtime, thus verifying the structural integrity of the class.
/*0251./ * As obvious, the system runs slightly faster with the integrity
/*0252./ * checking turned off. This check is not required by the JVM
/*0253./ * spec, but provides some additional assurance that the VM is
/*0254./ * behaving properly and that classfiles don't contain illegal code.
/*0255./ */
/*0256*/#ifndef VERIFYCONSTANTPOOLINTEGRITY
/*0257*/#define VERIFYCONSTANTPOOLINTEGRITY 1
/*0258*/#endif
/*0259*/
/*0260*//* This macro makes the virtual machine sleep when it has
/*0261./ * no better things to do. The default implementation is
/*0262./ * a busy loop. Most ports usually require a more efficient
/*0263./ * implementation that allow the VM to utilize the host-
/*0264./ * specific battery power conservation features.
/*0265./ *
/*0266./ */
/*0267*/#ifndef SLEEP_UNTIL
/*0268*/# define SLEEP_UNTIL(wakeupTime) \
/*0269*/ for (;;) { \
/*0270*/ ulong64 now = CurrentTime_md(); \
/*0271*/ if (ll_compare_ge(now, wakeupTime)) { \
/*0272*/ break; \
/*0273*/ } \
/*0274*/ }
/*0275*/#endif
/*0276*/
/*0277*//*=========================================================================
/*0278./ * KVM 1.0.2 interpreter execution options (redesigned interpreter)
/*0279./ *=======================================================================*/
/*0280*/
/*0281*//* Enabling this option will cause the interpreter to permit
/*0282./ * thread rescheduling only at branch and return statements.
/*0283./ * Disabling the options allows thread rescheduling to occur
/*0284./ * at the start of every bytecode (as in KVM 1.0). Turning
/*0285./ * this option on will speed up the interpreter by about 5%
/*0286./ * (simply because the time slice counter will be updated
/*0287./ * less frequently.)
/*0288./ */
/*0289*/#ifndef RESCHEDULEATBRANCH
/*0290*/#define RESCHEDULEATBRANCH 1
/*0291*/#endif
/*0292*/
/*0293*//* The time slice factor is used to calculate the base time slice and to
/*0294./ * set up a timeslice when a thread has its priority changed. This
/*0295./ * value determines how much execution time each thread receives
/*0296./ * before a thread switch occurs. Default value 100 is used when
/*0297./ * the RESCHEDULEATBRANCH option is on (meaning that the VM will
/*0298./ * switch threads when 100 branch instructions have been executed.)
/*0299./ * If RESCHEDULEATBRANCH option is off, we use value 1000 (meaning
/*0300./ * that thread switch occurs after this many bytecodes have been
/*0301./ * executed.)
/*0302./ */
/*0303*/#ifndef TIMESLICEFACTOR
/*0304*/#if RESCHEDULEATBRANCH
/*0305*/#define TIMESLICEFACTOR 100
/*0306*/#else
/*0307*/#define TIMESLICEFACTOR 1000
/*0308*/#endif
/*0309*/#endif
/*0310*/
/*0311*//* The value of this macro determines the basic frequency (as a number
/*0312./ * of bytecodes executed) by which the virtual machine performs thread
/*0313./ * switching, event notification, and some other periodically needed
/*0314./ * operations. A smaller number reduces event handling and thread
/*0315./ * switching latency, but causes the interpreter to run slower.
/*0316./ */
/*0317*/#ifndef BASETIMESLICE
/*0318*/#define BASETIMESLICE TIMESLICEFACTOR
/*0319*/#endif
/*0320*/
/*0321*//* This option will cause the infrequently called Java bytecodes to be
/*0322./ * split into a separate interpreter loop. It has been found that
/*0323./ * doing so gives a small space and performance benefit on many systems.
/*0324./ *
/*0325./ * IMPORTANT: This option works well only if ENABLEFASTBYTECODES
/*0326./ * option is also turned on. For this reason, we currently
/*0327./ * should not use this option on the Palm.
/*0328./ */
/*0329*/#ifndef SPLITINFREQUENTBYTECODES
/*0330*/#define SPLITINFREQUENTBYTECODES 1
/*0331*/#endif
/*0332*/
/*0333*//* This option when enabled will cause the main switch() statement in the
/*0334./ * interpreter loop to be padded with entries for unused bytecodes. It has
/*0335./ * been found that doing so on some systems will cause the code for the
/*0336./ * switch table to be larger, but the resulting code runs substantially
/*0337./ * faster. Use this option only when space is not absolutely critical.
/*0338./ */
/*0339*/#ifndef PADTABLE
/*0340*/#define PADTABLE 0
/*0341*/#endif
/*0342*/
/*0343*//* Turning this option on will allow the VM to allocate all the
/*0344./ * virtual machine registers (ip, fp, sp, lp and cp) in native
/*0345./ * registers inside the Interpret() routine. Enabling this feature
/*0346./ * significantly speeds up the interpreter (actual performance
/*0347./ * improvement depends on how good a job your C compiler does
/*0348./ * when compiling the interpreter loop.) This option is specific
/*0349./ * to KVM 1.0.2. When turned off, the interpreter speed is about
/*0350./ * the same as in KVM 1.0.
/*0351./ */
/*0352*/#ifndef LOCALVMREGISTERS
/*0353*/#define LOCALVMREGISTERS 1
/*0354*/#endif
/*0355*/
/*0356*//* The following definitions determine which virtual machine registers
/*0357./ * should be made local to the main interpreter loop. These macros
/*0358./ * allow you to more precisely control the allocation of these VM
/*0359./ * registers to hardware registers, yet in a portable fashion. This
/*0360./ * is valuable especially on those target platforms that have a
/*0361./ * limited number of hardware registers. Note that these macros
/*0362./ * have effect only if the LOCALVMREGISTERS option above is turned on.
/*0363./ *
/*0364./ * The macros below are defined in the order of "most-to-least
/*0365./ * bang-for-the-buck". In order to improve Java interpreter
/*0366./ * performance, IP and SP are most critical, then LP, FP and CP.
/*0367./ */
/*0368*//* IP = Instruction Pointer */
/*0369*/#ifndef IPISLOCAL
/*0370*/#define IPISLOCAL 1
/*0371*/#endif
/*0372*/
/*0373*//* SP = Stack Pointer */
/*0374*/#ifndef SPISLOCAL
/*0375*/#define SPISLOCAL 1
/*0376*/#endif
/*0377*/
/*0378*//* LP = Locals Pointer */
/*0379*/#ifndef LPISLOCAL
/*0380*/#define LPISLOCAL 0
/*0381*/#endif
/*0382*/
/*0383*//* FP = Frame Pointer */
/*0384*/#ifndef FPISLOCAL
/*0385*/#define FPISLOCAL 0
/*0386*/#endif
/*0387*/
/*0388*//* CP = Constant Pool Pointer */
/*0389*/#ifndef CPISLOCAL
/*0390*/#define CPISLOCAL 0
/*0391*/#endif
/*0392*/
/*0393*//*=========================================================================
/*0394./ * Java-level debugging options
/*0395./ *=======================================================================*/
/*0396*/
/*0397*//* KVM includes an interface that allows the virtual machine
/*0398./ * to be plugged into a third-party source-level Java debugger
/*0399./ * such as Forte, CodeWarrior or JBuilder.
/*0400./ *
/*0401./ * The macros below are related to the use of the new
/*0402./ * Java-level debugger. Actual debugger code is located
/*0403./ * in directory VmExtra.
/*0404./ */
/*0405*/
/*0412*//*=========================================================================
/*0413./ * Debugging and tracing options
/*0414./ *=======================================================================*/
/*0415*/
/*0416*//* The macros below enable/disable the debugging of the KVM itself
/*0417./ * (at the C code level). These macros, inherited from KVM 1.0,
/*0418./ * are independent of the Java-level debugging macros defined above.
/*0419./ */
/*0420*/
/*0421*//* Includes/eliminates a large amount of optional debugging code
/*0422./ * (such as class and stack frame printing operations) in/from
/*0423./ * the system. By eliminating debug code, the system will be smaller.
/*0424./ * Inclusion of debugging code increases the size of the system but
/*0425./ * does not introduce any performance overhead unless calls to the
/*0426./ * debugging routines are added to the source code or various tracing
/*0427./ * options are turned on. This option is normally turned off in
/*0428./ * production builds.
/*0429./ */
/*0430*/#ifndef INCLUDEDEBUGCODE
/*0431*/#define INCLUDEDEBUGCODE 0
/*0432*/#endif
/*0433*/
/*0434*//* Turns VM execution profiling and additional safety/sanity
/*0435./ * checks on/off. VM will run slightly slower with this option on.
/*0436./ * This option should normally be turned off in production builds.
/*0437./ */
/*0438*/#ifndef ENABLEPROFILING
/*0439*/#define ENABLEPROFILING 0
/*0440*/#endif
/*0441*/
/*0442*//*=========================================================================
/*0443./ * Compile-time flags for choosing different tracing/debugging options.
/*0444./ * These options can make the system very verbose. Turn them all off
/*0445./ * for normal VM operation. When turning them on, it is useful to
/*0446./ * turn INCLUDEDEBUGCODE on, too, since many of the routines utilize
/*0447./ * debugging code to provide more detailed information to the user.
/*0448./ *=======================================================================*/
/*0449*/
/*0450*//* Prints out less verbose messages on small machines */
/*0451*/#ifndef TERSE_MESSAGES
/*0452*/#define TERSE_MESSAGES 0
/*0453*/#endif
/*0454*/
/*0455*//* Turns exception handling backtrace information on/off */
/*0456*/#ifndef PRINT_BACKTRACE
/*0457*/#define PRINT_BACKTRACE INCLUDEDEBUGCODE
/*0458*/#endif
/*0459*/
/*0460*//*=========================================================================
/*0461./ * Miscellaneous macros and options
/*0462./ *=======================================================================*/
/*0463*/
/*0464*//* Some functions in the reference implementation take arguments
/*0465./ * that they do not use. Some compilers will issue warnings; others
/*0466./ * do not. For those compilers that issue warnings, this macro
/*0467./ * can be used to indicate that the corresponding variable,
/*0468./ * though and argument to the function, isn't actually used.
/*0469./ */
/*0470*/#ifndef UNUSEDPARAMETER
/*0471*/#define UNUSEDPARAMETER(x)
/*0472*/#endif
/*0473*/
/*0474*//* Some ROMized implementations may want to forbid any new classes
/*0475./ * from being loaded into any system package. The following macro
/*0476./ * defines whether a package name is one of these restricted packages.
/*0477./ * By default, we prevent dynamic class loading to java.* and javax.*.
/*0478./ */
/*0479*/#ifndef IS_RESTRICTED_PACKAGE_NAME
/*0480*/#define IS_RESTRICTED_PACKAGE_NAME(name) \
/*0481*/ ((strncmp(name, "java.", 5) == 0) || (strncmp(name, "javax.", 6) == 0))
/*0482*/#endif
/*0483*/
/*0484*//*=========================================================================
/*0485./ * VM startup function prototypes
/*0486./ *=======================================================================*/
/*0487*/
/*0488*/int StartJVM(int argc, char* argv[]);
/*0489*/int KVM_Initialize(void);
/*0490*/int KVM_Start(int argc, char* argv[]);
/*0491*/void KVM_Cleanup(void);
/*0492*/
/*0493*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -