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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 if (op->IsRegister()) { | 400 if (op->IsRegister()) { |
401 return ToRegister(op->index()); | 401 return ToRegister(op->index()); |
402 } else if (op->IsConstantOperand()) { | 402 } else if (op->IsConstantOperand()) { |
403 LConstantOperand* const_op = LConstantOperand::cast(op); | 403 LConstantOperand* const_op = LConstantOperand::cast(op); |
404 HConstant* constant = chunk_->LookupConstant(const_op); | 404 HConstant* constant = chunk_->LookupConstant(const_op); |
405 Handle<Object> literal = constant->handle(); | 405 Handle<Object> literal = constant->handle(); |
406 Representation r = chunk_->LookupLiteralRepresentation(const_op); | 406 Representation r = chunk_->LookupLiteralRepresentation(const_op); |
407 if (r.IsInteger32()) { | 407 if (r.IsInteger32()) { |
408 ASSERT(literal->IsNumber()); | 408 ASSERT(literal->IsNumber()); |
409 __ li(scratch, Operand(static_cast<int32_t>(literal->Number()))); | 409 __ li(scratch, Operand(static_cast<int32_t>(literal->Number()))); |
410 } else if (r.IsSmi()) { | |
411 ASSERT(constant->HasSmiValue()); | |
412 __ li(scratch, Operand(Smi::FromInt(constant->Integer32Value()))); | |
413 } else if (r.IsDouble()) { | 410 } else if (r.IsDouble()) { |
414 Abort("EmitLoadRegister: Unsupported double immediate."); | 411 Abort("EmitLoadRegister: Unsupported double immediate."); |
415 } else { | 412 } else { |
416 ASSERT(r.IsTagged()); | 413 ASSERT(r.IsTagged()); |
417 __ LoadObject(scratch, literal); | 414 __ LoadObject(scratch, literal); |
418 } | 415 } |
419 return scratch; | 416 return scratch; |
420 } else if (op->IsStackSlot() || op->IsArgument()) { | 417 } else if (op->IsStackSlot() || op->IsArgument()) { |
421 __ lw(scratch, ToMemOperand(op)); | 418 __ lw(scratch, ToMemOperand(op)); |
422 return scratch; | 419 return scratch; |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 } | 1514 } |
1518 } | 1515 } |
1519 | 1516 |
1520 | 1517 |
1521 void LCodeGen::DoShiftI(LShiftI* instr) { | 1518 void LCodeGen::DoShiftI(LShiftI* instr) { |
1522 // Both 'left' and 'right' are "used at start" (see LCodeGen::DoShift), so | 1519 // Both 'left' and 'right' are "used at start" (see LCodeGen::DoShift), so |
1523 // result may alias either of them. | 1520 // result may alias either of them. |
1524 LOperand* right_op = instr->right(); | 1521 LOperand* right_op = instr->right(); |
1525 Register left = ToRegister(instr->left()); | 1522 Register left = ToRegister(instr->left()); |
1526 Register result = ToRegister(instr->result()); | 1523 Register result = ToRegister(instr->result()); |
1527 Register scratch = scratch0(); | |
1528 | 1524 |
1529 if (right_op->IsRegister()) { | 1525 if (right_op->IsRegister()) { |
1530 // No need to mask the right operand on MIPS, it is built into the variable | 1526 // No need to mask the right operand on MIPS, it is built into the variable |
1531 // shift instructions. | 1527 // shift instructions. |
1532 switch (instr->op()) { | 1528 switch (instr->op()) { |
1533 case Token::ROR: | 1529 case Token::ROR: |
1534 __ Ror(result, left, Operand(ToRegister(right_op))); | 1530 __ Ror(result, left, Operand(ToRegister(right_op))); |
1535 break; | 1531 break; |
1536 case Token::SAR: | 1532 case Token::SAR: |
1537 __ srav(result, left, ToRegister(right_op)); | 1533 __ srav(result, left, ToRegister(right_op)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1574 } else { | 1570 } else { |
1575 if (instr->can_deopt()) { | 1571 if (instr->can_deopt()) { |
1576 __ And(at, left, Operand(0x80000000)); | 1572 __ And(at, left, Operand(0x80000000)); |
1577 DeoptimizeIf(ne, instr->environment(), at, Operand(zero_reg)); | 1573 DeoptimizeIf(ne, instr->environment(), at, Operand(zero_reg)); |
1578 } | 1574 } |
1579 __ Move(result, left); | 1575 __ Move(result, left); |
1580 } | 1576 } |
1581 break; | 1577 break; |
1582 case Token::SHL: | 1578 case Token::SHL: |
1583 if (shift_count != 0) { | 1579 if (shift_count != 0) { |
1584 if (instr->hydrogen_value()->representation().IsSmi() && | 1580 __ sll(result, left, shift_count); |
1585 instr->can_deopt()) { | |
1586 __ sll(result, left, shift_count - 1); | |
1587 __ SmiTagCheckOverflow(result, result, scratch); | |
1588 DeoptimizeIf(lt, instr->environment(), scratch, Operand(zero_reg)); | |
1589 } else { | |
1590 __ sll(result, left, shift_count); | |
1591 } | |
1592 } else { | 1581 } else { |
1593 __ Move(result, left); | 1582 __ Move(result, left); |
1594 } | 1583 } |
1595 break; | 1584 break; |
1596 default: | 1585 default: |
1597 UNREACHABLE(); | 1586 UNREACHABLE(); |
1598 break; | 1587 break; |
1599 } | 1588 } |
1600 } | 1589 } |
1601 } | 1590 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 | 1640 |
1652 | 1641 |
1653 void LCodeGen::DoConstantD(LConstantD* instr) { | 1642 void LCodeGen::DoConstantD(LConstantD* instr) { |
1654 ASSERT(instr->result()->IsDoubleRegister()); | 1643 ASSERT(instr->result()->IsDoubleRegister()); |
1655 DoubleRegister result = ToDoubleRegister(instr->result()); | 1644 DoubleRegister result = ToDoubleRegister(instr->result()); |
1656 double v = instr->value(); | 1645 double v = instr->value(); |
1657 __ Move(result, v); | 1646 __ Move(result, v); |
1658 } | 1647 } |
1659 | 1648 |
1660 | 1649 |
1661 void LCodeGen::DoConstantE(LConstantE* instr) { | |
1662 __ li(ToRegister(instr->result()), Operand(instr->value())); | |
1663 } | |
1664 | |
1665 | |
1666 void LCodeGen::DoConstantT(LConstantT* instr) { | 1650 void LCodeGen::DoConstantT(LConstantT* instr) { |
1667 Handle<Object> value = instr->value(); | 1651 Handle<Object> value = instr->value(); |
1668 AllowDeferredHandleDereference smi_check; | 1652 AllowDeferredHandleDereference smi_check; |
1669 __ LoadObject(ToRegister(instr->result()), value); | 1653 __ LoadObject(ToRegister(instr->result()), value); |
1670 } | 1654 } |
1671 | 1655 |
1672 | 1656 |
1673 void LCodeGen::DoMapEnumLength(LMapEnumLength* instr) { | 1657 void LCodeGen::DoMapEnumLength(LMapEnumLength* instr) { |
1674 Register result = ToRegister(instr->result()); | 1658 Register result = ToRegister(instr->result()); |
1675 Register map = ToRegister(instr->value()); | 1659 Register map = ToRegister(instr->value()); |
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2876 } | 2860 } |
2877 | 2861 |
2878 __ bind(&skip_assignment); | 2862 __ bind(&skip_assignment); |
2879 } | 2863 } |
2880 | 2864 |
2881 | 2865 |
2882 void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { | 2866 void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { |
2883 HObjectAccess access = instr->hydrogen()->access(); | 2867 HObjectAccess access = instr->hydrogen()->access(); |
2884 int offset = access.offset(); | 2868 int offset = access.offset(); |
2885 Register object = ToRegister(instr->object()); | 2869 Register object = ToRegister(instr->object()); |
2886 | |
2887 if (access.IsExternalMemory()) { | |
2888 Register result = ToRegister(instr->result()); | |
2889 __ lw(result, MemOperand(object, offset)); | |
2890 return; | |
2891 } | |
2892 | |
2893 if (instr->hydrogen()->representation().IsDouble()) { | 2870 if (instr->hydrogen()->representation().IsDouble()) { |
2894 DoubleRegister result = ToDoubleRegister(instr->result()); | 2871 DoubleRegister result = ToDoubleRegister(instr->result()); |
2895 __ ldc1(result, FieldMemOperand(object, offset)); | 2872 __ ldc1(result, FieldMemOperand(object, offset)); |
2896 return; | 2873 return; |
2897 } | 2874 } |
2898 | 2875 |
2899 Register result = ToRegister(instr->result()); | 2876 Register result = ToRegister(instr->result()); |
2900 if (access.IsInobject()) { | 2877 if (access.IsInobject()) { |
2901 __ lw(result, FieldMemOperand(object, offset)); | 2878 __ lw(result, FieldMemOperand(object, offset)); |
2902 } else { | 2879 } else { |
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4120 | 4097 |
4121 | 4098 |
4122 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { | 4099 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { |
4123 Representation representation = instr->representation(); | 4100 Representation representation = instr->representation(); |
4124 | 4101 |
4125 Register object = ToRegister(instr->object()); | 4102 Register object = ToRegister(instr->object()); |
4126 Register scratch = scratch0(); | 4103 Register scratch = scratch0(); |
4127 HObjectAccess access = instr->hydrogen()->access(); | 4104 HObjectAccess access = instr->hydrogen()->access(); |
4128 int offset = access.offset(); | 4105 int offset = access.offset(); |
4129 | 4106 |
4130 if (access.IsExternalMemory()) { | |
4131 Register value = ToRegister(instr->value()); | |
4132 __ sw(value, MemOperand(object, offset)); | |
4133 return; | |
4134 } | |
4135 | |
4136 Handle<Map> transition = instr->transition(); | 4107 Handle<Map> transition = instr->transition(); |
4137 | 4108 |
4138 if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { | 4109 if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { |
4139 Register value = ToRegister(instr->value()); | 4110 Register value = ToRegister(instr->value()); |
4140 if (!instr->hydrogen()->value()->type().IsHeapObject()) { | 4111 if (!instr->hydrogen()->value()->type().IsHeapObject()) { |
4141 __ And(scratch, value, Operand(kSmiTagMask)); | 4112 __ And(scratch, value, Operand(kSmiTagMask)); |
4142 DeoptimizeIf(eq, instr->environment(), scratch, Operand(zero_reg)); | 4113 DeoptimizeIf(eq, instr->environment(), scratch, Operand(zero_reg)); |
4143 } | 4114 } |
4144 } else if (FLAG_track_double_fields && representation.IsDouble()) { | 4115 } else if (FLAG_track_double_fields && representation.IsDouble()) { |
4145 ASSERT(transition.is_null()); | 4116 ASSERT(transition.is_null()); |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4466 __ lw(scratch, FieldMemOperand(object_reg, HeapObject::kMapOffset)); | 4437 __ lw(scratch, FieldMemOperand(object_reg, HeapObject::kMapOffset)); |
4467 __ Branch(¬_applicable, ne, scratch, Operand(from_map)); | 4438 __ Branch(¬_applicable, ne, scratch, Operand(from_map)); |
4468 | 4439 |
4469 if (IsSimpleMapChangeTransition(from_kind, to_kind)) { | 4440 if (IsSimpleMapChangeTransition(from_kind, to_kind)) { |
4470 Register new_map_reg = ToRegister(instr->new_map_temp()); | 4441 Register new_map_reg = ToRegister(instr->new_map_temp()); |
4471 __ li(new_map_reg, Operand(to_map)); | 4442 __ li(new_map_reg, Operand(to_map)); |
4472 __ sw(new_map_reg, FieldMemOperand(object_reg, HeapObject::kMapOffset)); | 4443 __ sw(new_map_reg, FieldMemOperand(object_reg, HeapObject::kMapOffset)); |
4473 // Write barrier. | 4444 // Write barrier. |
4474 __ RecordWriteField(object_reg, HeapObject::kMapOffset, new_map_reg, | 4445 __ RecordWriteField(object_reg, HeapObject::kMapOffset, new_map_reg, |
4475 scratch, GetRAState(), kDontSaveFPRegs); | 4446 scratch, GetRAState(), kDontSaveFPRegs); |
4476 } else { | 4447 } else if (FLAG_compiled_transitions) { |
4477 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); | 4448 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); |
4478 __ mov(a0, object_reg); | 4449 __ mov(a0, object_reg); |
4479 __ li(a1, Operand(to_map)); | 4450 __ li(a1, Operand(to_map)); |
4480 TransitionElementsKindStub stub(from_kind, to_kind); | 4451 TransitionElementsKindStub stub(from_kind, to_kind); |
4481 __ CallStub(&stub); | 4452 __ CallStub(&stub); |
4482 RecordSafepointWithRegisters( | 4453 RecordSafepointWithRegisters( |
4483 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt); | 4454 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt); |
| 4455 } else if (IsFastSmiElementsKind(from_kind) && |
| 4456 IsFastDoubleElementsKind(to_kind)) { |
| 4457 Register fixed_object_reg = ToRegister(instr->temp()); |
| 4458 ASSERT(fixed_object_reg.is(a2)); |
| 4459 Register new_map_reg = ToRegister(instr->new_map_temp()); |
| 4460 ASSERT(new_map_reg.is(a3)); |
| 4461 __ li(new_map_reg, Operand(to_map)); |
| 4462 __ mov(fixed_object_reg, object_reg); |
| 4463 CallCode(isolate()->builtins()->TransitionElementsSmiToDouble(), |
| 4464 RelocInfo::CODE_TARGET, instr); |
| 4465 } else if (IsFastDoubleElementsKind(from_kind) && |
| 4466 IsFastObjectElementsKind(to_kind)) { |
| 4467 Register fixed_object_reg = ToRegister(instr->temp()); |
| 4468 ASSERT(fixed_object_reg.is(a2)); |
| 4469 Register new_map_reg = ToRegister(instr->new_map_temp()); |
| 4470 ASSERT(new_map_reg.is(a3)); |
| 4471 __ li(new_map_reg, Operand(to_map)); |
| 4472 __ mov(fixed_object_reg, object_reg); |
| 4473 CallCode(isolate()->builtins()->TransitionElementsDoubleToObject(), |
| 4474 RelocInfo::CODE_TARGET, instr); |
| 4475 } else { |
| 4476 UNREACHABLE(); |
4484 } | 4477 } |
4485 __ bind(¬_applicable); | 4478 __ bind(¬_applicable); |
4486 } | 4479 } |
4487 | 4480 |
4488 | 4481 |
4489 void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) { | 4482 void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) { |
4490 Register object = ToRegister(instr->object()); | 4483 Register object = ToRegister(instr->object()); |
4491 Register temp = ToRegister(instr->temp()); | 4484 Register temp = ToRegister(instr->temp()); |
4492 Label fail; | 4485 Label fail; |
4493 __ TestJSArrayForAllocationMemento(object, temp, ne, &fail); | 4486 __ TestJSArrayForAllocationMemento(object, temp, ne, &fail); |
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5854 __ Subu(scratch, result, scratch); | 5847 __ Subu(scratch, result, scratch); |
5855 __ lw(result, FieldMemOperand(scratch, | 5848 __ lw(result, FieldMemOperand(scratch, |
5856 FixedArray::kHeaderSize - kPointerSize)); | 5849 FixedArray::kHeaderSize - kPointerSize)); |
5857 __ bind(&done); | 5850 __ bind(&done); |
5858 } | 5851 } |
5859 | 5852 |
5860 | 5853 |
5861 #undef __ | 5854 #undef __ |
5862 | 5855 |
5863 } } // namespace v8::internal | 5856 } } // namespace v8::internal |
OLD | NEW |