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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { | 404 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { |
405 object()->PrintTo(stream); | 405 object()->PrintTo(stream); |
406 stream->Add(" %p -> %p", *original_map(), *transitioned_map()); | 406 stream->Add(" %p -> %p", *original_map(), *transitioned_map()); |
407 } | 407 } |
408 | 408 |
409 | 409 |
410 LChunk::LChunk(CompilationInfo* info, HGraph* graph) | 410 LChunk::LChunk(CompilationInfo* info, HGraph* graph) |
411 : spill_slot_count_(0), | 411 : spill_slot_count_(0), |
412 info_(info), | 412 info_(info), |
413 graph_(graph), | 413 graph_(graph), |
414 instructions_(32), | 414 instructions_(32, graph->zone()), |
415 pointer_maps_(8), | 415 pointer_maps_(8, graph->zone()), |
416 inlined_closures_(1) { | 416 inlined_closures_(1, graph->zone()) { |
417 } | 417 } |
418 | 418 |
419 | 419 |
420 int LChunk::GetNextSpillIndex(bool is_double) { | 420 int LChunk::GetNextSpillIndex(bool is_double) { |
421 // Skip a slot if for a double-width slot. | 421 // Skip a slot if for a double-width slot. |
422 if (is_double) spill_slot_count_++; | 422 if (is_double) spill_slot_count_++; |
423 return spill_slot_count_++; | 423 return spill_slot_count_++; |
424 } | 424 } |
425 | 425 |
426 | 426 |
427 LOperand* LChunk::GetNextSpillSlot(bool is_double) { | 427 LOperand* LChunk::GetNextSpillSlot(bool is_double) { |
428 int index = GetNextSpillIndex(is_double); | 428 int index = GetNextSpillIndex(is_double); |
429 if (is_double) { | 429 if (is_double) { |
430 return LDoubleStackSlot::Create(index); | 430 return LDoubleStackSlot::Create(index, zone()); |
431 } else { | 431 } else { |
432 return LStackSlot::Create(index); | 432 return LStackSlot::Create(index, zone()); |
433 } | 433 } |
434 } | 434 } |
435 | 435 |
436 | 436 |
437 void LChunk::MarkEmptyBlocks() { | 437 void LChunk::MarkEmptyBlocks() { |
438 HPhase phase("L_Mark empty blocks", this); | 438 HPhase phase("L_Mark empty blocks", this); |
439 for (int i = 0; i < graph()->blocks()->length(); ++i) { | 439 for (int i = 0; i < graph()->blocks()->length(); ++i) { |
440 HBasicBlock* block = graph()->blocks()->at(i); | 440 HBasicBlock* block = graph()->blocks()->at(i); |
441 int first = block->first_instruction_index(); | 441 int first = block->first_instruction_index(); |
442 int last = block->last_instruction_index(); | 442 int last = block->last_instruction_index(); |
(...skipping 24 matching lines...) Expand all Loading... |
467 } | 467 } |
468 } | 468 } |
469 } | 469 } |
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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 if (needs_environment && !instr->HasEnvironment()) { | 756 if (needs_environment && !instr->HasEnvironment()) { |
756 instr = AssignEnvironment(instr); | 757 instr = AssignEnvironment(instr); |
757 } | 758 } |
758 | 759 |
759 return instr; | 760 return instr; |
760 } | 761 } |
761 | 762 |
762 | 763 |
763 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { | 764 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { |
764 ASSERT(!instr->HasPointerMap()); | 765 ASSERT(!instr->HasPointerMap()); |
765 instr->set_pointer_map(new(zone()) LPointerMap(position_)); | 766 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone())); |
766 return instr; | 767 return instr; |
767 } | 768 } |
768 | 769 |
769 | 770 |
770 LUnallocated* LChunkBuilder::TempRegister() { | 771 LUnallocated* LChunkBuilder::TempRegister() { |
771 LUnallocated* operand = | 772 LUnallocated* operand = |
772 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); | 773 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); |
773 operand->set_virtual_register(allocator_->GetVirtualRegister()); | 774 operand->set_virtual_register(allocator_->GetVirtualRegister()); |
774 if (!allocator_->AllocationOk()) Abort("Not enough virtual registers."); | 775 if (!allocator_->AllocationOk()) Abort("Not enough virtual registers."); |
775 return operand; | 776 return operand; |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 | 1339 |
1339 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { | 1340 HValue* LChunkBuilder::SimplifiedDivisorForMathFloorOfDiv(HValue* divisor) { |
1340 // Only optimize when we have magic numbers for the divisor. | 1341 // Only optimize when we have magic numbers for the divisor. |
1341 // The standard integer division routine is usually slower than transitionning | 1342 // The standard integer division routine is usually slower than transitionning |
1342 // to VFP. | 1343 // to VFP. |
1343 if (divisor->IsConstant() && | 1344 if (divisor->IsConstant() && |
1344 HConstant::cast(divisor)->HasInteger32Value()) { | 1345 HConstant::cast(divisor)->HasInteger32Value()) { |
1345 HConstant* constant_val = HConstant::cast(divisor); | 1346 HConstant* constant_val = HConstant::cast(divisor); |
1346 int32_t int32_val = constant_val->Integer32Value(); | 1347 int32_t int32_val = constant_val->Integer32Value(); |
1347 if (LChunkBuilder::HasMagicNumberForDivisor(int32_val)) { | 1348 if (LChunkBuilder::HasMagicNumberForDivisor(int32_val)) { |
1348 return constant_val->CopyToRepresentation(Representation::Integer32()); | 1349 return constant_val->CopyToRepresentation(Representation::Integer32(), |
| 1350 divisor->block()->zone()); |
1349 } | 1351 } |
1350 } | 1352 } |
1351 return NULL; | 1353 return NULL; |
1352 } | 1354 } |
1353 | 1355 |
1354 | 1356 |
1355 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | 1357 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { |
1356 HValue* right = instr->right(); | 1358 HValue* right = instr->right(); |
1357 LOperand* dividend = UseRegister(instr->left()); | 1359 LOperand* dividend = UseRegister(instr->left()); |
1358 LOperand* divisor = UseRegisterOrConstant(right); | 1360 LOperand* divisor = UseRegisterOrConstant(right); |
1359 LOperand* remainder = TempRegister(); | 1361 LOperand* remainder = TempRegister(); |
1360 ASSERT(right->IsConstant() && | 1362 ASSERT(right->IsConstant() && |
1361 HConstant::cast(right)->HasInteger32Value() && | 1363 HConstant::cast(right)->HasInteger32Value() && |
1362 HasMagicNumberForDivisor(HConstant::cast(right)->Integer32Value())); | 1364 HasMagicNumberForDivisor(HConstant::cast(right)->Integer32Value())); |
1363 return AssignEnvironment(DefineAsRegister( | 1365 return AssignEnvironment(DefineAsRegister( |
1364 new LMathFloorOfDiv(dividend, divisor, remainder))); | 1366 new(zone()) LMathFloorOfDiv(dividend, divisor, remainder))); |
1365 } | 1367 } |
1366 | 1368 |
1367 | 1369 |
1368 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | 1370 LInstruction* LChunkBuilder::DoMod(HMod* instr) { |
1369 if (instr->representation().IsInteger32()) { | 1371 if (instr->representation().IsInteger32()) { |
1370 ASSERT(instr->left()->representation().IsInteger32()); | 1372 ASSERT(instr->left()->representation().IsInteger32()); |
1371 ASSERT(instr->right()->representation().IsInteger32()); | 1373 ASSERT(instr->right()->representation().IsInteger32()); |
1372 | 1374 |
1373 LModI* mod; | 1375 LModI* mod; |
1374 if (instr->HasPowerOf2Divisor()) { | 1376 if (instr->HasPowerOf2Divisor()) { |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 | 1653 |
1652 LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { | 1654 LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { |
1653 LOperand* object = UseRegister(instr->value()); | 1655 LOperand* object = UseRegister(instr->value()); |
1654 LValueOf* result = new(zone()) LValueOf(object, TempRegister()); | 1656 LValueOf* result = new(zone()) LValueOf(object, TempRegister()); |
1655 return DefineAsRegister(result); | 1657 return DefineAsRegister(result); |
1656 } | 1658 } |
1657 | 1659 |
1658 | 1660 |
1659 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { | 1661 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { |
1660 LOperand* object = UseFixed(instr->value(), r0); | 1662 LOperand* object = UseFixed(instr->value(), r0); |
1661 LDateField* result = new LDateField(object, FixedTemp(r1), instr->index()); | 1663 LDateField* result = |
| 1664 new(zone()) LDateField(object, FixedTemp(r1), instr->index()); |
1662 return MarkAsCall(DefineFixed(result, r0), instr); | 1665 return MarkAsCall(DefineFixed(result, r0), instr); |
1663 } | 1666 } |
1664 | 1667 |
1665 | 1668 |
1666 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { | 1669 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { |
1667 LOperand* value = UseRegisterAtStart(instr->index()); | 1670 LOperand* value = UseRegisterAtStart(instr->index()); |
1668 LOperand* length = UseRegister(instr->length()); | 1671 LOperand* length = UseRegister(instr->length()); |
1669 return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); | 1672 return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); |
1670 } | 1673 } |
1671 | 1674 |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2163 } | 2166 } |
2164 | 2167 |
2165 | 2168 |
2166 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) { | 2169 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) { |
2167 LOperand* string = UseRegisterAtStart(instr->value()); | 2170 LOperand* string = UseRegisterAtStart(instr->value()); |
2168 return DefineAsRegister(new(zone()) LStringLength(string)); | 2171 return DefineAsRegister(new(zone()) LStringLength(string)); |
2169 } | 2172 } |
2170 | 2173 |
2171 | 2174 |
2172 LInstruction* LChunkBuilder::DoAllocateObject(HAllocateObject* instr) { | 2175 LInstruction* LChunkBuilder::DoAllocateObject(HAllocateObject* instr) { |
2173 LAllocateObject* result = new LAllocateObject(TempRegister(), TempRegister()); | 2176 LAllocateObject* result = |
| 2177 new(zone()) LAllocateObject(TempRegister(), TempRegister()); |
2174 return AssignPointerMap(DefineAsRegister(result)); | 2178 return AssignPointerMap(DefineAsRegister(result)); |
2175 } | 2179 } |
2176 | 2180 |
2177 | 2181 |
2178 LInstruction* LChunkBuilder::DoFastLiteral(HFastLiteral* instr) { | 2182 LInstruction* LChunkBuilder::DoFastLiteral(HFastLiteral* instr) { |
2179 return MarkAsCall(DefineFixed(new(zone()) LFastLiteral, r0), instr); | 2183 return MarkAsCall(DefineFixed(new(zone()) LFastLiteral, r0), instr); |
2180 } | 2184 } |
2181 | 2185 |
2182 | 2186 |
2183 LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) { | 2187 LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2391 | 2395 |
2392 | 2396 |
2393 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2397 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2394 LOperand* object = UseRegister(instr->object()); | 2398 LOperand* object = UseRegister(instr->object()); |
2395 LOperand* index = UseRegister(instr->index()); | 2399 LOperand* index = UseRegister(instr->index()); |
2396 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2400 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2397 } | 2401 } |
2398 | 2402 |
2399 | 2403 |
2400 } } // namespace v8::internal | 2404 } } // namespace v8::internal |
OLD | NEW |