Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Side by Side Diff: content/renderer/render_process_impl.cc

Issue 1890793002: [v8] Fix Chrome's "Experimental JavaScript" switch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/common/content_switches.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_process_impl.h" 5 #include "content/renderer/render_process_impl.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
11 #include <objidl.h> 11 #include <objidl.h>
12 #include <mlang.h> 12 #include <mlang.h>
13 #endif 13 #endif
14 14
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
17 #include "base/feature_list.h"
17 #include "base/sys_info.h" 18 #include "base/sys_info.h"
18 #include "content/child/site_isolation_stats_gatherer.h" 19 #include "content/child/site_isolation_stats_gatherer.h"
19 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
20 #include "content/public/renderer/content_renderer_client.h" 21 #include "content/public/renderer/content_renderer_client.h"
21 #include "third_party/WebKit/public/web/WebFrame.h" 22 #include "third_party/WebKit/public/web/WebFrame.h"
22 #include "v8/include/v8.h" 23 #include "v8/include/v8.h"
23 24
25 namespace {
26
27 const base::Feature kV8_ES2015_TailCalls_Feature {
28 "V8_ES2015_TailCalls", base::FEATURE_DISABLED_BY_DEFAULT
29 };
30
31 const base::Feature kV8SerializeEagerFeature{"V8_Serialize_Eager",
32 base::FEATURE_DISABLED_BY_DEFAULT};
33
34 const base::Feature kV8SerializeAgeCodeFeature{
35 "V8_Serialize_Age_Code", base::FEATURE_DISABLED_BY_DEFAULT};
36
37 void SetV8FlagIfFeature(const base::Feature& feature, const char* v8_flag) {
38 if (base::FeatureList::IsEnabled(feature)) {
39 v8::V8::SetFlagsFromString(v8_flag, strlen(v8_flag));
40 }
41 }
42
43 void SetV8FlagIfHasSwitch(const char* switch_name, const char* v8_flag) {
44 if (base::CommandLine::ForCurrentProcess()->HasSwitch(switch_name)) {
45 v8::V8::SetFlagsFromString(v8_flag, strlen(v8_flag));
46 }
47 }
48
49 } // namespace
50
24 namespace content { 51 namespace content {
25 52
26 RenderProcessImpl::RenderProcessImpl() 53 RenderProcessImpl::RenderProcessImpl()
27 : enabled_bindings_(0) { 54 : enabled_bindings_(0) {
28 #if defined(OS_WIN) 55 #if defined(OS_WIN)
29 // HACK: See http://b/issue?id=1024307 for rationale. 56 // HACK: See http://b/issue?id=1024307 for rationale.
30 if (GetModuleHandle(L"LPK.DLL") == NULL) { 57 if (GetModuleHandle(L"LPK.DLL") == NULL) {
31 // Makes sure lpk.dll is loaded by gdi32 to make sure ExtTextOut() works 58 // Makes sure lpk.dll is loaded by gdi32 to make sure ExtTextOut() works
32 // when buffering into a EMF buffer for printing. 59 // when buffering into a EMF buffer for printing.
33 typedef BOOL (__stdcall *GdiInitializeLanguagePack)(int LoadedShapingDLLs); 60 typedef BOOL (__stdcall *GdiInitializeLanguagePack)(int LoadedShapingDLLs);
34 GdiInitializeLanguagePack gdi_init_lpk = 61 GdiInitializeLanguagePack gdi_init_lpk =
35 reinterpret_cast<GdiInitializeLanguagePack>(GetProcAddress( 62 reinterpret_cast<GdiInitializeLanguagePack>(GetProcAddress(
36 GetModuleHandle(L"GDI32.DLL"), 63 GetModuleHandle(L"GDI32.DLL"),
37 "GdiInitializeLanguagePack")); 64 "GdiInitializeLanguagePack"));
38 DCHECK(gdi_init_lpk); 65 DCHECK(gdi_init_lpk);
39 if (gdi_init_lpk) { 66 if (gdi_init_lpk) {
40 gdi_init_lpk(0); 67 gdi_init_lpk(0);
41 } 68 }
42 } 69 }
43 #endif 70 #endif
44 71
45 if (base::SysInfo::IsLowEndDevice()) { 72 if (base::SysInfo::IsLowEndDevice()) {
46 std::string optimize_flag("--optimize-for-size"); 73 std::string optimize_flag("--optimize-for-size");
47 v8::V8::SetFlagsFromString(optimize_flag.c_str(), 74 v8::V8::SetFlagsFromString(optimize_flag.c_str(),
48 static_cast<int>(optimize_flag.size())); 75 static_cast<int>(optimize_flag.size()));
49 } 76 }
50 77
78 SetV8FlagIfFeature(kV8_ES2015_TailCalls_Feature, "--harmony-tailcalls");
79 SetV8FlagIfFeature(kV8SerializeEagerFeature, "--serialize_eager");
80 SetV8FlagIfFeature(kV8SerializeAgeCodeFeature, "--serialize_age_code");
81 SetV8FlagIfHasSwitch(switches::kDisableJavaScriptHarmonyShipping,
82 "--noharmony-shipping");
83 SetV8FlagIfHasSwitch(switches::kJavaScriptHarmony, "--harmony");
84 SetV8FlagIfHasSwitch(switches::kEnableWasm, "--expose-wasm");
85
51 const base::CommandLine& command_line = 86 const base::CommandLine& command_line =
52 *base::CommandLine::ForCurrentProcess(); 87 *base::CommandLine::ForCurrentProcess();
88
53 if (command_line.HasSwitch(switches::kJavaScriptFlags)) { 89 if (command_line.HasSwitch(switches::kJavaScriptFlags)) {
54 std::string flags( 90 std::string flags(
55 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags)); 91 command_line.GetSwitchValueASCII(switches::kJavaScriptFlags));
56 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size())); 92 v8::V8::SetFlagsFromString(flags.c_str(), static_cast<int>(flags.size()));
57 } 93 }
58 94
59 SiteIsolationStatsGatherer::SetEnabled( 95 SiteIsolationStatsGatherer::SetEnabled(
60 GetContentClient()->renderer()->ShouldGatherSiteIsolationStats()); 96 GetContentClient()->renderer()->ShouldGatherSiteIsolationStats());
61 } 97 }
62 98
63 RenderProcessImpl::~RenderProcessImpl() { 99 RenderProcessImpl::~RenderProcessImpl() {
64 #ifndef NDEBUG 100 #ifndef NDEBUG
65 int count = blink::WebFrame::instanceCount(); 101 int count = blink::WebFrame::instanceCount();
66 if (count) 102 if (count)
67 DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES"; 103 DLOG(ERROR) << "WebFrame LEAKED " << count << " TIMES";
68 #endif 104 #endif
69 105
70 GetShutDownEvent()->Signal(); 106 GetShutDownEvent()->Signal();
71 } 107 }
72 108
73 void RenderProcessImpl::AddBindings(int bindings) { 109 void RenderProcessImpl::AddBindings(int bindings) {
74 enabled_bindings_ |= bindings; 110 enabled_bindings_ |= bindings;
75 } 111 }
76 112
77 int RenderProcessImpl::GetEnabledBindings() const { 113 int RenderProcessImpl::GetEnabledBindings() const {
78 return enabled_bindings_; 114 return enabled_bindings_;
79 } 115 }
80 116
81 } // namespace content 117 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/content_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698