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

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

Issue 11293038: Fix issue 6288, move DeoptimizeAll to top level parsing. Allow optimizing compiler to optimize even… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | 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 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 15 matching lines...) Expand all
26 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks."); 26 DEFINE_FLAG(bool, enable_type_checks, false, "Enable type checks.");
27 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); 27 DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations.");
28 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors."); 28 DEFINE_FLAG(bool, warning_as_error, false, "Treat warnings as errors.");
29 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings."); 29 DEFINE_FLAG(bool, silent_warnings, false, "Silence warnings.");
30 DEFINE_FLAG(bool, warn_legacy_map_literal, false, 30 DEFINE_FLAG(bool, warn_legacy_map_literal, false,
31 "Warning on legacy map literal syntax (single type argument)"); 31 "Warning on legacy map literal syntax (single type argument)");
32 DEFINE_FLAG(bool, warn_legacy_dynamic, false, 32 DEFINE_FLAG(bool, warn_legacy_dynamic, false,
33 "Warning on legacy type Dynamic)"); 33 "Warning on legacy type Dynamic)");
34 DEFINE_FLAG(bool, warn_legacy_getters, false, 34 DEFINE_FLAG(bool, warn_legacy_getters, false,
35 "Warning on legacy getter syntax"); 35 "Warning on legacy getter syntax");
36 DECLARE_FLAG(bool, use_cha);
36 37
37 static void CheckedModeHandler(bool value) { 38 static void CheckedModeHandler(bool value) {
38 FLAG_enable_asserts = value; 39 FLAG_enable_asserts = value;
39 FLAG_enable_type_checks = value; 40 FLAG_enable_type_checks = value;
40 } 41 }
41 42
42 // --enable-checked-mode and --checked both enable checked mode which is 43 // --enable-checked-mode and --checked both enable checked mode which is
43 // equivalent to setting --enable-asserts and --enable-type-checks. 44 // equivalent to setting --enable-asserts and --enable-type-checks.
44 DEFINE_FLAG_HANDLER(CheckedModeHandler, 45 DEFINE_FLAG_HANDLER(CheckedModeHandler,
45 enable_checked_mode, 46 enable_checked_mode,
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 336
336 void Parser::SetPosition(intptr_t position) { 337 void Parser::SetPosition(intptr_t position) {
337 if (position < TokenPos() && position != 0) { 338 if (position < TokenPos() && position != 0) {
338 CompilerStats::num_tokens_rewind += (TokenPos() - position); 339 CompilerStats::num_tokens_rewind += (TokenPos() - position);
339 } 340 }
340 tokens_iterator_.SetCurrentPosition(position); 341 tokens_iterator_.SetCurrentPosition(position);
341 token_kind_ = Token::kILLEGAL; 342 token_kind_ = Token::kILLEGAL;
342 } 343 }
343 344
344 345
346 // Removes optimized code once we load more classes, since --use_cha based
347 // optimizations may have become invalid.
348 // TODO(srdjan): Note which functions use which CHA decision and deoptimize
349 // only the necessary ones.
350 static void RemoveOptimizedCode() {
351 ASSERT(FLAG_use_cha);
352 // Deoptimize all live frames.
353 DeoptimizeAll();
354 // Switch all functions' code to unoptimized.
355 const ClassTable& class_table = *Isolate::Current()->class_table();
356 Class& cls = Class::Handle();
357 Array& array = Array::Handle();
358 Function& function = Function::Handle();
359 const intptr_t num_cids = class_table.NumCids();
360 for (intptr_t i = kInstanceCid; i < num_cids; i++) {
361 if (!class_table.HasValidClassAt(i)) continue;
362 cls = class_table.At(i);
363 ASSERT(!cls.IsNull());
364 array = cls.functions();
365 intptr_t num_functions = array.IsNull() ? 0 : array.Length();
366 for (intptr_t f = 0; f < num_functions; f++) {
367 function ^= array.At(f);
368 ASSERT(!function.IsNull());
369 if (function.HasOptimizedCode()) {
370 function.SwitchToUnoptimizedCode();
371 }
372 }
373 }
374 }
375
376
345 void Parser::ParseCompilationUnit(const Library& library, 377 void Parser::ParseCompilationUnit(const Library& library,
346 const Script& script) { 378 const Script& script) {
379 if (FLAG_use_cha) {
380 RemoveOptimizedCode();
381 }
347 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump()); 382 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump());
348 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); 383 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer);
349 Parser parser(script, library); 384 Parser parser(script, library);
350 parser.ParseTopLevel(); 385 parser.ParseTopLevel();
351 } 386 }
352 387
353 388
354 Token::Kind Parser::CurrentToken() { 389 Token::Kind Parser::CurrentToken() {
355 if (token_kind_ == Token::kILLEGAL) { 390 if (token_kind_ == Token::kILLEGAL) {
356 token_kind_ = tokens_iterator_.CurrentTokenKind(); 391 token_kind_ = tokens_iterator_.CurrentTokenKind();
(...skipping 9511 matching lines...) Expand 10 before | Expand all | Expand 10 after
9868 void Parser::SkipQualIdent() { 9903 void Parser::SkipQualIdent() {
9869 ASSERT(IsIdentifier()); 9904 ASSERT(IsIdentifier());
9870 ConsumeToken(); 9905 ConsumeToken();
9871 if (CurrentToken() == Token::kPERIOD) { 9906 if (CurrentToken() == Token::kPERIOD) {
9872 ConsumeToken(); // Consume the kPERIOD token. 9907 ConsumeToken(); // Consume the kPERIOD token.
9873 ExpectIdentifier("identifier expected after '.'"); 9908 ExpectIdentifier("identifier expected after '.'");
9874 } 9909 }
9875 } 9910 }
9876 9911
9877 } // namespace dart 9912 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698