forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert of [gin] Unify snapshot loading on Windows and other platforms…
…. (patchset chromium#2 id:20001 of https://codereview.chromium.org/2103903002/ ) Reason for revert: Investigate effect on Win7 startup.cold.blank_page metrics. BUG=501799,625516 Original issue's description: > [gin] Unify snapshot loading on Windows and other platforms. > > Removes extra v8 snapshot and natives validation on Windows. All platforms > have the same validation henceforth. > > BUG=501799 > > Committed: https://crrev.com/10b5a96b363a6ff23176d27a2e7fb1bba300f089 > Cr-Commit-Position: refs/heads/master@{#403430} TBR=jochen@chromium.org,ben@chromium.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=501799 Review-Url: https://codereview.chromium.org/2141043002 Cr-Commit-Position: refs/heads/master@{#405111}
- Loading branch information
Showing
7 changed files
with
260 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright 2015 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
# This file is meant to be included into a target to provide a rule that | ||
# fingerprints the v8 snapshot and generates a .cc file which includes this | ||
# fingerprint. | ||
# | ||
# To use this, create a gyp target with the following form: | ||
# { | ||
# 'target_name': 'gin_v8_snapshot_fingerprint', | ||
# 'type': 'none', | ||
# 'variables': { | ||
# 'snapshot_file': 'snapshot blob file to be fingerprinted', | ||
# 'natives_file': 'natives blob file to be fingerprinted', | ||
# 'output_file': 'output .cc file to generate with fingerprints', | ||
# }, | ||
# 'includes': [ '../gin/fingerprint/fingerprint_v8_snapshot.gypi' ], | ||
# }, | ||
# | ||
|
||
{ | ||
'conditions': [ | ||
['v8_use_external_startup_data==1', { | ||
'actions': [ | ||
{ | ||
'action_name': 'Generate V8 snapshot fingerprint', | ||
'message': 'Generating V8 snapshot fingerprint', | ||
'inputs': [ | ||
'<(DEPTH)/gin/fingerprint/fingerprint_v8_snapshot.py', | ||
'<(snapshot_file)', | ||
'<(natives_file)', | ||
], | ||
'outputs': [ | ||
'<(output_file)', | ||
], | ||
'action': [ | ||
'python', '<(DEPTH)/gin/fingerprint/fingerprint_v8_snapshot.py', | ||
'--snapshot_file=<(snapshot_file)', | ||
'--natives_file=<(natives_file)', | ||
'--output_file=<(output_file)', | ||
], | ||
} | ||
], | ||
}], | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright 2015 The Chromium Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
"""Fingerprints the V8 snapshot blob files. | ||
Constructs a SHA256 fingerprint of the V8 natives and snapshot blob files and | ||
creates a .cc file which includes these fingerprint as variables. | ||
""" | ||
|
||
import hashlib | ||
import optparse | ||
import os | ||
import sys | ||
|
||
_HEADER = """// Copyright 2015 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
// This file was generated by fingerprint_v8_snapshot.py. | ||
namespace gin { | ||
""" | ||
|
||
_FOOTER = """ | ||
} // namespace gin | ||
""" | ||
|
||
|
||
def FingerprintFile(file_path): | ||
input_file = open(file_path, 'rb') | ||
sha256 = hashlib.sha256() | ||
while True: | ||
block = input_file.read(sha256.block_size) | ||
if not block: | ||
break | ||
sha256.update(block) | ||
return sha256.digest() | ||
|
||
|
||
def WriteFingerprint(output_file, variable_name, fingerprint): | ||
output_file.write('\nextern const unsigned char %s[] = { ' % variable_name) | ||
for byte in fingerprint: | ||
output_file.write(str(ord(byte)) + ', ') | ||
output_file.write('};\n') | ||
|
||
|
||
def WriteOutputFile(natives_fingerprint, | ||
snapshot_fingerprint, | ||
output_file_path): | ||
output_dir_path = os.path.dirname(output_file_path) | ||
if not os.path.exists(output_dir_path): | ||
os.makedirs(output_dir_path) | ||
output_file = open(output_file_path, 'w') | ||
|
||
output_file.write(_HEADER) | ||
WriteFingerprint(output_file, 'g_natives_fingerprint', natives_fingerprint) | ||
output_file.write('\n') | ||
WriteFingerprint(output_file, 'g_snapshot_fingerprint', snapshot_fingerprint) | ||
output_file.write(_FOOTER) | ||
|
||
|
||
def main(): | ||
parser = optparse.OptionParser() | ||
|
||
parser.add_option('--snapshot_file', | ||
help='The input V8 snapshot blob file path.') | ||
parser.add_option('--natives_file', | ||
help='The input V8 natives blob file path.') | ||
parser.add_option('--output_file', | ||
help='The path for the output cc file which will be write.') | ||
|
||
options, _ = parser.parse_args() | ||
|
||
natives_fingerprint = FingerprintFile(options.natives_file) | ||
snapshot_fingerprint = FingerprintFile(options.snapshot_file) | ||
WriteOutputFile( | ||
natives_fingerprint, snapshot_fingerprint, options.output_file) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters