| 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 // stack slots for int32 values. | 369 // stack slots for int32 values. |
| 370 int index = GetNextSpillIndex(is_double); | 370 int index = GetNextSpillIndex(is_double); |
| 371 if (is_double) { | 371 if (is_double) { |
| 372 return LDoubleStackSlot::Create(index, zone()); | 372 return LDoubleStackSlot::Create(index, zone()); |
| 373 } else { | 373 } else { |
| 374 return LStackSlot::Create(index, zone()); | 374 return LStackSlot::Create(index, zone()); |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 | 377 |
| 378 | 378 |
| 379 void LChunk::MarkEmptyBlocks() { | |
| 380 HPhase phase("L_Mark empty blocks", this); | |
| 381 for (int i = 0; i < graph()->blocks()->length(); ++i) { | |
| 382 HBasicBlock* block = graph()->blocks()->at(i); | |
| 383 int first = block->first_instruction_index(); | |
| 384 int last = block->last_instruction_index(); | |
| 385 LInstruction* first_instr = instructions()->at(first); | |
| 386 LInstruction* last_instr = instructions()->at(last); | |
| 387 | |
| 388 LLabel* label = LLabel::cast(first_instr); | |
| 389 if (last_instr->IsGoto()) { | |
| 390 LGoto* goto_instr = LGoto::cast(last_instr); | |
| 391 if (label->IsRedundant() && | |
| 392 !label->is_loop_header()) { | |
| 393 bool can_eliminate = true; | |
| 394 for (int i = first + 1; i < last && can_eliminate; ++i) { | |
| 395 LInstruction* cur = instructions()->at(i); | |
| 396 if (cur->IsGap()) { | |
| 397 LGap* gap = LGap::cast(cur); | |
| 398 if (!gap->IsRedundant()) { | |
| 399 can_eliminate = false; | |
| 400 } | |
| 401 } else { | |
| 402 can_eliminate = false; | |
| 403 } | |
| 404 } | |
| 405 | |
| 406 if (can_eliminate) { | |
| 407 label->set_replacement(GetLabel(goto_instr->block_id())); | |
| 408 } | |
| 409 } | |
| 410 } | |
| 411 } | |
| 412 } | |
| 413 | |
| 414 | |
| 415 void LStoreNamedField::PrintDataTo(StringStream* stream) { | 379 void LStoreNamedField::PrintDataTo(StringStream* stream) { |
| 416 object()->PrintTo(stream); | 380 object()->PrintTo(stream); |
| 417 stream->Add("."); | 381 stream->Add("."); |
| 418 stream->Add(*String::cast(*name())->ToCString()); | 382 stream->Add(*String::cast(*name())->ToCString()); |
| 419 stream->Add(" <- "); | 383 stream->Add(" <- "); |
| 420 value()->PrintTo(stream); | 384 value()->PrintTo(stream); |
| 421 } | 385 } |
| 422 | 386 |
| 423 | 387 |
| 424 void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { | 388 void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 value()->PrintTo(stream); | 420 value()->PrintTo(stream); |
| 457 } | 421 } |
| 458 | 422 |
| 459 | 423 |
| 460 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { | 424 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { |
| 461 object()->PrintTo(stream); | 425 object()->PrintTo(stream); |
| 462 stream->Add(" %p -> %p", *original_map(), *transitioned_map()); | 426 stream->Add(" %p -> %p", *original_map(), *transitioned_map()); |
| 463 } | 427 } |
| 464 | 428 |
| 465 | 429 |
| 466 void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) { | |
| 467 LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block); | |
| 468 int index = -1; | |
| 469 if (instr->IsControl()) { | |
| 470 instructions_.Add(gap, zone()); | |
| 471 index = instructions_.length(); | |
| 472 instructions_.Add(instr, zone()); | |
| 473 } else { | |
| 474 index = instructions_.length(); | |
| 475 instructions_.Add(instr, zone()); | |
| 476 instructions_.Add(gap, zone()); | |
| 477 } | |
| 478 if (instr->HasPointerMap()) { | |
| 479 pointer_maps_.Add(instr->pointer_map(), zone()); | |
| 480 instr->pointer_map()->set_lithium_position(index); | |
| 481 } | |
| 482 } | |
| 483 | |
| 484 | |
| 485 LConstantOperand* LChunk::DefineConstantOperand(HConstant* constant) { | |
| 486 return LConstantOperand::Create(constant->id(), zone()); | |
| 487 } | |
| 488 | |
| 489 | |
| 490 int LChunk::GetParameterStackSlot(int index) const { | |
| 491 // The receiver is at index 0, the first parameter at index 1, so we | |
| 492 // shift all parameter indexes down by the number of parameters, and | |
| 493 // make sure they end up negative so they are distinguishable from | |
| 494 // spill slots. | |
| 495 int result = index - info()->scope()->num_parameters() - 1; | |
| 496 ASSERT(result < 0); | |
| 497 return result; | |
| 498 } | |
| 499 | |
| 500 // A parameter relative to ebp in the arguments stub. | |
| 501 int LChunk::ParameterAt(int index) { | |
| 502 ASSERT(-1 <= index); // -1 is the receiver. | |
| 503 return (1 + info()->scope()->num_parameters() - index) * | |
| 504 kPointerSize; | |
| 505 } | |
| 506 | |
| 507 | |
| 508 LGap* LChunk::GetGapAt(int index) const { | |
| 509 return LGap::cast(instructions_[index]); | |
| 510 } | |
| 511 | |
| 512 | |
| 513 bool LChunk::IsGapAt(int index) const { | |
| 514 return instructions_[index]->IsGap(); | |
| 515 } | |
| 516 | |
| 517 | |
| 518 int LChunk::NearestGapPos(int index) const { | |
| 519 while (!IsGapAt(index)) index--; | |
| 520 return index; | |
| 521 } | |
| 522 | |
| 523 | |
| 524 void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) { | |
| 525 GetGapAt(index)->GetOrCreateParallelMove( | |
| 526 LGap::START, zone())->AddMove(from, to, zone()); | |
| 527 } | |
| 528 | |
| 529 | |
| 530 Handle<Object> LChunk::LookupLiteral(LConstantOperand* operand) const { | |
| 531 return HConstant::cast(graph_->LookupValue(operand->index()))->handle(); | |
| 532 } | |
| 533 | |
| 534 | |
| 535 Representation LChunk::LookupLiteralRepresentation( | |
| 536 LConstantOperand* operand) const { | |
| 537 return graph_->LookupValue(operand->index())->representation(); | |
| 538 } | |
| 539 | |
| 540 | |
| 541 LChunk* LChunkBuilder::Build() { | 430 LChunk* LChunkBuilder::Build() { |
| 542 ASSERT(is_unused()); | 431 ASSERT(is_unused()); |
| 543 chunk_ = new(zone()) LChunk(info(), graph()); | 432 chunk_ = new(zone()) LChunk(info(), graph()); |
| 544 HPhase phase("L_Building chunk", chunk_); | 433 HPhase phase("L_Building chunk", chunk_); |
| 545 status_ = BUILDING; | 434 status_ = BUILDING; |
| 546 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); | 435 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); |
| 547 for (int i = 0; i < blocks->length(); i++) { | 436 for (int i = 0; i < blocks->length(); i++) { |
| 548 HBasicBlock* next = NULL; | 437 HBasicBlock* next = NULL; |
| 549 if (i < blocks->length() - 1) next = blocks->at(i + 1); | 438 if (i < blocks->length() - 1) next = blocks->at(i + 1); |
| 550 DoBasicBlock(blocks->at(i), next); | 439 DoBasicBlock(blocks->at(i), next); |
| (...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2369 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2258 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2370 LOperand* object = UseRegister(instr->object()); | 2259 LOperand* object = UseRegister(instr->object()); |
| 2371 LOperand* index = UseTempRegister(instr->index()); | 2260 LOperand* index = UseTempRegister(instr->index()); |
| 2372 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2261 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2373 } | 2262 } |
| 2374 | 2263 |
| 2375 | 2264 |
| 2376 } } // namespace v8::internal | 2265 } } // namespace v8::internal |
| 2377 | 2266 |
| 2378 #endif // V8_TARGET_ARCH_X64 | 2267 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |