v8/tools/deprecation_stats.py

123 lines
3.6 KiB
Python
Raw Normal View History

Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
#!/usr/bin/env python
# Copyright 2018 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# for py2/py3 compatibility
from __future__ import print_function
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
import argparse
from datetime import datetime
import re
import subprocess
import sys
from os import path
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
RE_GITHASH = re.compile(r"^[0-9a-f]{40}")
RE_AUTHOR_TIME = re.compile(r"^author-time (\d+)$")
RE_FILENAME = re.compile(r"^filename (.+)$")
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
def GetBlame(file_path):
result = subprocess.check_output(
['git', 'blame', '-t', '--line-porcelain', file_path])
line_iter = iter(result.splitlines())
blame_list = list()
current_blame = None
while True:
line = next(line_iter, None)
if line is None:
break
if RE_GITHASH.match(line):
if current_blame is not None:
blame_list.append(current_blame)
current_blame = {'time': 0, 'filename': None, 'content': None}
continue
match = RE_AUTHOR_TIME.match(line)
if match:
current_blame['time'] = datetime.fromtimestamp(int(match.groups()[0]))
continue
match = RE_FILENAME.match(line)
if match:
current_blame['filename'] = match.groups()[0]
current_blame['content'] = next(line_iter).strip()
continue
blame_list.append(current_blame)
return blame_list
RE_MACRO_END = re.compile(r"\);")
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
RE_DEPRECATE_MACRO = re.compile(r"\(.*?,(.*)\);", re.MULTILINE)
def FilterAndPrint(blame_list, macro, options):
before = options.before
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
index = 0
re_macro = re.compile(macro)
deprecated = list()
while index < len(blame_list):
blame = blame_list[index]
time = blame['time']
if time >= before:
index += 1
continue
line = blame['content']
match = re_macro.search(line)
if match:
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
pos = match.end()
start = -1
parens = 0
while True:
if pos >= len(line):
# extend to next line
index = index + 1
blame = blame_list[index]
line = line + blame['content']
if line[pos] == '(':
parens = parens + 1
elif line[pos] == ')':
parens = parens - 1
if parens == 0:
# Exclud closing ")
pos = pos - 2
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
break
elif line[pos] == '"' and start == -1:
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
start = pos + 1
pos = pos + 1
# Extract content and replace double quotes from merged lines
content = line[start:pos].strip().replace('""', '')
deprecated.append([index + 1, time, content])
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
index = index + 1
print("Marked as " + macro + ": " + str(len(deprecated)))
for linenumber, time, content in deprecated:
print(" " + (options.v8_header + ":" +
str(linenumber)).rjust(len(options.v8_header) + 5) + "\t" +
str(time) + "\t" + content)
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
return len(deprecated)
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
def ParseOptions(args):
parser = argparse.ArgumentParser(
description="Collect deprecation statistics")
parser.add_argument("v8_header", nargs='?', help="Path to v8.h")
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
parser.add_argument("--before", help="Filter by date")
options = parser.parse_args(args)
if options.before:
options.before = datetime.strptime(options.before, '%Y-%m-%d')
else:
options.before = datetime.now()
if options.v8_header is None:
options.v8_header = path.join(path.dirname(__file__), '..', 'include', 'v8.h')
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
return options
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
def Main(args):
options = ParseOptions(args)
blame_list = GetBlame(options.v8_header)
FilterAndPrint(blame_list, "V8_DEPRECATE_SOON", options)
FilterAndPrint(blame_list, "V8_DEPRECATED", options)
Introduce script to collect deprecation statistics Example: ~/v8$ tools/deprecation_stats.py include/v8.h --before=2018-10-01 Marked as V8_DEPRECATE_SOON: 21 556 : 2017-11-15 11:00:49 : V8_INLINE void MarkIndependent() 568 : 2017-11-15 11:00:49 : V8_INLINE bool IsIndependent() const 2404 : 2018-09-24 13:05:31 : V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean(Local<Context> context) const 2421 : 2015-03-09 10:49:09 : Local<Number> ToNumber(Isolate* isolate) const 2423 : 2015-03-09 10:49:09 : Local<String> ToString(Isolate* isolate) const <...> 3416 : 2015-03-09 10:49:09 : Local<Array> GetOwnPropertyNames() 3516 : 2015-03-09 10:49:09 : bool HasRealNamedProperty(Local<String> key) 3533 : 2015-03-09 10:49:09 : bool HasRealIndexedProperty(uint32_t index) 3537 : 2015-03-09 10:49:09 : bool HasRealNamedCallbackProperty(Local<String> key) Marked as V8_DEPRECATED: 9 1395 : 2018-09-21 23:40:51 : const CachedData* GetCachedData() const 1853 : 2018-09-20 11:46:49 : MaybeLocal<Value> Parse(Isolate* isolate, Local<String> json_string) 1953 : 2018-09-20 11:46:49 : std::vector<uint8_t> ReleaseBuffer() 1977 : 2018-09-20 11:46:49 : void TransferSharedArrayBuffer(uint32_t transfer_id, Local<SharedArrayBuffer> shared_array_buffer) 5093 : 2018-09-20 11:46:49 : Local<Value> New(Isolate* isolate, double time) 6355 : 2018-09-20 11:46:49 : size_t max_semi_space_size() 6361 : 2018-09-20 11:46:49 : void set_max_semi_space_size(size_t limit_in_mb) 6380 : 2018-09-20 11:46:49 : size_t max_executable_size() const 6384 : 2018-09-20 11:46:49 : void set_max_executable_size(size_t limit_in_mb) R=delphick@chromium.org Change-Id: I723055d30457a4061cdc589a4be09c0279fd5923 Reviewed-on: https://chromium-review.googlesource.com/c/1352307 Commit-Queue: Dan Elphick <delphick@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by: Dan Elphick <delphick@chromium.org> Cr-Commit-Position: refs/heads/master@{#57906}
2018-11-28 14:26:24 +00:00
if __name__ == "__main__":
Main(sys.argv[1:])