OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/interpreter/bytecode-register-optimizer.h" | 5 #include "src/interpreter/bytecode-register-optimizer.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 namespace internal { | 8 namespace internal { |
9 namespace interpreter { | 9 namespace interpreter { |
10 | 10 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 Materialize(info); | 297 Materialize(info); |
298 result = info; | 298 result = info; |
299 } | 299 } |
300 DCHECK(result->register_value() != accumulator_); | 300 DCHECK(result->register_value() != accumulator_); |
301 return result; | 301 return result; |
302 } | 302 } |
303 | 303 |
304 void BytecodeRegisterOptimizer::Materialize(RegisterInfo* info) { | 304 void BytecodeRegisterOptimizer::Materialize(RegisterInfo* info) { |
305 if (!info->materialized()) { | 305 if (!info->materialized()) { |
306 RegisterInfo* materialized = info->GetMaterializedEquivalent(); | 306 RegisterInfo* materialized = info->GetMaterializedEquivalent(); |
| 307 DCHECK_NOT_NULL(materialized); |
307 OutputRegisterTransfer(materialized, info); | 308 OutputRegisterTransfer(materialized, info); |
308 } | 309 } |
309 } | 310 } |
310 | 311 |
311 void BytecodeRegisterOptimizer::AddToEquivalenceSet( | 312 void BytecodeRegisterOptimizer::AddToEquivalenceSet( |
312 RegisterInfo* set_member, RegisterInfo* non_set_member) { | 313 RegisterInfo* set_member, RegisterInfo* non_set_member) { |
313 non_set_member->AddToEquivalenceSetOf(set_member); | 314 non_set_member->AddToEquivalenceSetOf(set_member); |
314 // Flushing is only required when two or more registers are placed | 315 // Flushing is only required when two or more registers are placed |
315 // in the same equivalence set. | 316 // in the same equivalence set. |
316 flush_required_ = true; | 317 flush_required_ = true; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 void BytecodeRegisterOptimizer::GrowRegisterMap(Register reg) { | 404 void BytecodeRegisterOptimizer::GrowRegisterMap(Register reg) { |
404 DCHECK(RegisterIsTemporary(reg)); | 405 DCHECK(RegisterIsTemporary(reg)); |
405 size_t index = GetRegisterInfoTableIndex(reg); | 406 size_t index = GetRegisterInfoTableIndex(reg); |
406 if (index >= register_info_table_.size()) { | 407 if (index >= register_info_table_.size()) { |
407 size_t new_size = index + 1; | 408 size_t new_size = index + 1; |
408 size_t old_size = register_info_table_.size(); | 409 size_t old_size = register_info_table_.size(); |
409 register_info_table_.resize(new_size); | 410 register_info_table_.resize(new_size); |
410 for (size_t i = old_size; i < new_size; ++i) { | 411 for (size_t i = old_size; i < new_size; ++i) { |
411 register_info_table_[i] = | 412 register_info_table_[i] = |
412 new (zone()) RegisterInfo(RegisterFromRegisterInfoTableIndex(i), | 413 new (zone()) RegisterInfo(RegisterFromRegisterInfoTableIndex(i), |
413 NextEquivalenceId(), false, false); | 414 NextEquivalenceId(), true, false); |
414 } | 415 } |
415 } | 416 } |
416 } | 417 } |
417 | 418 |
418 void BytecodeRegisterOptimizer::RegisterAllocateEvent(Register reg) { | 419 void BytecodeRegisterOptimizer::RegisterAllocateEvent(Register reg) { |
419 GetOrCreateRegisterInfo(reg)->set_allocated(true); | 420 GetOrCreateRegisterInfo(reg)->set_allocated(true); |
420 } | 421 } |
421 | 422 |
422 void BytecodeRegisterOptimizer::RegisterListAllocateEvent( | 423 void BytecodeRegisterOptimizer::RegisterListAllocateEvent( |
423 RegisterList reg_list) { | 424 RegisterList reg_list) { |
424 if (reg_list.register_count() != 0) { | 425 if (reg_list.register_count() != 0) { |
425 int first_index = reg_list.first_register().index(); | 426 int first_index = reg_list.first_register().index(); |
426 GrowRegisterMap(Register(first_index + reg_list.register_count() - 1)); | 427 GrowRegisterMap(Register(first_index + reg_list.register_count() - 1)); |
427 for (int i = 0; i < reg_list.register_count(); i++) { | 428 for (int i = 0; i < reg_list.register_count(); i++) { |
428 GetRegisterInfo(Register(first_index + i))->set_allocated(true); | 429 GetRegisterInfo(Register(first_index + i))->set_allocated(true); |
429 } | 430 } |
430 } | 431 } |
431 } | 432 } |
432 | 433 |
433 void BytecodeRegisterOptimizer::RegisterListFreeEvent(RegisterList reg_list) { | 434 void BytecodeRegisterOptimizer::RegisterListFreeEvent(RegisterList reg_list) { |
434 int first_index = reg_list.first_register().index(); | 435 int first_index = reg_list.first_register().index(); |
435 for (int i = 0; i < reg_list.register_count(); i++) { | 436 for (int i = 0; i < reg_list.register_count(); i++) { |
436 GetRegisterInfo(Register(first_index + i))->set_allocated(false); | 437 GetRegisterInfo(Register(first_index + i))->set_allocated(false); |
437 } | 438 } |
438 } | 439 } |
439 | 440 |
440 } // namespace interpreter | 441 } // namespace interpreter |
441 } // namespace internal | 442 } // namespace internal |
442 } // namespace v8 | 443 } // namespace v8 |
OLD | NEW |