diff --git a/gin/BUILD.gn b/gin/BUILD.gn index 82edcb414f8203..53cb543fd2a31a 100644 --- a/gin/BUILD.gn +++ b/gin/BUILD.gn @@ -23,6 +23,8 @@ component("gin") { "function_template.cc", "function_template.h", "gin_export.h", + "gin_features.cc", + "gin_features.h", "handle.h", "interceptor.cc", "interceptor.h", diff --git a/gin/gin_features.cc b/gin/gin_features.cc new file mode 100644 index 00000000000000..1dc573404ea465 --- /dev/null +++ b/gin/gin_features.cc @@ -0,0 +1,13 @@ +// 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 extra masking and integrity checking in V8. +const base::Feature kV8ExtraMasking{"V8ExtraMasking", + base::FEATURE_DISABLED_BY_DEFAULT}; + +} // namespace features diff --git a/gin/gin_features.h b/gin/gin_features.h new file mode 100644 index 00000000000000..f779d6ec205616 --- /dev/null +++ b/gin/gin_features.h @@ -0,0 +1,17 @@ +// 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_FEATURES_H_ +#define GIN_FEATURES_H_ + +#include "base/feature_list.h" +#include "gin/gin_export.h" + +namespace features { + +GIN_EXPORT extern const base::Feature kV8ExtraMasking; + +} // namespace features + +#endif // GIN_FEATURES_H_ diff --git a/gin/v8_initializer.cc b/gin/v8_initializer.cc index 03353beb9ddb6e..292f4cb2a4d6a1 100644 --- a/gin/v8_initializer.cc +++ b/gin/v8_initializer.cc @@ -25,6 +25,7 @@ #include "base/threading/platform_thread.h" #include "base/time/time.h" #include "build/build_config.h" +#include "gin/gin_features.h" #if defined(V8_USE_EXTERNAL_STARTUP_DATA) #if defined(OS_ANDROID) @@ -231,6 +232,14 @@ void V8Initializer::Initialize(IsolateHolder::ScriptMode mode, v8::V8::InitializePlatform(V8Platform::Get()); + if (base::FeatureList::IsEnabled(features::kV8ExtraMasking)) { + static const char extra_masking[] = "--extra-masking"; + v8::V8::SetFlagsFromString(extra_masking, sizeof(extra_masking) - 1); + } else { + static const char no_extra_masking[] = "--no-extra-masking"; + v8::V8::SetFlagsFromString(no_extra_masking, sizeof(no_extra_masking) - 1); + } + if (IsolateHolder::kStrictMode == mode) { static const char use_strict[] = "--use_strict"; v8::V8::SetFlagsFromString(use_strict, sizeof(use_strict) - 1);