| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
| 6 | 6 |
| 7 #include "src/compiler/code-generator-impl.h" | 7 #include "src/compiler/code-generator-impl.h" |
| 8 #include "src/compiler/gap-resolver.h" | 8 #include "src/compiler/gap-resolver.h" |
| 9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
| 10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 if (FLAG_debug_code) { | 188 if (FLAG_debug_code) { |
| 189 // Check the function's context matches the context argument. | 189 // Check the function's context matches the context argument. |
| 190 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); | 190 __ cmp(esi, FieldOperand(func, JSFunction::kContextOffset)); |
| 191 __ Assert(equal, kWrongFunctionContext); | 191 __ Assert(equal, kWrongFunctionContext); |
| 192 } | 192 } |
| 193 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); | 193 __ call(FieldOperand(func, JSFunction::kCodeEntryOffset)); |
| 194 AddSafepointAndDeopt(instr); | 194 AddSafepointAndDeopt(instr); |
| 195 break; | 195 break; |
| 196 } | 196 } |
| 197 case kArchJmp: | 197 case kArchJmp: |
| 198 __ jmp(GetLabel(i.InputRpo(0))); | 198 AssembleArchJump(i.InputRpo(0)); |
| 199 break; | 199 break; |
| 200 case kArchNop: | 200 case kArchNop: |
| 201 // don't emit code for nops. | 201 // don't emit code for nops. |
| 202 break; | 202 break; |
| 203 case kArchRet: | 203 case kArchRet: |
| 204 AssembleReturn(); | 204 AssembleReturn(); |
| 205 break; | 205 break; |
| 206 case kArchStackPointer: | 206 case kArchStackPointer: |
| 207 __ mov(i.OutputRegister(), esp); | 207 __ mov(i.OutputRegister(), esp); |
| 208 break; | 208 break; |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 __ lea(index, Operand(object, index, times_1, 0)); | 478 __ lea(index, Operand(object, index, times_1, 0)); |
| 479 SaveFPRegsMode mode = | 479 SaveFPRegsMode mode = |
| 480 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; | 480 frame()->DidAllocateDoubleRegisters() ? kSaveFPRegs : kDontSaveFPRegs; |
| 481 __ RecordWrite(object, index, value, mode); | 481 __ RecordWrite(object, index, value, mode); |
| 482 break; | 482 break; |
| 483 } | 483 } |
| 484 } | 484 } |
| 485 } | 485 } |
| 486 | 486 |
| 487 | 487 |
| 488 // Assembles branches after an instruction. | 488 // Assembles a branch after an instruction. |
| 489 void CodeGenerator::AssembleArchBranch(Instruction* instr, | 489 void CodeGenerator::AssembleArchBranch(Instruction* instr, BranchInfo* branch) { |
| 490 FlagsCondition condition) { | |
| 491 IA32OperandConverter i(this, instr); | 490 IA32OperandConverter i(this, instr); |
| 492 Label done; | 491 Label::Distance flabel_distance = |
| 493 | 492 branch->fallthru ? Label::kNear : Label::kFar; |
| 494 // Emit a branch. The true and false targets are always the last two inputs | 493 Label* tlabel = branch->true_label; |
| 495 // to the instruction. | 494 Label* flabel = branch->false_label; |
| 496 BasicBlock::RpoNumber tblock = | 495 switch (branch->condition) { |
| 497 i.InputRpo(static_cast<int>(instr->InputCount()) - 2); | |
| 498 BasicBlock::RpoNumber fblock = | |
| 499 i.InputRpo(static_cast<int>(instr->InputCount()) - 1); | |
| 500 bool fallthru = IsNextInAssemblyOrder(fblock); | |
| 501 Label* tlabel = GetLabel(tblock); | |
| 502 Label* flabel = fallthru ? &done : GetLabel(fblock); | |
| 503 Label::Distance flabel_distance = fallthru ? Label::kNear : Label::kFar; | |
| 504 switch (condition) { | |
| 505 case kUnorderedEqual: | 496 case kUnorderedEqual: |
| 506 __ j(parity_even, flabel, flabel_distance); | 497 __ j(parity_even, flabel, flabel_distance); |
| 507 // Fall through. | 498 // Fall through. |
| 508 case kEqual: | 499 case kEqual: |
| 509 __ j(equal, tlabel); | 500 __ j(equal, tlabel); |
| 510 break; | 501 break; |
| 511 case kUnorderedNotEqual: | 502 case kUnorderedNotEqual: |
| 512 __ j(parity_even, tlabel); | 503 __ j(parity_even, tlabel); |
| 513 // Fall through. | 504 // Fall through. |
| 514 case kNotEqual: | 505 case kNotEqual: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 case kUnsignedGreaterThan: | 541 case kUnsignedGreaterThan: |
| 551 __ j(above, tlabel); | 542 __ j(above, tlabel); |
| 552 break; | 543 break; |
| 553 case kOverflow: | 544 case kOverflow: |
| 554 __ j(overflow, tlabel); | 545 __ j(overflow, tlabel); |
| 555 break; | 546 break; |
| 556 case kNotOverflow: | 547 case kNotOverflow: |
| 557 __ j(no_overflow, tlabel); | 548 __ j(no_overflow, tlabel); |
| 558 break; | 549 break; |
| 559 } | 550 } |
| 560 if (!fallthru) __ jmp(flabel, flabel_distance); // no fallthru to flabel. | 551 // Add a jump if not falling through to the next block. |
| 561 __ bind(&done); | 552 if (!branch->fallthru) __ jmp(flabel); |
| 562 } | 553 } |
| 563 | 554 |
| 564 | 555 |
| 556 void CodeGenerator::AssembleArchJump(BasicBlock::RpoNumber target) { |
| 557 if (!IsNextInAssemblyOrder(target)) __ jmp(GetLabel(target)); |
| 558 } |
| 559 |
| 560 |
| 565 // Assembles boolean materializations after an instruction. | 561 // Assembles boolean materializations after an instruction. |
| 566 void CodeGenerator::AssembleArchBoolean(Instruction* instr, | 562 void CodeGenerator::AssembleArchBoolean(Instruction* instr, |
| 567 FlagsCondition condition) { | 563 FlagsCondition condition) { |
| 568 IA32OperandConverter i(this, instr); | 564 IA32OperandConverter i(this, instr); |
| 569 Label done; | 565 Label done; |
| 570 | 566 |
| 571 // Materialize a full 32-bit 1 or 0 value. The result register is always the | 567 // Materialize a full 32-bit 1 or 0 value. The result register is always the |
| 572 // last output of the instruction. | 568 // last output of the instruction. |
| 573 Label check; | 569 Label check; |
| 574 DCHECK_NE(0, instr->OutputCount()); | 570 DCHECK_NE(0, instr->OutputCount()); |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 } | 1032 } |
| 1037 } | 1033 } |
| 1038 MarkLazyDeoptSite(); | 1034 MarkLazyDeoptSite(); |
| 1039 } | 1035 } |
| 1040 | 1036 |
| 1041 #undef __ | 1037 #undef __ |
| 1042 | 1038 |
| 1043 } // namespace compiler | 1039 } // namespace compiler |
| 1044 } // namespace internal | 1040 } // namespace internal |
| 1045 } // namespace v8 | 1041 } // namespace v8 |
| OLD | NEW |