OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
360 for (int i = 0; i < kNumberOfTrackedSideEffects; i++) { | 360 for (int i = 0; i < kNumberOfTrackedSideEffects; i++) { |
361 if (side_effects.ContainsFlag(GVNFlagFromInt(i))) { | 361 if (side_effects.ContainsFlag(GVNFlagFromInt(i))) { |
362 if (data_[i] == NULL) count_++; | 362 if (data_[i] == NULL) count_++; |
363 data_[i] = instr; | 363 data_[i] = instr; |
364 } | 364 } |
365 } | 365 } |
366 } | 366 } |
367 | 367 |
368 | 368 |
369 SideEffects SideEffectsTracker::ComputeChanges(HInstruction* instr) { | 369 SideEffects SideEffectsTracker::ComputeChanges(HInstruction* instr) { |
370 int index; | |
370 SideEffects result(instr->ChangesFlags()); | 371 SideEffects result(instr->ChangesFlags()); |
372 if (result.ContainsFlag(kGlobalVars)) { | |
373 if (instr->IsStoreGlobalCell() && | |
374 ComputeGlobalVar(HStoreGlobalCell::cast(instr)->cell(), &index)) { | |
375 result.RemoveFlag(kGlobalVars); | |
376 result.AddSpecial(GlobalVar(index)); | |
377 } else { | |
378 for (index = 0; index < kNumberOfGlobalVars; ++index) { | |
379 result.AddSpecial(GlobalVar(index)); | |
380 } | |
381 } | |
382 } | |
371 if (result.ContainsFlag(kInobjectFields)) { | 383 if (result.ContainsFlag(kInobjectFields)) { |
372 int index; | |
373 if (instr->IsStoreNamedField() && | 384 if (instr->IsStoreNamedField() && |
374 ComputeInobjectField(HStoreNamedField::cast(instr)->access(), &index)) { | 385 ComputeInobjectField(HStoreNamedField::cast(instr)->access(), &index)) { |
375 result.RemoveFlag(kInobjectFields); | 386 result.RemoveFlag(kInobjectFields); |
376 result.AddSpecial(index); | 387 result.AddSpecial(InobjectField(index)); |
377 } else { | 388 } else { |
378 result.AddAllSpecial(); | 389 for (index = 0; index < kNumberOfInobjectFields; ++index) { |
390 result.AddSpecial(InobjectField(index)); | |
391 } | |
379 } | 392 } |
380 } | 393 } |
381 return result; | 394 return result; |
382 } | 395 } |
383 | 396 |
384 | 397 |
385 SideEffects SideEffectsTracker::ComputeDependsOn(HInstruction* instr) { | 398 SideEffects SideEffectsTracker::ComputeDependsOn(HInstruction* instr) { |
399 int index; | |
386 SideEffects result(instr->DependsOnFlags()); | 400 SideEffects result(instr->DependsOnFlags()); |
401 if (result.ContainsFlag(kGlobalVars)) { | |
402 if (instr->IsLoadGlobalCell() && | |
403 ComputeGlobalVar(HLoadGlobalCell::cast(instr)->cell(), &index)) { | |
404 result.RemoveFlag(kGlobalVars); | |
405 result.AddSpecial(GlobalVar(index)); | |
406 } else { | |
407 for (index = 0; index < kNumberOfGlobalVars; ++index) { | |
408 result.AddSpecial(GlobalVar(index)); | |
409 } | |
410 } | |
411 } | |
387 if (result.ContainsFlag(kInobjectFields)) { | 412 if (result.ContainsFlag(kInobjectFields)) { |
388 int index; | |
389 if (instr->IsLoadNamedField() && | 413 if (instr->IsLoadNamedField() && |
390 ComputeInobjectField(HLoadNamedField::cast(instr)->access(), &index)) { | 414 ComputeInobjectField(HLoadNamedField::cast(instr)->access(), &index)) { |
391 result.RemoveFlag(kInobjectFields); | 415 result.RemoveFlag(kInobjectFields); |
392 result.AddSpecial(index); | 416 result.AddSpecial(InobjectField(index)); |
393 } else { | 417 } else { |
394 result.AddAllSpecial(); | 418 for (index = 0; index < kNumberOfInobjectFields; ++index) { |
419 result.AddSpecial(InobjectField(index)); | |
420 } | |
395 } | 421 } |
396 } | 422 } |
397 return result; | 423 return result; |
398 } | 424 } |
399 | 425 |
400 | 426 |
401 void SideEffectsTracker::PrintSideEffectsTo(StringStream* stream, | 427 void SideEffectsTracker::PrintSideEffectsTo(StringStream* stream, |
402 SideEffects side_effects) const { | 428 SideEffects side_effects) const { |
403 const char* separator = ""; | 429 const char* separator = ""; |
404 stream->Add("["); | 430 stream->Add("["); |
405 for (int bit = 0; bit < kNumberOfFlags; ++bit) { | 431 for (int bit = 0; bit < kNumberOfFlags; ++bit) { |
406 GVNFlag flag = GVNFlagFromInt(bit); | 432 GVNFlag flag = GVNFlagFromInt(bit); |
407 if (side_effects.ContainsFlag(flag)) { | 433 if (side_effects.ContainsFlag(flag)) { |
408 stream->Add(separator); | 434 stream->Add(separator); |
409 separator = ", "; | 435 separator = ", "; |
410 switch (flag) { | 436 switch (flag) { |
411 #define DECLARE_FLAG(Type) \ | 437 #define DECLARE_FLAG(Type) \ |
412 case k##Type: \ | 438 case k##Type: \ |
413 stream->Add(#Type); \ | 439 stream->Add(#Type); \ |
414 break; | 440 break; |
415 GVN_TRACKED_FLAG_LIST(DECLARE_FLAG) | 441 GVN_TRACKED_FLAG_LIST(DECLARE_FLAG) |
416 GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG) | 442 GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG) |
417 #undef DECLARE_FLAG | 443 #undef DECLARE_FLAG |
418 default: | 444 default: |
419 break; | 445 break; |
420 } | 446 } |
421 } | 447 } |
422 } | 448 } |
449 for (int index = 0; index < num_global_vars_; ++index) { | |
450 if (side_effects.ContainsSpecial(GlobalVar(index))) { | |
451 stream->Add(separator); | |
452 separator = ", "; | |
453 stream->Add("[%p]", *global_vars_[index].handle()); | |
Michael Starzinger
2014/03/06 15:45:28
See comment below.
Benedikt Meurer
2014/03/07 06:23:58
Done.
| |
454 } | |
455 } | |
423 for (int index = 0; index < num_inobject_fields_; ++index) { | 456 for (int index = 0; index < num_inobject_fields_; ++index) { |
424 if (side_effects.ContainsSpecial(index)) { | 457 if (side_effects.ContainsSpecial(InobjectField(index))) { |
425 stream->Add(separator); | 458 stream->Add(separator); |
426 separator = ", "; | 459 separator = ", "; |
427 inobject_fields_[index].PrintTo(stream); | 460 inobject_fields_[index].PrintTo(stream); |
428 } | 461 } |
429 } | 462 } |
430 stream->Add("]"); | 463 stream->Add("]"); |
431 } | 464 } |
432 | 465 |
433 | 466 |
467 bool SideEffectsTracker::ComputeGlobalVar(Unique<Cell> cell, int* index) { | |
468 for (int i = 0; i < num_global_vars_; ++i) { | |
469 if (cell == global_vars_[i]) { | |
470 *index = i; | |
471 return true; | |
472 } | |
473 } | |
474 if (num_global_vars_ < kNumberOfGlobalVars) { | |
475 if (FLAG_trace_gvn) { | |
476 HeapStringAllocator allocator; | |
477 StringStream stream(&allocator); | |
478 stream.Add("Tracking global var [%p] (mapped to index %d)\n", | |
479 *cell.handle(), num_global_vars_); | |
Michael Starzinger
2014/03/06 15:45:28
Dereferencing the handle here will not work if we
Benedikt Meurer
2014/03/07 06:23:58
Done.
| |
480 stream.OutputToStdOut(); | |
481 } | |
482 *index = num_global_vars_; | |
483 global_vars_[num_global_vars_++] = cell; | |
484 return true; | |
485 } | |
486 return false; | |
487 } | |
488 | |
489 | |
434 bool SideEffectsTracker::ComputeInobjectField(HObjectAccess access, | 490 bool SideEffectsTracker::ComputeInobjectField(HObjectAccess access, |
435 int* index) { | 491 int* index) { |
436 for (int i = 0; i < num_inobject_fields_; ++i) { | 492 for (int i = 0; i < num_inobject_fields_; ++i) { |
437 if (access.Equals(inobject_fields_[i])) { | 493 if (access.Equals(inobject_fields_[i])) { |
438 *index = i; | 494 *index = i; |
439 return true; | 495 return true; |
440 } | 496 } |
441 } | 497 } |
442 if (num_inobject_fields_ < SideEffects::kNumberOfSpecials) { | 498 if (num_inobject_fields_ < kNumberOfInobjectFields) { |
443 if (FLAG_trace_gvn) { | 499 if (FLAG_trace_gvn) { |
444 HeapStringAllocator allocator; | 500 HeapStringAllocator allocator; |
445 StringStream stream(&allocator); | 501 StringStream stream(&allocator); |
446 stream.Add("Tracking inobject field access "); | 502 stream.Add("Tracking inobject field access "); |
447 access.PrintTo(&stream); | 503 access.PrintTo(&stream); |
448 stream.Add(" (mapped to special index %d)\n", num_inobject_fields_); | 504 stream.Add(" (mapped to index %d)\n", num_inobject_fields_); |
449 stream.OutputToStdOut(); | 505 stream.OutputToStdOut(); |
450 } | 506 } |
451 *index = num_inobject_fields_; | 507 *index = num_inobject_fields_; |
452 inobject_fields_[num_inobject_fields_++] = access; | 508 inobject_fields_[num_inobject_fields_++] = access; |
453 return true; | 509 return true; |
454 } | 510 } |
455 return false; | 511 return false; |
456 } | 512 } |
457 | 513 |
458 | 514 |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
871 dominated); | 927 dominated); |
872 successor_map->Kill(side_effects_on_all_paths); | 928 successor_map->Kill(side_effects_on_all_paths); |
873 successor_dominators->Kill(side_effects_on_all_paths); | 929 successor_dominators->Kill(side_effects_on_all_paths); |
874 } | 930 } |
875 } | 931 } |
876 current = next; | 932 current = next; |
877 } | 933 } |
878 } | 934 } |
879 | 935 |
880 } } // namespace v8::internal | 936 } } // namespace v8::internal |
OLD | NEW |