| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/hydrogen.h" | 5 #include "src/hydrogen.h" |
| 6 #include "src/hydrogen-gvn.h" | 6 #include "src/hydrogen-gvn.h" |
| 7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 data_[i] = instr; | 339 data_[i] = instr; |
| 340 } | 340 } |
| 341 } | 341 } |
| 342 } | 342 } |
| 343 | 343 |
| 344 | 344 |
| 345 SideEffects SideEffectsTracker::ComputeChanges(HInstruction* instr) { | 345 SideEffects SideEffectsTracker::ComputeChanges(HInstruction* instr) { |
| 346 int index; | 346 int index; |
| 347 SideEffects result(instr->ChangesFlags()); | 347 SideEffects result(instr->ChangesFlags()); |
| 348 if (result.ContainsFlag(kGlobalVars)) { | 348 if (result.ContainsFlag(kGlobalVars)) { |
| 349 if (instr->IsStoreGlobalCell() && | 349 if (instr->IsStoreNamedField()) { |
| 350 ComputeGlobalVar(HStoreGlobalCell::cast(instr)->cell(), &index)) { | 350 HStoreNamedField* store = HStoreNamedField::cast(instr); |
| 351 result.RemoveFlag(kGlobalVars); | 351 HConstant* target = HConstant::cast(store->object()); |
| 352 result.AddSpecial(GlobalVar(index)); | 352 if (ComputeGlobalVar(Unique<PropertyCell>::cast(target->GetUnique()), |
| 353 } else { | 353 &index)) { |
| 354 for (index = 0; index < kNumberOfGlobalVars; ++index) { | 354 result.RemoveFlag(kGlobalVars); |
| 355 result.AddSpecial(GlobalVar(index)); | 355 result.AddSpecial(GlobalVar(index)); |
| 356 return result; |
| 356 } | 357 } |
| 357 } | 358 } |
| 358 } | 359 for (index = 0; index < kNumberOfGlobalVars; ++index) { |
| 359 if (result.ContainsFlag(kInobjectFields)) { | 360 result.AddSpecial(GlobalVar(index)); |
| 361 } |
| 362 } else if (result.ContainsFlag(kInobjectFields)) { |
| 360 if (instr->IsStoreNamedField() && | 363 if (instr->IsStoreNamedField() && |
| 361 ComputeInobjectField(HStoreNamedField::cast(instr)->access(), &index)) { | 364 ComputeInobjectField(HStoreNamedField::cast(instr)->access(), &index)) { |
| 362 result.RemoveFlag(kInobjectFields); | 365 result.RemoveFlag(kInobjectFields); |
| 363 result.AddSpecial(InobjectField(index)); | 366 result.AddSpecial(InobjectField(index)); |
| 364 } else { | 367 } else { |
| 365 for (index = 0; index < kNumberOfInobjectFields; ++index) { | 368 for (index = 0; index < kNumberOfInobjectFields; ++index) { |
| 366 result.AddSpecial(InobjectField(index)); | 369 result.AddSpecial(InobjectField(index)); |
| 367 } | 370 } |
| 368 } | 371 } |
| 369 } | 372 } |
| 370 return result; | 373 return result; |
| 371 } | 374 } |
| 372 | 375 |
| 373 | 376 |
| 374 SideEffects SideEffectsTracker::ComputeDependsOn(HInstruction* instr) { | 377 SideEffects SideEffectsTracker::ComputeDependsOn(HInstruction* instr) { |
| 375 int index; | 378 int index; |
| 376 SideEffects result(instr->DependsOnFlags()); | 379 SideEffects result(instr->DependsOnFlags()); |
| 377 if (result.ContainsFlag(kGlobalVars)) { | 380 if (result.ContainsFlag(kGlobalVars)) { |
| 378 if (instr->IsLoadGlobalCell() && | 381 if (instr->IsLoadNamedField()) { |
| 379 ComputeGlobalVar(HLoadGlobalCell::cast(instr)->cell(), &index)) { | 382 HLoadNamedField* load = HLoadNamedField::cast(instr); |
| 380 result.RemoveFlag(kGlobalVars); | 383 HConstant* target = HConstant::cast(load->object()); |
| 381 result.AddSpecial(GlobalVar(index)); | 384 if (ComputeGlobalVar(Unique<PropertyCell>::cast(target->GetUnique()), |
| 382 } else { | 385 &index)) { |
| 383 for (index = 0; index < kNumberOfGlobalVars; ++index) { | 386 result.RemoveFlag(kGlobalVars); |
| 384 result.AddSpecial(GlobalVar(index)); | 387 result.AddSpecial(GlobalVar(index)); |
| 388 return result; |
| 385 } | 389 } |
| 386 } | 390 } |
| 387 } | 391 for (index = 0; index < kNumberOfGlobalVars; ++index) { |
| 388 if (result.ContainsFlag(kInobjectFields)) { | 392 result.AddSpecial(GlobalVar(index)); |
| 393 } |
| 394 } else if (result.ContainsFlag(kInobjectFields)) { |
| 389 if (instr->IsLoadNamedField() && | 395 if (instr->IsLoadNamedField() && |
| 390 ComputeInobjectField(HLoadNamedField::cast(instr)->access(), &index)) { | 396 ComputeInobjectField(HLoadNamedField::cast(instr)->access(), &index)) { |
| 391 result.RemoveFlag(kInobjectFields); | 397 result.RemoveFlag(kInobjectFields); |
| 392 result.AddSpecial(InobjectField(index)); | 398 result.AddSpecial(InobjectField(index)); |
| 393 } else { | 399 } else { |
| 394 for (index = 0; index < kNumberOfInobjectFields; ++index) { | 400 for (index = 0; index < kNumberOfInobjectFields; ++index) { |
| 395 result.AddSpecial(InobjectField(index)); | 401 result.AddSpecial(InobjectField(index)); |
| 396 } | 402 } |
| 397 } | 403 } |
| 398 } | 404 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 if (te.effects.ContainsSpecial(t->InobjectField(index))) { | 438 if (te.effects.ContainsSpecial(t->InobjectField(index))) { |
| 433 os << separator << t->inobject_fields_[index]; | 439 os << separator << t->inobject_fields_[index]; |
| 434 separator = ", "; | 440 separator = ", "; |
| 435 } | 441 } |
| 436 } | 442 } |
| 437 os << "]"; | 443 os << "]"; |
| 438 return os; | 444 return os; |
| 439 } | 445 } |
| 440 | 446 |
| 441 | 447 |
| 442 bool SideEffectsTracker::ComputeGlobalVar(Unique<Cell> cell, int* index) { | 448 bool SideEffectsTracker::ComputeGlobalVar(Unique<PropertyCell> cell, |
| 449 int* index) { |
| 443 for (int i = 0; i < num_global_vars_; ++i) { | 450 for (int i = 0; i < num_global_vars_; ++i) { |
| 444 if (cell == global_vars_[i]) { | 451 if (cell == global_vars_[i]) { |
| 445 *index = i; | 452 *index = i; |
| 446 return true; | 453 return true; |
| 447 } | 454 } |
| 448 } | 455 } |
| 449 if (num_global_vars_ < kNumberOfGlobalVars) { | 456 if (num_global_vars_ < kNumberOfGlobalVars) { |
| 450 if (FLAG_trace_gvn) { | 457 if (FLAG_trace_gvn) { |
| 451 OFStream os(stdout); | 458 OFStream os(stdout); |
| 452 os << "Tracking global var [" << *cell.handle() << "] " | 459 os << "Tracking global var [" << *cell.handle() << "] " |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 dominated); | 888 dominated); |
| 882 successor_map->Kill(side_effects_on_all_paths); | 889 successor_map->Kill(side_effects_on_all_paths); |
| 883 successor_dominators->Kill(side_effects_on_all_paths); | 890 successor_dominators->Kill(side_effects_on_all_paths); |
| 884 } | 891 } |
| 885 } | 892 } |
| 886 current = next; | 893 current = next; |
| 887 } | 894 } |
| 888 } | 895 } |
| 889 | 896 |
| 890 } } // namespace v8::internal | 897 } } // namespace v8::internal |
| OLD | NEW |