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 5175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5186 CallRuntimeFromDeferred( | 5186 CallRuntimeFromDeferred( |
5187 Runtime::kAllocateInOldPointerSpace, 1, instr); | 5187 Runtime::kAllocateInOldPointerSpace, 1, instr); |
5188 } else { | 5188 } else { |
5189 CallRuntimeFromDeferred( | 5189 CallRuntimeFromDeferred( |
5190 Runtime::kAllocateInNewSpace, 1, instr); | 5190 Runtime::kAllocateInNewSpace, 1, instr); |
5191 } | 5191 } |
5192 __ StoreToSafepointRegisterSlot(v0, result); | 5192 __ StoreToSafepointRegisterSlot(v0, result); |
5193 } | 5193 } |
5194 | 5194 |
5195 | 5195 |
5196 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | |
5197 Handle<FixedArray> literals = instr->hydrogen()->literals(); | |
5198 ElementsKind boilerplate_elements_kind = | |
5199 instr->hydrogen()->boilerplate_elements_kind(); | |
5200 AllocationSiteMode allocation_site_mode = | |
5201 instr->hydrogen()->allocation_site_mode(); | |
5202 | |
5203 // Deopt if the array literal boilerplate ElementsKind is of a type different | |
5204 // than the expected one. The check isn't necessary if the boilerplate has | |
5205 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. | |
5206 if (CanTransitionToMoreGeneralFastElementsKind( | |
5207 boilerplate_elements_kind, true)) { | |
5208 __ LoadHeapObject(a1, instr->hydrogen()->boilerplate_object()); | |
5209 // Load map into a2. | |
5210 __ lw(a2, FieldMemOperand(a1, HeapObject::kMapOffset)); | |
5211 // Load the map's "bit field 2". | |
5212 __ lbu(a2, FieldMemOperand(a2, Map::kBitField2Offset)); | |
5213 // Retrieve elements_kind from bit field 2. | |
5214 __ Ext(a2, a2, Map::kElementsKindShift, Map::kElementsKindBitCount); | |
5215 DeoptimizeIf(ne, | |
5216 instr->environment(), | |
5217 a2, | |
5218 Operand(boilerplate_elements_kind)); | |
5219 } | |
5220 | |
5221 // Set up the parameters to the stub/runtime call. | |
5222 __ LoadHeapObject(a3, literals); | |
5223 __ li(a2, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); | |
5224 // Boilerplate already exists, constant elements are never accessed. | |
5225 // Pass an empty fixed array. | |
5226 __ li(a1, Operand(isolate()->factory()->empty_fixed_array())); | |
5227 | |
5228 // Pick the right runtime function or stub to call. | |
5229 int length = instr->hydrogen()->length(); | |
5230 if (instr->hydrogen()->IsCopyOnWrite()) { | |
5231 ASSERT(instr->hydrogen()->depth() == 1); | |
5232 FastCloneShallowArrayStub::Mode mode = | |
5233 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; | |
5234 FastCloneShallowArrayStub stub(mode, DONT_TRACK_ALLOCATION_SITE, length); | |
5235 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | |
5236 } else if (instr->hydrogen()->depth() > 1) { | |
5237 __ Push(a3, a2, a1); | |
5238 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); | |
5239 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { | |
5240 __ Push(a3, a2, a1); | |
5241 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); | |
5242 } else { | |
5243 FastCloneShallowArrayStub::Mode mode = | |
5244 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS | |
5245 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS | |
5246 : FastCloneShallowArrayStub::CLONE_ELEMENTS; | |
5247 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); | |
5248 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | |
5249 } | |
5250 } | |
5251 | |
5252 | |
5253 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { | 5196 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { |
5254 ASSERT(ToRegister(instr->value()).is(a0)); | 5197 ASSERT(ToRegister(instr->value()).is(a0)); |
5255 ASSERT(ToRegister(instr->result()).is(v0)); | 5198 ASSERT(ToRegister(instr->result()).is(v0)); |
5256 __ push(a0); | 5199 __ push(a0); |
5257 CallRuntime(Runtime::kToFastProperties, 1, instr); | 5200 CallRuntime(Runtime::kToFastProperties, 1, instr); |
5258 } | 5201 } |
5259 | 5202 |
5260 | 5203 |
5261 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { | 5204 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { |
5262 Label materialized; | 5205 Label materialized; |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5724 __ Subu(scratch, result, scratch); | 5667 __ Subu(scratch, result, scratch); |
5725 __ lw(result, FieldMemOperand(scratch, | 5668 __ lw(result, FieldMemOperand(scratch, |
5726 FixedArray::kHeaderSize - kPointerSize)); | 5669 FixedArray::kHeaderSize - kPointerSize)); |
5727 __ bind(&done); | 5670 __ bind(&done); |
5728 } | 5671 } |
5729 | 5672 |
5730 | 5673 |
5731 #undef __ | 5674 #undef __ |
5732 | 5675 |
5733 } } // namespace v8::internal | 5676 } } // namespace v8::internal |
OLD | NEW |