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

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

Issue 1930553002: Revert "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 11994 matching lines...) Expand 10 before | Expand all | Expand 10 after
12005 private: 12005 private:
12006 static uword HashValue(intptr_t url_hash, intptr_t pos) { 12006 static uword HashValue(intptr_t url_hash, intptr_t pos) {
12007 return url_hash * pos % (Smi::kMaxValue - 13); 12007 return url_hash * pos % (Smi::kMaxValue - 13);
12008 } 12008 }
12009 }; 12009 };
12010 typedef UnorderedHashMap<ConstMapKeyEqualsTraits> ConstantsMap; 12010 typedef UnorderedHashMap<ConstMapKeyEqualsTraits> ConstantsMap;
12011 12011
12012 12012
12013 void Parser::CacheConstantValue(TokenPosition token_pos, 12013 void Parser::CacheConstantValue(TokenPosition token_pos,
12014 const Instance& value) { 12014 const Instance& value) {
12015 if (current_function().kind() == RawFunction::kImplicitStaticFinalGetter) {
12016 // Don't cache constants in initializer expressions. They get
12017 // evaluated only once.
12018 return;
12019 }
12020 ConstantPosKey key(String::Handle(Z, script_.url()), token_pos); 12015 ConstantPosKey key(String::Handle(Z, script_.url()), token_pos);
12021 if (isolate()->object_store()->compile_time_constants() == Array::null()) { 12016 if (isolate()->object_store()->compile_time_constants() == Array::null()) {
12022 const intptr_t kInitialConstMapSize = 16; 12017 const intptr_t kInitialConstMapSize = 16;
12023 isolate()->object_store()->set_compile_time_constants( 12018 isolate()->object_store()->set_compile_time_constants(
12024 Array::Handle(Z, HashTables::New<ConstantsMap>(kInitialConstMapSize, 12019 Array::Handle(Z, HashTables::New<ConstantsMap>(kInitialConstMapSize,
12025 Heap::kNew))); 12020 Heap::kNew)));
12026 } 12021 }
12027 ConstantsMap constants(isolate()->object_store()->compile_time_constants()); 12022 ConstantsMap constants(isolate()->object_store()->compile_time_constants());
12028 constants.InsertNewOrGetValue(key, value); 12023 constants.InsertNewOrGetValue(key, value);
12029 if (FLAG_compiler_stats) { 12024 if (FLAG_compiler_stats) {
(...skipping 2449 matching lines...) Expand 10 before | Expand all | Expand 10 after
14479 const ArgumentListNode& function_args, 14474 const ArgumentListNode& function_args,
14480 const LocalVariable* temp_for_last_arg, 14475 const LocalVariable* temp_for_last_arg,
14481 bool is_super_invocation) { 14476 bool is_super_invocation) {
14482 UNREACHABLE(); 14477 UNREACHABLE();
14483 return NULL; 14478 return NULL;
14484 } 14479 }
14485 14480
14486 } // namespace dart 14481 } // namespace dart
14487 14482
14488 #endif // DART_PRECOMPILED_RUNTIME 14483 #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