OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/compiler/instruction.h" | 5 #include "src/compiler/instruction.h" |
6 | 6 |
7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 return GetBlockStart(block)->label(); | 311 return GetBlockStart(block)->label(); |
312 } | 312 } |
313 | 313 |
314 | 314 |
315 BlockStartInstruction* InstructionSequence::GetBlockStart(BasicBlock* block) { | 315 BlockStartInstruction* InstructionSequence::GetBlockStart(BasicBlock* block) { |
316 return BlockStartInstruction::cast(InstructionAt(block->code_start_)); | 316 return BlockStartInstruction::cast(InstructionAt(block->code_start_)); |
317 } | 317 } |
318 | 318 |
319 | 319 |
320 void InstructionSequence::StartBlock(BasicBlock* block) { | 320 void InstructionSequence::StartBlock(BasicBlock* block) { |
321 block->code_start_ = instructions_.size(); | 321 block->code_start_ = static_cast<int>(instructions_.size()); |
322 BlockStartInstruction* block_start = | 322 BlockStartInstruction* block_start = |
323 BlockStartInstruction::New(zone(), block); | 323 BlockStartInstruction::New(zone(), block); |
324 AddInstruction(block_start, block); | 324 AddInstruction(block_start, block); |
325 } | 325 } |
326 | 326 |
327 | 327 |
328 void InstructionSequence::EndBlock(BasicBlock* block) { | 328 void InstructionSequence::EndBlock(BasicBlock* block) { |
329 int end = instructions_.size(); | 329 int end = static_cast<int>(instructions_.size()); |
330 ASSERT(block->code_start_ >= 0 && block->code_start_ < end); | 330 ASSERT(block->code_start_ >= 0 && block->code_start_ < end); |
331 block->code_end_ = end; | 331 block->code_end_ = end; |
332 } | 332 } |
333 | 333 |
334 | 334 |
335 int InstructionSequence::AddInstruction(Instruction* instr, BasicBlock* block) { | 335 int InstructionSequence::AddInstruction(Instruction* instr, BasicBlock* block) { |
336 // TODO(titzer): the order of these gaps is a holdover from Lithium. | 336 // TODO(titzer): the order of these gaps is a holdover from Lithium. |
337 GapInstruction* gap = GapInstruction::New(zone()); | 337 GapInstruction* gap = GapInstruction::New(zone()); |
338 if (instr->IsControl()) instructions_.push_back(gap); | 338 if (instr->IsControl()) instructions_.push_back(gap); |
339 int index = instructions_.size(); | 339 int index = static_cast<int>(instructions_.size()); |
340 instructions_.push_back(instr); | 340 instructions_.push_back(instr); |
341 if (!instr->IsControl()) instructions_.push_back(gap); | 341 if (!instr->IsControl()) instructions_.push_back(gap); |
342 if (instr->NeedsPointerMap()) { | 342 if (instr->NeedsPointerMap()) { |
343 ASSERT(instr->pointer_map() == NULL); | 343 ASSERT(instr->pointer_map() == NULL); |
344 PointerMap* pointer_map = new (zone()) PointerMap(zone()); | 344 PointerMap* pointer_map = new (zone()) PointerMap(zone()); |
345 pointer_map->set_instruction_position(index); | 345 pointer_map->set_instruction_position(index); |
346 instr->set_pointer_map(pointer_map); | 346 instr->set_pointer_map(pointer_map); |
347 pointer_maps_.push_back(pointer_map); | 347 pointer_maps_.push_back(pointer_map); |
348 } | 348 } |
349 return index; | 349 return index; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 384 |
385 void InstructionSequence::AddGapMove(int index, InstructionOperand* from, | 385 void InstructionSequence::AddGapMove(int index, InstructionOperand* from, |
386 InstructionOperand* to) { | 386 InstructionOperand* to) { |
387 GapAt(index)->GetOrCreateParallelMove(GapInstruction::START, zone())->AddMove( | 387 GapAt(index)->GetOrCreateParallelMove(GapInstruction::START, zone())->AddMove( |
388 from, to, zone()); | 388 from, to, zone()); |
389 } | 389 } |
390 | 390 |
391 | 391 |
392 int InstructionSequence::AddDeoptimizationEntry( | 392 int InstructionSequence::AddDeoptimizationEntry( |
393 const FrameStateDescriptor& descriptor) { | 393 const FrameStateDescriptor& descriptor) { |
394 int deoptimization_id = deoptimization_entries_.size(); | 394 int deoptimization_id = static_cast<int>(deoptimization_entries_.size()); |
395 deoptimization_entries_.push_back(descriptor); | 395 deoptimization_entries_.push_back(descriptor); |
396 return deoptimization_id; | 396 return deoptimization_id; |
397 } | 397 } |
398 | 398 |
399 FrameStateDescriptor InstructionSequence::GetDeoptimizationEntry( | 399 FrameStateDescriptor InstructionSequence::GetDeoptimizationEntry( |
400 int deoptimization_id) { | 400 int deoptimization_id) { |
401 return deoptimization_entries_[deoptimization_id]; | 401 return deoptimization_entries_[deoptimization_id]; |
402 } | 402 } |
403 | 403 |
404 | 404 |
405 int InstructionSequence::GetDeoptimizationEntryCount() { | 405 int InstructionSequence::GetDeoptimizationEntryCount() { |
406 return deoptimization_entries_.size(); | 406 return static_cast<int>(deoptimization_entries_.size()); |
407 } | 407 } |
408 | 408 |
409 | 409 |
410 OStream& operator<<(OStream& os, const InstructionSequence& code) { | 410 OStream& operator<<(OStream& os, const InstructionSequence& code) { |
411 for (size_t i = 0; i < code.immediates_.size(); ++i) { | 411 for (size_t i = 0; i < code.immediates_.size(); ++i) { |
412 Constant constant = code.immediates_[i]; | 412 Constant constant = code.immediates_[i]; |
413 os << "IMM#" << i << ": " << constant << "\n"; | 413 os << "IMM#" << i << ": " << constant << "\n"; |
414 } | 414 } |
415 int i = 0; | 415 int i = 0; |
416 for (ConstantMap::const_iterator it = code.constants_.begin(); | 416 for (ConstantMap::const_iterator it = code.constants_.begin(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 os << " B" << (*iter)->id(); | 470 os << " B" << (*iter)->id(); |
471 } | 471 } |
472 os << "\n"; | 472 os << "\n"; |
473 } | 473 } |
474 return os; | 474 return os; |
475 } | 475 } |
476 | 476 |
477 } // namespace compiler | 477 } // namespace compiler |
478 } // namespace internal | 478 } // namespace internal |
479 } // namespace v8 | 479 } // namespace v8 |
OLD | NEW |