Skip to content

Commit

Permalink
[Gin] Add feature to do extra masking in V8.
Browse files Browse the repository at this point in the history
Change-Id: Iba70082c0c8cb01c8bcb8c5c6e7f0fa237184f30
Reviewed-on: https://chromium-review.googlesource.com/834088
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#525316}
  • Loading branch information
rmcilroy authored and Commit Bot committed Dec 20, 2017
1 parent 087e357 commit e265c9c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions gin/gin_features.cc
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions gin/gin_features.h
Original file line number Diff line number Diff line change
@@ -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_
9 changes: 9 additions & 0 deletions gin/v8_initializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e265c9c

Please sign in to comment.