Commit 45e9500a authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Gin] Add feature to control optimization in V8.

Change-Id: I7ff3a987d132d4ca8e0f350e851020b53d4fb009
Reviewed-on: https://chromium-review.googlesource.com/980947
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: default avatarMythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546143}
parent c1847936
...@@ -25,6 +25,8 @@ component("gin") { ...@@ -25,6 +25,8 @@ component("gin") {
"function_template.cc", "function_template.cc",
"function_template.h", "function_template.h",
"gin_export.h", "gin_export.h",
"gin_features.cc",
"gin_features.h",
"handle.h", "handle.h",
"interceptor.cc", "interceptor.cc",
"interceptor.h", "interceptor.h",
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gin/gin_features.h"
namespace features {
// Enables optimization of JavaScript in V8.
const base::Feature kV8OptimizeJavascript{"V8OptimizeJavascript",
base::FEATURE_ENABLED_BY_DEFAULT};
} // namespace features
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef GIN_GIN_FEATURES_H_
#define GIN_GIN_FEATURES_H_
#include "base/feature_list.h"
#include "gin/gin_export.h"
namespace features {
GIN_EXPORT extern const base::Feature kV8OptimizeJavascript;
} // namespace features
#endif // GIN_GIN_FEATURES_H_
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "base/threading/platform_thread.h" #include "base/threading/platform_thread.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "gin/gin_features.h"
#if defined(V8_USE_EXTERNAL_STARTUP_DATA) #if defined(V8_USE_EXTERNAL_STARTUP_DATA)
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
...@@ -242,6 +243,14 @@ void V8Initializer::Initialize(IsolateHolder::ScriptMode mode, ...@@ -242,6 +243,14 @@ void V8Initializer::Initialize(IsolateHolder::ScriptMode mode,
v8::V8::InitializePlatform(V8Platform::Get()); v8::V8::InitializePlatform(V8Platform::Get());
if (base::FeatureList::IsEnabled(features::kV8OptimizeJavascript)) {
static const char optimize[] = "--opt";
v8::V8::SetFlagsFromString(optimize, sizeof(optimize) - 1);
} else {
static const char no_optimize[] = "--no-opt";
v8::V8::SetFlagsFromString(no_optimize, sizeof(no_optimize) - 1);
}
if (IsolateHolder::kStrictMode == mode) { if (IsolateHolder::kStrictMode == mode) {
static const char use_strict[] = "--use_strict"; static const char use_strict[] = "--use_strict";
v8::V8::SetFlagsFromString(use_strict, sizeof(use_strict) - 1); v8::V8::SetFlagsFromString(use_strict, sizeof(use_strict) - 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment