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

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

Issue 11867020: Fix bug in optimization in the presence of externalized strings. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/intermediate_language.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/flow_graph_builder.h" 9 #include "vm/flow_graph_builder.h"
10 #include "vm/flow_graph_compiler.h" 10 #include "vm/flow_graph_compiler.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { 340 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
341 Definition* def = it.Current()->AsDefinition(); 341 Definition* def = it.Current()->AsDefinition();
342 if (def != NULL) { 342 if (def != NULL) {
343 InsertConversionsFor(def); 343 InsertConversionsFor(def);
344 } 344 }
345 } 345 }
346 } 346 }
347 } 347 }
348 348
349 349
350 static bool ICDataHasReceiverClassId(const ICData& ic_data, intptr_t class_id) {
351 ASSERT(ic_data.num_args_tested() > 0);
352 const intptr_t len = ic_data.NumberOfChecks();
353 for (intptr_t i = 0; i < len; i++) {
354 const intptr_t test_class_id = ic_data.GetReceiverClassIdAt(i);
355 if (test_class_id == class_id) {
356 return true;
357 }
358 }
359 return false;
360 }
361
362
363 static bool ICDataHasReceiverArgumentClassIds(const ICData& ic_data, 350 static bool ICDataHasReceiverArgumentClassIds(const ICData& ic_data,
364 intptr_t receiver_class_id, 351 intptr_t receiver_class_id,
365 intptr_t argument_class_id) { 352 intptr_t argument_class_id) {
366 ASSERT(receiver_class_id != kIllegalCid); 353 ASSERT(receiver_class_id != kIllegalCid);
367 ASSERT(argument_class_id != kIllegalCid); 354 ASSERT(argument_class_id != kIllegalCid);
368 if (ic_data.num_args_tested() != 2) return false; 355 if (ic_data.num_args_tested() != 2) return false;
369 356
370 Function& target = Function::Handle(); 357 Function& target = Function::Handle();
371 const intptr_t len = ic_data.NumberOfChecks(); 358 const intptr_t len = ic_data.NumberOfChecks();
372 for (intptr_t i = 0; i < len; i++) { 359 for (intptr_t i = 0; i < len; i++) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 !ClassIdIsOneOf(class_ids[1], argument_class_ids)) { 397 !ClassIdIsOneOf(class_ids[1], argument_class_ids)) {
411 return false; 398 return false;
412 } 399 }
413 } 400 }
414 return true; 401 return true;
415 } 402 }
416 403
417 404
418 static bool HasOnlyOneSmi(const ICData& ic_data) { 405 static bool HasOnlyOneSmi(const ICData& ic_data) {
419 return (ic_data.NumberOfChecks() == 1) 406 return (ic_data.NumberOfChecks() == 1)
420 && ICDataHasReceiverClassId(ic_data, kSmiCid); 407 && ic_data.HasReceiverClassId(kSmiCid);
421 } 408 }
422 409
423 410
424 static bool HasOnlySmiOrMint(const ICData& ic_data) { 411 static bool HasOnlySmiOrMint(const ICData& ic_data) {
425 if (ic_data.NumberOfChecks() == 1) { 412 if (ic_data.NumberOfChecks() == 1) {
426 return ICDataHasReceiverClassId(ic_data, kSmiCid) 413 return ic_data.HasReceiverClassId(kSmiCid)
427 || ICDataHasReceiverClassId(ic_data, kMintCid); 414 || ic_data.HasReceiverClassId(kMintCid);
428 } 415 }
429 return (ic_data.NumberOfChecks() == 2) 416 return (ic_data.NumberOfChecks() == 2)
430 && ICDataHasReceiverClassId(ic_data, kSmiCid) 417 && ic_data.HasReceiverClassId(kSmiCid)
431 && ICDataHasReceiverClassId(ic_data, kMintCid); 418 && ic_data.HasReceiverClassId(kMintCid);
432 } 419 }
433 420
434 421
435 static bool HasOnlyTwoSmis(const ICData& ic_data) { 422 static bool HasOnlyTwoSmis(const ICData& ic_data) {
436 return (ic_data.NumberOfChecks() == 1) && 423 return (ic_data.NumberOfChecks() == 1) &&
437 ICDataHasReceiverArgumentClassIds(ic_data, kSmiCid, kSmiCid); 424 ICDataHasReceiverArgumentClassIds(ic_data, kSmiCid, kSmiCid);
438 } 425 }
439 426
440 427
441 // Returns false if the ICData contains anything other than the 4 combinations 428 // Returns false if the ICData contains anything other than the 4 combinations
442 // of Mint and Smi for the receiver and argument classes. 429 // of Mint and Smi for the receiver and argument classes.
443 static bool HasTwoMintOrSmi(const ICData& ic_data) { 430 static bool HasTwoMintOrSmi(const ICData& ic_data) {
444 GrowableArray<intptr_t> class_ids(2); 431 GrowableArray<intptr_t> class_ids(2);
445 class_ids.Add(kSmiCid); 432 class_ids.Add(kSmiCid);
446 class_ids.Add(kMintCid); 433 class_ids.Add(kMintCid);
447 return ICDataHasOnlyReceiverArgumentClassIds(ic_data, class_ids, class_ids); 434 return ICDataHasOnlyReceiverArgumentClassIds(ic_data, class_ids, class_ids);
448 } 435 }
449 436
450 437
451 static bool HasOnlyOneDouble(const ICData& ic_data) { 438 static bool HasOnlyOneDouble(const ICData& ic_data) {
452 return (ic_data.NumberOfChecks() == 1) 439 return (ic_data.NumberOfChecks() == 1)
453 && ICDataHasReceiverClassId(ic_data, kDoubleCid); 440 && ic_data.HasReceiverClassId(kDoubleCid);
454 } 441 }
455 442
456 443
457 static bool ShouldSpecializeForDouble(const ICData& ic_data) { 444 static bool ShouldSpecializeForDouble(const ICData& ic_data) {
458 // Unboxed double operation can't handle case of two smis. 445 // Unboxed double operation can't handle case of two smis.
459 if (ICDataHasReceiverArgumentClassIds(ic_data, kSmiCid, kSmiCid)) { 446 if (ICDataHasReceiverArgumentClassIds(ic_data, kSmiCid, kSmiCid)) {
460 return false; 447 return false;
461 } 448 }
462 449
463 // Check that it have seen only smis and doubles. 450 // Check that it have seen only smis and doubles.
(...skipping 4094 matching lines...) Expand 10 before | Expand all | Expand 10 after
4558 4545
4559 if (FLAG_trace_constant_propagation) { 4546 if (FLAG_trace_constant_propagation) {
4560 OS::Print("\n==== After constant propagation ====\n"); 4547 OS::Print("\n==== After constant propagation ====\n");
4561 FlowGraphPrinter printer(*graph_); 4548 FlowGraphPrinter printer(*graph_);
4562 printer.PrintBlocks(); 4549 printer.PrintBlocks();
4563 } 4550 }
4564 } 4551 }
4565 4552
4566 4553
4567 } // namespace dart 4554 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/intermediate_language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698