Пример #1
0
void Options::initialize()
{
#if !PLATFORM(WKC)
    static std::once_flag initializeOptionsOnceFlag;
    
    std::call_once(
        initializeOptionsOnceFlag,
        [] {
#else
    WKC_DEFINE_STATIC_BOOL(initializeOptionsOnceFlag, false);
    if (!initializeOptionsOnceFlag) {
        initializeOptionsOnceFlag = true;
#endif
            // Initialize each of the options with their default values:
#define FOR_EACH_OPTION(type_, name_, defaultValue_, description_)      \
            name_() = defaultValue_;                                    \
            name_##Default() = defaultValue_;
            JSC_OPTIONS(FOR_EACH_OPTION)
#undef FOR_EACH_OPTION
    
                // It *probably* makes sense for other platforms to enable this.
#if PLATFORM(IOS) && CPU(ARM64)
                useLLVMFastISel() = true;
#endif
        
            // Allow environment vars to override options if applicable.
            // The evn var should be the name of the option prefixed with
            // "JSC_".
#define FOR_EACH_OPTION(type_, name_, defaultValue_, description_)      \
            overrideOptionWithHeuristic(name_(), "JSC_" #name_);
            JSC_OPTIONS(FOR_EACH_OPTION)
#undef FOR_EACH_OPTION

#if 0
                ; // Deconfuse editors that do auto indentation
#endif
    
            recomputeDependentOptions();

            // Do range checks where needed and make corrections to the options:
            ASSERT(Options::thresholdForOptimizeAfterLongWarmUp() >= Options::thresholdForOptimizeAfterWarmUp());
            ASSERT(Options::thresholdForOptimizeAfterWarmUp() >= Options::thresholdForOptimizeSoon());
            ASSERT(Options::thresholdForOptimizeAfterWarmUp() >= 0);

            if (Options::dumpOptions()) {
                DumpLevel level = static_cast<DumpLevel>(Options::dumpOptions());
                if (level > DumpLevel::Verbose)
                    level = DumpLevel::Verbose;

                const char* title = nullptr;
                switch (level) {
                case DumpLevel::None:
                    break;
                case DumpLevel::Overridden:
                    title = "Overridden JSC options:";
                    break;
                case DumpLevel::All:
                    title = "All JSC options:";
                    break;
                case DumpLevel::Verbose:
                    title = "All JSC options with descriptions:";
                    break;
                }
                dumpAllOptions(level, title);
            }

            ensureOptionsAreCoherent();
#if !PLATFORM(WKC)
        });
#else
    }
Пример #2
0
void Options::initialize()
{
    static std::once_flag initializeOptionsOnceFlag;
    
    std::call_once(
        initializeOptionsOnceFlag,
        [] {
            // Initialize each of the options with their default values:
#define FOR_EACH_OPTION(type_, name_, defaultValue_, description_)      \
            name_() = defaultValue_;                                    \
            name_##Default() = defaultValue_;
            JSC_OPTIONS(FOR_EACH_OPTION)
#undef FOR_EACH_OPTION
    
                // It *probably* makes sense for other platforms to enable this.
#if PLATFORM(IOS) && CPU(ARM64)
                enableLLVMFastISel() = true;
#endif
        
            // Allow environment vars to override options if applicable.
            // The evn var should be the name of the option prefixed with
            // "JSC_".
#define FOR_EACH_OPTION(type_, name_, defaultValue_, description_)      \
            overrideOptionWithHeuristic(name_(), "JSC_" #name_);
            JSC_OPTIONS(FOR_EACH_OPTION)
#undef FOR_EACH_OPTION

#if 0
                ; // Deconfuse editors that do auto indentation
#endif
    
            recomputeDependentOptions();

#if USE(OPTIONS_FILE)
            {
                const char* filename = OPTIONS_FILENAME;
                FILE* optionsFile = fopen(filename, "r");
                if (!optionsFile) {
                    dataLogF("Failed to open file %s. Did you add the file-read-data entitlement to WebProcess.sb?\n", filename);
                    return;
                }
                
                StringBuilder builder;
                char* line;
                char buffer[BUFSIZ];
                while ((line = fgets(buffer, sizeof(buffer), optionsFile)))
                    builder.append(buffer);
                
                const char* optionsStr = builder.toString().utf8().data();
                dataLogF("Setting options: %s\n", optionsStr);
                setOptions(optionsStr);
                
                int result = fclose(optionsFile);
                if (result)
                    dataLogF("Failed to close file %s: %s\n", filename, strerror(errno));
            }
#endif

            // Do range checks where needed and make corrections to the options:
            ASSERT(Options::thresholdForOptimizeAfterLongWarmUp() >= Options::thresholdForOptimizeAfterWarmUp());
            ASSERT(Options::thresholdForOptimizeAfterWarmUp() >= Options::thresholdForOptimizeSoon());
            ASSERT(Options::thresholdForOptimizeAfterWarmUp() >= 0);

            dumpOptionsIfNeeded();
            ensureOptionsAreCoherent();
        });
}
Пример #3
0
void Options::initialize()
{
    static std::once_flag initializeOptionsOnceFlag;
    
    std::call_once(
        initializeOptionsOnceFlag,
        [] {
            // Initialize each of the options with their default values:
#define FOR_EACH_OPTION(type_, name_, defaultValue_, availability_, description_) \
            name_() = defaultValue_;                                    \
            name_##Default() = defaultValue_;
            JSC_OPTIONS(FOR_EACH_OPTION)
#undef FOR_EACH_OPTION

            overrideDefaults();
                
            // Allow environment vars to override options if applicable.
            // The evn var should be the name of the option prefixed with
            // "JSC_".
#if PLATFORM(COCOA)
            bool hasBadOptions = false;
            for (char** envp = *_NSGetEnviron(); *envp; envp++) {
                const char* env = *envp;
                if (!strncmp("JSC_", env, 4)) {
                    if (!Options::setOption(&env[4])) {
                        dataLog("ERROR: invalid option: ", *envp, "\n");
                        hasBadOptions = true;
                    }
                }
            }
            if (hasBadOptions && Options::validateOptions())
                CRASH();
#else // PLATFORM(COCOA)
#define FOR_EACH_OPTION(type_, name_, defaultValue_, availability_, description_) \
            overrideOptionWithHeuristic(name_(), name_##ID, "JSC_" #name_, Availability::availability_);
            JSC_OPTIONS(FOR_EACH_OPTION)
#undef FOR_EACH_OPTION
#endif // PLATFORM(COCOA)

#define FOR_EACH_OPTION(aliasedName_, unaliasedName_, equivalence_) \
            overrideAliasedOptionWithHeuristic("JSC_" #aliasedName_);
            JSC_ALIASED_OPTIONS(FOR_EACH_OPTION)
#undef FOR_EACH_OPTION

#if 0
                ; // Deconfuse editors that do auto indentation
#endif
    
#if USE(OPTIONS_FILE)
            {
                const char* filename = OPTIONS_FILENAME;
                FILE* optionsFile = fopen(filename, "r");
                if (!optionsFile) {
                    dataLogF("Failed to open file %s. Did you add the file-read-data entitlement to WebProcess.sb?\n", filename);
                    return;
                }
                
                StringBuilder builder;
                char* line;
                char buffer[BUFSIZ];
                while ((line = fgets(buffer, sizeof(buffer), optionsFile)))
                    builder.append(buffer);
                
                const char* optionsStr = builder.toString().utf8().data();
                dataLogF("Setting options: %s\n", optionsStr);
                setOptions(optionsStr);
                
                int result = fclose(optionsFile);
                if (result)
                    dataLogF("Failed to close file %s: %s\n", filename, strerror(errno));
            }
#endif

            recomputeDependentOptions();

            // Do range checks where needed and make corrections to the options:
            ASSERT(Options::thresholdForOptimizeAfterLongWarmUp() >= Options::thresholdForOptimizeAfterWarmUp());
            ASSERT(Options::thresholdForOptimizeAfterWarmUp() >= Options::thresholdForOptimizeSoon());
            ASSERT(Options::thresholdForOptimizeAfterWarmUp() >= 0);

            dumpOptionsIfNeeded();
            ensureOptionsAreCoherent();
        });
}