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

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

Issue 11370008: Move lazy deoptimization of all optimized code from top level parsing to end of class finalization … (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/class_finalizer.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 17 matching lines...) Expand all
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 DEFINE_FLAG(bool, strict_function_literals, false, 36 DEFINE_FLAG(bool, strict_function_literals, false,
37 "enforce new function literal rules"); 37 "enforce new function literal rules");
38 DECLARE_FLAG(bool, use_cha);
39 38
40 static void CheckedModeHandler(bool value) { 39 static void CheckedModeHandler(bool value) {
41 FLAG_enable_asserts = value; 40 FLAG_enable_asserts = value;
42 FLAG_enable_type_checks = value; 41 FLAG_enable_type_checks = value;
43 } 42 }
44 43
45 // --enable-checked-mode and --checked both enable checked mode which is 44 // --enable-checked-mode and --checked both enable checked mode which is
46 // equivalent to setting --enable-asserts and --enable-type-checks. 45 // equivalent to setting --enable-asserts and --enable-type-checks.
47 DEFINE_FLAG_HANDLER(CheckedModeHandler, 46 DEFINE_FLAG_HANDLER(CheckedModeHandler,
48 enable_checked_mode, 47 enable_checked_mode,
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 330
332 void Parser::SetPosition(intptr_t position) { 331 void Parser::SetPosition(intptr_t position) {
333 if (position < TokenPos() && position != 0) { 332 if (position < TokenPos() && position != 0) {
334 CompilerStats::num_tokens_rewind += (TokenPos() - position); 333 CompilerStats::num_tokens_rewind += (TokenPos() - position);
335 } 334 }
336 tokens_iterator_.SetCurrentPosition(position); 335 tokens_iterator_.SetCurrentPosition(position);
337 token_kind_ = Token::kILLEGAL; 336 token_kind_ = Token::kILLEGAL;
338 } 337 }
339 338
340 339
341 // Removes optimized code once we load more classes, since --use_cha based
342 // optimizations may have become invalid.
343 // TODO(srdjan): Note which functions use which CHA decision and deoptimize
344 // only the necessary ones.
345 static void RemoveOptimizedCode() {
346 ASSERT(FLAG_use_cha);
347 // Deoptimize all live frames.
348 DeoptimizeAll();
349 // Switch all functions' code to unoptimized.
350 const ClassTable& class_table = *Isolate::Current()->class_table();
351 Class& cls = Class::Handle();
352 Array& array = Array::Handle();
353 Function& function = Function::Handle();
354 const intptr_t num_cids = class_table.NumCids();
355 for (intptr_t i = kInstanceCid; i < num_cids; i++) {
356 if (!class_table.HasValidClassAt(i)) continue;
357 cls = class_table.At(i);
358 ASSERT(!cls.IsNull());
359 array = cls.functions();
360 intptr_t num_functions = array.IsNull() ? 0 : array.Length();
361 for (intptr_t f = 0; f < num_functions; f++) {
362 function ^= array.At(f);
363 ASSERT(!function.IsNull());
364 if (function.HasOptimizedCode()) {
365 function.SwitchToUnoptimizedCode();
366 }
367 }
368 }
369 }
370
371
372 void Parser::ParseCompilationUnit(const Library& library, 340 void Parser::ParseCompilationUnit(const Library& library,
373 const Script& script) { 341 const Script& script) {
374 if (FLAG_use_cha) {
375 RemoveOptimizedCode();
376 }
377 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump()); 342 ASSERT(Isolate::Current()->long_jump_base()->IsSafeToJump());
378 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer); 343 TimerScope timer(FLAG_compiler_stats, &CompilerStats::parser_timer);
379 Parser parser(script, library); 344 Parser parser(script, library);
380 parser.ParseTopLevel(); 345 parser.ParseTopLevel();
381 } 346 }
382 347
383 348
384 Token::Kind Parser::CurrentToken() { 349 Token::Kind Parser::CurrentToken() {
385 if (token_kind_ == Token::kILLEGAL) { 350 if (token_kind_ == Token::kILLEGAL) {
386 token_kind_ = tokens_iterator_.CurrentTokenKind(); 351 token_kind_ = tokens_iterator_.CurrentTokenKind();
(...skipping 9661 matching lines...) Expand 10 before | Expand all | Expand 10 after
10048 void Parser::SkipQualIdent() { 10013 void Parser::SkipQualIdent() {
10049 ASSERT(IsIdentifier()); 10014 ASSERT(IsIdentifier());
10050 ConsumeToken(); 10015 ConsumeToken();
10051 if (CurrentToken() == Token::kPERIOD) { 10016 if (CurrentToken() == Token::kPERIOD) {
10052 ConsumeToken(); // Consume the kPERIOD token. 10017 ConsumeToken(); // Consume the kPERIOD token.
10053 ExpectIdentifier("identifier expected after '.'"); 10018 ExpectIdentifier("identifier expected after '.'");
10054 } 10019 }
10055 } 10020 }
10056 10021
10057 } // namespace dart 10022 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_finalizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698