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

Side by Side Diff: runtime/vm/parser.cc

Issue 1278003002: Change heuristic to determine which fields contain modifieable double boxes: do it if field was ini… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: s Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/ast_transformer.h" 9 #include "vm/ast_transformer.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 3954 matching lines...) Expand 10 before | Expand all | Expand 10 after
3965 // For instance fields, the expression is parsed when a constructor 3965 // For instance fields, the expression is parsed when a constructor
3966 // is compiled. 3966 // is compiled.
3967 // For static fields with very simple initializer expressions 3967 // For static fields with very simple initializer expressions
3968 // (e.g. a literal number or string), we optimize away the 3968 // (e.g. a literal number or string), we optimize away the
3969 // kImplicitStaticFinalGetter and initialize the field here. 3969 // kImplicitStaticFinalGetter and initialize the field here.
3970 // However, the class finalizer will check the value type for 3970 // However, the class finalizer will check the value type for
3971 // assignability once the declared field type can be resolved. If the 3971 // assignability once the declared field type can be resolved. If the
3972 // value is not assignable (assuming checked mode and disregarding actual 3972 // value is not assignable (assuming checked mode and disregarding actual
3973 // mode), the field value is reset and a kImplicitStaticFinalGetter is 3973 // mode), the field value is reset and a kImplicitStaticFinalGetter is
3974 // created at finalization time. 3974 // created at finalization time.
3975 if (LookaheadToken(1) == Token::kSEMICOLON) { 3975 if ((LookaheadToken(1) == Token::kSEMICOLON) ||
3976 (LookaheadToken(1) == Token::kCOMMA)) {
3976 has_simple_literal = IsSimpleLiteral(*field->type, &init_value); 3977 has_simple_literal = IsSimpleLiteral(*field->type, &init_value);
3977 } 3978 }
3978 SkipExpr(); 3979 SkipExpr();
3979 } else { 3980 } else {
3980 // Static const and static final fields must have an initializer. 3981 // Static const and static final fields must have an initializer.
3981 // Static const fields are implicitly final. 3982 // Static const fields are implicitly final.
3982 if (field->has_static && field->has_final) { 3983 if (field->has_static && field->has_final) {
3983 ReportError(field->name_pos, 3984 ReportError(field->name_pos,
3984 "static %s field '%s' must have an initializer expression", 3985 "static %s field '%s' must have an initializer expression",
3985 field->has_const ? "const" : "final", 3986 field->has_const ? "const" : "final",
(...skipping 17 matching lines...) Expand all
4003 field->field_ = &class_field; 4004 field->field_ = &class_field;
4004 if (field->metadata_pos >= 0) { 4005 if (field->metadata_pos >= 0) {
4005 library_.AddFieldMetadata(class_field, field->metadata_pos); 4006 library_.AddFieldMetadata(class_field, field->metadata_pos);
4006 } 4007 }
4007 4008
4008 // Start tracking types for fields with simple initializers in their 4009 // Start tracking types for fields with simple initializers in their
4009 // definition. This avoids some of the overhead to track this at runtime 4010 // definition. This avoids some of the overhead to track this at runtime
4010 // and rules out many fields from being unnecessary unboxing candidates. 4011 // and rules out many fields from being unnecessary unboxing candidates.
4011 if (!field->has_static && has_initializer && has_simple_literal) { 4012 if (!field->has_static && has_initializer && has_simple_literal) {
4012 class_field.RecordStore(init_value); 4013 class_field.RecordStore(init_value);
4014 if (!init_value.IsNull() && init_value.IsDouble()) {
4015 class_field.set_is_double_initialized(true);
4016 }
4013 } 4017 }
4014 4018
4015 // For static final fields (this includes static const fields), set value to 4019 // For static final fields (this includes static const fields), set value to
4016 // "uninitialized" and create a kImplicitStaticFinalGetter getter method. 4020 // "uninitialized" and create a kImplicitStaticFinalGetter getter method.
4017 if (field->has_static && has_initializer) { 4021 if (field->has_static && has_initializer) {
4018 class_field.set_value(init_value); 4022 class_field.set_value(init_value);
4019 if (!has_simple_literal) { 4023 if (!has_simple_literal) {
4020 String& getter_name = 4024 String& getter_name =
4021 String::Handle(Z, Field::GetterSymbol(*field->name)); 4025 String::Handle(Z, Field::GetterSymbol(*field->name));
4022 getter = Function::New(getter_name, 4026 getter = Function::New(getter_name,
(...skipping 10034 matching lines...) Expand 10 before | Expand all | Expand 10 after
14057 void Parser::SkipQualIdent() { 14061 void Parser::SkipQualIdent() {
14058 ASSERT(IsIdentifier()); 14062 ASSERT(IsIdentifier());
14059 ConsumeToken(); 14063 ConsumeToken();
14060 if (CurrentToken() == Token::kPERIOD) { 14064 if (CurrentToken() == Token::kPERIOD) {
14061 ConsumeToken(); // Consume the kPERIOD token. 14065 ConsumeToken(); // Consume the kPERIOD token.
14062 ExpectIdentifier("identifier expected after '.'"); 14066 ExpectIdentifier("identifier expected after '.'");
14063 } 14067 }
14064 } 14068 }
14065 14069
14066 } // namespace dart 14070 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698