|
|
Created:
3 years, 8 months ago by peria Modified:
3 years, 4 months ago Reviewers:
rkc, jochen (gone - plz use gerrit), Michael Lippautz, jam, agrieve, dcheng, Yuki, kinuko, eroman, haraken, brettw, Nico CC:
apavlov+blink_chromium.org, blink-reviews, blink-reviews-api_chromium.org, blink-reviews-bindings_chromium.org, blink-worker-reviews_chromium.org, caseq+blink_chromium.org, cbentzel+watch_chromium.org, chromium-reviews, darin-cc_chromium.org, devtools-reviews_chromium.org, dglazkov+blink, falken+watch_chromium.org, horo+watch_chromium.org, jam, kinuko+watch, kinuko+worker_chromium.org, kozyatinskiy+blink_chromium.org, lushnikov+blink_chromium.org, net-reviews_chromium.org, pfeldman+blink_chromium.org, shimazu+worker_chromium.org Target Ref:
refs/heads/master Project:
chromium Visibility:
Public. |
DescriptionCreate and use V8 context snapshots.
This CL does two things.
1. In compile time, creates a snapshot file, which consists of V8 contexts.
2. Creates v8::Context from the snapshot in LocalWindowProxy::CreateContext().
We expect this speeds up context creation for 3 times faster on Android.
Detailed information is described in the design doc [1].
[1] Design doc: https://docs.google.com/document/d/1jpQQX0piaxcHJPWakp_Kr_03g5Gnma5h5-Kdlqu7jVQ/edit#heading=h.k6iklq6rvd30
Test expectations are changed due to http://crbug.com/705364
BUG=588893, 617892, 705364
Review-Url: https://codereview.chromium.org/2841443005
Cr-Commit-Position: refs/heads/master@{#490329}
Committed: https://chromium.googlesource.com/chromium/src/+/54afe29f866e4c3878242de7a78941fc363791e9
Patch Set 1 : . #
Total comments: 32
Patch Set 2 : Fix tests and introduce RuntimeEnabled flag #
Total comments: 2
Patch Set 3 : Fix some behaviors #
Total comments: 124
Patch Set 4 : Work for some comments #
Total comments: 58
Patch Set 5 : Work for most comments #
Total comments: 84
Patch Set 6 : Work for most comments #
Total comments: 14
Patch Set 7 : Work for all comments #
Total comments: 48
Patch Set 8 : Support runtime feature on templates #
Total comments: 10
Patch Set 9 : Work for yuki's comments #
Total comments: 34
Patch Set 10 : Move snapshot maker to tools/ and work for comments #
Total comments: 11
Patch Set 11 : Work for comments #
Total comments: 2
Patch Set 12 : Work for comments #Patch Set 13 : Disable on ChromeOS and reduce size of table #
Total comments: 150
Patch Set 14 : Work for comments #
Total comments: 52
Patch Set 15 : Work for other than DOMWrapperWorld #Patch Set 16 : Work for nits and libc fix? #
Total comments: 8
Patch Set 17 : Update GN files #Patch Set 18 : Clean up #
Total comments: 4
Patch Set 19 : Update manifest #Patch Set 20 : Take it down on Android #Patch Set 21 : Fix libc++ error #Patch Set 22 : Rebase #Messages
Total messages: 205 (125 generated)
Description was changed from ========== Create and use V8 context snapshots. This CL does two things. 1. Creates a file "context_blob.bin", which has snapshots of V8 contexts. 2. Instantiates v8::Context from the snapshot. Design doc: https://docs.google.com/document/d/1jpQQX0piaxcHJPWakp_Kr_03g5Gnma5h5-Kdlqu7j... BUG=588893, 617892 ========== to ========== Create and use V8 context snapshots. This CL does two things. 1. Creates a file "context_blob.bin", which has snapshots of V8 contexts, during compile time. 2. Instantiates v8::Context from the snapshot in LocalWindowProxy::createContext(). Design doc: https://docs.google.com/document/d/1jpQQX0piaxcHJPWakp_Kr_03g5Gnma5h5-Kdlqu7j... BUG=588893, 617892 ==========
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_chromeos_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
Patchset #2 (id:20001) has been deleted
Patchset #1 (id:1) has been deleted
peria@chromium.org changed reviewers: + haraken@chromium.org, yukishiino@chromium.org
Not for land for now. PS1 still have build failures on 3 trybots, but I believe it passes all unit tests and layout tests on others. So please take a look on the code design and components' dependencies. I'm working to fix the build errors, which should be fixed with updating build files.
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
I've not yet reviewed the entire CL, but I'm about running out the time. So, let me send intermediate comments. I'll review the rest after Golden Week. https://codereview.chromium.org/2841443005/diff/40001/chrome/BUILD.gn File chrome/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/40001/chrome/BUILD.gn#newcode793 chrome/BUILD.gn:793: "$root_out_dir/context_blob.bin", I'd prefer a different name, such as blink_v8_context_snapshot.bin. "context_blob" looks too generic and vague. https://codereview.chromium.org/2841443005/diff/40001/content/app/content_mai... File content/app/content_main_runner.cc (right): https://codereview.chromium.org/2841443005/diff/40001/content/app/content_mai... content/app/content_main_runner.cc:220: file_descriptor_store.MaybeTakeFD(kV8ContextDataDescriptor, ®ion); Here and there, you seem calling "a snapshot of V8 context for the use in Blink" "V8 context". It seems quite confusing. I'd propose the followings. 1) explicitly distinguish a snapshot of V8 context from a V8 context. 2) explicitly distinguish a snapshot of V8 context for Blink from the V8 snapshot of V8 built-in's. For example, v8_context_snapshot_fd and kV8ContextSnapshotDataDescriptor, or, considering that the owner is Blink (not V8), blink_v8_context_snapshot_fd (Blink's snapshot of V8 context) and kBlinkV8ContextSnapshotDataDescriptor. (I'd prefer the latter, but I think that not few people prefer the former.) https://codereview.chromium.org/2841443005/diff/40001/content/app/content_mai... content/app/content_main_runner.cc:222: gin::V8Initializer::LoadV8ContextFromFD(v8_context_fd.get(), region.offset, LoadV8ContextSnapshotFromFD? https://codereview.chromium.org/2841443005/diff/40001/content/public/common/c... File content/public/common/content_descriptor_keys.cc (right): https://codereview.chromium.org/2841443005/diff/40001/content/public/common/c... content/public/common/content_descriptor_keys.cc:17: const char kV8ContextDataDescriptor[] = "v8_context_data"; v8_context_snapshot_data? https://codereview.chromium.org/2841443005/diff/40001/content/public/common/c... File content/public/common/content_descriptor_keys.h (right): https://codereview.chromium.org/2841443005/diff/40001/content/public/common/c... content/public/common/content_descriptor_keys.h:15: // sync. Don't we need to update content/public/app/mojo/content_renderer_manifest.json , too? https://codereview.chromium.org/2841443005/diff/40001/gin/BUILD.gn File gin/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/40001/gin/BUILD.gn#newcode135 gin/BUILD.gn:135: exec = "$root_out_dir/gin_blink_snapshot" Not so bad, but a little confusing name, I think. We don't take a snapshot of Blink... You can add a header comment for action("run_gin_blink_snapshot") describing what it does and what it is meant for. https://codereview.chromium.org/2841443005/diff/40001/gin/BUILD.gn#newcode174 gin/BUILD.gn:174: ":noicf", Better to comment why we need :noicf. https://codereview.chromium.org/2841443005/diff/40001/gin/public/isolate_hold... File gin/public/isolate_holder.h (right): https://codereview.chromium.org/2841443005/diff/40001/gin/public/isolate_hold... gin/public/isolate_holder.h:69: intptr_t*, Write the parameter name, e.g. snapshot_external_references. https://codereview.chromium.org/2841443005/diff/40001/gin/run.py File gin/run.py (right): https://codereview.chromium.org/2841443005/diff/40001/gin/run.py#newcode2 gin/run.py:2: # Copyright 2016 The Chromium Authors. All rights reserved. nit: You may want to update the year to 2017, but I'm not sure. Same for other files, too. https://codereview.chromium.org/2841443005/diff/40001/gin/shell/gin_prepare_m... File gin/shell/gin_prepare_main.cc (right): https://codereview.chromium.org/2841443005/diff/40001/gin/shell/gin_prepare_m... gin/shell/gin_prepare_main.cc:75: blink::SnapshotCreator::SetTakingSnapshot(true); s/SetTakingSnapshot/SetTakeSnapshot/ https://codereview.chromium.org/2841443005/diff/40001/gin/shell/gin_prepare_m... gin/shell/gin_prepare_main.cc:78: v8::StartupData blob = blink::SnapshotCreator::SetUpSnapshotCreator(creator); I've not yet read the implementation of SetUpSnapshotCreator, but this looks weird. Probably, blob = TakeSnapshot() ? https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.cc File gin/v8_initializer.cc (right): https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.cc#n... gin/v8_initializer.cc:48: const char kV8ContextFileName[] = "context_blob.bin"; kV8ContextSnapshotFilename? https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.cc#n... gin/v8_initializer.cc:447: return; Is it really okay to simply return? Do we need to fallback to LoadV8Context()? Or, should we crash? If it's okay as is, then I'd like a comment about why. https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.cc#n... gin/v8_initializer.cc:459: if (result == V8_LOAD_SUCCESS) { Why don't you simply write if (MapV8File(...)) { ... } ? https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.cc#n... gin/v8_initializer.cc:466: base::PlatformFile V8Initializer::GetOpenV8ContextFileForChildProcesses( GetOpened? I'm not sure what child processes are. Are they renderer processes? Then, ForRendererProcesses is preferred. https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.h File gin/v8_initializer.h (right): https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.h#ne... gin/v8_initializer.h:33: static void GetV8ContextData(const char** snapshot_data_out, GetV8ContextSnapshotData?
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Not address Shiino-san's comments yet, but please take another look. I believe PS2 passes all trybot tests. Plus, I introduced RuntimeEnabled flag to use the snapshot context.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
mlippautz@chromium.org changed reviewers: + mlippautz@chromium.org
https://codereview.chromium.org/2841443005/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:232: per_isolate_data->GetScriptWrappableVisitor()->RegisterV8Reference( Line 232 is not needed. SetWrapper will take care of announcing the wrapper using the write barrier, which will bail out if tracing is off. Whenever you think you need to call into ScriptWrappableVisitor, consider adding me as CC to clarify whether this should be needed.
Description was changed from ========== Create and use V8 context snapshots. This CL does two things. 1. Creates a file "context_blob.bin", which has snapshots of V8 contexts, during compile time. 2. Instantiates v8::Context from the snapshot in LocalWindowProxy::createContext(). Design doc: https://docs.google.com/document/d/1jpQQX0piaxcHJPWakp_Kr_03g5Gnma5h5-Kdlqu7j... BUG=588893, 617892 ========== to ========== Create and use V8 context snapshots. This CL does two things. 1. Creates a file "context_blob.bin", which has snapshots of V8 contexts, during compile time. 2. Instantiates v8::Context from the snapshot in LocalWindowProxy::createContext(). Test expectations are changed due to http://crbug.com/705364 Design doc: https://docs.google.com/document/d/1jpQQX0piaxcHJPWakp_Kr_03g5Gnma5h5-Kdlqu7j... BUG=588893, 617892, 705364 ==========
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2841443005/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:232: per_isolate_data->GetScriptWrappableVisitor()->RegisterV8Reference( On 2017/05/04 17:30:23, Michael Lippautz wrote: > Line 232 is not needed. SetWrapper will take care of announcing the wrapper > using the write barrier, which will bail out if tracing is off. > > Whenever you think you need to call into ScriptWrappableVisitor, consider adding > me as CC to clarify whether this should be needed. Done. The issue I asked you had gone with your change in V8. Thank you.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_amd64-generic_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_amd64-...)
Still reviewing, but let me send another intermediate review comments. There seem a lot of things to look at in this CL. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:162: TRACE_EVENT1("v8", "notification", "isMainWindow", nit: I'm not clear about what "main window" is. Would "isMainFrame" be a better name? At least, isMainFrame is not confusing against "main-world window". https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:179: struct DataForDeserializer { You don't want to expose this kind of hack outside V8SnapshotCreater. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:184: const WrapperTypeInfo* FieldTypeToWrapperTypeInfo( V8SnapshotCreater should be responsible about the mapping between enum FieldType and WrapperTypeInfo. Why don't you define this function in V8SnapshotCreater? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:214: case V8SnapshotCreator::kNodeType: nit: Probably it's cleaner to use bit flags here. kInterfaceObject = 1 << n1, kPlatformObject = 1 << n2, kNodeInterface = kInterfaceObject | 1 << 0, kDocumentInterface = kInterfaceObject | 1 << 1, ... kHTMLDocumentInstance = kPlatformObject | 1 << 0, for example. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:219: index, const_cast<WrapperTypeInfo*>(wrapper_type_info)); I'm not confident, but we wouldn't need to set an internal field on an interface object nor prototype object. I know that we are setting internal fields on prototype objects, but are we really setting them on interface objects, too? If so, can we stop setting them? I vaguely guess that we could stop setting internal fields on prototype objects, too. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:220: wrapper_type_info->WrapperCreated(); IIUC, interface objects are not considered as "wrapper objects", or at least no need to call WrapperCreated(). Plus, WrapperCreated() is now a static member function. No need to use wrapper_type_info, here. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:232: CHECK(document->SetWrapper(isolate, wrapper_type_info, wrapper)); I think that you should use document->AssociateWithWrapper. ScriptWrappable::SetWrapper only works for the main world, plus it doesn't take care of WrapperCreated() nor SetNativeInfo(). https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:247: if (V8PerIsolateData::From(GetIsolate())->UseSnapshot()) { This kind of code should live hidden in V8SnapshotCreater, and CreateContext()'d better call an API of V8SnapshotCreater. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:289: (!World().IsMainWorld() || (document && document->IsHTMLDocument()))) { I don't understand these conditions. I thought that we always have |document|. In what cases don't we have |document|? Also, why the world matters? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:290: const int index = World().IsMainWorld() ? 0 : 1; Where these magic numbers 0 and 1 come from? You may not want to expose these magic numbers outside V8SnapshotCreater. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:299: if (context.IsEmpty()) { Should this simply be } else { ? It seems that you're not expecting any failure of Context::FromSnapshot. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:322: TRACE_EVENT1("v8", "LocalWindowProxy::setupWindowPrototypeChain", nit: s/setup/Setup/ https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:377: TRACE_EVENT1("v8", "LocalWindowProxy::updateDocumentProperty", "isMainWindow", nit: s/update/Update/ https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:387: v8::Local<v8::Object> wrapper = document_wrapper.As<v8::Object>(); s/wrapper/htmldocument_wrapper/ and make it clear that you're following platform object of type HTMLDocument => HTMLDocument.prototype => Document.prototype Use of htmldocument_prototype would be good. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:392: V8Document::installRuntimeEnabledFeatures(GetIsolate(), World(), wrapper, Although it's noop, we do have {V8HTMLDocument,V8Node,...}::installRuntimeEnabledFeatures. You should call them, too, or it will be fragile or surprising in future. Also, you'd like to hide all this kind of things in V8SnapshotCreater. My understanding is that V8SnapshotCreater is responsible to take a snapshot of what things, which interface objects and which platform objects. LocalWindowProxy must not need to know which interface or platform objects are taken into a snapshot.
I'll review the following two files next week. bindings/core/v8/V8SnapshotCreator.cpp bindings/templates/snapshot.cpp.tmpl I think that I've taken the first look at other files. https://codereview.chromium.org/2841443005/diff/80001/gin/public/isolate_hold... File gin/public/isolate_holder.h (right): https://codereview.chromium.org/2841443005/diff/80001/gin/public/isolate_hold... gin/public/isolate_holder.h:69: intptr_t*, nit: Write the argument name that is not trivial. v8_snapshot_external_references? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:692: if (V8SnapshotCreator::TakingSnapshot()) { Curious. Why V8SnapshotCreator::TakingSnapshot() is a static member while data->UseSnapshot() is a non-static member? A little asymmetric. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:694: data->FindInterfaceTemplateTemp(world, wrapper_type_info); I think it's better not to expose FindInterfaceTemplateTemp. It's better to make this hidden in V8PerIsolateData. V8PerIsolateData::FindInterfaceTemplate(...) { if (V8SnapshotCreator::TakingSnapshot()) { return ...new code...; } else { return ...old code...; } } Ditto for SetInterfaceTemplate. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:698: static const WrapperTypeInfo* snapshot_types[] = { These things should be hidden in V8SnapshotCreator. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:708: for (size_t i = 0; i < WTF_ARRAY_LENGTH(snapshot_types); ++i) { nit: I think you can use range-based for-loop. for (const auto& wrapper_type_info : snapshotted_types) https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:711: .ToLocal(&interface_template)) { nit: ToLocalChecked()? Or are we really going to support a fallback mechanism, seriously? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp:450: void V8Initializer::InitializeMainThread(intptr_t* table) { |table| doesn't make much sense. v8_snapshot_external_references for example? Should this be retrieved through V8SnapshotCreator::GetExternalReferences() rather than passing in as an argument? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8Initializer.h:39: static void InitializeMainThread(intptr_t*); nit: Write the argument name. It's not trivial. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:1: #include "bindings/core/v8/V8SnapshotCreator.h" Copyright? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:16: #include <v8.h> s|<v8.h>|"v8/include/v8.h"| https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h:16: class CORE_EXPORT V8SnapshotCreator { The class header comment is welcome. Function comments are also welcome. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp:40: #include "platform/instrumentation/tracing/TraceEvent.h" Why do we need this here? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/modules/v8/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/modules/v8/BUILD.gn:16: ":bindings_v8_generated_reference_table", "reference_table" seems not clear about what it is. "bindings_v8_(context_)snapshot_external_references" for example? I'm not insisting to this name. Any better names are welcome. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/modules/v8/V8SnapshotReference.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/modules/v8/V8SnapshotReference.h:8: #include <v8.h> s|<v8.h>|"v8/include/v8.h"| https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/modules/v8/V8SnapshotReference.h:14: class MODULES_EXPORT V8SnapshotReference { STATIC_ONLY? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/modules/v8/V8SnapshotReference.h:16: static intptr_t* getExternalReferences(); s/get/Get/ https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/scripts/scripts.gni (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/scripts/scripts.gni:300: template("idl_reference_table") { V8 snapshot is not relevant to Web IDL at all. Without the context of "V8 (context) snapshot", "reference_table" is not clear about what it is, because "reference" and "table" are general terms. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/scripts/scripts.gni:302: script = "//third_party/WebKit/Source/bindings/scripts/generate_reference_table.py" Ditto. "generate_reference_table" is vague. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/templates/templates.gni (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/templates/templates.gni:28: "snapshot.cpp.tmpl", s/snapshot/snapshot_reference/ following the class name? I think that "snapshot_external_reference" is a better name, though. My understanding is that: - snapshot = a serialized blob - snapshot reference = a reference to a snapshot? or external references? better than "snapshot", but still a bit unclear. - snapshot external references = a list of external references for a snapshot. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/bindings/V8DOMWrapper.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8DOMWrapper.cpp:70: v8::Local<v8::Function> ConstructPlainType(v8::Isolate* isolate, No one seems using this function? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:57: bool take_snapshot) bool argument, which is ambiguous, is not recommended. enum is preferred. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:103: static v8::Isolate* Initialize(WebTaskRunner*, intptr_t*, bool); Write argument names when they're not trivial. enum is preferred to bool. If V8SnapshotCreator::GetExternalReferences() is the standard way to get the external references, probably we'd like to use it directly without taking it as an argument. Ideally, V8SnapshotCreator well encapsulate things and there should be no need for client code to refer to the external references, i.e. the external references are preferred being a private member of V8SnapshotCreator. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:235: bool UseSnapshot() const { Probably ShouldUseSnapshot()? This function is a predictor, so names like DoSomething are not good. Predictors are expected to be named like IsSomething, ShouldDoSomething, etc. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:241: explicit V8PerIsolateData(WebTaskRunner*, intptr_t*, bool); s/explicit// https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:244: using CopyableTraits = v8::CopyablePersistentTraits<v8::FunctionTemplate>; Could you let me know why we need CopyablePersistentTraits? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:246: v8::Persistent<v8::FunctionTemplate, CopyableTraits>; If these types are only used at the following line, I'd prefer not aliasing because it's not clear what V8PerIsolateData::CopyableTraits is. It's not clear that it's related to V8 snapshotting. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:247: using V8TemporaryFunctionTemplateMap = "Temporary" doesn't make much sense, or even misleading. V8FunctionTemplateMapForV8ContextSnapshot for example? Maybe better to define this type after V8FunctionTemplateMap because most people read code from top to down. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/web/DevToolsEmulator.cpp (left): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/web/DevToolsEmulator.cpp:324: is_orientation_event_enabled_); You can do this in a separate CL. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/publ... File third_party/WebKit/public/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/publ... third_party/WebKit/public/BUILD.gn:448: "web/SnapshotCreator.h", I'm not confident, but should this file be WebSnapshotCreator.h? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/publ... File third_party/WebKit/public/web/SnapshotCreator.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/publ... third_party/WebKit/public/web/SnapshotCreator.h:8: #include <cstdint> I'm curious about why we need <cstdint>. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/publ... third_party/WebKit/public/web/SnapshotCreator.h:16: // static intptr_t* getExternalReferences(); Remove this line. https://codereview.chromium.org/2841443005/diff/80001/url/BUILD.gn File url/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/80001/url/BUILD.gn#newcode75 url/BUILD.gn:75: if (use_platform_icu_alternatives && current_toolchain == default_toolchain) { Why do we need this change?
(I'm sorry that I didn't have time to look at this CL (and may not have enough time this week). I'd like to defer the initial review to shiino-san.)
https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:22: bool g_taking_snapshot = false; Put a comment when this is true and what is guaranteed or constrained. For example, this must be used only on the main thread. The name looks like that it will be true only during taking a snapshot, but actually seems like that it's true when the process is invoked in the mode to take a snapshot. It's ambiguous whether you're controlling timing of taking a snapshot or controlling a mode of a process. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:26: v8::Local<v8::Function> ConstructPlainType(v8::Isolate* isolate, Let's merge this code into V8PerContextData::ConstructorForTypeSlowCase(). Let's create a common implementation function that is used by both of taking and using a snapshot, and on the top of it, let's create two thin wrappers dedicated to taking and using a snapshot. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:68: v8::Local<v8::Object> CreatePlainWrapper(v8::Isolate* isolate, Ditto. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:105: v8::Local<v8::FunctionTemplate> event_target_function_template = nit: We could have an array of WrapperTypeInfo or V8T::domTemplate, and we could write a single for-loop (at least except for HTMLDocument and Window). https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:165: isolate->RemoveMessageListeners(V8Initializer::MessageHandlerInMainThread); Please comment why we need to remove message listeners. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:176: RuntimeEnabledFeatures::setTestFeaturesEnabled(false); nit: We might want to define RuntimeEnabledFeatures::setAllFeaturesEnabled(false); https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:176: RuntimeEnabledFeatures::setTestFeaturesEnabled(false); Is there any good way to confirm that we've not yet created any function template before disabling runtime-enabled features? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:183: TakeSnapshot(creator, 1); // non main world I'm not happy with use of the magic numbers. Shall we define an enum? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:190: DCHECK(g_taking_snapshot); Add a DCHECK to confirm that it's the main thread. Maybe, all the member functions are expected to be used only on the main thread? Then, we'd like to have the DCHECK here and there. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:196: return g_taking_snapshot; Add a DCHECK to confirm that it's the main thread. Otherwise, racy. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:203: v8::StartupData V8SnapshotCreator::Serialize(v8::Local<v8::Object> holder, s/Serialize/Serialize(An)InternalField/ Let's make it clear what this function serializes. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h:18: enum FieldType { Let's add enum class FieldType : unsigned char https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h:26: static void TakeSnapshot(v8::SnapshotCreator*, int worldId); Do we need to expose (all of) these APIs to public:? https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:154: void ClearAll(); This function does not actually clear *all*, right? For example, we don't clear string_cache_ (and no need). Let's rename the function name so that it's clear that a) this is designed to be used for snapshotting, and b) what actually this does.
https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h:18: enum FieldType { s/FieldType/InternalFieldType/? "FieldType" would be a little ambiguous.
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_...)
Sorry about the review delay! I finally got a chance to look at this. Here is a first round of comments. The overall approach looks good to me :D https://codereview.chromium.org/2841443005/diff/100001/content/app/content_ma... File content/app/content_main_runner.cc (right): https://codereview.chromium.org/2841443005/diff/100001/content/app/content_ma... content/app/content_main_runner.cc:219: #if defined(OS_POSIX) && !defined(OS_MACOSX) Does this mean that we don't support the context snapshot on Win? https://codereview.chromium.org/2841443005/diff/100001/content/app/content_ma... content/app/content_main_runner.cc:225: } else { When do we hit this else branch? https://codereview.chromium.org/2841443005/diff/100001/gin/isolate_holder.cc File gin/isolate_holder.cc (right): https://codereview.chromium.org/2841443005/diff/100001/gin/isolate_holder.cc#... gin/isolate_holder.cc:55: snapshot_creator_.reset(new v8::SnapshotCreator(reference)); It looks strange that we have to create the snapshot when instantiating the IsolateHolder. Can we delay creating the snapshot to when blink::SnapshotCreator::TakeSnapshot gets called? I think it will simplify the code. e.g., I think we can remove blink::SnapshotCreator::SetTakingSnapshot(true) from gin_prepare_main.cc. https://codereview.chromium.org/2841443005/diff/100001/gin/isolate_holder.cc#... gin/isolate_holder.cc:57: isolate_->Exit(); Just to confirm: Does "new v8::SnapshotCreator(reference)" do all the work to take the snapshot and thus we no longer need the isolate (and can exit immediately) here, right? Also is there any reason you have to call isolate->Exit()? It might be okay but looks a bit strange because the isolate is used afterwards. https://codereview.chromium.org/2841443005/diff/100001/gin/isolate_holder.cc#... gin/isolate_holder.cc:74: &startup_data_.raw_size); Can we move this code to when LocalWindowProxy uses the snapshot? In general it looks strange to do context-snapshot-related things when instantiating IsolateHolder. I hope all the changes to this file are moved to other places. https://codereview.chromium.org/2841443005/diff/100001/gin/isolate_holder.cc#... gin/isolate_holder.cc:79: v8_context_mode_ = kDefault; Why do we need to overwrite v8_context_mode_ here? https://codereview.chromium.org/2841443005/diff/100001/gin/public/isolate_hol... File gin/public/isolate_holder.h (right): https://codereview.chromium.org/2841443005/diff/100001/gin/public/isolate_hol... gin/public/isolate_holder.h:57: enum V8ContextMode { V8ContextShapshotMode https://codereview.chromium.org/2841443005/diff/100001/gin/public/isolate_hol... gin/public/isolate_holder.h:58: kDefault, kDoNotUseSnapshot https://codereview.chromium.org/2841443005/diff/100001/gin/public/isolate_hol... gin/public/isolate_holder.h:70: intptr_t*, intptr_t* reference_table https://codereview.chromium.org/2841443005/diff/100001/gin/public/isolate_hol... gin/public/isolate_holder.h:123: V8ContextMode v8_context_mode_; Can we probably simplify the code by moving these members from gin::isolate_holder to V8PerIsolateData? It looks redundant to redirect methods from V8PerIsolateData to gin::isolate_holder. https://codereview.chromium.org/2841443005/diff/100001/gin/shell/gin_prepare_... File gin/shell/gin_prepare_main.cc (right): https://codereview.chromium.org/2841443005/diff/100001/gin/shell/gin_prepare_... gin/shell/gin_prepare_main.cc:38: class GinShellRunnerDelegate final : public ModuleRunnerDelegate { Where is this used? https://codereview.chromium.org/2841443005/diff/100001/gin/shell/gin_prepare_... gin/shell/gin_prepare_main.cc:58: int main(int argc, char** argv) { Just to confirm: This runs when Chrome is compiled, right? https://codereview.chromium.org/2841443005/diff/100001/gin/shell/gin_prepare_... gin/shell/gin_prepare_main.cc:78: v8::StartupData blob = blink::SnapshotCreator::TakeSnapshot(creator); Can we merge the three blink::SnapshotCreator:: public APIs into one? https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Lay... File third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-none-2x-expected.txt (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Lay... third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-none-2x-expected.txt:10: window.orientation = 0 What does this change mean? https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:289: script_state_.Get(), document_wrapper.As<v8::Object>()); UpdateDocumentProperty() is called every time window.document gets updated. Is it a right timing to install runtime-enabled features? I guess we should install runtime-enabled features when the document wrapper is instantiated. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:27: bool g_taking_snapshot = false; Shall we move this flag to gin/isolate_holder.h? Then we can remove TakingSnapshot() and SetTakingSnapshot() from V8SnapshotCreator. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h:16: class CORE_EXPORT V8SnapshotCreator { Most methods of V8SnapshotCreator are taking an Isolate* parameter. Would it make more sense to move V8SnapshotCreator to V8PerIsolateData instead of making it a STATIC_ONLY class? Conceptually the V8SnapshotCreator should exist per isolate. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/scripts/generate_reference_table.py (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_reference_table.py:1: #!/usr/bin/env python Add a copyright. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/scripts/scripts.gni (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/scripts.gni:300: template("idl_reference_table") { v8_snapshot_reference_table https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/scripts.gni:302: script = "//third_party/WebKit/Source/bindings/scripts/generate_reference_table.py" Rename it to generate_v8_snapshot_reference_table.py. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/templates/snapshot.cpp.tmpl (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/templates/snapshot.cpp.tmpl:110: reinterpret_cast<intptr_t>(V8ObjectConstructor::IsValidConstructorMode), Why do we need this? https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/templates/snapshot.cpp.tmpl:111: reinterpret_cast<intptr_t>(V8ConstructorAttributeGetter), Why do we need this? https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/templates/snapshot.cpp.tmpl:112: 0 // terminate with a null What happens if we forget to add some C++ references to this table? I'm curious how we can detect the programming error and fix it. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp:67: V8SnapshotCreator::GetReferenceTable(), gin::IsolateHolder::kUseSnapshot); gin::IsolateHolder::kUseSnapshot won't make sense because we don't use the context snapshot on worker global scopes, right? https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:183: if (GetV8ContextMode() == gin::IsolateHolder::kTakeSnapshot) { I don't fully understand this code. Would you help me understand why we need to use interface_template_persistent_map_ when taking a snapshot? https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:213: private_property_.reset(); Why do we need to clear private_property_? https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:256: using CopyablePersistent = Would you help me understand why you need to use CopyablePersistent? CopyablePersistent is highly discouraged. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/web/DevToolsEmulator.cpp (left): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/web/DevToolsEmulator.cpp:324: is_orientation_event_enabled_); What is this change for? https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/web/SnapshotCreator.cpp (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/web/SnapshotCreator.cpp:1: #include "public/web/SnapshotCreator.h" Add a copyright.
Thank you for your reviews. Worked for most comments other than naming consensuses. PTAL. https://codereview.chromium.org/2841443005/diff/40001/gin/shell/gin_prepare_m... File gin/shell/gin_prepare_main.cc (right): https://codereview.chromium.org/2841443005/diff/40001/gin/shell/gin_prepare_m... gin/shell/gin_prepare_main.cc:78: v8::StartupData blob = blink::SnapshotCreator::SetUpSnapshotCreator(creator); On 2017/04/28 13:48:27, Yuki wrote: > I've not yet read the implementation of SetUpSnapshotCreator, but this looks > weird. Probably, > blob = TakeSnapshot() > ? Done. https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.cc File gin/v8_initializer.cc (right): https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.cc#n... gin/v8_initializer.cc:459: if (result == V8_LOAD_SUCCESS) { On 2017/04/28 13:48:27, Yuki wrote: > Why don't you simply write > if (MapV8File(...)) { ... } > ? Done. https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.cc#n... gin/v8_initializer.cc:466: base::PlatformFile V8Initializer::GetOpenV8ContextFileForChildProcesses( On 2017/04/28 13:48:27, Yuki wrote: > GetOpened? > > I'm not sure what child processes are. Are they renderer processes? Then, > ForRendererProcesses is preferred. Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/gin/public/isolate_hold... File gin/public/isolate_holder.h (right): https://codereview.chromium.org/2841443005/diff/80001/gin/public/isolate_hold... gin/public/isolate_holder.h:69: intptr_t*, On 2017/05/12 15:20:09, Yuki wrote: > nit: Write the argument name that is not trivial. > v8_snapshot_external_references? Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:179: struct DataForDeserializer { On 2017/05/10 08:58:43, Yuki wrote: > You don't want to expose this kind of hack outside V8SnapshotCreater. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:184: const WrapperTypeInfo* FieldTypeToWrapperTypeInfo( On 2017/05/10 08:58:43, Yuki wrote: > V8SnapshotCreater should be responsible about the mapping between enum FieldType > and WrapperTypeInfo. Why don't you define this function in V8SnapshotCreater? Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:214: case V8SnapshotCreator::kNodeType: On 2017/05/10 08:58:42, Yuki wrote: > nit: Probably it's cleaner to use bit flags here. > > kInterfaceObject = 1 << n1, > kPlatformObject = 1 << n2, > > kNodeInterface = kInterfaceObject | 1 << 0, > kDocumentInterface = kInterfaceObject | 1 << 1, > ... > > kHTMLDocumentInstance = kPlatformObject | 1 << 0, > > for example. Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:219: index, const_cast<WrapperTypeInfo*>(wrapper_type_info)); On 2017/05/10 08:58:43, Yuki wrote: > I'm not confident, but we wouldn't need to set an internal field on an interface > object nor prototype object. > > I know that we are setting internal fields on prototype objects, but are we > really setting them on interface objects, too? If so, can we stop setting them? > > I vaguely guess that we could stop setting internal fields on prototype objects, > too. Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:220: wrapper_type_info->WrapperCreated(); On 2017/05/10 08:58:43, Yuki wrote: > IIUC, interface objects are not considered as "wrapper objects", or at least no > need to call WrapperCreated(). > > Plus, WrapperCreated() is now a static member function. No need to use > wrapper_type_info, here. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:232: CHECK(document->SetWrapper(isolate, wrapper_type_info, wrapper)); On 2017/05/10 08:58:42, Yuki wrote: > I think that you should use document->AssociateWithWrapper. > ScriptWrappable::SetWrapper only works for the main world, plus it doesn't take > care of WrapperCreated() nor SetNativeInfo(). This routine is run during creating v8::Context, so it has no context nor ScriptState to be used in AssociateWithWrapper(). https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:247: if (V8PerIsolateData::From(GetIsolate())->UseSnapshot()) { On 2017/05/10 08:58:43, Yuki wrote: > This kind of code should live hidden in V8SnapshotCreater, and CreateContext()'d > better call an API of V8SnapshotCreater. Done. This part should be run once per context. I put a TODO comment to do it. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:289: (!World().IsMainWorld() || (document && document->IsHTMLDocument()))) { On 2017/05/10 08:58:42, Yuki wrote: > I don't understand these conditions. > > I thought that we always have |document|. In what cases don't we have > |document|? > > Also, why the world matters? First of all, we need at least two types of contexts in a snapshot; one is for main world, and the other is for non-main world. They can have some different callback functions. And in practice, we assume to have a HTMLDocument wrapper in the context for main world. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:290: const int index = World().IsMainWorld() ? 0 : 1; On 2017/05/10 08:58:43, Yuki wrote: > Where these magic numbers 0 and 1 come from? > > You may not want to expose these magic numbers outside V8SnapshotCreater. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:299: if (context.IsEmpty()) { On 2017/05/10 08:58:43, Yuki wrote: > Should this simply be > } else { > ? > > It seems that you're not expecting any failure of Context::FromSnapshot. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:322: TRACE_EVENT1("v8", "LocalWindowProxy::setupWindowPrototypeChain", On 2017/05/10 08:58:43, Yuki wrote: > nit: s/setup/Setup/ Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:377: TRACE_EVENT1("v8", "LocalWindowProxy::updateDocumentProperty", "isMainWindow", On 2017/05/10 08:58:43, Yuki wrote: > nit: s/update/Update/ Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:387: v8::Local<v8::Object> wrapper = document_wrapper.As<v8::Object>(); On 2017/05/10 08:58:42, Yuki wrote: > s/wrapper/htmldocument_wrapper/ > and make it clear that you're following > platform object of type HTMLDocument > => HTMLDocument.prototype > => Document.prototype > > Use of htmldocument_prototype would be good. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:392: V8Document::installRuntimeEnabledFeatures(GetIsolate(), World(), wrapper, On 2017/05/10 08:58:43, Yuki wrote: > Although it's noop, we do have > {V8HTMLDocument,V8Node,...}::installRuntimeEnabledFeatures. You should call > them, too, or it will be fragile or surprising in future. > > Also, you'd like to hide all this kind of things in V8SnapshotCreater. My > understanding is that V8SnapshotCreater is responsible to take a snapshot of > what things, which interface objects and which platform objects. > LocalWindowProxy must not need to know which interface or platform objects are > taken into a snapshot. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:692: if (V8SnapshotCreator::TakingSnapshot()) { On 2017/05/12 15:20:09, Yuki wrote: > Curious. Why V8SnapshotCreator::TakingSnapshot() is a static member while > data->UseSnapshot() is a non-static member? A little asymmetric. Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:694: data->FindInterfaceTemplateTemp(world, wrapper_type_info); On 2017/05/12 15:20:09, Yuki wrote: > I think it's better not to expose FindInterfaceTemplateTemp. It's better to > make this hidden in V8PerIsolateData. > > V8PerIsolateData::FindInterfaceTemplate(...) { > if (V8SnapshotCreator::TakingSnapshot()) { > return ...new code...; > } else { > return ...old code...; > } > } > > Ditto for SetInterfaceTemplate. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:698: static const WrapperTypeInfo* snapshot_types[] = { On 2017/05/12 15:20:10, Yuki wrote: > These things should be hidden in V8SnapshotCreator. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:708: for (size_t i = 0; i < WTF_ARRAY_LENGTH(snapshot_types); ++i) { On 2017/05/12 15:20:09, Yuki wrote: > nit: I think you can use range-based for-loop. > for (const auto& wrapper_type_info : snapshotted_types) no. this routine requires the index number. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:711: .ToLocal(&interface_template)) { On 2017/05/12 15:20:09, Yuki wrote: > nit: ToLocalChecked()? > > Or are we really going to support a fallback mechanism, seriously? Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp:450: void V8Initializer::InitializeMainThread(intptr_t* table) { On 2017/05/12 15:20:10, Yuki wrote: > |table| doesn't make much sense. > v8_snapshot_external_references for example? > > Should this be retrieved through V8SnapshotCreator::GetExternalReferences() > rather than passing in as an argument? Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8Initializer.h:39: static void InitializeMainThread(intptr_t*); On 2017/05/12 15:20:10, Yuki wrote: > nit: Write the argument name. It's not trivial. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:1: #include "bindings/core/v8/V8SnapshotCreator.h" On 2017/05/12 15:20:10, Yuki wrote: > Copyright? Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:16: #include <v8.h> On 2017/05/12 15:20:10, Yuki wrote: > s|<v8.h>|"v8/include/v8.h"| Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:22: bool g_taking_snapshot = false; On 2017/05/15 09:37:29, Yuki wrote: > Put a comment when this is true and what is guaranteed or constrained. > > For example, this must be used only on the main thread. > > The name looks like that it will be true only during taking a snapshot, but > actually seems like that it's true when the process is invoked in the mode to > take a snapshot. It's ambiguous whether you're controlling timing of taking a > snapshot or controlling a mode of a process. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:26: v8::Local<v8::Function> ConstructPlainType(v8::Isolate* isolate, On 2017/05/15 09:37:29, Yuki wrote: > Let's merge this code into V8PerContextData::ConstructorForTypeSlowCase(). > Let's create a common implementation function that is used by both of taking and > using a snapshot, and on the top of it, let's create two thin wrappers dedicated > to taking and using a snapshot. Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:68: v8::Local<v8::Object> CreatePlainWrapper(v8::Isolate* isolate, On 2017/05/15 09:37:29, Yuki wrote: > Ditto. Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:105: v8::Local<v8::FunctionTemplate> event_target_function_template = On 2017/05/15 09:37:29, Yuki wrote: > nit: We could have an array of WrapperTypeInfo or V8T::domTemplate, and we could > write a single for-loop (at least except for HTMLDocument and Window). Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:165: isolate->RemoveMessageListeners(V8Initializer::MessageHandlerInMainThread); On 2017/05/15 09:37:29, Yuki wrote: > Please comment why we need to remove message listeners. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:176: RuntimeEnabledFeatures::setTestFeaturesEnabled(false); On 2017/05/15 09:37:29, Yuki wrote: > nit: We might want to define > RuntimeEnabledFeatures::setAllFeaturesEnabled(false); Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:183: TakeSnapshot(creator, 1); // non main world On 2017/05/15 09:37:29, Yuki wrote: > I'm not happy with use of the magic numbers. Shall we define an enum? Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:190: DCHECK(g_taking_snapshot); On 2017/05/15 09:37:29, Yuki wrote: > Add a DCHECK to confirm that it's the main thread. > > Maybe, all the member functions are expected to be used only on the main thread? > Then, we'd like to have the DCHECK here and there. Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:196: return g_taking_snapshot; On 2017/05/15 09:37:29, Yuki wrote: > Add a DCHECK to confirm that it's the main thread. > Otherwise, racy. Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:203: v8::StartupData V8SnapshotCreator::Serialize(v8::Local<v8::Object> holder, On 2017/05/15 09:37:29, Yuki wrote: > s/Serialize/Serialize(An)InternalField/ > Let's make it clear what this function serializes. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h:18: enum FieldType { On 2017/05/15 09:39:35, Yuki wrote: > s/FieldType/InternalFieldType/? > "FieldType" would be a little ambiguous. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h:18: enum FieldType { On 2017/05/15 09:37:29, Yuki wrote: > Let's add > enum class FieldType : unsigned char Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h:26: static void TakeSnapshot(v8::SnapshotCreator*, int worldId); On 2017/05/15 09:37:29, Yuki wrote: > Do we need to expose (all of) these APIs to public:? move some methods to private: https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp:40: #include "platform/instrumentation/tracing/TraceEvent.h" On 2017/05/12 15:20:10, Yuki wrote: > Why do we need this here? Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/modules/v8/V8SnapshotReference.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/modules/v8/V8SnapshotReference.h:8: #include <v8.h> On 2017/05/12 15:20:10, Yuki wrote: > s|<v8.h>|"v8/include/v8.h"| Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/modules/v8/V8SnapshotReference.h:14: class MODULES_EXPORT V8SnapshotReference { On 2017/05/12 15:20:10, Yuki wrote: > STATIC_ONLY? Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/modules/v8/V8SnapshotReference.h:16: static intptr_t* getExternalReferences(); On 2017/05/12 15:20:10, Yuki wrote: > s/get/Get/ Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/bindings/V8DOMWrapper.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8DOMWrapper.cpp:70: v8::Local<v8::Function> ConstructPlainType(v8::Isolate* isolate, On 2017/05/12 15:20:10, Yuki wrote: > No one seems using this function? Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:57: bool take_snapshot) On 2017/05/12 15:20:10, Yuki wrote: > bool argument, which is ambiguous, is not recommended. > enum is preferred. Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:103: static v8::Isolate* Initialize(WebTaskRunner*, intptr_t*, bool); On 2017/05/12 15:20:10, Yuki wrote: > Write argument names when they're not trivial. > enum is preferred to bool. > > If V8SnapshotCreator::GetExternalReferences() is the standard way to get the > external references, probably we'd like to use it directly without taking it as > an argument. > > Ideally, V8SnapshotCreator well encapsulate things and there should be no need > for client code to refer to the external references, i.e. the external > references are preferred being a private member of V8SnapshotCreator. V8SnapshotCreator is under bindings/core and is not referable from platform/bindings. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:154: void ClearAll(); On 2017/05/15 09:37:29, Yuki wrote: > This function does not actually clear *all*, right? > For example, we don't clear string_cache_ (and no need). Let's rename the > function name so that it's clear that a) this is designed to be used for > snapshotting, and b) what actually this does. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:235: bool UseSnapshot() const { On 2017/05/12 15:20:10, Yuki wrote: > Probably ShouldUseSnapshot()? > > This function is a predictor, so names like DoSomething are not good. > Predictors are expected to be named like IsSomething, ShouldDoSomething, etc. Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:241: explicit V8PerIsolateData(WebTaskRunner*, intptr_t*, bool); On 2017/05/12 15:20:10, Yuki wrote: > s/explicit// Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:244: using CopyableTraits = v8::CopyablePersistentTraits<v8::FunctionTemplate>; On 2017/05/12 15:20:10, Yuki wrote: > Could you let me know why we need CopyablePersistentTraits? This is abused to follow V8FunctionTemplateMap. I'll change this with ScopedPersistent or something like it. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:247: using V8TemporaryFunctionTemplateMap = On 2017/05/12 15:20:10, Yuki wrote: > "Temporary" doesn't make much sense, or even misleading. > > V8FunctionTemplateMapForV8ContextSnapshot for example? > > Maybe better to define this type after V8FunctionTemplateMap because most people > read code from top to down. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/web/DevToolsEmulator.cpp (left): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/web/DevToolsEmulator.cpp:324: is_orientation_event_enabled_); On 2017/05/12 15:20:11, Yuki wrote: > You can do this in a separate CL. reverted. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/publ... File third_party/WebKit/public/web/SnapshotCreator.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/publ... third_party/WebKit/public/web/SnapshotCreator.h:8: #include <cstdint> On 2017/05/12 15:20:11, Yuki wrote: > I'm curious about why we need <cstdint>. Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/publ... third_party/WebKit/public/web/SnapshotCreator.h:16: // static intptr_t* getExternalReferences(); On 2017/05/12 15:20:11, Yuki wrote: > Remove this line. Done. https://codereview.chromium.org/2841443005/diff/100001/content/app/content_ma... File content/app/content_main_runner.cc (right): https://codereview.chromium.org/2841443005/diff/100001/content/app/content_ma... content/app/content_main_runner.cc:219: #if defined(OS_POSIX) && !defined(OS_MACOSX) On 2017/05/20 19:10:01, haraken wrote: > > Does this mean that we don't support the context snapshot on Win? unfortunately, I'm not sure. This follows the routine of V8 native+snapshot. https://codereview.chromium.org/2841443005/diff/100001/content/app/content_ma... content/app/content_main_runner.cc:225: } else { On 2017/05/20 19:10:01, haraken wrote: > > When do we hit this else branch? ditto. https://codereview.chromium.org/2841443005/diff/100001/gin/isolate_holder.cc File gin/isolate_holder.cc (right): https://codereview.chromium.org/2841443005/diff/100001/gin/isolate_holder.cc#... gin/isolate_holder.cc:55: snapshot_creator_.reset(new v8::SnapshotCreator(reference)); On 2017/05/20 19:10:02, haraken wrote: > > It looks strange that we have to create the snapshot when instantiating the > IsolateHolder. Can we delay creating the snapshot to when > blink::SnapshotCreator::TakeSnapshot gets called? > > I think it will simplify the code. e.g., I think we can remove > blink::SnapshotCreator::SetTakingSnapshot(true) from gin_prepare_main.cc. > > Done. https://codereview.chromium.org/2841443005/diff/100001/gin/isolate_holder.cc#... gin/isolate_holder.cc:57: isolate_->Exit(); On 2017/05/20 19:10:02, haraken wrote: > > Just to confirm: Does "new v8::SnapshotCreator(reference)" do all the work to > take the snapshot and thus we no longer need the isolate (and can exit > immediately) here, right? > > Also is there any reason you have to call isolate->Exit()? It might be okay but > looks a bit strange because the isolate is used afterwards. > Acknowledged. https://codereview.chromium.org/2841443005/diff/100001/gin/isolate_holder.cc#... gin/isolate_holder.cc:74: &startup_data_.raw_size); On 2017/05/20 19:10:02, haraken wrote: > > Can we move this code to when LocalWindowProxy uses the snapshot? > > In general it looks strange to do context-snapshot-related things when > instantiating IsolateHolder. I hope all the changes to this file are moved to > other places. > Function name seems wrong, but this actually loads the snapshot blob file, and does not create contexts. https://codereview.chromium.org/2841443005/diff/100001/gin/isolate_holder.cc#... gin/isolate_holder.cc:79: v8_context_mode_ = kDefault; On 2017/05/20 19:10:02, haraken wrote: > > Why do we need to overwrite v8_context_mode_ here? it is used to handle context creation (FromSnapshot() or New()) If it fails to load Snapshot file, we can't do Context::FromSnapshot() https://codereview.chromium.org/2841443005/diff/100001/gin/public/isolate_hol... File gin/public/isolate_holder.h (right): https://codereview.chromium.org/2841443005/diff/100001/gin/public/isolate_hol... gin/public/isolate_holder.h:58: kDefault, On 2017/05/20 19:10:02, haraken wrote: > > kDoNotUseSnapshot Done. https://codereview.chromium.org/2841443005/diff/100001/gin/public/isolate_hol... gin/public/isolate_holder.h:70: intptr_t*, On 2017/05/20 19:10:02, haraken wrote: > > intptr_t* reference_table Done. https://codereview.chromium.org/2841443005/diff/100001/gin/public/isolate_hol... gin/public/isolate_holder.h:123: V8ContextMode v8_context_mode_; On 2017/05/20 19:10:02, haraken wrote: > > Can we probably simplify the code by moving these members from > gin::isolate_holder to V8PerIsolateData? It looks redundant to redirect methods > from V8PerIsolateData to gin::isolate_holder. Done. https://codereview.chromium.org/2841443005/diff/100001/gin/shell/gin_prepare_... File gin/shell/gin_prepare_main.cc (right): https://codereview.chromium.org/2841443005/diff/100001/gin/shell/gin_prepare_... gin/shell/gin_prepare_main.cc:58: int main(int argc, char** argv) { On 2017/05/20 19:10:02, haraken wrote: > > Just to confirm: This runs when Chrome is compiled, right? Right. This main() is expected not to run in Chrome's processes. https://codereview.chromium.org/2841443005/diff/100001/gin/shell/gin_prepare_... gin/shell/gin_prepare_main.cc:78: v8::StartupData blob = blink::SnapshotCreator::TakeSnapshot(creator); On 2017/05/20 19:10:02, haraken wrote: > > Can we merge the three blink::SnapshotCreator:: public APIs into one? Done. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Lay... File third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-none-2x-expected.txt (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Lay... third_party/WebKit/LayoutTests/inspector-protocol/emulation/device-emulation-none-2x-expected.txt:10: window.orientation = 0 On 2017/05/20 19:10:02, haraken wrote: > > What does this change mean? This is an effect of RuntimeEnabledFeature=OrientationEvent. DevToolsEmulator sets the runtime enabled feature after creating interface templates, so it works in a wrong way on ToT, and will be fixed with this change. http://crbug.com/705364 It is difficult to fix the current behavior without Snapshot for me. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:289: script_state_.Get(), document_wrapper.As<v8::Object>()); On 2017/05/20 19:10:02, haraken wrote: > > UpdateDocumentProperty() is called every time window.document gets updated. Is > it a right timing to install runtime-enabled features? > > I guess we should install runtime-enabled features when the document wrapper is > instantiated. > Agree. will do in the next update. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:27: bool g_taking_snapshot = false; On 2017/05/20 19:10:02, haraken wrote: > > Shall we move this flag to gin/isolate_holder.h? Then we can remove > TakingSnapshot() and SetTakingSnapshot() from V8SnapshotCreator. Acknowledged. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/scripts/generate_reference_table.py (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_reference_table.py:1: #!/usr/bin/env python On 2017/05/20 19:10:02, haraken wrote: > > Add a copyright. Done. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/templates/snapshot.cpp.tmpl (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/templates/snapshot.cpp.tmpl:110: reinterpret_cast<intptr_t>(V8ObjectConstructor::IsValidConstructorMode), On 2017/05/20 19:10:03, haraken wrote: > > Why do we need this? it is referred from V8Window class https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/templates/snapshot.cpp.tmpl:111: reinterpret_cast<intptr_t>(V8ConstructorAttributeGetter), On 2017/05/20 19:10:03, haraken wrote: > > Why do we need this? ditto. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/templates/snapshot.cpp.tmpl:112: 0 // terminate with a null On 2017/05/20 19:10:02, haraken wrote: > > What happens if we forget to add some C++ references to this table? I'm curious > how we can detect the programming error and fix it. v8::SnapshotCreator crashes if it hits unkown external references while it creating a snapshot. So a lack of entry must be triggered in trybots before committing the patch. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp:67: V8SnapshotCreator::GetReferenceTable(), gin::IsolateHolder::kUseSnapshot); On 2017/05/20 19:10:03, haraken wrote: > > gin::IsolateHolder::kUseSnapshot won't make sense because we don't use the > context snapshot on worker global scopes, right? Done. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:183: if (GetV8ContextMode() == gin::IsolateHolder::kTakeSnapshot) { On 2017/05/20 19:10:03, haraken wrote: > > I don't fully understand this code. Would you help me understand why we need to > use interface_template_persistent_map_ when taking a snapshot? We have to remove all references from the embedder (=Blink) to V8 objects, and we can't do it with v8::Eternal<>. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:213: private_property_.reset(); On 2017/05/20 19:10:03, haraken wrote: > > Why do we need to clear private_property_? > > To clear WindowDocumentCachedAccessor. https://chromium.googlesource.com/chromium/src/+/74b864441c2ce011435c511f23ea... https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:256: using CopyablePersistent = On 2017/05/20 19:10:03, haraken wrote: > > Would you help me understand why you need to use CopyablePersistent? > CopyablePersistent is highly discouraged. Will replace with ScopedPersistent or something usable. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/web/DevToolsEmulator.cpp (left): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/web/DevToolsEmulator.cpp:324: is_orientation_event_enabled_); On 2017/05/20 19:10:03, haraken wrote: > > What is this change for? reverted https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/web/SnapshotCreator.cpp (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/web/SnapshotCreator.cpp:1: #include "public/web/SnapshotCreator.h" On 2017/05/20 19:10:03, haraken wrote: > > Add a copyright. Done.
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_x64_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_x64_...)
Comments from an intermediate review. I'm still reviewing. Will send the rest later. https://codereview.chromium.org/2841443005/diff/120001/chrome/BUILD.gn File chrome/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/120001/chrome/BUILD.gn#newcod... chrome/BUILD.gn:123: "$root_out_dir/context_blob.bin", super nit: s/context_blob/v8_context_blob/ I think that a term "context" is highly context-dependent. Would like to avoid any possible ambiguity. https://codereview.chromium.org/2841443005/diff/120001/content/app/content_ma... File content/app/content_main_runner.cc (right): https://codereview.chromium.org/2841443005/diff/120001/content/app/content_ma... content/app/content_main_runner.cc:228: #elif !defined(CHROME_MULTIPLE_DLL_BROWSER) Why is this not |#else|? Is it okay to not run LoadV8Context(); https://codereview.chromium.org/2841443005/diff/120001/gin/BUILD.gn File gin/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/120001/gin/BUILD.gn#newcode161 gin/BUILD.gn:161: # but we must keep duplicated entries in external references for V8 snapshot. Good comment. Let's make this a little more explicit. The following is just an example. This config disables a link time optimization, which may merge two different functions into one if the function signature and body of them are identical. This unification breaks 1:1 mappings of the external references of V8 snapshot. So, disables the LTO while taking a V8 snapshot. https://codereview.chromium.org/2841443005/diff/120001/gin/BUILD.gn#newcode171 gin/BUILD.gn:171: executable("gin_blink_snapshot") { nit: s/gin_blink_snapshot/gin_blink_v8_snapshot/ https://codereview.chromium.org/2841443005/diff/120001/gin/isolate_holder.cc File gin/isolate_holder.cc (right): https://codereview.chromium.org/2841443005/diff/120001/gin/isolate_holder.cc#... gin/isolate_holder.cc:69: } What happens if GetV8ContextData fails to load the snapshot blob? Should we report an error if (!startup_data->data)? https://codereview.chromium.org/2841443005/diff/120001/gin/isolate_holder.cc#... gin/isolate_holder.cc:90: : isolate_(isolate), access_mode_(kSingleThread) { Could you avoid copy&pasting? Can we have a helper function instead? The former constructor above should call the helper function with the created isolate. https://codereview.chromium.org/2841443005/diff/120001/gin/public/isolate_hol... File gin/public/isolate_holder.h (right): https://codereview.chromium.org/2841443005/diff/120001/gin/public/isolate_hol... gin/public/isolate_holder.h:65: // To take snapshot of v8 Context. Let's be a little more descriptive. // Creates an IsolateHolder from an existing v8::Isolate. // v8::SnapshotCreator creates a new v8::Isolate, and we need to instantiate an IsolateHolder from that v8::Isolate. https://codereview.chromium.org/2841443005/diff/120001/gin/shell/gin_prepare_... File gin/shell/gin_prepare_main.cc (right): https://codereview.chromium.org/2841443005/diff/120001/gin/shell/gin_prepare_... gin/shell/gin_prepare_main.cc:60: int main(int argc, char** argv) { Can you put a comment about the usage of this program? What arguments are expected? How to invoke this program? What this program does? By the way, why is this named "gin_prepare_main.cc"? "take_blink_v8_context_snapshot_main.cc" makes more sense to me. (I agree that it's a little bit too long, though.) https://codereview.chromium.org/2841443005/diff/120001/gin/shell/gin_prepare_... gin/shell/gin_prepare_main.cc:68: // set up environment to make Blink and V8 workable. nit: s/set/Set/ https://codereview.chromium.org/2841443005/diff/120001/gin/v8_initializer.cc File gin/v8_initializer.cc (right): https://codereview.chromium.org/2841443005/diff/120001/gin/v8_initializer.cc#... gin/v8_initializer.cc:37: #include "base/path_service.h" Should this #include be moved up? https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:181: V8SnapshotCreator::EnsureInterfaceTemplates(GetIsolate(), World()); EnsureInterfaceTemplates() is NOT context-dependent, it's isolate-dependent and context-independent. So this line looks strange to me. Can we put this line into V8PerIsolateData for example? Then, we can easily call EnsureInterfaceTemplates() only once per isolate. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:711: interface_template = V8SnapshotCreator::CreateInterfaceTemplate( nit: This seems not creating an interface template. Extract, retrieve, get, deserialize, ... umm. InterfaceTemplateFromSnapshot (following v8::FunctionTemplate::FromSnapshot) can be an option (FromSnapshot could be redundant, though). https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.h (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8Initializer.h:39: static void InitializeMainThread(bool take_snapshot); The style guide recommends |enum| instead of |bool|. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:10: #include "bindings/core/v8/V8Document.h" V8Document.h and V8Node.h are not necessary here. Or, if you prefer including them explicitly, then let's explicitly include V8EventTarget.h, too. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:97: &V8EventTarget::wrapperTypeInfo, &V8Window::wrapperTypeInfo, nit: Let's put them one-entry-per-line. Why don't you put V8Window::wrapperTypeInfo at first? You're assuming that kSnapshotWrapperTypes[1] is V8Window later below... Why don't you make it [0]? https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:120: case InternalFieldType::kNone: nit: The same order of the type definition is preferred. kNone, kNodeType, ... https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:135: void V8SnapshotCreator::TakeSnapshotForWorld(v8::SnapshotCreator* creator, nit: The style guide recommends the same order of declarations and definitions. You declared TakeSnapshot() first in the class definition. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:164: context->Enter(); v8::Context::Scope enters into the context. You don't need to enter the context on this line. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:177: context->Exit(); Ditto. The Scope automatically exits. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:208: isolate, DOMWrapperWorld::WorldType::kTesting)); kTesting looks too weird, although I understand that it's working fine... Shall we use kIsolated instead? https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:234: v8::Isolate* isolate, nit: You can take a V8PerIsolateData* instead of v8::Isolate*. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:259: void* /*data*/) { You define another |data| in the body of the function. This is rather confusing. Let's remove /*data*/. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:276: // To confirm covering all patterns to be serialized. nit: I guess that this comment is obvious? Probably we don't need this comment. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:314: CHECK(document->SetWrapper(isolate, wrapper_type_info, holder)); Add a comment that this only works in the main world + you're taking a snapshot of window.document only in the main world. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:314: CHECK(document->SetWrapper(isolate, wrapper_type_info, holder)); WrapperTypeInfo::WrapperCreated() should be called, shall not? https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:338: return v8::Local<v8::Context>(); Maybe NOTREACHED()? https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:347: .ToLocal(&context)); ToLocalChecked() instead of CHECK()? https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:380: v8::Local<v8::FunctionTemplate>()); Why there is no Node and EventTarget related code? Why only V8Document::preparePrototypeAndInterfaceObject without V8HTMLDocument::prepare...? Less assumption, better maintainability, I think. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:399: isolate, world, global, window_prototype, window_interface); Ditto. Why no prepare...? Why no V8EventTarget? https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:403: g_snapshot_reference_table = table; Nice to have DCHECK(!g_snapshot_reference_table); https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:407: return g_snapshot_reference_table; Nice to have DCHECK(g_snapshot_reference_table); https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h:22: static v8::StartupData SerializeInternalField(v8::Local<v8::Object> holder, Can this be private:? https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/modules/v8/V8SnapshotReference.h (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/modules/v8/V8SnapshotReference.h:19: static intptr_t* GetReferenceTable(); It's nice to comment that the definition of this function is auto-generated as V8SnapshotReference.cpp. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp:64: // TODO(peria): Replace GetReferenceTable with nullptr. Could you elaborate why we'd like to replace it? Or why we cannot replace it at this moment? https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8DOMWrapper.cpp (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8DOMWrapper.cpp:70: v8::Local<v8::Function> ConstructPlainType(v8::Isolate* isolate, Why don't you remove this function? https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:64: context_mode == V8ContextMode::kUseSnapshot ? &startup_data_ Better to set v8_context_mode_ first, and use members rather than arguments. v8_context_mode_(context_mode), isolate_holder_(... v8_context_mode_ ...), https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:75: v8_context_mode_ = V8ContextMode::kDontUseSnapshot; Probably I asked this question before. Do we really want to fall back rather than CHECK / NOTREACHED? https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:152: void ClearPersistents(); Add a comment what this function does (and why we need this). This member function is public: but it's not expected to be used widely. Explicitly describe who are expected to call this function. Maybe, ClearPersistentsForV8Snapshot would be a better name. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:153: V8ContextMode GetV8ContextMode() const { return v8_context_mode_; } GetV8ContextMode() seems relevant to GetSnapshotCreator(). Why are they put apart? https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:252: // before IsolateHolder. Members required for snapshotted contexts. Need to be instantiated before |isolate_holder_| gets instantiated. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:264: using CopyablePersistent = I think that it's worth commenting that this is using v8::Persistent instead of v8::Eternal and why we need to replace it. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:269: V8FunctionTemplatePersistentMap interface_template_persistent_map_; interface_template_maps_for_snapshot_; would be clearer?
(I've posted all major comments in #37 and you've already addressed them, so let me take the final look after shiino-san's review.)
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Worked for most comments, including renames. I think remaining concerns are - to rename V8SnapshotCreator to more feasible name. - where InstallRuntimeEnabledFeatureOnDocument should be applied - how should we do when we fail to load the snapshot file. - some gn related changes https://codereview.chromium.org/2841443005/diff/40001/chrome/BUILD.gn File chrome/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/40001/chrome/BUILD.gn#newcode793 chrome/BUILD.gn:793: "$root_out_dir/context_blob.bin", On 2017/04/28 13:48:27, Yuki wrote: > I'd prefer a different name, such as blink_v8_context_snapshot.bin. > > "context_blob" looks too generic and vague. Done. https://codereview.chromium.org/2841443005/diff/40001/content/app/content_mai... File content/app/content_main_runner.cc (right): https://codereview.chromium.org/2841443005/diff/40001/content/app/content_mai... content/app/content_main_runner.cc:220: file_descriptor_store.MaybeTakeFD(kV8ContextDataDescriptor, ®ion); On 2017/04/28 13:48:27, Yuki wrote: > Here and there, you seem calling "a snapshot of V8 context for the use in Blink" > "V8 context". It seems quite confusing. > > I'd propose the followings. > 1) explicitly distinguish a snapshot of V8 context from a V8 context. > 2) explicitly distinguish a snapshot of V8 context for Blink from the V8 > snapshot of V8 built-in's. > > For example, v8_context_snapshot_fd and kV8ContextSnapshotDataDescriptor, or, > considering that the owner is Blink (not V8), blink_v8_context_snapshot_fd > (Blink's snapshot of V8 context) and kBlinkV8ContextSnapshotDataDescriptor. > > (I'd prefer the latter, but I think that not few people prefer the former.) Done. https://codereview.chromium.org/2841443005/diff/40001/content/app/content_mai... content/app/content_main_runner.cc:222: gin::V8Initializer::LoadV8ContextFromFD(v8_context_fd.get(), region.offset, On 2017/04/28 13:48:27, Yuki wrote: > LoadV8ContextSnapshotFromFD? Done. https://codereview.chromium.org/2841443005/diff/40001/content/public/common/c... File content/public/common/content_descriptor_keys.cc (right): https://codereview.chromium.org/2841443005/diff/40001/content/public/common/c... content/public/common/content_descriptor_keys.cc:17: const char kV8ContextDataDescriptor[] = "v8_context_data"; On 2017/04/28 13:48:27, Yuki wrote: > v8_context_snapshot_data? Done. https://codereview.chromium.org/2841443005/diff/40001/content/public/common/c... File content/public/common/content_descriptor_keys.h (right): https://codereview.chromium.org/2841443005/diff/40001/content/public/common/c... content/public/common/content_descriptor_keys.h:15: // sync. On 2017/04/28 13:48:27, Yuki wrote: > Don't we need to update content/public/app/mojo/content_renderer_manifest.json , > too? Done. https://codereview.chromium.org/2841443005/diff/40001/gin/BUILD.gn File gin/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/40001/gin/BUILD.gn#newcode135 gin/BUILD.gn:135: exec = "$root_out_dir/gin_blink_snapshot" On 2017/04/28 13:48:27, Yuki wrote: > Not so bad, but a little confusing name, I think. > We don't take a snapshot of Blink... > > You can add a header comment for action("run_gin_blink_snapshot") describing > what it does and what it is meant for. Done. https://codereview.chromium.org/2841443005/diff/40001/gin/public/isolate_hold... File gin/public/isolate_holder.h (right): https://codereview.chromium.org/2841443005/diff/40001/gin/public/isolate_hold... gin/public/isolate_holder.h:69: intptr_t*, On 2017/04/28 13:48:27, Yuki wrote: > Write the parameter name, e.g. snapshot_external_references. Done. https://codereview.chromium.org/2841443005/diff/40001/gin/run.py File gin/run.py (right): https://codereview.chromium.org/2841443005/diff/40001/gin/run.py#newcode2 gin/run.py:2: # Copyright 2016 The Chromium Authors. All rights reserved. On 2017/04/28 13:48:27, Yuki wrote: > nit: You may want to update the year to 2017, but I'm not sure. > Same for other files, too. Done. https://codereview.chromium.org/2841443005/diff/40001/gin/shell/gin_prepare_m... File gin/shell/gin_prepare_main.cc (right): https://codereview.chromium.org/2841443005/diff/40001/gin/shell/gin_prepare_m... gin/shell/gin_prepare_main.cc:75: blink::SnapshotCreator::SetTakingSnapshot(true); On 2017/04/28 13:48:27, Yuki wrote: > s/SetTakingSnapshot/SetTakeSnapshot/ Acknowledged. https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.cc File gin/v8_initializer.cc (right): https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.cc#n... gin/v8_initializer.cc:48: const char kV8ContextFileName[] = "context_blob.bin"; On 2017/04/28 13:48:27, Yuki wrote: > kV8ContextSnapshotFilename? Done. https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.cc#n... gin/v8_initializer.cc:447: return; On 2017/04/28 13:48:27, Yuki wrote: > Is it really okay to simply return? > > Do we need to fallback to LoadV8Context()? > Or, should we crash? > > If it's okay as is, then I'd like a comment about why. In this case, we fail to load the blob file. Let's discuss the behavior in such a case. IMO, I'd like to keep working even without snapshot. https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.h File gin/v8_initializer.h (right): https://codereview.chromium.org/2841443005/diff/40001/gin/v8_initializer.h#ne... gin/v8_initializer.h:33: static void GetV8ContextData(const char** snapshot_data_out, On 2017/04/28 13:48:28, Yuki wrote: > GetV8ContextSnapshotData? Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:162: TRACE_EVENT1("v8", "notification", "isMainWindow", On 2017/05/10 08:58:42, Yuki wrote: > nit: I'm not clear about what "main window" is. > > Would "isMainFrame" be a better name? > At least, isMainFrame is not confusing against "main-world window". Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/modules/v8/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/modules/v8/BUILD.gn:16: ":bindings_v8_generated_reference_table", On 2017/05/12 15:20:10, Yuki wrote: > "reference_table" seems not clear about what it is. > > "bindings_v8_(context_)snapshot_external_references" for example? > I'm not insisting to this name. Any better names are welcome. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/scripts/scripts.gni (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/scripts/scripts.gni:300: template("idl_reference_table") { On 2017/05/12 15:20:10, Yuki wrote: > V8 snapshot is not relevant to Web IDL at all. > > Without the context of "V8 (context) snapshot", "reference_table" is not clear > about what it is, because "reference" and "table" are general terms. Removed. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/scripts/scripts.gni:302: script = "//third_party/WebKit/Source/bindings/scripts/generate_reference_table.py" On 2017/05/12 15:20:10, Yuki wrote: > Ditto. "generate_reference_table" is vague. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/templates/templates.gni (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/templates/templates.gni:28: "snapshot.cpp.tmpl", On 2017/05/12 15:20:10, Yuki wrote: > s/snapshot/snapshot_reference/ > following the class name? > > I think that "snapshot_external_reference" is a better name, though. My > understanding is that: > - snapshot = a serialized blob > - snapshot reference = a reference to a snapshot? or external references? > better than "snapshot", but still a bit unclear. > - snapshot external references = a list of external references for a snapshot. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:246: v8::Persistent<v8::FunctionTemplate, CopyableTraits>; On 2017/05/12 15:20:10, Yuki wrote: > If these types are only used at the following line, I'd prefer not aliasing > because it's not clear what V8PerIsolateData::CopyableTraits is. It's not clear > that it's related to V8 snapshotting. Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/publ... File third_party/WebKit/public/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/publ... third_party/WebKit/public/BUILD.gn:448: "web/SnapshotCreator.h", On 2017/05/12 15:20:11, Yuki wrote: > I'm not confident, but should this file be WebSnapshotCreator.h? Done. https://codereview.chromium.org/2841443005/diff/100001/gin/public/isolate_hol... File gin/public/isolate_holder.h (right): https://codereview.chromium.org/2841443005/diff/100001/gin/public/isolate_hol... gin/public/isolate_holder.h:57: enum V8ContextMode { On 2017/05/20 19:10:02, haraken wrote: > > V8ContextShapshotMode Done. https://codereview.chromium.org/2841443005/diff/100001/gin/shell/gin_prepare_... File gin/shell/gin_prepare_main.cc (right): https://codereview.chromium.org/2841443005/diff/100001/gin/shell/gin_prepare_... gin/shell/gin_prepare_main.cc:38: class GinShellRunnerDelegate final : public ModuleRunnerDelegate { On 2017/05/20 19:10:02, haraken wrote: > > Where is this used? removed. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h:16: class CORE_EXPORT V8SnapshotCreator { On 2017/05/20 19:10:02, haraken wrote: > > Most methods of V8SnapshotCreator are taking an Isolate* parameter. Would it > make more sense to move V8SnapshotCreator to V8PerIsolateData instead of making > it a STATIC_ONLY class? Conceptually the V8SnapshotCreator should exist per > isolate. V8PerIsolateData cannot depend on core/, and most features here needs references on core/V8DOMInterfaces. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/scripts/scripts.gni (right): https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/scripts.gni:300: template("idl_reference_table") { On 2017/05/20 19:10:02, haraken wrote: > > v8_snapshot_reference_table removed. https://codereview.chromium.org/2841443005/diff/100001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/scripts.gni:302: script = "//third_party/WebKit/Source/bindings/scripts/generate_reference_table.py" On 2017/05/20 19:10:02, haraken wrote: > > Rename it to generate_v8_snapshot_reference_table.py. Done. https://codereview.chromium.org/2841443005/diff/120001/chrome/BUILD.gn File chrome/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/120001/chrome/BUILD.gn#newcod... chrome/BUILD.gn:123: "$root_out_dir/context_blob.bin", On 2017/05/30 14:35:55, Yuki wrote: > super nit: s/context_blob/v8_context_blob/ > > I think that a term "context" is highly context-dependent. Would like to avoid > any possible ambiguity. Renamed it blink_snapshot_blob.bin. https://codereview.chromium.org/2841443005/diff/120001/gin/BUILD.gn File gin/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/120001/gin/BUILD.gn#newcode161 gin/BUILD.gn:161: # but we must keep duplicated entries in external references for V8 snapshot. On 2017/05/30 14:35:56, Yuki wrote: > Good comment. Let's make this a little more explicit. The following is just an > example. > > This config disables a link time optimization, which may merge two different > functions into one if the function signature and body of them are identical. > This unification breaks 1:1 mappings of the external references of V8 snapshot. > So, disables the LTO while taking a V8 snapshot. Done. https://codereview.chromium.org/2841443005/diff/120001/gin/BUILD.gn#newcode171 gin/BUILD.gn:171: executable("gin_blink_snapshot") { On 2017/05/30 14:35:56, Yuki wrote: > nit: s/gin_blink_snapshot/gin_blink_v8_snapshot/ Done. https://codereview.chromium.org/2841443005/diff/120001/gin/isolate_holder.cc File gin/isolate_holder.cc (right): https://codereview.chromium.org/2841443005/diff/120001/gin/isolate_holder.cc#... gin/isolate_holder.cc:69: } On 2017/05/30 14:35:56, Yuki wrote: > What happens if GetV8ContextData fails to load the snapshot blob? > Should we report an error if (!startup_data->data)? I can't agree to make it an error. Even if Chrome fails to load blob, it can work with kDontUseSnapshot mode. https://codereview.chromium.org/2841443005/diff/120001/gin/isolate_holder.cc#... gin/isolate_holder.cc:90: : isolate_(isolate), access_mode_(kSingleThread) { On 2017/05/30 14:35:56, Yuki wrote: > Could you avoid copy&pasting? Can we have a helper function instead? > > The former constructor above should call the helper function with the created > isolate. Done. Will move to another CL. https://codereview.chromium.org/2841443005/diff/120001/gin/public/isolate_hol... File gin/public/isolate_holder.h (right): https://codereview.chromium.org/2841443005/diff/120001/gin/public/isolate_hol... gin/public/isolate_holder.h:65: // To take snapshot of v8 Context. On 2017/05/30 14:35:56, Yuki wrote: > Let's be a little more descriptive. > > // Creates an IsolateHolder from an existing v8::Isolate. > // v8::SnapshotCreator creates a new v8::Isolate, and we need to instantiate an > IsolateHolder from that v8::Isolate. Done. https://codereview.chromium.org/2841443005/diff/120001/gin/shell/gin_prepare_... File gin/shell/gin_prepare_main.cc (right): https://codereview.chromium.org/2841443005/diff/120001/gin/shell/gin_prepare_... gin/shell/gin_prepare_main.cc:60: int main(int argc, char** argv) { On 2017/05/30 14:35:56, Yuki wrote: > Can you put a comment about the usage of this program? > What arguments are expected? How to invoke this program? What this program > does? > > By the way, why is this named "gin_prepare_main.cc"? > "take_blink_v8_context_snapshot_main.cc" makes more sense to me. (I agree that > it's a little bit too long, though.) Done. https://codereview.chromium.org/2841443005/diff/120001/gin/shell/gin_prepare_... gin/shell/gin_prepare_main.cc:68: // set up environment to make Blink and V8 workable. On 2017/05/30 14:35:56, Yuki wrote: > nit: s/set/Set/ Done. https://codereview.chromium.org/2841443005/diff/120001/gin/v8_initializer.cc File gin/v8_initializer.cc (right): https://codereview.chromium.org/2841443005/diff/120001/gin/v8_initializer.cc#... gin/v8_initializer.cc:37: #include "base/path_service.h" On 2017/05/30 14:35:56, Yuki wrote: > Should this #include be moved up? Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:181: V8SnapshotCreator::EnsureInterfaceTemplates(GetIsolate(), World()); On 2017/05/30 14:35:56, Yuki wrote: > EnsureInterfaceTemplates() is NOT context-dependent, it's isolate-dependent and > context-independent. So this line looks strange to me. > > Can we put this line into V8PerIsolateData for example? Then, we can easily > call EnsureInterfaceTemplates() only once per isolate. Moved to V8Initializer::InitializeV8Common(). https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:711: interface_template = V8SnapshotCreator::CreateInterfaceTemplate( On 2017/05/30 14:35:56, Yuki wrote: > nit: This seems not creating an interface template. > Extract, retrieve, get, deserialize, ... umm. > InterfaceTemplateFromSnapshot (following v8::FunctionTemplate::FromSnapshot) can > be an option (FromSnapshot could be redundant, though). Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:10: #include "bindings/core/v8/V8Document.h" On 2017/05/30 14:35:57, Yuki wrote: > V8Document.h and V8Node.h are not necessary here. > Or, if you prefer including them explicitly, then let's explicitly include > V8EventTarget.h, too. Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:97: &V8EventTarget::wrapperTypeInfo, &V8Window::wrapperTypeInfo, On 2017/05/30 14:35:57, Yuki wrote: > nit: Let's put them one-entry-per-line. > clang-format does it. > Why don't you put V8Window::wrapperTypeInfo at first? > You're assuming that kSnapshotWrapperTypes[1] is V8Window later below... Why > don't you make it [0]? done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:120: case InternalFieldType::kNone: On 2017/05/30 14:35:57, Yuki wrote: > nit: The same order of the type definition is preferred. > kNone, kNodeType, ... Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:135: void V8SnapshotCreator::TakeSnapshotForWorld(v8::SnapshotCreator* creator, On 2017/05/30 14:35:57, Yuki wrote: > nit: The style guide recommends the same order of declarations and definitions. > You declared TakeSnapshot() first in the class definition. Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:164: context->Enter(); On 2017/05/30 14:35:56, Yuki wrote: > v8::Context::Scope enters into the context. > You don't need to enter the context on this line. Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:177: context->Exit(); On 2017/05/30 14:35:56, Yuki wrote: > Ditto. The Scope automatically exits. Acknowledged. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:208: isolate, DOMWrapperWorld::WorldType::kTesting)); On 2017/05/30 14:35:57, Yuki wrote: > kTesting looks too weird, although I understand that it's working fine... > Shall we use kIsolated instead? Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:234: v8::Isolate* isolate, On 2017/05/30 14:35:57, Yuki wrote: > nit: You can take a V8PerIsolateData* instead of v8::Isolate*. Acknowledged. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:259: void* /*data*/) { On 2017/05/30 14:35:57, Yuki wrote: > You define another |data| in the body of the function. > This is rather confusing. Let's remove /*data*/. Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:276: // To confirm covering all patterns to be serialized. On 2017/05/30 14:35:57, Yuki wrote: > nit: I guess that this comment is obvious? Probably we don't need this comment. Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:314: CHECK(document->SetWrapper(isolate, wrapper_type_info, holder)); On 2017/05/30 14:35:57, Yuki wrote: > WrapperTypeInfo::WrapperCreated() should be called, shall not? Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:314: CHECK(document->SetWrapper(isolate, wrapper_type_info, holder)); On 2017/05/30 14:35:57, Yuki wrote: > Add a comment that this only works in the main world + you're taking a snapshot > of window.document only in the main world. Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:338: return v8::Local<v8::Context>(); On 2017/05/30 14:35:57, Yuki wrote: > Maybe NOTREACHED()? No. For example, loading XML files comes here. (w/ main world and XMLDocument) https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:347: .ToLocal(&context)); On 2017/05/30 14:35:57, Yuki wrote: > ToLocalChecked() instead of CHECK()? Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:380: v8::Local<v8::FunctionTemplate>()); On 2017/05/30 14:35:57, Yuki wrote: > Why there is no Node and EventTarget related code? > > Why only V8Document::preparePrototypeAndInterfaceObject without > V8HTMLDocument::prepare...? > > Less assumption, better maintainability, I think. I'll update code generator to make InstallRuntimeEnabledFeatures() call recursively. preparePrototypeAndInterfaceObject() is defined only on V8Document in our target. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:399: isolate, world, global, window_prototype, window_interface); On 2017/05/30 14:35:56, Yuki wrote: > Ditto. > > Why no prepare...? Why no V8EventTarget? ditto. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:403: g_snapshot_reference_table = table; On 2017/05/30 14:35:56, Yuki wrote: > Nice to have DCHECK(!g_snapshot_reference_table); Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:407: return g_snapshot_reference_table; On 2017/05/30 14:35:57, Yuki wrote: > Nice to have DCHECK(g_snapshot_reference_table); Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h:22: static v8::StartupData SerializeInternalField(v8::Local<v8::Object> holder, On 2017/05/30 14:35:57, Yuki wrote: > Can this be private:? Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/modules/v8/V8SnapshotReference.h (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/modules/v8/V8SnapshotReference.h:19: static intptr_t* GetReferenceTable(); On 2017/05/30 14:35:57, Yuki wrote: > It's nice to comment that the definition of this function is auto-generated as > V8SnapshotReference.cpp. Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/core/workers/WorkerBackingThread.cpp:64: // TODO(peria): Replace GetReferenceTable with nullptr. On 2017/05/30 14:35:57, Yuki wrote: > Could you elaborate why we'd like to replace it? > Or why we cannot replace it at this moment? Due to V8 issue. http://crbug.com/v8/6448 https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8DOMWrapper.cpp (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8DOMWrapper.cpp:70: v8::Local<v8::Function> ConstructPlainType(v8::Isolate* isolate, On 2017/05/30 14:35:57, Yuki wrote: > Why don't you remove this function? Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:64: context_mode == V8ContextMode::kUseSnapshot ? &startup_data_ On 2017/05/30 14:35:58, Yuki wrote: > Better to set v8_context_mode_ first, and use members rather than arguments. > v8_context_mode_(context_mode), > isolate_holder_(... v8_context_mode_ ...), Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:75: v8_context_mode_ = V8ContextMode::kDontUseSnapshot; On 2017/05/30 14:35:58, Yuki wrote: > Probably I asked this question before. > Do we really want to fall back rather than CHECK / NOTREACHED? Let's chat again. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:152: void ClearPersistents(); On 2017/05/30 14:35:58, Yuki wrote: > Add a comment what this function does (and why we need this). > This member function is public: but it's not expected to be used widely. > Explicitly describe who are expected to call this function. > > Maybe, ClearPersistentsForV8Snapshot would be a better name. Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:153: V8ContextMode GetV8ContextMode() const { return v8_context_mode_; } On 2017/05/30 14:35:58, Yuki wrote: > GetV8ContextMode() seems relevant to GetSnapshotCreator(). > Why are they put apart? Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:252: // before IsolateHolder. On 2017/05/30 14:35:58, Yuki wrote: > Members required for snapshotted contexts. > Need to be instantiated before |isolate_holder_| gets instantiated. Done. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:264: using CopyablePersistent = On 2017/05/30 14:35:58, Yuki wrote: > I think that it's worth commenting that this is using v8::Persistent instead of > v8::Eternal and why we need to replace it. Acknowledged. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:269: V8FunctionTemplatePersistentMap interface_template_persistent_map_; On 2017/05/30 14:35:58, Yuki wrote: > interface_template_maps_for_snapshot_; > would be clearer? Done.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_...)
Will review PS6 tomorrow. https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:99: g_main_thread_per_isolate_data = this; Let's avoid copy&pasting. Then, we'll simply have if (IsMainThread()) g_main_thread_per_isolate_data = this; and it looks correct to me. Currently we're unconditionally assuming that it's on the main thread, and I think it's not good. https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:110: intptr_t* table, nit: s/table/reference_table/ https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:112: V8PerIsolateData* data = nullptr; Nice to have DCHECK(context_mode == kDontUseSnapshot || reference_table)? https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:116: v8::Isolate* isolate = data->GetIsolate(); Better to share these lines of code with the latter case. Otherwise, declaring V8PerIsolateData* data = nullptr; doesn't make sense. https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/web/WebKit.cpp (right): https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/web/WebKit.cpp:87: V8SnapshotCreator::SetReferenceTable( Can we put this into InitializeMainThread() considering that V8Initializer should be responsible all V8-related initialization? https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/web/WebKit.cpp:89: V8Initializer::InitializeMainThread(platform->TakeV8Snapshot()); Can we simply pass |platform| and let InitliazeMainThread take care of the rest? V8Initializer::InitializeMainThread(platform); looks simpler to me. https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/pub... File third_party/WebKit/public/platform/Platform.h (right): https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/pub... third_party/WebKit/public/platform/Platform.h:679: virtual bool TakeV8Snapshot() { return false; } Can we give a predictor-like name to this function? v8::StartupData TakeSnapshot() { ... } makes good sense but bool TakeSnapshot() { ... } does not.
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Updated. PTAL. Discussed with Yuki again and I'll update to install runtime features on templates (and on HTMLDocument wrapper in snapshot) in next PS soon. https://codereview.chromium.org/2841443005/diff/40001/gin/BUILD.gn File gin/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/40001/gin/BUILD.gn#newcode174 gin/BUILD.gn:174: ":noicf", On 2017/04/28 13:48:27, Yuki wrote: > Better to comment why we need :noicf. Done. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.cpp:176: RuntimeEnabledFeatures::setTestFeaturesEnabled(false); On 2017/05/15 09:37:29, Yuki wrote: > nit: We might want to define > RuntimeEnabledFeatures::setAllFeaturesEnabled(false); Acknowledged. https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h (right): https://codereview.chromium.org/2841443005/diff/80001/third_party/WebKit/Sour... third_party/WebKit/Source/bindings/core/v8/V8SnapshotCreator.h:16: class CORE_EXPORT V8SnapshotCreator { On 2017/05/12 15:20:10, Yuki wrote: > The class header comment is welcome. > Function comments are also welcome. Done. https://codereview.chromium.org/2841443005/diff/80001/url/BUILD.gn File url/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/80001/url/BUILD.gn#newcode75 url/BUILD.gn:75: if (use_platform_icu_alternatives && current_toolchain == default_toolchain) { On 2017/05/12 15:20:11, Yuki wrote: > Why do we need this change? To use ICU alternatives on Android, but it can't be used on the host machine (Linux). https://codereview.chromium.org/2841443005/diff/120001/content/app/content_ma... File content/app/content_main_runner.cc (right): https://codereview.chromium.org/2841443005/diff/120001/content/app/content_ma... content/app/content_main_runner.cc:228: #elif !defined(CHROME_MULTIPLE_DLL_BROWSER) On 2017/05/30 14:35:56, Yuki wrote: > Why is this not |#else|? > Is it okay to not run LoadV8Context(); it seems we can't use V8initializer on MULTIPLE_DLL_BROWSER environment. It has a problem in link. https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.h (right): https://codereview.chromium.org/2841443005/diff/120001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8Initializer.h:39: static void InitializeMainThread(bool take_snapshot); On 2017/05/30 14:35:56, Yuki wrote: > The style guide recommends |enum| instead of |bool|. Acknowledged. https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:99: g_main_thread_per_isolate_data = this; On 2017/06/01 14:15:51, Yuki wrote: > Let's avoid copy&pasting. Then, we'll simply have > if (IsMainThread()) > g_main_thread_per_isolate_data = this; > and it looks correct to me. Currently we're unconditionally assuming that it's > on the main thread, and I think it's not good. I feel this routine should not be run on non-main threads. Done. https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:110: intptr_t* table, On 2017/06/01 14:15:51, Yuki wrote: > nit: s/table/reference_table/ Done. https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:112: V8PerIsolateData* data = nullptr; On 2017/06/01 14:15:51, Yuki wrote: > Nice to have DCHECK(context_mode == kDontUseSnapshot || reference_table)? Done. https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:116: v8::Isolate* isolate = data->GetIsolate(); On 2017/06/01 14:15:51, Yuki wrote: > Better to share these lines of code with the latter case. > > Otherwise, declaring V8PerIsolateData* data = nullptr; doesn't make sense. Done. https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... File third_party/WebKit/Source/web/WebKit.cpp (right): https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/web/WebKit.cpp:87: V8SnapshotCreator::SetReferenceTable( On 2017/06/01 14:15:51, Yuki wrote: > Can we put this into InitializeMainThread() considering that V8Initializer > should be responsible all V8-related initialization? No, we can't. V8Initializer is under core/, and V8SnapshotExternalReferences is under module/. And what this line does must be a part of GetModulesInitializer().Initialize() (2 lines below), but this work must be done before isolates' instantiation. https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/Sou... third_party/WebKit/Source/web/WebKit.cpp:89: V8Initializer::InitializeMainThread(platform->TakeV8Snapshot()); On 2017/06/01 14:15:51, Yuki wrote: > Can we simply pass |platform| and let InitliazeMainThread take care of the rest? > > V8Initializer::InitializeMainThread(platform); > > looks simpler to me. Done. I found we can call platform via Platform::Current(), so we don't need to pass it here. https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/pub... File third_party/WebKit/public/platform/Platform.h (right): https://codereview.chromium.org/2841443005/diff/140001/third_party/WebKit/pub... third_party/WebKit/public/platform/Platform.h:679: virtual bool TakeV8Snapshot() { return false; } On 2017/06/01 14:15:51, Yuki wrote: > Can we give a predictor-like name to this function? > > v8::StartupData TakeSnapshot() { ... } > makes good sense but > bool TakeSnapshot() { ... } > does not. Done.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
https://codereview.chromium.org/2841443005/diff/160001/gin/BUILD.gn File gin/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/160001/gin/BUILD.gn#newcode142 gin/BUILD.gn:142: # functions into one if the function signatures and body of them are identical. s/signatures/signature/ https://codereview.chromium.org/2841443005/diff/160001/gin/BUILD.gn#newcode147 gin/BUILD.gn:147: } else if (is_posix && !is_mac) { nit: It would be better to depend on toolchain rather than platform. If we're using GNU ld or its compatibles, then "-Wl,--icf=none" should be valid. Whether it's POSIX platform or not doesn't matter much. Same for is_win. I don't know much about this area. Please consult with a build expert. https://codereview.chromium.org/2841443005/diff/160001/gin/BUILD.gn#newcode154 gin/BUILD.gn:154: "shell/blink_v8_snapshot_generator_main.cc", This program highly depends on Blink (and it actually directly calls a Blink API), why is this program part of gin/shell/? Should this be placed somewhere else? For example, we have //tools/blink_rename_merge_helper/ directory. https://codereview.chromium.org/2841443005/diff/160001/gin/isolate_holder.cc File gin/isolate_holder.cc (right): https://codereview.chromium.org/2841443005/diff/160001/gin/isolate_holder.cc#... gin/isolate_holder.cc:81: Setup(nullptr, kSingleThread); AccessMode::kSingleThread https://codereview.chromium.org/2841443005/diff/160001/gin/isolate_holder.cc#... gin/isolate_holder.cc:84: void IsolateHolder::Setup( nit: gtest uses SetUp(). https://codereview.chromium.org/2841443005/diff/160001/gin/isolate_holder.cc#... gin/isolate_holder.cc:84: void IsolateHolder::Setup( Keep the same order of declarations in the header and definitions in the implementation file. https://codereview.chromium.org/2841443005/diff/160001/gin/isolate_holder.cc#... gin/isolate_holder.cc:87: access_mode_ = access_mode; access_mode_ was already initialized on line 50. Shouldn't initialize it twice. https://codereview.chromium.org/2841443005/diff/160001/gin/v8_initializer.cc File gin/v8_initializer.cc (right): https://codereview.chromium.org/2841443005/diff/160001/gin/v8_initializer.cc#... gin/v8_initializer.cc:408: #if defined(CHROME_MULTIPLE_DLL_BROWSER) Does this mean that, if we're building with is_component_build=true, the snapshot will be disabled? If so, it's not good because most of people are developing with the component builds, and it will be hard to catch issues. https://codereview.chromium.org/2841443005/diff/160001/pdf/pdfium/pdfium_engi... File pdf/pdfium/pdfium_engine.cc (right): https://codereview.chromium.org/2841443005/diff/160001/pdf/pdfium/pdfium_engi... pdf/pdfium/pdfium_engine.cc:601: new gin::IsolateHolder(base::ThreadTaskRunnerHandle::Get()); Is this a good change? It seems better to explicitly pass kSingleThread rather than implicitly assuming kSingleThread. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Lay... File third_party/WebKit/LayoutTests/SlowTests (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Lay... third_party/WebKit/LayoutTests/SlowTests:396: # When we enable snapshot feature, adding an external reference table makes isolate nit: 80 columns. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:206: if (context.IsEmpty()) { We shouldn't hit this case except for a few cases, then it would be worth printing a warning (LOG(ERROR) for example). https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:740: interface_template = V8SnapshotUtil::InterfaceTemplateFromSnapshot( Do we really need this code? V8SnapshotUtil::EnsureInterfaceTemplates() registers all interfaces in the snapshot, then we shouldn't need this. You can EnsureInterfaceTemplates for both of main and non-main world. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp:443: WebScheduler* scheduler = thread ? thread->Scheduler() : nullptr; Why |thread| can be null? https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:99: &V8Window::wrapperTypeInfo, &V8HTMLDocument::wrapperTypeInfo, nit: one entry per line rather than manual spacing? https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:139: // To ignore the terminate entry '0'. It seems that you're not counting the null terminator IIUC? for (; *p; ++p) means that you only count in case of p != nullptr, doesn't it? Why do we need to start from -1 then? https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:199: // FIXME: Confirm interface_tempaltes[0] is a template of V8Window. s/FIXME/TODO(peria)/ https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h:9: #include "platform/bindings/V8Binding.h" Just curious. What makes you need this header? class DOMWrapperWorld; does the trick? https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/ScriptWrappable.h (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/ScriptWrappable.h:163: friend class V8SnapshotUtil; Add TODO(peria): Remove V8SnapshotUtil from a list of friend classes. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/ScriptWrappableVisitor.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/ScriptWrappableVisitor.cpp:98: if (!current_thread || !current_thread->Scheduler()) Why current_thread can be null? https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerContextData.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerContextData.cpp:92: v8::Local<v8::Context> context = GetContext(); |context| seems never used again? https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerContextData.h (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerContextData.h:134: friend class V8SnapshotUtil; Can you remove this? https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:102: // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. s/FIXME/TODO(peria)/ https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:156: // persistent handles from Blink. This method clears them. s/from/in/
PTL. Worked for comments on other than gin/BUILD.gn. The main change is to install runtime enabled features on interface templates (and some v8::Objects in snapshot). https://codereview.chromium.org/2841443005/diff/160001/gin/BUILD.gn File gin/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/160001/gin/BUILD.gn#newcode142 gin/BUILD.gn:142: # functions into one if the function signatures and body of them are identical. On 2017/06/20 14:20:10, Yuki wrote: > s/signatures/signature/ Done. https://codereview.chromium.org/2841443005/diff/160001/gin/isolate_holder.cc File gin/isolate_holder.cc (right): https://codereview.chromium.org/2841443005/diff/160001/gin/isolate_holder.cc#... gin/isolate_holder.cc:81: Setup(nullptr, kSingleThread); On 2017/06/20 14:20:10, Yuki wrote: > AccessMode::kSingleThread Done. https://codereview.chromium.org/2841443005/diff/160001/gin/isolate_holder.cc#... gin/isolate_holder.cc:84: void IsolateHolder::Setup( On 2017/06/20 14:20:10, Yuki wrote: > nit: gtest uses SetUp(). Done. https://codereview.chromium.org/2841443005/diff/160001/gin/isolate_holder.cc#... gin/isolate_holder.cc:84: void IsolateHolder::Setup( On 2017/06/20 14:20:10, Yuki wrote: > Keep the same order of declarations in the header and definitions in the > implementation file. Done. https://codereview.chromium.org/2841443005/diff/160001/gin/isolate_holder.cc#... gin/isolate_holder.cc:87: access_mode_ = access_mode; On 2017/06/20 14:20:10, Yuki wrote: > access_mode_ was already initialized on line 50. Shouldn't initialize it twice. Done. https://codereview.chromium.org/2841443005/diff/160001/gin/v8_initializer.cc File gin/v8_initializer.cc (right): https://codereview.chromium.org/2841443005/diff/160001/gin/v8_initializer.cc#... gin/v8_initializer.cc:408: #if defined(CHROME_MULTIPLE_DLL_BROWSER) On 2017/06/20 14:20:10, Yuki wrote: > Does this mean that, if we're building with is_component_build=true, the > snapshot will be disabled? If so, it's not good because most of people are > developing with the component builds, and it will be hard to catch issues. This #if disables snasphot feature for non-component build on Windows. I'll look for a workaround. https://codereview.chromium.org/2841443005/diff/160001/pdf/pdfium/pdfium_engi... File pdf/pdfium/pdfium_engine.cc (right): https://codereview.chromium.org/2841443005/diff/160001/pdf/pdfium/pdfium_engi... pdf/pdfium/pdfium_engine.cc:601: new gin::IsolateHolder(base::ThreadTaskRunnerHandle::Get()); On 2017/06/20 14:20:10, Yuki wrote: > Is this a good change? It seems better to explicitly pass kSingleThread rather > than implicitly assuming kSingleThread. Done. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Lay... File third_party/WebKit/LayoutTests/SlowTests (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Lay... third_party/WebKit/LayoutTests/SlowTests:396: # When we enable snapshot feature, adding an external reference table makes isolate On 2017/06/20 14:20:10, Yuki wrote: > nit: 80 columns. Done. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:206: if (context.IsEmpty()) { On 2017/06/20 14:20:10, Yuki wrote: > We shouldn't hit this case except for a few cases, then it would be worth > printing a warning (LOG(ERROR) for example). I feel it is not practical to list the condition here, and in such a case, it must hit a CHECK() in V8SnapshotUtil:CreateContext(). If we need some specific log message, we should replace the CHECK in V8SnapshotUtil::CreateContext to LOG_IF(ERROR, !context.IsEmpty). https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8DOMConfiguration.cpp:740: interface_template = V8SnapshotUtil::InterfaceTemplateFromSnapshot( On 2017/06/20 14:20:11, Yuki wrote: > Do we really need this code? > V8SnapshotUtil::EnsureInterfaceTemplates() registers all interfaces in the > snapshot, then we shouldn't need this. You can EnsureInterfaceTemplates for > both of main and non-main world. Done. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp:443: WebScheduler* scheduler = thread ? thread->Scheduler() : nullptr; On 2017/06/20 14:20:11, Yuki wrote: > Why |thread| can be null? In taking snapshot process, we have no implementation for Platform::CurrentThread(), and it returns nullptr. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:99: &V8Window::wrapperTypeInfo, &V8HTMLDocument::wrapperTypeInfo, On 2017/06/20 14:20:11, Yuki wrote: > nit: one entry per line rather than manual spacing? clang-format does it. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:139: // To ignore the terminate entry '0'. On 2017/06/20 14:20:11, Yuki wrote: > It seems that you're not counting the null terminator IIUC? > > for (; *p; ++p) means that you only count in case of p != nullptr, doesn't it? > > Why do we need to start from -1 then? Done. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:199: // FIXME: Confirm interface_tempaltes[0] is a template of V8Window. On 2017/06/20 14:20:11, Yuki wrote: > s/FIXME/TODO(peria)/ Done. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h:9: #include "platform/bindings/V8Binding.h" On 2017/06/20 14:20:11, Yuki wrote: > Just curious. What makes you need this header? > class DOMWrapperWorld; does the trick? It supported - STATIC_ONLY() - DOMWrapperWorld - WrapperTypeInfo replaced with better descriptions. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/ScriptWrappable.h (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/ScriptWrappable.h:163: friend class V8SnapshotUtil; On 2017/06/20 14:20:11, Yuki wrote: > Add TODO(peria): Remove V8SnapshotUtil from a list of friend classes. Done. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/ScriptWrappableVisitor.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/ScriptWrappableVisitor.cpp:98: if (!current_thread || !current_thread->Scheduler()) On 2017/06/20 14:20:11, Yuki wrote: > Why current_thread can be null? ditto to V8Initializer.cpp https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerContextData.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerContextData.cpp:92: v8::Local<v8::Context> context = GetContext(); On 2017/06/20 14:20:11, Yuki wrote: > |context| seems never used again? Done. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerContextData.h (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerContextData.h:134: friend class V8SnapshotUtil; On 2017/06/20 14:20:11, Yuki wrote: > Can you remove this? Done. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:102: // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. On 2017/06/20 14:20:11, Yuki wrote: > s/FIXME/TODO(peria)/ Acknowledged. https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/160001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:156: // persistent handles from Blink. This method clears them. On 2017/06/20 14:20:11, Yuki wrote: > s/from/in/ Done.
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: ios-simulator on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/bui...)
Major points were discussed offline. Only minor comments here. https://codereview.chromium.org/2841443005/diff/180001/gin/isolate_holder.cc File gin/isolate_holder.cc (right): https://codereview.chromium.org/2841443005/diff/180001/gin/isolate_holder.cc#... gin/isolate_holder.cc:85: void IsolateHolder::SetUp( nit: Better to put this definition at the end of this file so that it's the same order as declarations in the header. https://codereview.chromium.org/2841443005/diff/180001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/180001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:362: if (world.IsMainWorld() && !(document && document->IsHTMLDocument())) { Could you elaborate why it's possible that it's not a HTMLDocument? https://codereview.chromium.org/2841443005/diff/180001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:407: v8::Local<v8::Object> wrapper = global_proxy->GetPrototype().As<v8::Object>(); I think that s/wrapper/window_wrapper/ makes the following code clearer, why we don't pass |wrapper| to Node case for example. https://codereview.chromium.org/2841443005/diff/180001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl (right): https://codereview.chromium.org/2841443005/diff/180001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl:720: void {{v8_class_or_partial}}::InstallRuntimeEnabledFeaturesOnTemplate( Probably we could land this change separately in advance of this CL? Then, we can easily confirm no regression caused by this change. Let's consider this option once things get settled. https://codereview.chromium.org/2841443005/diff/180001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl:739: // Register DOM constants, attributes and operations. nit: s/DOM/IDL/
Description was changed from ========== Create and use V8 context snapshots. This CL does two things. 1. Creates a file "context_blob.bin", which has snapshots of V8 contexts, during compile time. 2. Instantiates v8::Context from the snapshot in LocalWindowProxy::createContext(). Test expectations are changed due to http://crbug.com/705364 Design doc: https://docs.google.com/document/d/1jpQQX0piaxcHJPWakp_Kr_03g5Gnma5h5-Kdlqu7j... BUG=588893, 617892, 705364 ========== to ========== Create and use V8 context snapshots. This CL does two things. 1. Creates a file "blink_v8_snapshot.bin", which has snapshots of V8 contexts, during compile time. 2. Instantiates v8::Context from the snapshot in LocalWindowProxy::createContext(). Test expectations are changed due to http://crbug.com/705364 Design doc: https://docs.google.com/document/d/1jpQQX0piaxcHJPWakp_Kr_03g5Gnma5h5-Kdlqu7j... BUG=588893, 617892, 705364 ==========
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
methods to install runtime enabled features on templates are willing to land in another patch (https://chromium-review.googlesource.com/c/544743/) https://codereview.chromium.org/2841443005/diff/160001/gin/BUILD.gn File gin/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/160001/gin/BUILD.gn#newcode147 gin/BUILD.gn:147: } else if (is_posix && !is_mac) { On 2017/06/20 14:20:10, Yuki wrote: > nit: It would be better to depend on toolchain rather than platform. > If we're using GNU ld or its compatibles, then "-Wl,--icf=none" should be valid. > Whether it's POSIX platform or not doesn't matter much. Same for is_win. > > I don't know much about this area. Please consult with a build expert. Trying... https://codereview.chromium.org/2841443005/diff/160001/gin/BUILD.gn#newcode154 gin/BUILD.gn:154: "shell/blink_v8_snapshot_generator_main.cc", On 2017/06/20 14:20:10, Yuki wrote: > This program highly depends on Blink (and it actually directly calls a Blink > API), why is this program part of gin/shell/? Should this be placed somewhere > else? > > For example, we have //tools/blink_rename_merge_helper/ directory. I think //tools is a place for developer tools, which CAN be used in developments, and not a part of build flow. This program depends on V8 and Blink. It is required to build Chromium, but is not a part of Chromium binary itself. So I feel gin/ is a good place to have this program. (and jochen@ suggested to use gin/.) https://codereview.chromium.org/2841443005/diff/180001/gin/isolate_holder.cc File gin/isolate_holder.cc (right): https://codereview.chromium.org/2841443005/diff/180001/gin/isolate_holder.cc#... gin/isolate_holder.cc:85: void IsolateHolder::SetUp( On 2017/06/21 09:23:21, Yuki wrote: > nit: Better to put this definition at the end of this file so that it's the same > order as declarations in the header. Done. https://codereview.chromium.org/2841443005/diff/180001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/180001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:362: if (world.IsMainWorld() && !(document && document->IsHTMLDocument())) { On 2017/06/21 09:23:21, Yuki wrote: > Could you elaborate why it's possible that it's not a HTMLDocument? Done. https://codereview.chromium.org/2841443005/diff/180001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:407: v8::Local<v8::Object> wrapper = global_proxy->GetPrototype().As<v8::Object>(); On 2017/06/21 09:23:21, Yuki wrote: > I think that s/wrapper/window_wrapper/ makes the following code clearer, why we > don't pass |wrapper| to Node case for example. Done. https://codereview.chromium.org/2841443005/diff/180001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl (right): https://codereview.chromium.org/2841443005/diff/180001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl:720: void {{v8_class_or_partial}}::InstallRuntimeEnabledFeaturesOnTemplate( On 2017/06/21 09:23:21, Yuki wrote: > Probably we could land this change separately in advance of this CL? > Then, we can easily confirm no regression caused by this change. > > Let's consider this option once things get settled. Yes, of course, will do. It is included in this change to check the editing direction. https://codereview.chromium.org/2841443005/diff/180001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/templates/interface_base.cpp.tmpl:739: // Register DOM constants, attributes and operations. On 2017/06/21 09:23:21, Yuki wrote: > nit: s/DOM/IDL/ Done.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:273: // and Window. I think that now we don't need these lines of code. Do we still need this? This is actually, noop, I think. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp (right): https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp:450: WebThread* thread = platform->CurrentThread(); As I took a look at the codebase, it seems better to implement Platform::CurrentThread() so that it returns a non-null WebThread with no implementation. For example, https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/testi... https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/IdleD... https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/Scrip... There are many call sites of CurrentThread() and the contract seems that it never returns null. Then, we shouldn't change that contract. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp:459: : thread ? thread->GetWebTaskRunner() : nullptr, Ditto. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:42: if (!interface_template->GetFunction(context).ToLocal(&interface_object)) s/ToLocal/ToLocalChecked/ https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:54: .ToLocal(&prototype_value)); s/CHECK(...ToLocal(...))/ToLocalChecked()/ https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:84: .ToLocal(&instance_template)); s/CHECK(...ToLocal(...))/ToLocalChecked()/ https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:183: void V8SnapshotUtil::TakeSnapshotForWorld(v8::SnapshotCreator* creator, Be consistent with the declaration order in the header. Chromium's coding style guide recommends it. Ditto for others. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:190: Vector<v8::Local<v8::FunctionTemplate>> interface_templates; It's not allowed to put v8::Local on heap. Vector<v8::Local<T>> is wrong, I think. Maybe std::array would be best? https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:222: CHECK(V8PrivateProperty::GetWindowDocumentCachedAccessor(isolate).Set( Probably, this should be gone. You're now setting the private property twice, here for the first time, and LocalWindowProxy::Initialize => UpdateDocumentInternal => UpdateDocumentProperty for the second time. Either of putting this code here or removing this code from here looks hacky to me. But setting the private property twice makes it hackier. So, I'd vote to remove this. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:258: v8::Local<v8::FunctionTemplate> V8SnapshotUtil::InterfaceTemplateFromSnapshot( InterfaceTemplateFromSnapshot is only used in EnsureInterfaceTemplatesForWorld, and we're registering all interface templates in the snapshot to the V8PerIsolateData. Then, this looks a little bit inefficient. for (wrapper_type_info : kSnapshotWrapperType) { if (wrapper_type_info == V8Window) { index = 0; // setup 0th template. } if (wrapper_type_info == V8HTMLDocument) { index = 1; // setup 1st template. } ... } Why don't we have a tuple of index, WrapperTypeInfo, V8<T>::InstallV8<T>RuntimeEnabledOnTemplateFunction and then, we can simply write a loop. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:269: V8Window::installV8WindowRuntimeEnabledOnTemplateFunction( s/installV8Window.../InstallV8Window.../ Does this CL successfully compile? https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:338: void V8SnapshotUtil::DeserializeInternalField(v8::Local<v8::Object> holder, s/holder/object/ This is not relevant to a holder that holds own properties. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:427: v8::Local<v8::Function> constructor = data->ConstructorForType(type); nit: s/constructor/interface/ We're not interested in constructing a new object, and it's an IDL interface object, isn't it? https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:446: if (world.IsMainWorld() && document && document->IsHTMLDocument()) { This condition must appear at the very beginning of this function, I think. If it's not an HTMLDocument, CreateContext does nothing at all, i.e. the use of the snapshot is totally disabled. Then, SetupContext must do nothing, too. Optionally, you may want to define a helper function for this condition, and make both of CreateContext and SetupContext use it so that they're consistent. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h (right): https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h:43: // Do not call this in browsers. s/browsers/production/ This could read that it's okay to call this in a renderer, not in a browser process. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/ScriptWrappableVisitor.cpp (right): https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/ScriptWrappableVisitor.cpp:97: WebThread* current_thread = Platform::Current()->CurrentThread(); Once CurrentThread() is implemented, we should revert this file. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:105: // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. s/FIXME/TODO(peria)/
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2841443005/diff/160001/gin/BUILD.gn File gin/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/160001/gin/BUILD.gn#newcode147 gin/BUILD.gn:147: } else if (is_posix && !is_mac) { On 2017/06/23 02:22:05, peria wrote: > On 2017/06/20 14:20:10, Yuki wrote: > > nit: It would be better to depend on toolchain rather than platform. > > If we're using GNU ld or its compatibles, then "-Wl,--icf=none" should be > valid. > > Whether it's POSIX platform or not doesn't matter much. Same for is_win. > > > > I don't know much about this area. Please consult with a build expert. > > Trying... ldflags seems to be set depend on platforms, and it is difficult to change it with other flags correctly. https://codereview.chromium.org/2841443005/diff/160001/gin/BUILD.gn#newcode154 gin/BUILD.gn:154: "shell/blink_v8_snapshot_generator_main.cc", On 2017/06/23 02:22:05, peria wrote: > On 2017/06/20 14:20:10, Yuki wrote: > > This program highly depends on Blink (and it actually directly calls a Blink > > API), why is this program part of gin/shell/? Should this be placed somewhere > > else? > > > > For example, we have //tools/blink_rename_merge_helper/ directory. > > I think //tools is a place for developer tools, which CAN be used in > developments, and not a part of build flow. > This program depends on V8 and Blink. It is required to build Chromium, but is > not a part of Chromium binary itself. > So I feel gin/ is a good place to have this program. (and jochen@ suggested to > use gin/.) moved to tools/blink_v8_snapshot https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:273: // and Window. On 2017/06/23 15:20:44, Yuki wrote: > I think that now we don't need these lines of code. Do we still need this? > This is actually, noop, I think. Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp (right): https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp:450: WebThread* thread = platform->CurrentThread(); On 2017/06/23 15:20:44, Yuki wrote: > As I took a look at the codebase, it seems better to implement > Platform::CurrentThread() so that it returns a non-null WebThread with no > implementation. > > For example, > https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/testi... > https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/IdleD... > https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/Scrip... > > There are many call sites of CurrentThread() and the contract seems that it > never returns null. Then, we shouldn't change that contract. Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp:459: : thread ? thread->GetWebTaskRunner() : nullptr, On 2017/06/23 15:20:44, Yuki wrote: > Ditto. Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:42: if (!interface_template->GetFunction(context).ToLocal(&interface_object)) On 2017/06/23 15:20:45, Yuki wrote: > s/ToLocal/ToLocalChecked/ Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:54: .ToLocal(&prototype_value)); On 2017/06/23 15:20:44, Yuki wrote: > s/CHECK(...ToLocal(...))/ToLocalChecked()/ Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:84: .ToLocal(&instance_template)); On 2017/06/23 15:20:44, Yuki wrote: > s/CHECK(...ToLocal(...))/ToLocalChecked()/ Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:183: void V8SnapshotUtil::TakeSnapshotForWorld(v8::SnapshotCreator* creator, On 2017/06/23 15:20:45, Yuki wrote: > Be consistent with the declaration order in the header. Chromium's coding style > guide recommends it. Ditto for others. Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:190: Vector<v8::Local<v8::FunctionTemplate>> interface_templates; On 2017/06/23 15:20:45, Yuki wrote: > It's not allowed to put v8::Local on heap. Vector<v8::Local<T>> is wrong, I > think. Maybe std::array would be best? Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:222: CHECK(V8PrivateProperty::GetWindowDocumentCachedAccessor(isolate).Set( On 2017/06/23 15:20:44, Yuki wrote: > Probably, this should be gone. > > You're now setting the private property twice, here for the first time, and > LocalWindowProxy::Initialize => UpdateDocumentInternal => UpdateDocumentProperty > for the second time. > > Either of putting this code here or removing this code from here looks hacky to > me. But setting the private property twice makes it hackier. So, I'd vote to > remove this. Hmm. This code is required here to keep the HTMLDocument wrapper alive. Beside it, the code in LocalWindowProxy::UpdateDocumentProperty can be called for other documents or for contexts without snapshot. It is difficult to remove with correct branching ... https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:258: v8::Local<v8::FunctionTemplate> V8SnapshotUtil::InterfaceTemplateFromSnapshot( On 2017/06/23 15:20:44, Yuki wrote: > InterfaceTemplateFromSnapshot is only used in EnsureInterfaceTemplatesForWorld, > and we're registering all interface templates in the snapshot to the > V8PerIsolateData. Then, this looks a little bit inefficient. > > for (wrapper_type_info : kSnapshotWrapperType) { > if (wrapper_type_info == V8Window) { > index = 0; > // setup 0th template. > } > if (wrapper_type_info == V8HTMLDocument) { > index = 1; > // setup 1st template. > } > ... > } > > Why don't we have a tuple of > index, WrapperTypeInfo, V8<T>::InstallV8<T>RuntimeEnabledOnTemplateFunction > and then, we can simply write a loop. Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:269: V8Window::installV8WindowRuntimeEnabledOnTemplateFunction( On 2017/06/23 15:20:44, Yuki wrote: > s/installV8Window.../InstallV8Window.../ > > Does this CL successfully compile? For V8Window, we call it via static function pointer, because V8Window has partial classes in modules/. It will be clear after other CL (https://chromium-review.googlesource.com/c/544743/) is landed. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:338: void V8SnapshotUtil::DeserializeInternalField(v8::Local<v8::Object> holder, On 2017/06/23 15:20:44, Yuki wrote: > s/holder/object/ > > This is not relevant to a holder that holds own properties. Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:427: v8::Local<v8::Function> constructor = data->ConstructorForType(type); On 2017/06/23 15:20:44, Yuki wrote: > nit: s/constructor/interface/ > > We're not interested in constructing a new object, and it's an IDL interface > object, isn't it? Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:446: if (world.IsMainWorld() && document && document->IsHTMLDocument()) { On 2017/06/23 15:20:44, Yuki wrote: > This condition must appear at the very beginning of this function, I think. > > If it's not an HTMLDocument, CreateContext does nothing at all, i.e. the use of > the snapshot is totally disabled. Then, SetupContext must do nothing, too. > > Optionally, you may want to define a helper function for this condition, and > make both of CreateContext and SetupContext use it so that they're consistent. Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h (right): https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h:43: // Do not call this in browsers. On 2017/06/23 15:20:45, Yuki wrote: > s/browsers/production/ > > This could read that it's okay to call this in a renderer, not in a browser > process. Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/ScriptWrappableVisitor.cpp (right): https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/ScriptWrappableVisitor.cpp:97: WebThread* current_thread = Platform::Current()->CurrentThread(); On 2017/06/23 15:20:45, Yuki wrote: > Once CurrentThread() is implemented, we should revert this file. Done. https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/200001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:105: // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. On 2017/06/23 15:20:45, Yuki wrote: > s/FIXME/TODO(peria)/ Acknowledged.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_tsan_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_comp...)
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #10 (id:220001) has been deleted
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_...)
https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:166: CHECK(!context.IsEmpty()); This CHECK is meaningless after ToLocalChecked(). https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:194: V8EventTarget::InstallRuntimeEnabledFeatures(isolate, world, window_wrapper, I'm confused again. Exactly what InstallRuntimeEnabledFeatures does? Suppose that EventTarget has an [Unforgeable] attribute |foo|, Does V8Window::InstallRuntimeEnabledFeatures install |foo|? Like InstanceTemplate(), if the most derived interface takes care of all inherited properties, we shouldn't pass |window_wrapper| here. https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:207: if (world.IsMainWorld()) { nit: Can we do an early-exit? https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:212: document->MainWorldWrapper(isolate); Is this the only reason that V8SnapshotUtil needs to be a friend of ScriptWrappable? Then, we should use ToV8 instead. https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:383: Document* document) { nit: Can we add DCHECK(document)? If document == nullptr is expected, why? https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:390: if (world.IsMainWorld() && !(document && document->IsHTMLDocument())) { nit: A→B is defined as ¬A∨B, hence (!A || B) is one of well-known patterns. return !world.IsMainWorld() || document->IsHTMLDocument(); https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:412: static const InstallRuntimeEnabledFeaturesOnTemplateFunction kInstallers[] = { Maybe my comment was unclear. I was recommending to define a struct to represent tuples of WrapperTypeInfo and installer function. struct T { const WrapperTypeInfo* wrapper_type_info; InstallFunction install_function; } kSnapshotWrapperTypes[] = { {V8Window::wrapperTypeInfo, V8Window::InstallRuntimeEnabledFeaturesOnTemplate}, ... }; https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:427: kInstallers[i](isolate, world, interface_template); Just a comment for future work, it's not good to have a side effect in a getter function, or to name a non-getter function a getter-like name.
https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:207: if (world.IsMainWorld()) { nit: Can we do an early-exit? https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:412: static const InstallRuntimeEnabledFeaturesOnTemplateFunction kInstallers[] = { Maybe my comment was unclear. I was recommending to define a struct to represent tuples of WrapperTypeInfo and installer function. struct T { const WrapperTypeInfo* wrapper_type_info; InstallFunction install_function; } kSnapshotWrapperTypes[] = { {V8Window::wrapperTypeInfo, V8Window::InstallRuntimeEnabledFeaturesOnTemplate}, ... }; https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:427: kInstallers[i](isolate, world, interface_template); Just a comment for future work, it's not good to have a side effect in a getter function, or to name a non-getter function a getter-like name.
https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:166: CHECK(!context.IsEmpty()); On 2017/06/27 12:43:47, Yuki wrote: > This CHECK is meaningless after ToLocalChecked(). Done. https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:194: V8EventTarget::InstallRuntimeEnabledFeatures(isolate, world, window_wrapper, On 2017/06/27 12:43:47, Yuki wrote: > I'm confused again. Exactly what InstallRuntimeEnabledFeatures does? > > Suppose that EventTarget has an [Unforgeable] attribute |foo|, > Does V8Window::InstallRuntimeEnabledFeatures install |foo|? > > Like InstanceTemplate(), if the most derived interface takes care of all > inherited properties, we shouldn't pass |window_wrapper| here. Ah, I think your understanding is correct. No need to pass |window_wrapper| for V8EventTarget. https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:207: if (world.IsMainWorld()) { On 2017/06/27 12:43:49, Yuki wrote: > nit: Can we do an early-exit? Done. https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:212: document->MainWorldWrapper(isolate); On 2017/06/27 12:43:47, Yuki wrote: > Is this the only reason that V8SnapshotUtil needs to be a friend of > ScriptWrappable? > Then, we should use ToV8 instead. Done. https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:383: Document* document) { On 2017/06/27 12:43:47, Yuki wrote: > nit: Can we add DCHECK(document)? > > If document == nullptr is expected, why? Done. https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:390: if (world.IsMainWorld() && !(document && document->IsHTMLDocument())) { On 2017/06/27 12:43:47, Yuki wrote: > nit: A→B is defined as ¬A∨B, hence (!A || B) is one of well-known patterns. > return !world.IsMainWorld() || document->IsHTMLDocument(); Done. https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:412: static const InstallRuntimeEnabledFeaturesOnTemplateFunction kInstallers[] = { On 2017/06/27 12:43:49, Yuki wrote: > Maybe my comment was unclear. I was recommending to define a struct to > represent tuples of WrapperTypeInfo and installer function. > > struct T { > const WrapperTypeInfo* wrapper_type_info; > InstallFunction install_function; > } kSnapshotWrapperTypes[] = { > {V8Window::wrapperTypeInfo, > V8Window::InstallRuntimeEnabledFeaturesOnTemplate}, > ... > }; Done. https://codereview.chromium.org/2841443005/diff/240001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:427: kInstallers[i](isolate, world, interface_template); On 2017/06/27 12:43:49, Yuki wrote: > Just a comment for future work, it's not good to have a side effect in a getter > function, or to name a non-getter function a getter-like name. Acknowledged.
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromeos_daisy_chromium_compile_only_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromeos_daisy_...)
LGTM with comments. https://codereview.chromium.org/2841443005/diff/260001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/260001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:264: // Update the install function for V8Window to work for partial interfaces. This should be hidden in V8Window. V8Window::InstallRuntimeEnabledFeaturesOnTemplate() { install_runtime_enabled_features_on_template_function_(); } Otherwise, this is going to be broken when someone introduces runtime-enabled attributes / operations in partial interfaces in modules. https://codereview.chromium.org/2841443005/diff/260001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:418: v8::Local<v8::FunctionTemplate> V8SnapshotUtil::InterfaceTemplateFromSnapshot( Talked offline. We don't need this function.
(I'll take a look at this CL by next Tue.)
On 2017/06/28 07:19:50, haraken wrote: > (I'll take a look at this CL by next Tue.) got it. I'll update the document with measuring performance.
On 2017/06/28 07:39:24, peria wrote: > On 2017/06/28 07:19:50, haraken wrote: > > (I'll take a look at this CL by next Tue.) > > got it. I'll update the document with measuring performance. Sounds awesome. Let's compare performance between before you started a bunch of optimizations (6 months ago?) and now. Also do we have any UMA to measure the frame initialization time (to evaluate how much this CL improves performance)?
On 2017/06/28 07:42:29, haraken wrote: > On 2017/06/28 07:39:24, peria wrote: > > On 2017/06/28 07:19:50, haraken wrote: > > > (I'll take a look at this CL by next Tue.) > > > > got it. I'll update the document with measuring performance. > > Sounds awesome. Let's compare performance between before you started a bunch of > optimizations (6 months ago?) and now. > > Also do we have any UMA to measure the frame initialization time (to evaluate > how much this CL improves performance)? Yes, Blink.Binding.Initialize(Non)MainLocalWindowProxy are. We also track Blink.Binding.Initialize(Non)MainRemoteWindowProxy, but it is not on our focus now.
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: cast_shell_linux on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/cast_shell_linu...) linux_chromium_asan_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) linux_chromium_tsan_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
Patchset #12 (id:280001) has been deleted
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_compile_dbg_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_compile_dbg_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
Let me take a look at V8SnapshotUtil.cpp tomorrow. All the comments are about nits. Looks good! https://codereview.chromium.org/2841443005/diff/320001/content/app/content_ma... File content/app/content_main_runner.cc (right): https://codereview.chromium.org/2841443005/diff/320001/content/app/content_ma... content/app/content_main_runner.cc:229: LoadBlinkV8SnapshotFile(); LoadV8ContextSnapshotFile https://codereview.chromium.org/2841443005/diff/320001/gin/isolate_holder.cc File gin/isolate_holder.cc (right): https://codereview.chromium.org/2841443005/diff/320001/gin/isolate_holder.cc#... gin/isolate_holder.cc:53: CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first"; You can remove line 52 and 53. https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.cc File gin/v8_initializer.cc (right): https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.cc#... gin/v8_initializer.cc:44: base::MemoryMappedFile* g_mapped_blink_v8_snapshot = nullptr; blink_v8_snapshot => v8_context_snapshot https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.cc#... gin/v8_initializer.cc:46: const char kBlinkV8SnapshotFileName[] = "blink_v8_snapshot.bin"; blink_v8_snapshot.bin => v8_context_snapshot.bin https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.h File gin/v8_initializer.h (right): https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.h#n... gin/v8_initializer.h:80: static void LoadBlinkV8SnapshotFromFD(base::PlatformFile snapshot_fd, LoadV8ContextSnapshotFromFD https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.h#n... gin/v8_initializer.h:83: static void LoadBlinkV8Snapshot(); LoadV8ContextSnapshot https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.h#n... gin/v8_initializer.h:84: static void GetBlinkV8SnapshotData(const char** snapshot_data_out, GetV8ContextSnapshotData https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:141: V8SnapshotUtil::SetupContext(context, GetFrame()->GetDocument()); SetupContext => InstallRuntimeEnabledFeatures ? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:163: TRACE_EVENT1("v8", "Notification", "IsMainFrame", Notification => ContextCreationNotification https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:167: GetFrame()->Client()->DidCreateScriptContext(context, world_->GetWorldId()); Oh, the context creation notification still exits. Is the performance problem already gone? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:198: TRACE_EVENT1("v8", "ContextCreation", "IsMainFrame", Is this trace event useful? I guess that the trace event at line 178 would be enough. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:205: if (context.IsEmpty()) { Add a comment and explain when this can happen. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp:393: v8::HandleScope handle_scope(isolate); Can we move the HandleScope into EnsureInterfaceTemplates? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/modules/v8/V8SnapshotExternalReferences.h (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/modules/v8/V8SnapshotExternalReferences.h:1: // Copyright 2017 The Chromium Authors. All rights reserved. Rename this file to V8ContextSnapshotExternalReferences.h. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/scripts/generate_v8_snapshot_external_references.py (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_v8_snapshot_external_references.py:1: # Copyright 2017 The Chromium Authors. All rights reserved. Rename the file to generate_v8_context_snapshot_external_references.py. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_v8_snapshot_external_references.py:61: class InterfaceTemplateContextBuilder(object): Add a class-level comment. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_v8_snapshot_external_references.py:62: # NOTE: This class is equivalent of v8_interface.py is equivalent to https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_v8_snapshot_external_references.py:167: return False Why is it okay to return False when the interface is a runtime enabled feature? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:67: : nullptr), Nit: It looks a bit weird to do the heavy work during the constructor. Would it be possible to create a helper function in isolate_holder.h (e.g., IsolateHolder::CreateIsolate()) and call it at line 75? I don't fully understand why the v8::Islate needs to be initialized during the constructor. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:75: // If it fails to load the snapshot file, falls back to kDontUseSnapshot mode. When can this happen? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:100: // Blink, and it must be run on the main thread. // This constructor is used for taking a V8 context snapshot. It must run on the main thread. Move this comment to line 89. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:105: // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. Remove this comment. This FIXME is for GetIsolate()->Enter(). https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:107: GetIsolate()->AddMicrotasksCompletedCallback(&MicrotasksCompletedCallback); I don't think we need line 106 and 107. What happens if we remove the two lines? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:128: if (!RuntimeEnabledFeatures::V8ContextSnapshotEnabled()) { It looks a bit strange to override the setting after calling V8PerIsolateData::Initialize. Can we move line 128 - 130 to the caller site? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:63: enum class V8ContextMode { V8ContextMode => V8ContextSnapshotMode ? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:245: V8PerIsolateData(intptr_t* reference_table); Add explicit. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:275: // Members requried for snapshotted context. required ... for the V8 context snapshot. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:277: // instantiated before |isoalte_holder_| gets instantiated. isolate_holder_ https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:277: // instantiated before |isoalte_holder_| gets instantiated. // v8::Context is created from this blob data image. This needs to be instantiated ... https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:279: // In taking V8 snapshot, we can't keep V8 objects with eternal handles. // When taking a V8 context snapshot, https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:281: // snapshots. // So we use a special interface map that doesn't use eternal handles instead of the default V8FunctionTemplateMap. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/web/WebKit.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/web/WebKit.cpp:86: // Refernce table must be updated before creating isolates. creating an isolate. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/web/WebKit.cpp:88: V8Initializer::InitializeMainThread(); Would it be possible to pass in V8SnapshotExternalReferences::GetTable() to InitializeMainThread() and call SetReferenceTable() in InitializeMainThread(). In general I prefer keeping blink::Initialize as simple as possible. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/web/WebV8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/web/WebV8SnapshotUtil.cpp:1: // Copyright 2017 The Chromium Authors. All rights reserved. We're now removing the web/ directory as part of Onion Soup 2.0. web/ will be gone in the near future. Would you move this file to bindings/core/v8/? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/pub... File third_party/WebKit/public/platform/Platform.h (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/pub... third_party/WebKit/public/platform/Platform.h:706: virtual bool IsToTakeV8Snapshot() { return false; } IsTakingV8ContextSnapshot ? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/pub... File third_party/WebKit/public/web/WebV8SnapshotUtil.h (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/pub... third_party/WebKit/public/web/WebV8SnapshotUtil.h:1: // Copyright 2017 The Chromium Authors. All rights reserved. Rename this file to WebV8ContextSnapshot.h. (Also I'd prefer avoiding "Util".) https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/pub... third_party/WebKit/public/web/WebV8SnapshotUtil.h:13: class BLINK_EXPORT WebV8SnapshotUtil { Add a class-level comment. https://codereview.chromium.org/2841443005/diff/320001/tools/blink_v8_snapsho... File tools/blink_v8_snapshot/blink_v8_snapshot_generator.cc (right): https://codereview.chromium.org/2841443005/diff/320001/tools/blink_v8_snapsho... tools/blink_v8_snapshot/blink_v8_snapshot_generator.cc:38: // We assume those contexts made in this program are used in Blink. We assume ... => The snapshot file is consumed by Blink. https://codereview.chromium.org/2841443005/diff/320001/tools/blink_v8_snapsho... tools/blink_v8_snapshot/blink_v8_snapshot_generator.cc:64: base::WriteFile(file_path, blob.data, blob.raw_size); Shall we assert that we've written non-zero-byte data? https://codereview.chromium.org/2841443005/diff/320001/tools/blink_v8_snapsho... File tools/blink_v8_snapshot/run.py (right): https://codereview.chromium.org/2841443005/diff/320001/tools/blink_v8_snapsho... tools/blink_v8_snapshot/run.py:6: scripts.""" Is this a common way to run a script? I'm just curious.
This CL is mixing "Blink V8 snapshot", "V8 snapshot" and "V8 context snapshot". I'd like to unify the terms into "V8 context snapshot".
Description was changed from ========== Create and use V8 context snapshots. This CL does two things. 1. Creates a file "blink_v8_snapshot.bin", which has snapshots of V8 contexts, during compile time. 2. Instantiates v8::Context from the snapshot in LocalWindowProxy::createContext(). Test expectations are changed due to http://crbug.com/705364 Design doc: https://docs.google.com/document/d/1jpQQX0piaxcHJPWakp_Kr_03g5Gnma5h5-Kdlqu7j... BUG=588893, 617892, 705364 ========== to ========== Create and use V8 context snapshots. This CL does two things. 1. Creates a file "v8_context_snapshot.bin", which has snapshots of V8 contexts, during compile time. 2. Instantiates v8::Context from the snapshot in LocalWindowProxy::createContext(). Test expectations are changed due to http://crbug.com/705364 Design doc: https://docs.google.com/document/d/1jpQQX0piaxcHJPWakp_Kr_03g5Gnma5h5-Kdlqu7j... BUG=588893, 617892, 705364 ==========
Here is a final round of comments! https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:36: v8::Context::Scope scope(context); Add CHECK(V8HTMLDocument::wrapperTypeInfo.Equals(type));. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:104: SnapshotInterface g_snapshot_interfaces[] = { Add a detailed comment about what are contained in the snapshot. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:144: struct DataForDeserializer { struct => class https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:161: v8::Local<v8::Context> V8SnapshotUtil::CreateContext( CreateContextFromSnapshot https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:185: void V8SnapshotUtil::SetupContext(v8::Local<v8::Context> context, SetupContext => InstallRuntimeEnabledFeatures https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:194: TRACE_EVENT1("v8", "InstallRuntimeEnabled", "IsMainFrame", "V8SnapshotUtil::InstallRuntimeEnabledFeatures" https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:205: v8::Local<v8::Function> interface = data->ConstructorForType(type); interface => instance https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:214: v8::Local<v8::Function> interface = data->ConstructorForType(type); interface => instance https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:222: if (!world.IsMainWorld()) { Why is it okay to skip the rest of this method for non-main worlds? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:233: v8::Local<v8::Function> interface = data->ConstructorForType(type); interface => instance https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:242: v8::Local<v8::Function> interface = data->ConstructorForType(type); interface => instance https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:251: v8::Local<v8::Function> interface = data->ConstructorForType(type); interface => instance https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:275: *DOMWrapperWorld::EnsureIsolatedWorld(isolate, kWorldIdForNonMainWorld)); This forcibly creates an isolated world. Not only does this increase memory usage but also slows down a fast path of ToV8() (which assumes that there is only one main world in common cases). We should avoid creating an isolated world here. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:302: // Disable all runtime enabled featuers features https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:309: creator->SetDefaultContext(v8::Context::New(isolate)); Why do we need to create a context here? Won't it be enough to create a context at line 458? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:318: // So we remove a message handler for the main thread. Other threads don't use the snapshot, right? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:346: char* data = new char[size]; Who deallocates the memory? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:404: // a HTMLDocument. Would you help me understand why we need this condition? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:419: v8::FunctionTemplate::FromSnapshot(isolate, index_offset + i) Add a comment about what index_offset+i is doing. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:434: std::array<v8::Local<v8::FunctionTemplate>, kSnapshotInterfaceSize> Use WTF::Vector. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:456: V8PerIsolateData::UseCounterDisabledScope use_counter_disabled( Add a comment about why we need this. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:462: if (world.IsMainWorld()) { Add a comment about what this block is doing. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:482: V8PerIsolateData::From(isolate)->ClearPersistentsForV8Snapshot(); We should call this outside TakeSnapshotForWorld. We won't need to call this twice. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h:17: // V8SnapshotUtil supports handling V8 snapshots. // This class contains helper functions to take a V8 context snapshot.
https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:144: struct DataForDeserializer { On 2017/07/06 13:15:53, haraken wrote: > > struct => class I'm okay with "struct => class", but in that case, we should rename "document => document_" as well. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:205: v8::Local<v8::Function> interface = data->ConstructorForType(type); On 2017/07/06 13:15:53, haraken wrote: > > interface => instance No, this is not a platform object (aka instance object), this is an interface object. Ditto for belows. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:222: if (!world.IsMainWorld()) { On 2017/07/06 13:15:53, haraken wrote: > > Why is it okay to skip the rest of this method for non-main worlds? We lazily instantiate a V8 wrapper for document in isolated worlds. We eagerly instantiate the V8 wrapper for document only in the main world. Peria is not going to change this situation. The snapshot for isolated worlds doesn't contain a document wrapper, and it gets lazily instantiated later. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:309: creator->SetDefaultContext(v8::Context::New(isolate)); On 2017/07/06 13:15:54, haraken wrote: > > Why do we need to create a context here? Won't it be enough to create a context > at line 458? This is the *default* context that is not associated with any structure such as V8Window's global template. I don't know details, but peria said v8::SnapshotCreater requires the default context to be registered (as a fallback?). https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:404: // a HTMLDocument. On 2017/07/06 13:15:52, haraken wrote: > > Would you help me understand why we need this condition? We eagerly instantiates the V8 wrapper for window.document of type HTMLDocument, however, it's possible that window.document is of type SVGDocument. The snapshot for the main world contains the wrapper of type HTMLDocument, and it's NOT applicable to a SVGDocument, so we cannot use the snapshot in case of SVGDocument. However, the snapshot for isolated worlds does not contain any wrapper for window.document, so we can use the snapshot in case of SVGDocument, too. So we need this condition: If main world => must be a HTMLDocument exactly, not a SVGDocument or anything. Peria may want to brush up the comment, explaining a non-applicable case with an example (SVGDocument). https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:434: std::array<v8::Local<v8::FunctionTemplate>, kSnapshotInterfaceSize> On 2017/07/06 13:15:52, haraken wrote: > > Use WTF::Vector. IIUC, it's wrong to put a v8::Local<T> on heap. v8::Local<T> must be put on stack. WTF::Vector<T> allocates content objects on heap, doesn't it? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:456: V8PerIsolateData::UseCounterDisabledScope use_counter_disabled( On 2017/07/06 13:15:54, haraken wrote: > > Add a comment about why we need this. UseCOunterDisabledScope has its own excuse on their side. I think that we don't want duplicates. https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/bindi... https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:482: V8PerIsolateData::From(isolate)->ClearPersistentsForV8Snapshot(); On 2017/07/06 13:15:53, haraken wrote: > > We should call this outside TakeSnapshotForWorld. We won't need to call this > twice. I don't see a benefit to move this out. TakeSnapshotForWorld(world1); CleanUp(); TakeSnapshotForWorld(world2); CleanUp(); TakeSnapshotForWorld(world3); doesn't look great to me. Plus, I don't like the following example. void foo(world1, world2) { TakeSnapshotForWorld(world1); CleanUp(); TakeSnapshotForWorld(world2); } foo(worldA, worldB); foo(worldC, worldD); // What happens!!? Moving this out makes it structurally fragile. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h:17: // V8SnapshotUtil supports handling V8 snapshots. On 2017/07/06 13:15:54, haraken wrote: > > // This class contains helper functions to take a V8 context snapshot. s/to take/to take and use/? Some of helper functions are meant to use a snapshot.
https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:144: struct DataForDeserializer { On 2017/07/06 14:12:28, Yuki wrote: > On 2017/07/06 13:15:53, haraken wrote: > > > > struct => class > > I'm okay with "struct => class", but in that case, we should rename "document => > document_" as well. Oops, maybe not okay. I'm not sure, but V8 would expect DataForDeserializer to be a PoD. Then, this should be a struct.
https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:222: if (!world.IsMainWorld()) { On 2017/07/06 14:12:28, Yuki wrote: > On 2017/07/06 13:15:53, haraken wrote: > > > > Why is it okay to skip the rest of this method for non-main worlds? > > We lazily instantiate a V8 wrapper for document in isolated worlds. We eagerly > instantiate the V8 wrapper for document only in the main world. > > Peria is not going to change this situation. The snapshot for isolated worlds > doesn't contain a document wrapper, and it gets lazily instantiated later. Makes sense. The logic to handle the eagerly instantiated window.document is making the code a lot complex. Let's add a comment to the places that are handling window.document. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:482: V8PerIsolateData::From(isolate)->ClearPersistentsForV8Snapshot(); On 2017/07/06 14:12:28, Yuki wrote: > On 2017/07/06 13:15:53, haraken wrote: > > > > We should call this outside TakeSnapshotForWorld. We won't need to call this > > twice. > > I don't see a benefit to move this out. > > TakeSnapshotForWorld(world1); > CleanUp(); > TakeSnapshotForWorld(world2); > CleanUp(); > TakeSnapshotForWorld(world3); > > doesn't look great to me. > > Plus, I don't like the following example. > > void foo(world1, world2) { > TakeSnapshotForWorld(world1); > CleanUp(); > TakeSnapshotForWorld(world2); > } > > foo(worldA, worldB); > foo(worldC, worldD); // What happens!!? > > Moving this out makes it structurally fragile. I'm confused. Why do we need to call CleanUp() every time you call TakeSnapshotForWorld()? The snapshot is taken when you call creator->CreateBlob(), isn't it?
https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:482: V8PerIsolateData::From(isolate)->ClearPersistentsForV8Snapshot(); On 2017/07/06 14:22:13, haraken wrote: > On 2017/07/06 14:12:28, Yuki wrote: > > On 2017/07/06 13:15:53, haraken wrote: > > > > > > We should call this outside TakeSnapshotForWorld. We won't need to call this > > > twice. > > > > I don't see a benefit to move this out. > > > > TakeSnapshotForWorld(world1); > > CleanUp(); > > TakeSnapshotForWorld(world2); > > CleanUp(); > > TakeSnapshotForWorld(world3); > > > > doesn't look great to me. > > > > Plus, I don't like the following example. > > > > void foo(world1, world2) { > > TakeSnapshotForWorld(world1); > > CleanUp(); > > TakeSnapshotForWorld(world2); > > } > > > > foo(worldA, worldB); > > foo(worldC, worldD); // What happens!!? > > > > Moving this out makes it structurally fragile. > > I'm confused. Why do we need to call CleanUp() every time you call > TakeSnapshotForWorld()? > > The snapshot is taken when you call creator->CreateBlob(), isn't it? My understanding is that: a) For snapshotting, we don't use the existing v8::Template cache in V8PerIsolateData because it's using v8::Eternal and v8::SnapshotCreater doesn't support v8::Eternal. b) We instead add another v8::Template cache for snapshotting with using v8::Persistent, instead of v8::Eternal. c) The v8::Template cache for snapshotting is *NOT* separated for main and isolated worlds, unlike the existing cache. It's a single instance of cache and we re-use the same cache for both of main and isolated worlds. Thus, the current version of the CL is doing: TakeSnapshotForWorld(main_world); // This registers v8::Templates for the main world // to V8PerIsolateData's cache. As a result, // V8Window::domTemplate(world) returns the template // for the main world regardless of |world| because // V8PerIsolateData doesn't support world-aware cache. // Next, we'd like to take a snapshot for isolated worlds, // but V8Window::domTemplate(world) returns the template // for the main world... // Let's clear the cache out! ClearPersistentsForV8Snapshot(); // Now the cache is empty. TakeSnapshotForWorld(isolated_world); // V8Window::domTemplate(world) creates a new v8::Template // for the given world because of no cache. :)
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Worked for most comments. Some experimental works are on going. Thank you Yuki for answering many questions. https://codereview.chromium.org/2841443005/diff/320001/content/app/content_ma... File content/app/content_main_runner.cc (right): https://codereview.chromium.org/2841443005/diff/320001/content/app/content_ma... content/app/content_main_runner.cc:229: LoadBlinkV8SnapshotFile(); On 2017/07/04 15:04:19, haraken wrote: > > LoadV8ContextSnapshotFile Done. https://codereview.chromium.org/2841443005/diff/320001/gin/isolate_holder.cc File gin/isolate_holder.cc (right): https://codereview.chromium.org/2841443005/diff/320001/gin/isolate_holder.cc#... gin/isolate_holder.cc:53: CHECK(allocator) << "You need to invoke gin::IsolateHolder::Initialize first"; On 2017/07/04 15:04:19, haraken wrote: > > You can remove line 52 and 53. Re-storing into a local variable is optional, but g_array_buffer_allocator is needed on line #60. https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.cc File gin/v8_initializer.cc (right): https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.cc#... gin/v8_initializer.cc:44: base::MemoryMappedFile* g_mapped_blink_v8_snapshot = nullptr; On 2017/07/04 15:04:19, haraken wrote: > > blink_v8_snapshot => v8_context_snapshot Done. https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.cc#... gin/v8_initializer.cc:46: const char kBlinkV8SnapshotFileName[] = "blink_v8_snapshot.bin"; On 2017/07/04 15:04:19, haraken wrote: > > blink_v8_snapshot.bin => v8_context_snapshot.bin Done. https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.h File gin/v8_initializer.h (right): https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.h#n... gin/v8_initializer.h:80: static void LoadBlinkV8SnapshotFromFD(base::PlatformFile snapshot_fd, On 2017/07/04 15:04:19, haraken wrote: > > LoadV8ContextSnapshotFromFD Done. https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.h#n... gin/v8_initializer.h:83: static void LoadBlinkV8Snapshot(); On 2017/07/04 15:04:19, haraken wrote: > > LoadV8ContextSnapshot Done. https://codereview.chromium.org/2841443005/diff/320001/gin/v8_initializer.h#n... gin/v8_initializer.h:84: static void GetBlinkV8SnapshotData(const char** snapshot_data_out, On 2017/07/04 15:04:19, haraken wrote: > > GetV8ContextSnapshotData Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:141: V8SnapshotUtil::SetupContext(context, GetFrame()->GetDocument()); On 2017/07/04 15:04:19, haraken wrote: > > SetupContext => InstallRuntimeEnabledFeatures ? Done. sounds better. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:163: TRACE_EVENT1("v8", "Notification", "IsMainFrame", On 2017/07/04 15:04:19, haraken wrote: > > Notification => ContextCreationNotification Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:167: GetFrame()->Client()->DidCreateScriptContext(context, world_->GetWorldId()); On 2017/07/04 15:04:19, haraken wrote: > > Oh, the context creation notification still exits. Is the performance problem > already gone? Yes, as the closed issue http://crbug.com/v8/6175 shows, they had instantiated console.log dynamically, and it is now builtin. Time spent in "Notification" became ~10 times faster (1.5ms -> 0.16ms), and this is no longer a performance bottleneck. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:198: TRACE_EVENT1("v8", "ContextCreation", "IsMainFrame", On 2017/07/04 15:04:19, haraken wrote: > > Is this trace event useful? I guess that the trace event at line 178 would be > enough. > I introduced this trace to confirm other tasks in LocalWindowProxy::CreateContext() are light enough. Now we know it correct, so I removed. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/LocalWindowProxy.cpp:205: if (context.IsEmpty()) { On 2017/07/04 15:04:19, haraken wrote: > > Add a comment and explain when this can happen. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp:393: v8::HandleScope handle_scope(isolate); On 2017/07/04 15:04:19, haraken wrote: > > Can we move the HandleScope into EnsureInterfaceTemplates? Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:36: v8::Context::Scope scope(context); On 2017/07/06 13:15:52, haraken wrote: > > Add CHECK(V8HTMLDocument::wrapperTypeInfo.Equals(type));. if we need it, we need V8HTMLDocument::... || V8Document::... || V8Node::... || V8EventElement::... because it calls itself recursively. (#48) https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:104: SnapshotInterface g_snapshot_interfaces[] = { On 2017/07/06 13:15:53, haraken wrote: > > Add a detailed comment about what are contained in the snapshot. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:144: struct DataForDeserializer { On 2017/07/06 13:15:53, haraken wrote: > > struct => class Hmm, is there any background to do it? I feel it not needed to make it a class; i.e. it needs to make the member private and to create a getter. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:161: v8::Local<v8::Context> V8SnapshotUtil::CreateContext( On 2017/07/06 13:15:53, haraken wrote: > > CreateContextFromSnapshot Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:185: void V8SnapshotUtil::SetupContext(v8::Local<v8::Context> context, On 2017/07/06 13:15:54, haraken wrote: > > SetupContext => InstallRuntimeEnabledFeatures Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:194: TRACE_EVENT1("v8", "InstallRuntimeEnabled", "IsMainFrame", On 2017/07/06 13:15:53, haraken wrote: > > "V8SnapshotUtil::InstallRuntimeEnabledFeatures" Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:205: v8::Local<v8::Function> interface = data->ConstructorForType(type); On 2017/07/06 14:12:28, Yuki wrote: > On 2017/07/06 13:15:53, haraken wrote: > > > > interface => instance > > No, this is not a platform object (aka instance object), this is an interface > object. > > Ditto for belows. +1 to Yuki. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:214: v8::Local<v8::Function> interface = data->ConstructorForType(type); On 2017/07/06 13:15:53, haraken wrote: > > interface => instance Acknowledged. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:233: v8::Local<v8::Function> interface = data->ConstructorForType(type); On 2017/07/06 13:15:53, haraken wrote: > > interface => instance Acknowledged. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:251: v8::Local<v8::Function> interface = data->ConstructorForType(type); On 2017/07/06 13:15:54, haraken wrote: > > interface => instance Acknowledged. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:302: // Disable all runtime enabled featuers On 2017/07/06 13:15:53, haraken wrote: > > features Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:318: // So we remove a message handler for the main thread. On 2017/07/06 13:15:53, haraken wrote: > > Other threads don't use the snapshot, right? As for now, it is correct, but we don't have to make it a rule. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:346: char* data = new char[size]; On 2017/07/06 13:15:52, haraken wrote: > > Who deallocates the memory? V8's snapshot serializer does. https://cs.chromium.org/chromium/src/v8/src/snapshot/partial-serializer.cc?l=149 https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:404: // a HTMLDocument. On 2017/07/06 14:12:28, Yuki wrote: > On 2017/07/06 13:15:52, haraken wrote: > > > > Would you help me understand why we need this condition? > > We eagerly instantiates the V8 wrapper for window.document of type HTMLDocument, > however, it's possible that window.document is of type SVGDocument. The > snapshot for the main world contains the wrapper of type HTMLDocument, and it's > NOT applicable to a SVGDocument, so we cannot use the snapshot in case of > SVGDocument. However, the snapshot for isolated worlds does not contain any > wrapper for window.document, so we can use the snapshot in case of SVGDocument, > too. > > So we need this condition: If main world => must be a HTMLDocument exactly, not > a SVGDocument or anything. > > Peria may want to brush up the comment, explaining a non-applicable case with an > example (SVGDocument). Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:404: // a HTMLDocument. On 2017/07/06 13:15:52, haraken wrote: > > Would you help me understand why we need this condition? Acknowledged. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:419: v8::FunctionTemplate::FromSnapshot(isolate, index_offset + i) On 2017/07/06 13:15:54, haraken wrote: > > Add a comment about what index_offset+i is doing. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:456: V8PerIsolateData::UseCounterDisabledScope use_counter_disabled( On 2017/07/06 13:15:54, haraken wrote: > > Add a comment about why we need this. Acknowledged. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:456: V8PerIsolateData::UseCounterDisabledScope use_counter_disabled( On 2017/07/06 14:12:28, Yuki wrote: > On 2017/07/06 13:15:54, haraken wrote: > > > > Add a comment about why we need this. > > UseCOunterDisabledScope has its own excuse on their side. I think that we don't > want duplicates. > https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/bindi... +1 https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:462: if (world.IsMainWorld()) { On 2017/07/06 13:15:53, haraken wrote: > > Add a comment about what this block is doing. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:482: V8PerIsolateData::From(isolate)->ClearPersistentsForV8Snapshot(); On 2017/07/06 14:40:09, Yuki wrote: > On 2017/07/06 14:22:13, haraken wrote: > > On 2017/07/06 14:12:28, Yuki wrote: > > > On 2017/07/06 13:15:53, haraken wrote: > > > > > > > > We should call this outside TakeSnapshotForWorld. We won't need to call > this > > > > twice. > > > > > > I don't see a benefit to move this out. > > > > > > TakeSnapshotForWorld(world1); > > > CleanUp(); > > > TakeSnapshotForWorld(world2); > > > CleanUp(); > > > TakeSnapshotForWorld(world3); > > > > > > doesn't look great to me. > > > > > > Plus, I don't like the following example. > > > > > > void foo(world1, world2) { > > > TakeSnapshotForWorld(world1); > > > CleanUp(); > > > TakeSnapshotForWorld(world2); > > > } > > > > > > foo(worldA, worldB); > > > foo(worldC, worldD); // What happens!!? > > > > > > Moving this out makes it structurally fragile. > > > > I'm confused. Why do we need to call CleanUp() every time you call > > TakeSnapshotForWorld()? > > > > The snapshot is taken when you call creator->CreateBlob(), isn't it? > > My understanding is that: > > a) For snapshotting, we don't use the existing v8::Template cache in > V8PerIsolateData because it's using v8::Eternal and v8::SnapshotCreater doesn't > support v8::Eternal. > > b) We instead add another v8::Template cache for snapshotting with using > v8::Persistent, instead of v8::Eternal. > > c) The v8::Template cache for snapshotting is *NOT* separated for main and > isolated worlds, unlike the existing cache. It's a single instance of cache and > we re-use the same cache for both of main and isolated worlds. > > Thus, the current version of the CL is doing: > > TakeSnapshotForWorld(main_world); > // This registers v8::Templates for the main world > // to V8PerIsolateData's cache. As a result, > // V8Window::domTemplate(world) returns the template > // for the main world regardless of |world| because > // V8PerIsolateData doesn't support world-aware cache. > > // Next, we'd like to take a snapshot for isolated worlds, > // but V8Window::domTemplate(world) returns the template > // for the main world... > > // Let's clear the cache out! > ClearPersistentsForV8Snapshot(); > // Now the cache is empty. > > TakeSnapshotForWorld(isolated_world); > // V8Window::domTemplate(world) creates a new v8::Template > // for the given world because of no cache. :) Yes, Yuki's understanding is correct, and c) is the critical reason to call ClearPersistents here. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h:17: // V8SnapshotUtil supports handling V8 snapshots. On 2017/07/06 13:15:54, haraken wrote: > > // This class contains helper functions to take a V8 context snapshot. Acknowledged. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.h:17: // V8SnapshotUtil supports handling V8 snapshots. On 2017/07/06 14:12:28, Yuki wrote: > On 2017/07/06 13:15:54, haraken wrote: > > > > // This class contains helper functions to take a V8 context snapshot. > > s/to take/to take and use/? > > Some of helper functions are meant to use a snapshot. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/modules/v8/V8SnapshotExternalReferences.h (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/modules/v8/V8SnapshotExternalReferences.h:1: // Copyright 2017 The Chromium Authors. All rights reserved. On 2017/07/04 15:04:19, haraken wrote: > > Rename this file to V8ContextSnapshotExternalReferences.h. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/scripts/generate_v8_snapshot_external_references.py (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_v8_snapshot_external_references.py:1: # Copyright 2017 The Chromium Authors. All rights reserved. On 2017/07/04 15:04:19, haraken wrote: > > Rename the file to generate_v8_context_snapshot_external_references.py. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_v8_snapshot_external_references.py:61: class InterfaceTemplateContextBuilder(object): On 2017/07/04 15:04:19, haraken wrote: > > Add a class-level comment. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_v8_snapshot_external_references.py:62: # NOTE: This class is equivalent of v8_interface.py On 2017/07/04 15:04:19, haraken wrote: > > is equivalent to it is no longer equivalent. Removed. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_v8_snapshot_external_references.py:167: return False On 2017/07/04 15:04:19, haraken wrote: > > Why is it okay to return False when the interface is a runtime enabled feature? In general, runtime enabled interfaces are not constructed in creating a snapshot, and it means we don't need their callback functions for them. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:67: : nullptr), On 2017/07/04 15:04:20, haraken wrote: > > Nit: It looks a bit weird to do the heavy work during the constructor. > > Would it be possible to create a helper function in isolate_holder.h (e.g., > IsolateHolder::CreateIsolate()) and call it at line 75? > > I don't fully understand why the v8::Islate needs to be initialized during the > constructor. Hmm, of course it is technically possible, but what does it change in practice? Instantiation of v8::Isolate (and gin::IsolateHolder) are done here to guarantee their lifetime same with V8PerIsolateData. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:75: // If it fails to load the snapshot file, falls back to kDontUseSnapshot mode. On 2017/07/04 15:04:20, haraken wrote: > > When can this happen? I hope this happens just in some unit tests, which do not have v8_context_snapshot.blob binded. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:100: // Blink, and it must be run on the main thread. On 2017/07/04 15:04:20, haraken wrote: > > // This constructor is used for taking a V8 context snapshot. It must run on the > main thread. > > Move this comment to line 89. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:105: // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. On 2017/07/04 15:04:20, haraken wrote: > > Remove this comment. This FIXME is for GetIsolate()->Enter(). > > Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:128: if (!RuntimeEnabledFeatures::V8ContextSnapshotEnabled()) { On 2017/07/04 15:04:20, haraken wrote: > > It looks a bit strange to override the setting after calling > V8PerIsolateData::Initialize. Can we move line 128 - 130 to the caller site? Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:63: enum class V8ContextMode { On 2017/07/04 15:04:20, haraken wrote: > > V8ContextMode => V8ContextSnapshotMode ? Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:245: V8PerIsolateData(intptr_t* reference_table); On 2017/07/04 15:04:20, haraken wrote: > > Add explicit. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:275: // Members requried for snapshotted context. On 2017/07/04 15:04:20, haraken wrote: > > required > > ... for the V8 context snapshot. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:277: // instantiated before |isoalte_holder_| gets instantiated. On 2017/07/04 15:04:20, haraken wrote: > > isolate_holder_ Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:277: // instantiated before |isoalte_holder_| gets instantiated. On 2017/07/04 15:04:20, haraken wrote: > > // v8::Context is created from this blob data image. This needs to be > instantiated ... > Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:279: // In taking V8 snapshot, we can't keep V8 objects with eternal handles. On 2017/07/04 15:04:20, haraken wrote: > > // When taking a V8 context snapshot, Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:281: // snapshots. On 2017/07/04 15:04:20, haraken wrote: > > // So we use a special interface map that doesn't use eternal handles instead of > the default V8FunctionTemplateMap. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/web/WebKit.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/web/WebKit.cpp:86: // Refernce table must be updated before creating isolates. On 2017/07/04 15:04:20, haraken wrote: > > creating an isolate. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/web/WebKit.cpp:88: V8Initializer::InitializeMainThread(); On 2017/07/04 15:04:20, haraken wrote: > > Would it be possible to pass in V8SnapshotExternalReferences::GetTable() to > InitializeMainThread() and call SetReferenceTable() in InitializeMainThread(). > > In general I prefer keeping blink::Initialize as simple as possible. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/web/WebV8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/web/WebV8SnapshotUtil.cpp:1: // Copyright 2017 The Chromium Authors. All rights reserved. On 2017/07/04 15:04:20, haraken wrote: > > We're now removing the web/ directory as part of Onion Soup 2.0. web/ will be > gone in the near future. > > Would you move this file to bindings/core/v8/? > Just to confirm before actually working for it. You mean, we can use files under bindings/core/v8/ directly from tools/blink_v8_snapshot/? Then I prefer to use V8ContextSnapshotUtil::TakeSnapshot() instead. Is it allowed in Onion Soup 2.0? https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/pub... File third_party/WebKit/public/platform/Platform.h (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/pub... third_party/WebKit/public/platform/Platform.h:706: virtual bool IsToTakeV8Snapshot() { return false; } On 2017/07/04 15:04:20, haraken wrote: > > IsTakingV8ContextSnapshot ? Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/pub... File third_party/WebKit/public/web/WebV8SnapshotUtil.h (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/pub... third_party/WebKit/public/web/WebV8SnapshotUtil.h:1: // Copyright 2017 The Chromium Authors. All rights reserved. On 2017/07/04 15:04:20, haraken wrote: > > Rename this file to WebV8ContextSnapshot.h. > > (Also I'd prefer avoiding "Util".) Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/pub... third_party/WebKit/public/web/WebV8SnapshotUtil.h:13: class BLINK_EXPORT WebV8SnapshotUtil { On 2017/07/04 15:04:20, haraken wrote: > > Add a class-level comment. Done. https://codereview.chromium.org/2841443005/diff/320001/tools/blink_v8_snapsho... File tools/blink_v8_snapshot/blink_v8_snapshot_generator.cc (right): https://codereview.chromium.org/2841443005/diff/320001/tools/blink_v8_snapsho... tools/blink_v8_snapshot/blink_v8_snapshot_generator.cc:38: // We assume those contexts made in this program are used in Blink. On 2017/07/04 15:04:20, haraken wrote: > > We assume ... => The snapshot file is consumed by Blink. Done. https://codereview.chromium.org/2841443005/diff/320001/tools/blink_v8_snapsho... tools/blink_v8_snapshot/blink_v8_snapshot_generator.cc:64: base::WriteFile(file_path, blob.data, blob.raw_size); On 2017/07/04 15:04:20, haraken wrote: > > Shall we assert that we've written non-zero-byte data? Done. https://codereview.chromium.org/2841443005/diff/320001/tools/blink_v8_snapsho... File tools/blink_v8_snapshot/run.py (right): https://codereview.chromium.org/2841443005/diff/320001/tools/blink_v8_snapsho... tools/blink_v8_snapshot/run.py:6: scripts.""" On 2017/07/04 15:04:21, haraken wrote: > > Is this a common way to run a script? I'm just curious. We can specify only python script to run in .gn, so we need to execute a binary file through a python script.
https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:346: char* data = new char[size]; On 2017/07/07 06:22:00, peria wrote: > On 2017/07/06 13:15:52, haraken wrote: > > > > Who deallocates the memory? > > V8's snapshot serializer does. > https://cs.chromium.org/chromium/src/v8/src/snapshot/partial-serializer.cc?l=149 OK, let's add a comment. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:67: : nullptr), On 2017/07/07 06:22:03, peria wrote: > On 2017/07/04 15:04:20, haraken wrote: > > > > Nit: It looks a bit weird to do the heavy work during the constructor. > > > > Would it be possible to create a helper function in isolate_holder.h (e.g., > > IsolateHolder::CreateIsolate()) and call it at line 75? > > > > I don't fully understand why the v8::Islate needs to be initialized during the > > constructor. > > Hmm, of course it is technically possible, but what does it change in practice? > > Instantiation of v8::Isolate (and gin::IsolateHolder) are done here to guarantee > their lifetime same with V8PerIsolateData. I just don't really like doing a complex thing during a constructor because the object is half-backed. Can we delay instantiating the isolate instantiation to line 75 as well? In short, I'd prefer moving what you're currently doing in IsolateHolder's constructor to line 75. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:75: // If it fails to load the snapshot file, falls back to kDontUseSnapshot mode. On 2017/07/07 06:22:03, peria wrote: > On 2017/07/04 15:04:20, haraken wrote: > > > > When can this happen? > > I hope this happens just in some unit tests, which do not have > v8_context_snapshot.blob binded. Let's add a comment. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/web/WebV8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/web/WebV8SnapshotUtil.cpp:1: // Copyright 2017 The Chromium Authors. All rights reserved. On 2017/07/07 06:22:04, peria wrote: > On 2017/07/04 15:04:20, haraken wrote: > > > > We're now removing the web/ directory as part of Onion Soup 2.0. web/ will be > > gone in the near future. > > > > Would you move this file to bindings/core/v8/? > > > > Just to confirm before actually working for it. > You mean, we can use files under bindings/core/v8/ directly from > tools/blink_v8_snapshot/? Then I prefer to use > V8ContextSnapshotUtil::TakeSnapshot() instead. Is it allowed in Onion Soup 2.0? We should keep the public API in public/web/. We can put the implementation in bindings/core/v8/. tools/blink_v8_snapshot/ can use the public API. (Once Onion Soup 2.0 is done, tools/blink_v8_snapshot/ can directly use bindings/core/v8/, but we are not yet there.)
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
Patchset #14 (id:340001) has been deleted
PTAL. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:242: v8::Local<v8::Function> interface = data->ConstructorForType(type); On 2017/07/06 13:15:53, haraken wrote: > > interface => instance Acknowledged. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:275: *DOMWrapperWorld::EnsureIsolatedWorld(isolate, kWorldIdForNonMainWorld)); On 2017/07/06 13:15:53, haraken wrote: > > This forcibly creates an isolated world. Not only does this increase memory > usage but also slows down a fast path of ToV8() (which assumes that there is > only one main world in common cases). > > We should avoid creating an isolated world here. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8SnapshotUtil.cpp:346: char* data = new char[size]; On 2017/07/07 06:59:11, haraken wrote: > On 2017/07/07 06:22:00, peria wrote: > > On 2017/07/06 13:15:52, haraken wrote: > > > > > > Who deallocates the memory? > > > > V8's snapshot serializer does. > > > https://cs.chromium.org/chromium/src/v8/src/snapshot/partial-serializer.cc?l=149 > > OK, let's add a comment. Done. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:67: : nullptr), On 2017/07/07 06:59:11, haraken wrote: > On 2017/07/07 06:22:03, peria wrote: > > On 2017/07/04 15:04:20, haraken wrote: > > > > > > Nit: It looks a bit weird to do the heavy work during the constructor. > > > > > > Would it be possible to create a helper function in isolate_holder.h (e.g., > > > IsolateHolder::CreateIsolate()) and call it at line 75? > > > > > > I don't fully understand why the v8::Islate needs to be initialized during > the > > > constructor. > > > > Hmm, of course it is technically possible, but what does it change in > practice? > > > > Instantiation of v8::Isolate (and gin::IsolateHolder) are done here to > guarantee > > their lifetime same with V8PerIsolateData. > > I just don't really like doing a complex thing during a constructor because the > object is half-backed. > > Can we delay instantiating the isolate instantiation to line 75 as well? In > short, I'd prefer moving what you're currently doing in IsolateHolder's > constructor to line 75. > Line 75 is also in V8PerIsolateData's constructor, and it is half-baked there. What the difference here and there? And in that sense, IsolateHolder is also half-baked instance at line #75, so I have to move some other members *below* #75 together. I think your change will make it more dangerous. FYI, Jochen opposed to instantiate isolate separately. (https://codereview.chromium.org/2897853002/#msg18) https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:107: GetIsolate()->AddMicrotasksCompletedCallback(&MicrotasksCompletedCallback); On 2017/07/04 15:04:20, haraken wrote: > > I don't think we need line 106 and 107. What happens if we remove the two lines? Seems no problems. Done.
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
peria@chromium.org changed reviewers: + thakis@chromium.org
+Nico in R. Could you take a look, especially for GN changes?
Description was changed from ========== Create and use V8 context snapshots. This CL does two things. 1. Creates a file "v8_context_snapshot.bin", which has snapshots of V8 contexts, during compile time. 2. Instantiates v8::Context from the snapshot in LocalWindowProxy::createContext(). Test expectations are changed due to http://crbug.com/705364 Design doc: https://docs.google.com/document/d/1jpQQX0piaxcHJPWakp_Kr_03g5Gnma5h5-Kdlqu7j... BUG=588893, 617892, 705364 ========== to ========== Create and use V8 context snapshots. This CL does two things. 1. In compile time, creates a snapshot file, which consists of V8 contexts. 2. Creates v8::Context from the snapshot in LocalWindowProxy::CreateContext(). We expect this speeds up context creation for 3 times faster on Android. Detailed information is described in the design doc [1]. [1] Design doc: https://docs.google.com/document/d/1jpQQX0piaxcHJPWakp_Kr_03g5Gnma5h5-Kdlqu7j... Test expectations are changed due to http://crbug.com/705364 BUG=588893, 617892, 705364 ==========
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: android_compile_dbg on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_comp...)
https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:67: : nullptr), On 2017/07/10 03:39:13, peria wrote: > On 2017/07/07 06:59:11, haraken wrote: > > On 2017/07/07 06:22:03, peria wrote: > > > On 2017/07/04 15:04:20, haraken wrote: > > > > > > > > Nit: It looks a bit weird to do the heavy work during the constructor. > > > > > > > > Would it be possible to create a helper function in isolate_holder.h > (e.g., > > > > IsolateHolder::CreateIsolate()) and call it at line 75? > > > > > > > > I don't fully understand why the v8::Islate needs to be initialized during > > the > > > > constructor. > > > > > > Hmm, of course it is technically possible, but what does it change in > > practice? > > > > > > Instantiation of v8::Isolate (and gin::IsolateHolder) are done here to > > guarantee > > > their lifetime same with V8PerIsolateData. > > > > I just don't really like doing a complex thing during a constructor because > the > > object is half-backed. > > > > Can we delay instantiating the isolate instantiation to line 75 as well? In > > short, I'd prefer moving what you're currently doing in IsolateHolder's > > constructor to line 75. > > > > Line 75 is also in V8PerIsolateData's constructor, and it is half-baked there. > What the difference here and there? > And in that sense, IsolateHolder is also half-baked instance at line #75, > so I have to move some other members *below* #75 together. > > I think your change will make it more dangerous. > > FYI, Jochen opposed to instantiate isolate separately. > (https://codereview.chromium.org/2897853002/#msg18) In this specific case, it will be safe because V8PerIsolateData doesn't have a vtable (by accident). However, if V8PerIsolateData has a vtable, it is not correctly initialized until line 75. That's a difference between before line 75 and after line 75. Because of the difference, there are a couple of restrictions about what we can do during the constructor (i.e., before 75) e.g., we're not allowed to call a V8 API that may cause an incremental marking. We've spent lots of time fixing subtle bugs caused by that (we've removed V8 APIs from almost all object constructors.). So, in general I want to avoid doing complex things (e.g., calling V8 APIs) during an object constructor. https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:67: : nullptr), On 2017/07/10 03:39:13, peria wrote: > On 2017/07/07 06:59:11, haraken wrote: > > On 2017/07/07 06:22:03, peria wrote: > > > On 2017/07/04 15:04:20, haraken wrote: > > > > > > > > Nit: It looks a bit weird to do the heavy work during the constructor. > > > > > > > > Would it be possible to create a helper function in isolate_holder.h > (e.g., > > > > IsolateHolder::CreateIsolate()) and call it at line 75? > > > > > > > > I don't fully understand why the v8::Islate needs to be initialized during > > the > > > > constructor. > > > > > > Hmm, of course it is technically possible, but what does it change in > > practice? > > > > > > Instantiation of v8::Isolate (and gin::IsolateHolder) are done here to > > guarantee > > > their lifetime same with V8PerIsolateData. > > > > I just don't really like doing a complex thing during a constructor because > the > > object is half-backed. > > > > Can we delay instantiating the isolate instantiation to line 75 as well? In > > short, I'd prefer moving what you're currently doing in IsolateHolder's > > constructor to line 75. > > > > Line 75 is also in V8PerIsolateData's constructor, and it is half-baked there. > What the difference here and there? > And in that sense, IsolateHolder is also half-baked instance at line #75, > so I have to move some other members *below* #75 together. > > I think your change will make it more dangerous. > > FYI, Jochen opposed to instantiate isolate separately. > (https://codereview.chromium.org/2897853002/#msg18) In this particular case, it will be safe. However, if V8PerIsolateData has a vtable, it won't be correctly initialized until line 75. That's the difference between before line 75 and after line 75. For example, we've removed V8 APIs from object constructors (i.e., before line 75) because the V8 API may trigger an incremental marking, access the object whose vtable is not yet initialized and crash. So in general I want to avoid doing complex things (e.g., calling V8 APIs) during an object constructor. Would it be hard to refactor the code like this? V8PerIsolateData() : ... // Initialize only members that don't need isolate_holder_. { isolate_holder.Initialize(); // Read the startup_data_ and initialize the isolate. ...; // Initialize members that need isolate_holder_. }
https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp (right): https://codereview.chromium.org/2841443005/diff/320001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp:67: : nullptr), On 2017/07/10 04:58:46, haraken wrote: > On 2017/07/10 03:39:13, peria wrote: > > On 2017/07/07 06:59:11, haraken wrote: > > > On 2017/07/07 06:22:03, peria wrote: > > > > On 2017/07/04 15:04:20, haraken wrote: > > > > > > > > > > Nit: It looks a bit weird to do the heavy work during the constructor. > > > > > > > > > > Would it be possible to create a helper function in isolate_holder.h > > (e.g., > > > > > IsolateHolder::CreateIsolate()) and call it at line 75? > > > > > > > > > > I don't fully understand why the v8::Islate needs to be initialized > during > > > the > > > > > constructor. > > > > > > > > Hmm, of course it is technically possible, but what does it change in > > > practice? > > > > > > > > Instantiation of v8::Isolate (and gin::IsolateHolder) are done here to > > > guarantee > > > > their lifetime same with V8PerIsolateData. > > > > > > I just don't really like doing a complex thing during a constructor because > > the > > > object is half-backed. > > > > > > Can we delay instantiating the isolate instantiation to line 75 as well? In > > > short, I'd prefer moving what you're currently doing in IsolateHolder's > > > constructor to line 75. > > > > > > > Line 75 is also in V8PerIsolateData's constructor, and it is half-baked there. > > What the difference here and there? > > And in that sense, IsolateHolder is also half-baked instance at line #75, > > so I have to move some other members *below* #75 together. > > > > I think your change will make it more dangerous. > > > > FYI, Jochen opposed to instantiate isolate separately. > > (https://codereview.chromium.org/2897853002/#msg18) > > In this particular case, it will be safe. > > However, if V8PerIsolateData has a vtable, it won't be correctly initialized > until line 75. That's the difference between before line 75 and after line 75. > For example, we've removed V8 APIs from object constructors (i.e., before line > 75) because the V8 API may trigger an incremental marking, access the object > whose vtable is not yet initialized and crash. > > So in general I want to avoid doing complex things (e.g., calling V8 APIs) > during an object constructor. > > Would it be hard to refactor the code like this? > > V8PerIsolateData() : ... // Initialize only members that don't need > isolate_holder_. > { > isolate_holder.Initialize(); // Read the startup_data_ and initialize the > isolate. > ...; // Initialize members that need isolate_holder_. > } Agreed to avoid doing complex things in V8PerIsolateData, and tried it, but it seems difficult because of the newly introduced V8GlobalValueMap |interface_template_map_for_v8_snapshot_|. It has DISALLOW_NEW().
LGTM with comments! https://codereview.chromium.org/2841443005/diff/360001/gin/v8_initializer.h File gin/v8_initializer.h (right): https://codereview.chromium.org/2841443005/diff/360001/gin/v8_initializer.h#n... gin/v8_initializer.h:84: static void GetV8ContextSnapshotData(const char** snapshot_data_out, Add per-method comments like other methods in this file. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:31: // V8PerContext::ConstructorForTypeSlowCase(), so merge with it. Yeah, it's error-prone to duplicate the method here. Let's merge the implementation in a follow-up CL. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:226: { // The below code handles window.document on the main world. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:276: DOMWrapperWorld::Create(isolate, DOMWrapperWorld::WorldType::kTesting); This creates a new isolated world, right? As I mentioned before, it is not allowed to create an unnecessary isolated world because it disabled the performance optimization at CanUseMainWorldWrapper() (https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/bindi...). https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:313: // For non main worlds, we can use any type to create a context. It is fine to create an isolated world here because this code is executed only when taking a snapshot. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:342: } Can we add a DCHECK to verify that these wrappers / objects have an expected number of internal fields? https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:359: // with |document| being HTMLDocument. What happens when a non-main world calls DeserializeInternalField? https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:374: case InternalFieldType::kHTMLDocumentObject: { // The below code handles window.document on the main world. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:418: // |kSnapshotInterfaceSize| templates are for the main world, and other The first |kSnapshotInterfaceSize| templates are ... and the remaining templates are ... https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:471: // because it is used for "window.document" in most cases. // For the main world context, we need to prepare a HTMLDocument wrapper and set it to window.document. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.h (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.h:17: // This class contains helper functions to take and use a V8 context snapshot. Explain how the V8 context snapshot works. In particular: - The context snapshot is taken by tools/v8_context_snapshot/ when Chromium is built. - The context snapshot is used when Blink creates a new V8 context. - The context snapshot contains: --- Interface templates of Window, Node, Document and HTMLDocument. --- Internal fields of wrappers of Window, Node, Document and HTMLDocument. --- References of C++ callbacks exposed to V8. --- window.document (only for the main world). --- anything else? - The context snapshot supports only the main thread. If it is the main world, we need a special logic to serialize / deserialize window.document (so only HTMLDocument is supported on the main world). Worker threads are not yet supported. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp:459: reference_table = nullptr; Why do we need to set nullptr to reference_table? https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/modules/v8/V8ContextSnapshotExternalReferences.h (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/modules/v8/V8ContextSnapshotExternalReferences.h:15: class MODULES_EXPORT V8ContextSnapshotExternalReferences { Add a per-class comment. // V8ContextSnapshotExternalReferences::GetTable() provides a table of pointers of all C++ callbacks exposed to V8. The table contains C++ callbacks for DOM attribute getters, setters, DOM methods, wrapper type info etc. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/modules/v8/V8ContextSnapshotExternalReferences.h:20: // V8ContextSnapshotExternalReferences.cpp. // The definition of this method is auto-generated in V8ContextSnapshotExternalReferences.cpp. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/scripts/generate_v8_context_snapshot_external_references.py (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_v8_context_snapshot_external_references.py:108: if not interface.is_partial: Why doesn't the line 108 - 114 need to be in the 'if interface.name in SNAPSHOTTED_INTERFACES:' block at line 86? I guess the line 108 - 114 is needed only when the interface is in SNAPSHOTTED_INTERFACES. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_v8_context_snapshot_external_references.py:164: def has_impl(interface): Add more comments about what this method is doing. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/templates/external_reference_table.cpp.tmpl (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/templates/external_reference_table.cpp.tmpl:93: reinterpret_cast<intptr_t>({{v8_class}}::indexedPropertyDefinerCallback), I'm just curious but how did you notice that you need to add the definer callback? If you forget to add this, do you hit a crash? https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/controller/BlinkInitializer.cpp (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/controller/BlinkInitializer.cpp:73: // Refernce table must be updated before creating an isolate. reference We could drop this comment because now the initialization logic is encapsulated in V8Initializer::InitializeMainThread. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:264: gin::IsolateHolder isolate_holder_; // This isolate_holder_ must be initialized before initializing other members below. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/web/WebV8ContextSnapshot.cpp (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/web/WebV8ContextSnapshot.cpp:1: // Copyright 2017 The Chromium Authors. All rights reserved. Consider moving this file to bindings/core/v8/. web/ will be gone in the very near future. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/pub... File third_party/WebKit/public/platform/Platform.h (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/pub... third_party/WebKit/public/platform/Platform.h:706: virtual bool IsTakingV8ContextSnapshot() { return false; } // This method returns true only when tools/v8_context_snapshot/v8_context_snapshot_generator is running (which runs during Chromium's build step). https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/pub... File third_party/WebKit/public/web/WebV8ContextSnapshot.h (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/pub... third_party/WebKit/public/web/WebV8ContextSnapshot.h:13: // WebV8ContextSnapshot is an API to take a snapshot of V8 context. Add: // This API should be used only by tools/v8_context_snapshot, which runs during Chromium's build step. https://codereview.chromium.org/2841443005/diff/360001/tools/v8_context_snaps... File tools/v8_context_snapshot/OWNERS (right): https://codereview.chromium.org/2841443005/diff/360001/tools/v8_context_snaps... tools/v8_context_snapshot/OWNERS:3: yukishiino@chromium.org Add TEAMS and COMPONENT. https://codereview.chromium.org/2841443005/diff/360001/tools/v8_context_snaps... File tools/v8_context_snapshot/v8_context_snapshot_generator.cc (right): https://codereview.chromium.org/2841443005/diff/360001/tools/v8_context_snaps... tools/v8_context_snapshot/v8_context_snapshot_generator.cc:55: // Take snapshot Take a snapshot. https://codereview.chromium.org/2841443005/diff/360001/tools/v8_context_snaps... tools/v8_context_snapshot/v8_context_snapshot_generator.cc:60: // Save snapshot as a file. Filename is given in a command line option. Save the snapshot to a file.
The CQ bit was checked by peria@chromium.org to run a CQ dry run
https://codereview.chromium.org/2841443005/diff/360001/gin/v8_initializer.h File gin/v8_initializer.h (right): https://codereview.chromium.org/2841443005/diff/360001/gin/v8_initializer.h#n... gin/v8_initializer.h:84: static void GetV8ContextSnapshotData(const char** snapshot_data_out, On 2017/07/10 06:52:08, haraken wrote: > > Add per-method comments like other methods in this file. > Done. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:31: // V8PerContext::ConstructorForTypeSlowCase(), so merge with it. On 2017/07/10 06:52:08, haraken wrote: > > Yeah, it's error-prone to duplicate the method here. Let's merge the > implementation in a follow-up CL. Acknowledged. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:226: { On 2017/07/10 06:52:08, haraken wrote: > > // The below code handles window.document on the main world. > Done. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:276: DOMWrapperWorld::Create(isolate, DOMWrapperWorld::WorldType::kTesting); On 2017/07/10 06:52:08, haraken wrote: > > This creates a new isolated world, right? > > As I mentioned before, it is not allowed to create an unnecessary isolated world > because it disabled the performance optimization at CanUseMainWorldWrapper() > > (https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/bindi...). Ah, right. Is there a way to swipe out DOMWraperWorlds? https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:313: // For non main worlds, we can use any type to create a context. On 2017/07/10 06:52:08, haraken wrote: > > It is fine to create an isolated world here because this code is executed only > when taking a snapshot. Acknowledged. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:342: } On 2017/07/10 06:52:08, haraken wrote: > > Can we add a DCHECK to verify that these wrappers / objects have an expected > number of internal fields? Done. But for 'V8HTMLDocument' objects, it is difficult to distinguish it is a wrapper object or a prototype object without looking the internal field count. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:359: // with |document| being HTMLDocument. On 2017/07/10 06:52:08, haraken wrote: > > What happens when a non-main world calls DeserializeInternalField? it goes as far as it passes CHECK_EQ() and NOTREACHED(). https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:374: case InternalFieldType::kHTMLDocumentObject: { On 2017/07/10 06:52:08, haraken wrote: > > // The below code handles window.document on the main world. Done. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:418: // |kSnapshotInterfaceSize| templates are for the main world, and other On 2017/07/10 06:52:08, haraken wrote: > > The first |kSnapshotInterfaceSize| templates are ... and the remaining templates > are ... Done. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:471: // because it is used for "window.document" in most cases. On 2017/07/10 06:52:08, haraken wrote: > > // For the main world context, we need to prepare a HTMLDocument wrapper and set > it to window.document. Done. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.h (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.h:17: // This class contains helper functions to take and use a V8 context snapshot. On 2017/07/10 06:52:08, haraken wrote: > > Explain how the V8 context snapshot works. In particular: > > - The context snapshot is taken by tools/v8_context_snapshot/ when Chromium is > built. > > - The context snapshot is used when Blink creates a new V8 context. > > - The context snapshot contains: > --- Interface templates of Window, Node, Document and HTMLDocument. > --- Internal fields of wrappers of Window, Node, Document and HTMLDocument. > --- References of C++ callbacks exposed to V8. > --- window.document (only for the main world). > --- anything else? > > - The context snapshot supports only the main thread. If it is the main world, > we need a special logic to serialize / deserialize window.document (so only > HTMLDocument is supported on the main world). Worker threads are not yet > supported. Done. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8Initializer.cpp:459: reference_table = nullptr; On 2017/07/10 06:52:08, haraken wrote: > > Why do we need to set nullptr to reference_table? To avoid http://crbug.com/v8/6433 https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/modules/v8/V8ContextSnapshotExternalReferences.h (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/modules/v8/V8ContextSnapshotExternalReferences.h:15: class MODULES_EXPORT V8ContextSnapshotExternalReferences { On 2017/07/10 06:52:09, haraken wrote: > > Add a per-class comment. > > // V8ContextSnapshotExternalReferences::GetTable() provides a table of pointers > of all C++ callbacks exposed to V8. The table contains C++ callbacks for DOM > attribute getters, setters, DOM methods, wrapper type info etc. Done. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/modules/v8/V8ContextSnapshotExternalReferences.h:20: // V8ContextSnapshotExternalReferences.cpp. On 2017/07/10 06:52:09, haraken wrote: > > // The definition of this method is auto-generated in > V8ContextSnapshotExternalReferences.cpp. Done. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/scripts/generate_v8_context_snapshot_external_references.py (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_v8_context_snapshot_external_references.py:108: if not interface.is_partial: On 2017/07/10 06:52:09, haraken wrote: > > Why doesn't the line 108 - 114 need to be in the 'if interface.name in > SNAPSHOTTED_INTERFACES:' block at line 86? > > I guess the line 108 - 114 is needed only when the interface is in > SNAPSHOTTED_INTERFACES. Done. This change reduce the number of the entries in the table. 2200->1400. 1400 is very close to the ideal number. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/scripts/generate_v8_context_snapshot_external_references.py:164: def has_impl(interface): On 2017/07/10 06:52:09, haraken wrote: > > Add more comments about what this method is doing. Done. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/templates/external_reference_table.cpp.tmpl (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/templates/external_reference_table.cpp.tmpl:93: reinterpret_cast<intptr_t>({{v8_class}}::indexedPropertyDefinerCallback), On 2017/07/10 06:52:09, haraken wrote: > > I'm just curious but how did you notice that you need to add the definer > callback? If you forget to add this, do you hit a crash? > Right. If the generated table lacks a pointer referred in a snapshot, v8_context_snapshot crashes with a message. And because it happens in build time, we can't release a broken table. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/controller/BlinkInitializer.cpp (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/controller/BlinkInitializer.cpp:73: // Refernce table must be updated before creating an isolate. On 2017/07/10 06:52:09, haraken wrote: > > reference > > We could drop this comment because now the initialization logic is encapsulated > in V8Initializer::InitializeMainThread. Done. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h:264: gin::IsolateHolder isolate_holder_; On 2017/07/10 06:52:09, haraken wrote: > > // This isolate_holder_ must be initialized before initializing other members > below. Done. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/web/WebV8ContextSnapshot.cpp (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/web/WebV8ContextSnapshot.cpp:1: // Copyright 2017 The Chromium Authors. All rights reserved. On 2017/07/10 06:52:09, haraken wrote: > > Consider moving this file to bindings/core/v8/. web/ will be gone in the very > near future. I'm sorry. I forgot to do it. Done. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/pub... File third_party/WebKit/public/platform/Platform.h (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/pub... third_party/WebKit/public/platform/Platform.h:706: virtual bool IsTakingV8ContextSnapshot() { return false; } On 2017/07/10 06:52:09, haraken wrote: > > // This method returns true only when > tools/v8_context_snapshot/v8_context_snapshot_generator is running (which runs > during Chromium's build step). Done. https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/pub... File third_party/WebKit/public/web/WebV8ContextSnapshot.h (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/pub... third_party/WebKit/public/web/WebV8ContextSnapshot.h:13: // WebV8ContextSnapshot is an API to take a snapshot of V8 context. On 2017/07/10 06:52:09, haraken wrote: > > Add: > > // This API should be used only by tools/v8_context_snapshot, which runs during > Chromium's build step. Done. https://codereview.chromium.org/2841443005/diff/360001/tools/v8_context_snaps... File tools/v8_context_snapshot/OWNERS (right): https://codereview.chromium.org/2841443005/diff/360001/tools/v8_context_snaps... tools/v8_context_snapshot/OWNERS:3: yukishiino@chromium.org On 2017/07/10 06:52:09, haraken wrote: > > Add TEAMS and COMPONENT. Done. https://codereview.chromium.org/2841443005/diff/360001/tools/v8_context_snaps... File tools/v8_context_snapshot/v8_context_snapshot_generator.cc (right): https://codereview.chromium.org/2841443005/diff/360001/tools/v8_context_snaps... tools/v8_context_snapshot/v8_context_snapshot_generator.cc:55: // Take snapshot On 2017/07/10 06:52:09, haraken wrote: > > Take a snapshot. Done. https://codereview.chromium.org/2841443005/diff/360001/tools/v8_context_snaps... tools/v8_context_snapshot/v8_context_snapshot_generator.cc:60: // Save snapshot as a file. Filename is given in a command line option. On 2017/07/10 06:52:09, haraken wrote: > > Save the snapshot to a file. Done.
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: android_compile_dbg on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_comp...)
https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:276: DOMWrapperWorld::Create(isolate, DOMWrapperWorld::WorldType::kTesting); On 2017/07/10 10:18:43, peria wrote: > On 2017/07/10 06:52:08, haraken wrote: > > > > This creates a new isolated world, right? > > > > As I mentioned before, it is not allowed to create an unnecessary isolated > world > > because it disabled the performance optimization at CanUseMainWorldWrapper() > > > > > (https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/bindi...). > > Ah, right. > Is there a way to swipe out DOMWraperWorlds? My understanding was wrong, and this code works well. Because DOMWrapperWorld.cpp holds a hash map, but its type is not a refptr but a raw pointer. So all other pointer holders release their pointer, the world is gone. So this code releases |isolated_world| and CanUseMainWorldWrapper() works as intended.
LGTM! https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... File third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp (right): https://codereview.chromium.org/2841443005/diff/360001/third_party/WebKit/Sou... third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp:276: DOMWrapperWorld::Create(isolate, DOMWrapperWorld::WorldType::kTesting); On 2017/07/11 06:54:31, peria wrote: > On 2017/07/10 10:18:43, peria wrote: > > On 2017/07/10 06:52:08, haraken wrote: > > > > > > This creates a new isolated world, right? > > > > > > As I mentioned before, it is not allowed to create an unnecessary isolated > > world > > > because it disabled the performance optimization at CanUseMainWorldWrapper() > > > > > > > > > (https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/bindi...). > > > > Ah, right. > > Is there a way to swipe out DOMWraperWorlds? > > My understanding was wrong, and this code works well. > Because DOMWrapperWorld.cpp holds a hash map, but its type is not a refptr but a > raw pointer. So all other pointer holders release their pointer, the world is > gone. > So this code releases |isolated_world| and CanUseMainWorldWrapper() works as > intended. Makes sense. kTesting => kDeserializeV8ContextSnapshot
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
peria@chromium.org changed reviewers: + jam@chromium.org, jochen@chromium.org
+R jochen for gin/ jam for content/ Please take a look
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
The gn changes generally lgtm. Was there an intent-to-implement thread for this somewhere? What's the disk space cost of this? https://codereview.chromium.org/2841443005/diff/400001/build/config/features.gni File build/config/features.gni (right): https://codereview.chromium.org/2841443005/diff/400001/build/config/features.... build/config/features.gni:65: current_toolchain == default_toolchain Why do you need this? https://codereview.chromium.org/2841443005/diff/400001/tools/v8_context_snaps... File tools/v8_context_snapshot/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/400001/tools/v8_context_snaps... tools/v8_context_snapshot/BUILD.gn:4: add a comment giving a short overview of what this file does (maybe link to the design doc, or give a short overview inline) https://codereview.chromium.org/2841443005/diff/400001/tools/v8_context_snaps... tools/v8_context_snapshot/BUILD.gn:57: # functions into one if the function signature and body of them are identical. why? https://codereview.chromium.org/2841443005/diff/400001/tools/v8_context_snaps... tools/v8_context_snapshot/BUILD.gn:84: # for V8 snapshot. So, we disable it while taking a V8 snapshot. Aha. Put this comment at the end of the comment on the config instead.
Thank you for reviewing. I updated the document, and the disk usage will grow for 1.6MB on Android. https://codereview.chromium.org/2841443005/diff/400001/build/config/features.gni File build/config/features.gni (right): https://codereview.chromium.org/2841443005/diff/400001/build/config/features.... build/config/features.gni:65: current_toolchain == default_toolchain On 2017/07/11 18:59:39, Nico (vacation Jun 30-Jul 11) wrote: > Why do you need this? gconf has an assert to check it. And if current_TC != default_TC, target_os is not Linux, and I believe GNOME is not necessary for server side programs on Linux. https://codereview.chromium.org/2841443005/diff/400001/tools/v8_context_snaps... File tools/v8_context_snapshot/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/400001/tools/v8_context_snaps... tools/v8_context_snapshot/BUILD.gn:4: On 2017/07/11 18:59:39, Nico (vacation Jun 30-Jul 11) wrote: > add a comment giving a short overview of what this file does (maybe link to the > design doc, or give a short overview inline) Done. https://codereview.chromium.org/2841443005/diff/400001/tools/v8_context_snaps... tools/v8_context_snapshot/BUILD.gn:57: # functions into one if the function signature and body of them are identical. On 2017/07/11 18:59:39, Nico (vacation Jun 30-Jul 11) wrote: > why? The reason to disable ICF is on #83-84. https://codereview.chromium.org/2841443005/diff/400001/tools/v8_context_snaps... tools/v8_context_snapshot/BUILD.gn:84: # for V8 snapshot. So, we disable it while taking a V8 snapshot. On 2017/07/11 18:59:39, Nico (vacation Jun 30-Jul 11) wrote: > Aha. Put this comment at the end of the comment on the config instead. Done.
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
peria@chromium.org changed reviewers: + brettw@chromium.org, dcheng@chromium.org, eroman@chromium.org, rkc@chromium.org
+R dcheng@ for content/public/app/mojo/content_renderer_manifest.json rkc@ for extensions/shell/BUILD.gn eroman@ for net/BUILD.gn brettw@ for url/BUILD.gn Could you take a look?
https://codereview.chromium.org/2841443005/diff/440001/content/public/app/moj... File content/public/app/mojo/content_renderer_manifest.json (right): https://codereview.chromium.org/2841443005/diff/440001/content/public/app/moj... content/public/app/mojo/content_renderer_manifest.json:81: "path": "v8_context_snapshot.bin", Nit: please use spaces https://codereview.chromium.org/2841443005/diff/440001/content/public/app/moj... content/public/app/mojo/content_renderer_manifest.json:85: "path": "assets/v8_context_snapshot.bin", Just to confirm: these assets are read-only? It's not possible for a rogue renderer to modify the snapshot? (Sorry if this is a silly question, this is the first time I've seen changes like this: based on the fact that this is already used by other things, I assume that this must be true. It's just not very obvious to me why it's true)
https://codereview.chromium.org/2841443005/diff/440001/content/public/app/moj... File content/public/app/mojo/content_renderer_manifest.json (right): https://codereview.chromium.org/2841443005/diff/440001/content/public/app/moj... content/public/app/mojo/content_renderer_manifest.json:81: "path": "v8_context_snapshot.bin", On 2017/07/12 09:55:09, dcheng wrote: > Nit: please use spaces Done. https://codereview.chromium.org/2841443005/diff/440001/content/public/app/moj... content/public/app/mojo/content_renderer_manifest.json:85: "path": "assets/v8_context_snapshot.bin", On 2017/07/12 09:55:09, dcheng wrote: > Just to confirm: these assets are read-only? It's not possible for a rogue > renderer to modify the snapshot? > > (Sorry if this is a silly question, this is the first time I've seen changes > like this: based on the fact that this is already used by other things, I assume > that this must be true. It's just not very obvious to me why it's true) Yes, they are read-only.
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On Jul 11, 2017 10:38 PM, <peria@chromium.org> wrote: Thank you for reviewing. I updated the document, and the disk usage will grow for 1.6MB on Android. This might be prohibitively large.+agrieve to evaluate. https://codereview.chromium.org/2841443005/diff/400001/ build/config/features.gni File build/config/features.gni (right): https://codereview.chromium.org/2841443005/diff/400001/ build/config/features.gni#newcode65 build/config/features.gni:65: current_toolchain == default_toolchain On 2017/07/11 18:59:39, Nico (vacation Jun 30-Jul 11) wrote: > Why do you need this? gconf has an assert to check it. And if current_TC != default_TC, target_os is not Linux, and I believe GNOME is not necessary for server side programs on Linux. https://codereview.chromium.org/2841443005/diff/400001/ tools/v8_context_snapshot/BUILD.gn File tools/v8_context_snapshot/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/400001/ tools/v8_context_snapshot/BUILD.gn#newcode4 tools/v8_context_snapshot/BUILD.gn:4: On 2017/07/11 18:59:39, Nico (vacation Jun 30-Jul 11) wrote: > add a comment giving a short overview of what this file does (maybe link to the > design doc, or give a short overview inline) Done. https://codereview.chromium.org/2841443005/diff/400001/ tools/v8_context_snapshot/BUILD.gn#newcode57 tools/v8_context_snapshot/BUILD.gn:57: # functions into one if the function signature and body of them are identical. On 2017/07/11 18:59:39, Nico (vacation Jun 30-Jul 11) wrote: > why? The reason to disable ICF is on #83-84. https://codereview.chromium.org/2841443005/diff/400001/ tools/v8_context_snapshot/BUILD.gn#newcode84 tools/v8_context_snapshot/BUILD.gn:84: # for V8 snapshot. So, we disable it while taking a V8 snapshot. On 2017/07/11 18:59:39, Nico (vacation Jun 30-Jul 11) wrote: > Aha. Put this comment at the end of the comment on the config instead. Done. https://codereview.chromium.org/2841443005/ -- You received this message because you are subscribed to the Google Groups "Chromium-reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to chromium-reviews+unsubscribe@chromium.org.
On Jul 11, 2017 10:38 PM, <peria@chromium.org> wrote: Thank you for reviewing. I updated the document, and the disk usage will grow for 1.6MB on Android. This might be prohibitively large.+agrieve to evaluate. https://codereview.chromium.org/2841443005/diff/400001/ build/config/features.gni File build/config/features.gni (right): https://codereview.chromium.org/2841443005/diff/400001/ build/config/features.gni#newcode65 build/config/features.gni:65: current_toolchain == default_toolchain On 2017/07/11 18:59:39, Nico (vacation Jun 30-Jul 11) wrote: > Why do you need this? gconf has an assert to check it. And if current_TC != default_TC, target_os is not Linux, and I believe GNOME is not necessary for server side programs on Linux. https://codereview.chromium.org/2841443005/diff/400001/ tools/v8_context_snapshot/BUILD.gn File tools/v8_context_snapshot/BUILD.gn (right): https://codereview.chromium.org/2841443005/diff/400001/ tools/v8_context_snapshot/BUILD.gn#newcode4 tools/v8_context_snapshot/BUILD.gn:4: On 2017/07/11 18:59:39, Nico (vacation Jun 30-Jul 11) wrote: > add a comment giving a short overview of what this file does (maybe link to the > design doc, or give a short overview inline) Done. https://codereview.chromium.org/2841443005/diff/400001/ tools/v8_context_snapshot/BUILD.gn#newcode57 tools/v8_context_snapshot/BUILD.gn:57: # functions into one if the function signature and body of them are identical. On 2017/07/11 18:59:39, Nico (vacation Jun 30-Jul 11) wrote: > why? The reason to disable ICF is on #83-84. https://codereview.chromium.org/2841443005/diff/400001/ tools/v8_context_snapshot/BUILD.gn#newcode84 tools/v8_context_snapshot/BUILD.gn:84: # for V8 snapshot. So, we disable it while taking a V8 snapshot. On 2017/07/11 18:59:39, Nico (vacation Jun 30-Jul 11) wrote: > Aha. Put this comment at the end of the comment on the config instead. Done. https://codereview.chromium.org/2841443005/ -- You received this message because you are subscribed to the Google Groups "Blink Reviews" group. To unsubscribe from this group and stop receiving emails from it, send an email to blink-reviews+unsubscribe@chromium.org.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
peria@chromium.org changed reviewers: + agrieve@chromium.org
manifest change lgtm
//net LGTM (although I didn't see the conclusion for why current_toolchain == default_toolchain needs to be done at this level).
rs-lgtm for //extensions/shell/BUILD.gn
As discussed in blink-dev@, let's disable the V8 context snapshot on Android at the moment.
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_compile_dbg_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by peria@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2017/07/13 01:21:16, haraken wrote: > As discussed in blink-dev@, let's disable the V8 context snapshot on Android at > the moment. Yeah. I take it down on Android (PS20). Now this CL does not increase APK size.
jam@, jochen@ Could you take a look? content/ and gin/ contain some important changes.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_...)
gin lgtm
jam@ Could you take a look?
jochen@, Could you also review code under content/?
Can you move this CL forward?
On 2017/07/27 18:01:30, haraken wrote: > Can you move this CL forward? Sure. I need to ask another OWNER of content/..
peria@chromium.org changed reviewers: + kinuko@chromium.org
Kinuko-san, Could you review changes under content/?
On 2017/07/27 23:36:54, peria wrote: > Kinuko-san, > Could you review changes under content/? lgtm
The CQ bit was checked by peria@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from yukishiino@chromium.org, haraken@chromium.org, thakis@chromium.org, rkc@chromium.org, dcheng@chromium.org, eroman@chromium.org, jochen@chromium.org, kinuko@chromium.org Link to the patchset: https://codereview.chromium.org/2841443005/#ps520001 (title: "Rebase")
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Thank you, all reviewers. Trying to land it.
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_android_rel_ng on master.tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/linux_androi...)
The CQ bit was checked by peria@chromium.org
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch. Bot data: {"patchset_id": 520001, "attempt_start_ts": 1501220562177710, "parent_rev": "694c68aa96287265d701778157b20cf1554e1b2c", "commit_rev": "87ae25601580e3f8be96281207922e6edcdbeb17"}
CQ is committing da patch. Bot data: {"patchset_id": 520001, "attempt_start_ts": 1501220562177710, "parent_rev": "bcae6b3deb023f6494441a8f3b993f9edc3b56d6", "commit_rev": "77da07ff00fed466b936dab24bd82ab300237fff"}
CQ is committing da patch. Bot data: {"patchset_id": 520001, "attempt_start_ts": 1501220562177710, "parent_rev": "04ea2d90d8ba0c1061982330eaf520751878e459", "commit_rev": "5de4462d6d5595936c81df53669b678d66221558"}
The CQ bit was unchecked by commit-bot@chromium.org
Failed to commit the patch.
The CQ bit was checked by peria@chromium.org
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch. Bot data: {"patchset_id": 520001, "attempt_start_ts": 1501231552410440, "parent_rev": "abc4634436dd4fc1b909ec04e589288464d432aa", "commit_rev": "29293944852dcb1ea635971f36d5719b80e85371"}
CQ is committing da patch. Bot data: {"patchset_id": 520001, "attempt_start_ts": 1501231552410440, "parent_rev": "2c00a0f2d994e135931d1730a526d4d14ff9586f", "commit_rev": "54afe29f866e4c3878242de7a78941fc363791e9"}
Message was sent while issue was closed.
Description was changed from ========== Create and use V8 context snapshots. This CL does two things. 1. In compile time, creates a snapshot file, which consists of V8 contexts. 2. Creates v8::Context from the snapshot in LocalWindowProxy::CreateContext(). We expect this speeds up context creation for 3 times faster on Android. Detailed information is described in the design doc [1]. [1] Design doc: https://docs.google.com/document/d/1jpQQX0piaxcHJPWakp_Kr_03g5Gnma5h5-Kdlqu7j... Test expectations are changed due to http://crbug.com/705364 BUG=588893, 617892, 705364 ========== to ========== Create and use V8 context snapshots. This CL does two things. 1. In compile time, creates a snapshot file, which consists of V8 contexts. 2. Creates v8::Context from the snapshot in LocalWindowProxy::CreateContext(). We expect this speeds up context creation for 3 times faster on Android. Detailed information is described in the design doc [1]. [1] Design doc: https://docs.google.com/document/d/1jpQQX0piaxcHJPWakp_Kr_03g5Gnma5h5-Kdlqu7j... Test expectations are changed due to http://crbug.com/705364 BUG=588893, 617892, 705364 Review-Url: https://codereview.chromium.org/2841443005 Cr-Commit-Position: refs/heads/master@{#490329} Committed: https://chromium.googlesource.com/chromium/src/+/54afe29f866e4c3878242de7a789... ==========
Message was sent while issue was closed.
Committed patchset #22 (id:520001) as https://chromium.googlesource.com/chromium/src/+/54afe29f866e4c3878242de7a789...
Message was sent while issue was closed.
A revert of this CL (patchset #22 id:520001) has been created in https://codereview.chromium.org/2989793003/ by blundell@chromium.org. The reason for reverting is: Causes compile to fail on MSAN because of usage of uninitialized memory: https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.webkit%2FWebKit... .
Message was sent while issue was closed.
On 2017/07/28 09:47:03, blundell wrote: > A revert of this CL (patchset #22 id:520001) has been created in > https://codereview.chromium.org/2989793003/ by mailto:blundell@chromium.org. > > The reason for reverting is: Causes compile to fail on MSAN because of usage > of uninitialized memory: > > https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.webkit%2FWebKit... > . FYI, I discovered after the revert landed that also caused what looks like a distinct compile failure on the official build: https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.chrome%2FGoogle...
Message was sent while issue was closed.
On 2017/07/28 09:55:20, blundell wrote: > On 2017/07/28 09:47:03, blundell wrote: > > A revert of this CL (patchset #22 id:520001) has been created in > > https://codereview.chromium.org/2989793003/ by mailto:blundell@chromium.org. > > > > The reason for reverting is: Causes compile to fail on MSAN because of usage > > of uninitialized memory: > > > > > https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.webkit%2FWebKit... > > . > > FYI, I discovered after the revert landed that also caused what looks like a > distinct compile failure on the official build: > > https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.chrome%2FGoogle... Also worth noting that this registered as an 18kb apk size increase. Based on the change, this is probably expected, but thought I'd point it out in case this is at all addressable.
Message was sent while issue was closed.
On 2017/07/28 18:25:33, agrieve wrote: > Also worth noting that this registered as an 18kb apk size increase. Based on > the change, this is probably expected, but thought I'd point it out in case this > is at all addressable. Thank you for pointing it out. It should be addressed in the patch, and I'll work for it on re-landing. |