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

Unified Diff: src/parsing/preparser.h

Issue 2481163002: Assign unique IDs to FunctionLiterals (Closed)
Patch Set: updates Created 4 years, 1 month 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
Index: src/parsing/preparser.h
diff --git a/src/parsing/preparser.h b/src/parsing/preparser.h
index 0bac1277b048ff62fcf17febeecd0f7d7e77d32a..551193cd5b75822bba547a6eb6a622162263134a 100644
--- a/src/parsing/preparser.h
+++ b/src/parsing/preparser.h
@@ -662,7 +662,7 @@ class PreParserFactory {
FunctionLiteral::ParameterFlag has_duplicate_parameters,
FunctionLiteral::FunctionType function_type,
FunctionLiteral::EagerCompileHint eager_compile_hint, int position,
- bool has_braces) {
+ bool has_braces, int function_literal_num) {
return PreParserExpression::Default();
}
@@ -1080,10 +1080,33 @@ class PreParser : public ParserBase<PreParser> {
int class_token_pos, bool* ok) {}
V8_INLINE void DeclareClassProperty(PreParserIdentifier class_name,
PreParserExpression property,
- ClassInfo* class_info, bool* ok) {}
+ ClassLiteralProperty::Kind kind,
+ bool is_static, ClassInfo* class_info,
+ bool* ok) {
+ if (class_info->has_seen_constructor &&
+ !class_info->constructor.IsEmpty()) {
+ // We use Empty to differentiate an existing constructor from Default
+ // which encodes the absence of a constructor.
+ class_info->constructor = PreParserExpression::Empty();
marja 2016/11/18 10:51:10 Hmm, why does this matter?
jochen (gone - plz use gerrit) 2016/11/21 08:03:47 When the ParserBase defines the constructor, it se
+ return;
+ }
+ if (kind == ClassLiteralProperty::FIELD && !is_static) {
+ class_info->instance_field_initializers->Add(
+ PreParserExpression::Default(), zone());
+ }
+ }
V8_INLINE PreParserExpression RewriteClassLiteral(PreParserIdentifier name,
ClassInfo* class_info,
int pos, bool* ok) {
+ bool has_default_constructor = !class_info->has_seen_constructor;
+ bool has_instance_fields =
marja 2016/11/18 10:51:10 Where's the equivalent thing for these on the pars
jochen (gone - plz use gerrit) 2016/11/21 08:03:47 In Parser::RewriteClassLiteral - it's exactly the
+ class_info->instance_field_initializers->length() > 0;
+ // Account for the default constructor.
+ if (has_default_constructor) GetNextFunctionLiteralNum();
+ if (allow_harmony_class_fields() && has_instance_fields) {
+ // Account for initializer function.
+ GetNextFunctionLiteralNum();
+ }
return PreParserExpression::Default();
}

Powered by Google App Engine
This is Rietveld 408576698