OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 int LChunk::GetNextSpillIndex(bool is_double) { | 369 int LChunk::GetNextSpillIndex(bool is_double) { |
370 // Skip a slot if for a double-width slot. | 370 // Skip a slot if for a double-width slot. |
371 if (is_double) spill_slot_count_++; | 371 if (is_double) spill_slot_count_++; |
372 return spill_slot_count_++; | 372 return spill_slot_count_++; |
373 } | 373 } |
374 | 374 |
375 | 375 |
376 LOperand* LChunk::GetNextSpillSlot(bool is_double) { | 376 LOperand* LChunk::GetNextSpillSlot(bool is_double) { |
377 int index = GetNextSpillIndex(is_double); | 377 int index = GetNextSpillIndex(is_double); |
378 if (is_double) { | 378 if (is_double) { |
379 return LDoubleStackSlot::Create(index); | 379 return LDoubleStackSlot::Create(index, zone()); |
380 } else { | 380 } else { |
381 return LStackSlot::Create(index); | 381 return LStackSlot::Create(index, zone()); |
382 } | 382 } |
383 } | 383 } |
384 | 384 |
385 | 385 |
386 void LChunk::MarkEmptyBlocks() { | 386 void LChunk::MarkEmptyBlocks() { |
387 HPhase phase("L_Mark empty blocks", this); | 387 HPhase phase("L_Mark empty blocks", this); |
388 for (int i = 0; i < graph()->blocks()->length(); ++i) { | 388 for (int i = 0; i < graph()->blocks()->length(); ++i) { |
389 HBasicBlock* block = graph()->blocks()->at(i); | 389 HBasicBlock* block = graph()->blocks()->at(i); |
390 int first = block->first_instruction_index(); | 390 int first = block->first_instruction_index(); |
391 int last = block->last_instruction_index(); | 391 int last = block->last_instruction_index(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { | 467 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { |
468 object()->PrintTo(stream); | 468 object()->PrintTo(stream); |
469 stream->Add(" %p -> %p", *original_map(), *transitioned_map()); | 469 stream->Add(" %p -> %p", *original_map(), *transitioned_map()); |
470 } | 470 } |
471 | 471 |
472 | 472 |
473 void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) { | 473 void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) { |
474 LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block); | 474 LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block); |
475 int index = -1; | 475 int index = -1; |
476 if (instr->IsControl()) { | 476 if (instr->IsControl()) { |
477 instructions_.Add(gap); | 477 instructions_.Add(gap, zone()); |
478 index = instructions_.length(); | 478 index = instructions_.length(); |
479 instructions_.Add(instr); | 479 instructions_.Add(instr, zone()); |
480 } else { | 480 } else { |
481 index = instructions_.length(); | 481 index = instructions_.length(); |
482 instructions_.Add(instr); | 482 instructions_.Add(instr, zone()); |
483 instructions_.Add(gap); | 483 instructions_.Add(gap, zone()); |
484 } | 484 } |
485 if (instr->HasPointerMap()) { | 485 if (instr->HasPointerMap()) { |
486 pointer_maps_.Add(instr->pointer_map()); | 486 pointer_maps_.Add(instr->pointer_map(), zone()); |
487 instr->pointer_map()->set_lithium_position(index); | 487 instr->pointer_map()->set_lithium_position(index); |
488 } | 488 } |
489 } | 489 } |
490 | 490 |
491 | 491 |
492 LConstantOperand* LChunk::DefineConstantOperand(HConstant* constant) { | 492 LConstantOperand* LChunk::DefineConstantOperand(HConstant* constant) { |
493 return LConstantOperand::Create(constant->id()); | 493 return LConstantOperand::Create(constant->id(), zone()); |
494 } | 494 } |
495 | 495 |
496 | 496 |
497 int LChunk::GetParameterStackSlot(int index) const { | 497 int LChunk::GetParameterStackSlot(int index) const { |
498 // The receiver is at index 0, the first parameter at index 1, so we | 498 // The receiver is at index 0, the first parameter at index 1, so we |
499 // shift all parameter indexes down by the number of parameters, and | 499 // shift all parameter indexes down by the number of parameters, and |
500 // make sure they end up negative so they are distinguishable from | 500 // make sure they end up negative so they are distinguishable from |
501 // spill slots. | 501 // spill slots. |
502 int result = index - info()->scope()->num_parameters() - 1; | 502 int result = index - info()->scope()->num_parameters() - 1; |
503 ASSERT(result < 0); | 503 ASSERT(result < 0); |
(...skipping 18 matching lines...) Expand all Loading... |
522 } | 522 } |
523 | 523 |
524 | 524 |
525 int LChunk::NearestGapPos(int index) const { | 525 int LChunk::NearestGapPos(int index) const { |
526 while (!IsGapAt(index)) index--; | 526 while (!IsGapAt(index)) index--; |
527 return index; | 527 return index; |
528 } | 528 } |
529 | 529 |
530 | 530 |
531 void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) { | 531 void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) { |
532 GetGapAt(index)->GetOrCreateParallelMove(LGap::START)->AddMove(from, to); | 532 GetGapAt(index)->GetOrCreateParallelMove( |
| 533 LGap::START, zone())->AddMove(from, to, zone()); |
533 } | 534 } |
534 | 535 |
535 | 536 |
536 Handle<Object> LChunk::LookupLiteral(LConstantOperand* operand) const { | 537 Handle<Object> LChunk::LookupLiteral(LConstantOperand* operand) const { |
537 return HConstant::cast(graph_->LookupValue(operand->index()))->handle(); | 538 return HConstant::cast(graph_->LookupValue(operand->index()))->handle(); |
538 } | 539 } |
539 | 540 |
540 | 541 |
541 Representation LChunk::LookupLiteralRepresentation( | 542 Representation LChunk::LookupLiteralRepresentation( |
542 LConstantOperand* operand) const { | 543 LConstantOperand* operand) const { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 if (needs_environment && !instr->HasEnvironment()) { | 758 if (needs_environment && !instr->HasEnvironment()) { |
758 instr = AssignEnvironment(instr); | 759 instr = AssignEnvironment(instr); |
759 } | 760 } |
760 | 761 |
761 return instr; | 762 return instr; |
762 } | 763 } |
763 | 764 |
764 | 765 |
765 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { | 766 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { |
766 ASSERT(!instr->HasPointerMap()); | 767 ASSERT(!instr->HasPointerMap()); |
767 instr->set_pointer_map(new(zone()) LPointerMap(position_)); | 768 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone())); |
768 return instr; | 769 return instr; |
769 } | 770 } |
770 | 771 |
771 | 772 |
772 LUnallocated* LChunkBuilder::TempRegister() { | 773 LUnallocated* LChunkBuilder::TempRegister() { |
773 LUnallocated* operand = | 774 LUnallocated* operand = |
774 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); | 775 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); |
775 operand->set_virtual_register(allocator_->GetVirtualRegister()); | 776 operand->set_virtual_register(allocator_->GetVirtualRegister()); |
776 if (!allocator_->AllocationOk()) { | 777 if (!allocator_->AllocationOk()) { |
777 Abort("Not enough virtual registers (temps)."); | 778 Abort("Not enough virtual registers (temps)."); |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { | 1539 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) { |
1539 ASSERT(instr->value()->representation().IsTagged()); | 1540 ASSERT(instr->value()->representation().IsTagged()); |
1540 LOperand* temp = TempRegister(); | 1541 LOperand* temp = TempRegister(); |
1541 return new(zone()) LIsObjectAndBranch(UseRegister(instr->value()), temp); | 1542 return new(zone()) LIsObjectAndBranch(UseRegister(instr->value()), temp); |
1542 } | 1543 } |
1543 | 1544 |
1544 | 1545 |
1545 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) { | 1546 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) { |
1546 ASSERT(instr->value()->representation().IsTagged()); | 1547 ASSERT(instr->value()->representation().IsTagged()); |
1547 LOperand* temp = TempRegister(); | 1548 LOperand* temp = TempRegister(); |
1548 return new LIsStringAndBranch(UseRegister(instr->value()), temp); | 1549 return new(zone()) LIsStringAndBranch(UseRegister(instr->value()), temp); |
1549 } | 1550 } |
1550 | 1551 |
1551 | 1552 |
1552 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) { | 1553 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) { |
1553 ASSERT(instr->value()->representation().IsTagged()); | 1554 ASSERT(instr->value()->representation().IsTagged()); |
1554 return new(zone()) LIsSmiAndBranch(Use(instr->value())); | 1555 return new(zone()) LIsSmiAndBranch(Use(instr->value())); |
1555 } | 1556 } |
1556 | 1557 |
1557 | 1558 |
1558 LInstruction* LChunkBuilder::DoIsUndetectableAndBranch( | 1559 LInstruction* LChunkBuilder::DoIsUndetectableAndBranch( |
1559 HIsUndetectableAndBranch* instr) { | 1560 HIsUndetectableAndBranch* instr) { |
1560 ASSERT(instr ->value()->representation().IsTagged()); | 1561 ASSERT(instr ->value()->representation().IsTagged()); |
1561 return new(zone()) LIsUndetectableAndBranch( | 1562 return new(zone()) LIsUndetectableAndBranch( |
1562 UseRegisterAtStart(instr->value()), TempRegister()); | 1563 UseRegisterAtStart(instr->value()), TempRegister()); |
1563 } | 1564 } |
1564 | 1565 |
1565 | 1566 |
1566 LInstruction* LChunkBuilder::DoStringCompareAndBranch( | 1567 LInstruction* LChunkBuilder::DoStringCompareAndBranch( |
1567 HStringCompareAndBranch* instr) { | 1568 HStringCompareAndBranch* instr) { |
1568 ASSERT(instr->left()->representation().IsTagged()); | 1569 ASSERT(instr->left()->representation().IsTagged()); |
1569 ASSERT(instr->right()->representation().IsTagged()); | 1570 ASSERT(instr->right()->representation().IsTagged()); |
1570 LOperand* context = UseFixed(instr->context(), esi); | 1571 LOperand* context = UseFixed(instr->context(), esi); |
1571 LOperand* left = UseFixed(instr->left(), edx); | 1572 LOperand* left = UseFixed(instr->left(), edx); |
1572 LOperand* right = UseFixed(instr->right(), eax); | 1573 LOperand* right = UseFixed(instr->right(), eax); |
1573 | 1574 |
1574 LStringCompareAndBranch* result = new | 1575 LStringCompareAndBranch* result = new(zone()) |
1575 LStringCompareAndBranch(context, left, right); | 1576 LStringCompareAndBranch(context, left, right); |
1576 | 1577 |
1577 return MarkAsCall(result, instr); | 1578 return MarkAsCall(result, instr); |
1578 } | 1579 } |
1579 | 1580 |
1580 | 1581 |
1581 LInstruction* LChunkBuilder::DoHasInstanceTypeAndBranch( | 1582 LInstruction* LChunkBuilder::DoHasInstanceTypeAndBranch( |
1582 HHasInstanceTypeAndBranch* instr) { | 1583 HHasInstanceTypeAndBranch* instr) { |
1583 ASSERT(instr->value()->representation().IsTagged()); | 1584 ASSERT(instr->value()->representation().IsTagged()); |
1584 return new(zone()) LHasInstanceTypeAndBranch( | 1585 return new(zone()) LHasInstanceTypeAndBranch( |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2438 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2439 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2439 LOperand* object = UseRegister(instr->object()); | 2440 LOperand* object = UseRegister(instr->object()); |
2440 LOperand* index = UseTempRegister(instr->index()); | 2441 LOperand* index = UseTempRegister(instr->index()); |
2441 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2442 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2442 } | 2443 } |
2443 | 2444 |
2444 | 2445 |
2445 } } // namespace v8::internal | 2446 } } // namespace v8::internal |
2446 | 2447 |
2447 #endif // V8_TARGET_ARCH_IA32 | 2448 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |