Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: src/ia32/lithium-ia32.cc

Issue 10701141: Remove duplicated LChunk code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix nits. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/lithium.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 LOperand* LChunk::GetNextSpillSlot(bool is_double) { 380 LOperand* LChunk::GetNextSpillSlot(bool is_double) {
381 int index = GetNextSpillIndex(is_double); 381 int index = GetNextSpillIndex(is_double);
382 if (is_double) { 382 if (is_double) {
383 return LDoubleStackSlot::Create(index, zone()); 383 return LDoubleStackSlot::Create(index, zone());
384 } else { 384 } else {
385 return LStackSlot::Create(index, zone()); 385 return LStackSlot::Create(index, zone());
386 } 386 }
387 } 387 }
388 388
389 389
390 void LChunk::MarkEmptyBlocks() {
391 HPhase phase("L_Mark empty blocks", this);
392 for (int i = 0; i < graph()->blocks()->length(); ++i) {
393 HBasicBlock* block = graph()->blocks()->at(i);
394 int first = block->first_instruction_index();
395 int last = block->last_instruction_index();
396 LInstruction* first_instr = instructions()->at(first);
397 LInstruction* last_instr = instructions()->at(last);
398
399 LLabel* label = LLabel::cast(first_instr);
400 if (last_instr->IsGoto()) {
401 LGoto* goto_instr = LGoto::cast(last_instr);
402 if (label->IsRedundant() &&
403 !label->is_loop_header()) {
404 bool can_eliminate = true;
405 for (int i = first + 1; i < last && can_eliminate; ++i) {
406 LInstruction* cur = instructions()->at(i);
407 if (cur->IsGap()) {
408 LGap* gap = LGap::cast(cur);
409 if (!gap->IsRedundant()) {
410 can_eliminate = false;
411 }
412 } else {
413 can_eliminate = false;
414 }
415 }
416
417 if (can_eliminate) {
418 label->set_replacement(GetLabel(goto_instr->block_id()));
419 }
420 }
421 }
422 }
423 }
424
425
426 void LStoreNamedField::PrintDataTo(StringStream* stream) { 390 void LStoreNamedField::PrintDataTo(StringStream* stream) {
427 object()->PrintTo(stream); 391 object()->PrintTo(stream);
428 stream->Add("."); 392 stream->Add(".");
429 stream->Add(*String::cast(*name())->ToCString()); 393 stream->Add(*String::cast(*name())->ToCString());
430 stream->Add(" <- "); 394 stream->Add(" <- ");
431 value()->PrintTo(stream); 395 value()->PrintTo(stream);
432 } 396 }
433 397
434 398
435 void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { 399 void LStoreNamedGeneric::PrintDataTo(StringStream* stream) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 value()->PrintTo(stream); 431 value()->PrintTo(stream);
468 } 432 }
469 433
470 434
471 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { 435 void LTransitionElementsKind::PrintDataTo(StringStream* stream) {
472 object()->PrintTo(stream); 436 object()->PrintTo(stream);
473 stream->Add(" %p -> %p", *original_map(), *transitioned_map()); 437 stream->Add(" %p -> %p", *original_map(), *transitioned_map());
474 } 438 }
475 439
476 440
477 void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) {
478 LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block);
479 int index = -1;
480 if (instr->IsControl()) {
481 instructions_.Add(gap, zone());
482 index = instructions_.length();
483 instructions_.Add(instr, zone());
484 } else {
485 index = instructions_.length();
486 instructions_.Add(instr, zone());
487 instructions_.Add(gap, zone());
488 }
489 if (instr->HasPointerMap()) {
490 pointer_maps_.Add(instr->pointer_map(), zone());
491 instr->pointer_map()->set_lithium_position(index);
492 }
493 }
494
495
496 LConstantOperand* LChunk::DefineConstantOperand(HConstant* constant) {
497 return LConstantOperand::Create(constant->id(), zone());
498 }
499
500
501 int LChunk::GetParameterStackSlot(int index) const {
502 // The receiver is at index 0, the first parameter at index 1, so we
503 // shift all parameter indexes down by the number of parameters, and
504 // make sure they end up negative so they are distinguishable from
505 // spill slots.
506 int result = index - info()->scope()->num_parameters() - 1;
507 ASSERT(result < 0);
508 return result;
509 }
510
511 // A parameter relative to ebp in the arguments stub.
512 int LChunk::ParameterAt(int index) {
513 ASSERT(-1 <= index); // -1 is the receiver.
514 return (1 + info()->scope()->num_parameters() - index) *
515 kPointerSize;
516 }
517
518
519 LGap* LChunk::GetGapAt(int index) const {
520 return LGap::cast(instructions_[index]);
521 }
522
523
524 bool LChunk::IsGapAt(int index) const {
525 return instructions_[index]->IsGap();
526 }
527
528
529 int LChunk::NearestGapPos(int index) const {
530 while (!IsGapAt(index)) index--;
531 return index;
532 }
533
534
535 void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) {
536 GetGapAt(index)->GetOrCreateParallelMove(
537 LGap::START, zone())->AddMove(from, to, zone());
538 }
539
540
541 Handle<Object> LChunk::LookupLiteral(LConstantOperand* operand) const {
542 return HConstant::cast(graph_->LookupValue(operand->index()))->handle();
543 }
544
545
546 Representation LChunk::LookupLiteralRepresentation(
547 LConstantOperand* operand) const {
548 return graph_->LookupValue(operand->index())->representation();
549 }
550
551
552 LChunk* LChunkBuilder::Build() { 441 LChunk* LChunkBuilder::Build() {
553 ASSERT(is_unused()); 442 ASSERT(is_unused());
554 chunk_ = new(zone()) LChunk(info(), graph()); 443 chunk_ = new(zone()) LChunk(info(), graph());
555 HPhase phase("L_Building chunk", chunk_); 444 HPhase phase("L_Building chunk", chunk_);
556 status_ = BUILDING; 445 status_ = BUILDING;
557 446
558 // Reserve the first spill slot for the state of dynamic alignment. 447 // Reserve the first spill slot for the state of dynamic alignment.
559 int alignment_state_index = chunk_->GetNextSpillIndex(false); 448 int alignment_state_index = chunk_->GetNextSpillIndex(false);
560 ASSERT_EQ(alignment_state_index, 0); 449 ASSERT_EQ(alignment_state_index, 0);
561 USE(alignment_state_index); 450 USE(alignment_state_index);
(...skipping 1931 matching lines...) Expand 10 before | Expand all | Expand 10 after
2493 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { 2382 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2494 LOperand* object = UseRegister(instr->object()); 2383 LOperand* object = UseRegister(instr->object());
2495 LOperand* index = UseTempRegister(instr->index()); 2384 LOperand* index = UseTempRegister(instr->index());
2496 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); 2385 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index));
2497 } 2386 }
2498 2387
2499 2388
2500 } } // namespace v8::internal 2389 } } // namespace v8::internal
2501 2390
2502 #endif // V8_TARGET_ARCH_IA32 2391 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-ia32.h ('k') | src/lithium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698