OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved.7 | 1 // Copyright 2012 the V8 project authors. All rights reserved.7 |
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 5058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5069 | 5069 |
5070 // Allocate memory for the object. | 5070 // Allocate memory for the object. |
5071 AllocationFlags flags = NO_ALLOCATION_FLAGS; | 5071 AllocationFlags flags = NO_ALLOCATION_FLAGS; |
5072 if (instr->hydrogen()->MustAllocateDoubleAligned()) { | 5072 if (instr->hydrogen()->MustAllocateDoubleAligned()) { |
5073 flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT); | 5073 flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT); |
5074 } | 5074 } |
5075 if (instr->hydrogen()->IsOldSpaceAllocation()) { | 5075 if (instr->hydrogen()->IsOldSpaceAllocation()) { |
5076 DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); | 5076 DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); |
5077 flags = static_cast<AllocationFlags>(flags | PRETENURE); | 5077 flags = static_cast<AllocationFlags>(flags | PRETENURE); |
5078 } | 5078 } |
| 5079 |
| 5080 if (instr->hydrogen()->IsAllocationFoldingDominator()) { |
| 5081 flags = static_cast<AllocationFlags>(flags | ALLOCATION_FOLDING_DOMINATOR); |
| 5082 } |
| 5083 |
| 5084 if (instr->hydrogen()->IsAllocationFolded()) { |
| 5085 flags = static_cast<AllocationFlags>(flags | ALLOCATION_FOLDED); |
| 5086 } |
| 5087 |
5079 if (instr->size()->IsConstantOperand()) { | 5088 if (instr->size()->IsConstantOperand()) { |
5080 int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); | 5089 int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); |
5081 CHECK(size <= Page::kMaxRegularHeapObjectSize); | 5090 CHECK(size <= Page::kMaxRegularHeapObjectSize); |
5082 __ Allocate(size, result, scratch, scratch2, deferred->entry(), flags); | 5091 __ Allocate(size, result, scratch, scratch2, deferred->entry(), flags); |
5083 } else { | 5092 } else { |
5084 Register size = ToRegister(instr->size()); | 5093 Register size = ToRegister(instr->size()); |
5085 __ Allocate(size, result, scratch, scratch2, deferred->entry(), flags); | 5094 __ Allocate(size, result, scratch, scratch2, deferred->entry(), flags); |
5086 } | 5095 } |
5087 | 5096 |
5088 __ bind(deferred->exit()); | 5097 __ bind(deferred->exit()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5137 DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); | 5146 DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); |
5138 flags = AllocateTargetSpace::update(flags, OLD_SPACE); | 5147 flags = AllocateTargetSpace::update(flags, OLD_SPACE); |
5139 } else { | 5148 } else { |
5140 flags = AllocateTargetSpace::update(flags, NEW_SPACE); | 5149 flags = AllocateTargetSpace::update(flags, NEW_SPACE); |
5141 } | 5150 } |
5142 __ Push(Smi::FromInt(flags)); | 5151 __ Push(Smi::FromInt(flags)); |
5143 | 5152 |
5144 CallRuntimeFromDeferred( | 5153 CallRuntimeFromDeferred( |
5145 Runtime::kAllocateInTargetSpace, 2, instr, instr->context()); | 5154 Runtime::kAllocateInTargetSpace, 2, instr, instr->context()); |
5146 __ StoreToSafepointRegisterSlot(v0, result); | 5155 __ StoreToSafepointRegisterSlot(v0, result); |
| 5156 |
| 5157 if (instr->hydrogen()->IsAllocationFoldingDominator()) { |
| 5158 AllocationFlags allocation_flags = NO_ALLOCATION_FLAGS; |
| 5159 if (instr->hydrogen()->IsOldSpaceAllocation()) { |
| 5160 DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); |
| 5161 allocation_flags = static_cast<AllocationFlags>(flags | PRETENURE); |
| 5162 } |
| 5163 // If the allocation folding dominator allocate triggered a GC, allocation |
| 5164 // happend in the runtime. We have to reset the top pointer to virtually |
| 5165 // undo the allocation. |
| 5166 ExternalReference allocation_top = |
| 5167 AllocationUtils::GetAllocationTopReference(isolate(), allocation_flags); |
| 5168 Register top_address = scratch0(); |
| 5169 __ Subu(v0, v0, Operand(kHeapObjectTag)); |
| 5170 __ li(top_address, Operand(allocation_top)); |
| 5171 __ sw(v0, MemOperand(top_address)); |
| 5172 __ Addu(v0, v0, Operand(kHeapObjectTag)); |
| 5173 } |
| 5174 } |
| 5175 |
| 5176 void LCodeGen::DoFastAllocate(LFastAllocate* instr) { |
| 5177 DCHECK(instr->hydrogen()->IsAllocationFolded()); |
| 5178 Register result = ToRegister(instr->result()); |
| 5179 Register scratch1 = ToRegister(instr->temp1()); |
| 5180 Register scratch2 = ToRegister(instr->temp2()); |
| 5181 |
| 5182 AllocationFlags flags = NO_ALLOCATION_FLAGS; |
| 5183 if (instr->hydrogen()->MustAllocateDoubleAligned()) { |
| 5184 flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT); |
| 5185 } |
| 5186 if (instr->hydrogen()->IsOldSpaceAllocation()) { |
| 5187 DCHECK(!instr->hydrogen()->IsNewSpaceAllocation()); |
| 5188 flags = static_cast<AllocationFlags>(flags | PRETENURE); |
| 5189 } |
| 5190 if (!instr->hydrogen()->IsAllocationFoldingDominator()) { |
| 5191 if (instr->size()->IsConstantOperand()) { |
| 5192 int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); |
| 5193 CHECK(size <= Page::kMaxRegularHeapObjectSize); |
| 5194 __ FastAllocate(size, result, scratch1, scratch2, flags); |
| 5195 } else { |
| 5196 Register size = ToRegister(instr->size()); |
| 5197 __ FastAllocate(size, result, scratch1, scratch2, flags); |
| 5198 } |
| 5199 } |
5147 } | 5200 } |
5148 | 5201 |
5149 | 5202 |
5150 void LCodeGen::DoTypeof(LTypeof* instr) { | 5203 void LCodeGen::DoTypeof(LTypeof* instr) { |
5151 DCHECK(ToRegister(instr->value()).is(a3)); | 5204 DCHECK(ToRegister(instr->value()).is(a3)); |
5152 DCHECK(ToRegister(instr->result()).is(v0)); | 5205 DCHECK(ToRegister(instr->result()).is(v0)); |
5153 Label end, do_call; | 5206 Label end, do_call; |
5154 Register value_register = ToRegister(instr->value()); | 5207 Register value_register = ToRegister(instr->value()); |
5155 __ JumpIfNotSmi(value_register, &do_call); | 5208 __ JumpIfNotSmi(value_register, &do_call); |
5156 __ li(v0, Operand(isolate()->factory()->number_string())); | 5209 __ li(v0, Operand(isolate()->factory()->number_string())); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5531 __ lw(result, FieldMemOperand(scratch, | 5584 __ lw(result, FieldMemOperand(scratch, |
5532 FixedArray::kHeaderSize - kPointerSize)); | 5585 FixedArray::kHeaderSize - kPointerSize)); |
5533 __ bind(deferred->exit()); | 5586 __ bind(deferred->exit()); |
5534 __ bind(&done); | 5587 __ bind(&done); |
5535 } | 5588 } |
5536 | 5589 |
5537 #undef __ | 5590 #undef __ |
5538 | 5591 |
5539 } // namespace internal | 5592 } // namespace internal |
5540 } // namespace v8 | 5593 } // namespace v8 |
OLD | NEW |