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

Unified Diff: src/dateparser-inl.h

Issue 2050733004: Add UseCounter for Date.parse's legacy parse heuristics. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/dateparser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/dateparser-inl.h
diff --git a/src/dateparser-inl.h b/src/dateparser-inl.h
index 7e5c4e355e1a9d6122241ddf7158048cea61c0cb..57e4fa5e6789dd2ee9540d42ea808c6e0e4d1ea9 100644
--- a/src/dateparser-inl.h
+++ b/src/dateparser-inl.h
@@ -13,9 +13,8 @@ namespace v8 {
namespace internal {
template <typename Char>
-bool DateParser::Parse(Vector<Char> str,
- FixedArray* out,
- UnicodeCache* unicode_cache) {
+bool DateParser::Parse(Isolate* isolate, Vector<Char> str, FixedArray* out) {
+ UnicodeCache* unicode_cache = isolate->unicode_cache();
DCHECK(out->length() >= OUTPUT_SIZE);
InputReader<Char> in(unicode_cache, str);
DateStringTokenizer<Char> scanner(&in);
@@ -76,6 +75,7 @@ bool DateParser::Parse(Vector<Char> str,
if (next_unhandled_token.IsInvalid()) return false;
bool has_read_number = !day.IsEmpty();
// If there's anything left, continue with the legacy parser.
+ bool legacy_parser = !next_unhandled_token.IsEndOfInput();
for (DateToken token = next_unhandled_token;
!token.IsEndOfInput();
token = scanner.Next()) {
@@ -170,7 +170,13 @@ bool DateParser::Parse(Vector<Char> str,
}
}
- return day.Write(out) && time.Write(out) && tz.Write(out);
+ bool success = day.Write(out) && time.Write(out) && tz.Write(out);
+
+ if (legacy_parser && success) {
+ isolate->CountUsage(v8::Isolate::kLegacyDateParser);
Dan Ehrenberg 2016/06/09 12:16:32 I bet we'll find that this gets hit a significant
+ }
+
+ return success;
}
« no previous file with comments | « src/dateparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698