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

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

Issue 1923743002: Don’t cache constants in initializer expressions (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | no next file » | 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 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 11993 matching lines...) Expand 10 before | Expand all | Expand 10 after
12004 private: 12004 private:
12005 static uword HashValue(intptr_t url_hash, intptr_t pos) { 12005 static uword HashValue(intptr_t url_hash, intptr_t pos) {
12006 return url_hash * pos % (Smi::kMaxValue - 13); 12006 return url_hash * pos % (Smi::kMaxValue - 13);
12007 } 12007 }
12008 }; 12008 };
12009 typedef UnorderedHashMap<ConstMapKeyEqualsTraits> ConstantsMap; 12009 typedef UnorderedHashMap<ConstMapKeyEqualsTraits> ConstantsMap;
12010 12010
12011 12011
12012 void Parser::CacheConstantValue(TokenPosition token_pos, 12012 void Parser::CacheConstantValue(TokenPosition token_pos,
12013 const Instance& value) { 12013 const Instance& value) {
12014 if (current_function().kind() == RawFunction::kImplicitStaticFinalGetter) {
12015 // Don't cache constants in initializer expressions. They get
12016 // evaluated only once.
12017 return;
12018 }
12014 ConstantPosKey key(String::Handle(Z, script_.url()), token_pos); 12019 ConstantPosKey key(String::Handle(Z, script_.url()), token_pos);
12015 if (isolate()->object_store()->compile_time_constants() == Array::null()) { 12020 if (isolate()->object_store()->compile_time_constants() == Array::null()) {
12016 const intptr_t kInitialConstMapSize = 16; 12021 const intptr_t kInitialConstMapSize = 16;
12017 isolate()->object_store()->set_compile_time_constants( 12022 isolate()->object_store()->set_compile_time_constants(
12018 Array::Handle(Z, HashTables::New<ConstantsMap>(kInitialConstMapSize, 12023 Array::Handle(Z, HashTables::New<ConstantsMap>(kInitialConstMapSize,
12019 Heap::kNew))); 12024 Heap::kNew)));
12020 } 12025 }
12021 ConstantsMap constants(isolate()->object_store()->compile_time_constants()); 12026 ConstantsMap constants(isolate()->object_store()->compile_time_constants());
12022 constants.InsertNewOrGetValue(key, value); 12027 constants.InsertNewOrGetValue(key, value);
12023 if (FLAG_compiler_stats) { 12028 if (FLAG_compiler_stats) {
(...skipping 2449 matching lines...) Expand 10 before | Expand all | Expand 10 after
14473 const ArgumentListNode& function_args, 14478 const ArgumentListNode& function_args,
14474 const LocalVariable* temp_for_last_arg, 14479 const LocalVariable* temp_for_last_arg,
14475 bool is_super_invocation) { 14480 bool is_super_invocation) {
14476 UNREACHABLE(); 14481 UNREACHABLE();
14477 return NULL; 14482 return NULL;
14478 } 14483 }
14479 14484
14480 } // namespace dart 14485 } // namespace dart
14481 14486
14482 #endif // DART_PRECOMPILED_RUNTIME 14487 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698