OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 5143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5154 CallRuntimeFromDeferred( | 5154 CallRuntimeFromDeferred( |
5155 Runtime::kAllocateInOldPointerSpace, 1, instr); | 5155 Runtime::kAllocateInOldPointerSpace, 1, instr); |
5156 } else { | 5156 } else { |
5157 CallRuntimeFromDeferred( | 5157 CallRuntimeFromDeferred( |
5158 Runtime::kAllocateInNewSpace, 1, instr); | 5158 Runtime::kAllocateInNewSpace, 1, instr); |
5159 } | 5159 } |
5160 __ StoreToSafepointRegisterSlot(result, rax); | 5160 __ StoreToSafepointRegisterSlot(result, rax); |
5161 } | 5161 } |
5162 | 5162 |
5163 | 5163 |
5164 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | |
5165 Handle<FixedArray> literals = instr->hydrogen()->literals(); | |
5166 ElementsKind boilerplate_elements_kind = | |
5167 instr->hydrogen()->boilerplate_elements_kind(); | |
5168 AllocationSiteMode allocation_site_mode = | |
5169 instr->hydrogen()->allocation_site_mode(); | |
5170 | |
5171 // Deopt if the array literal boilerplate ElementsKind is of a type different | |
5172 // than the expected one. The check isn't necessary if the boilerplate has | |
5173 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. | |
5174 if (CanTransitionToMoreGeneralFastElementsKind( | |
5175 boilerplate_elements_kind, true)) { | |
5176 __ LoadHeapObject(rax, instr->hydrogen()->boilerplate_object()); | |
5177 __ movq(rbx, FieldOperand(rax, HeapObject::kMapOffset)); | |
5178 // Load the map's "bit field 2". | |
5179 __ movb(rbx, FieldOperand(rbx, Map::kBitField2Offset)); | |
5180 // Retrieve elements_kind from bit field 2. | |
5181 __ and_(rbx, Immediate(Map::kElementsKindMask)); | |
5182 __ cmpb(rbx, Immediate(boilerplate_elements_kind << | |
5183 Map::kElementsKindShift)); | |
5184 DeoptimizeIf(not_equal, instr->environment()); | |
5185 } | |
5186 | |
5187 // Set up the parameters to the stub/runtime call and pick the right | |
5188 // runtime function or stub to call. Boilerplate already exists, | |
5189 // constant elements are never accessed, pass an empty fixed array. | |
5190 int length = instr->hydrogen()->length(); | |
5191 if (instr->hydrogen()->IsCopyOnWrite()) { | |
5192 ASSERT(instr->hydrogen()->depth() == 1); | |
5193 __ LoadHeapObject(rax, literals); | |
5194 __ Move(rbx, Smi::FromInt(instr->hydrogen()->literal_index())); | |
5195 __ Move(rcx, isolate()->factory()->empty_fixed_array()); | |
5196 FastCloneShallowArrayStub::Mode mode = | |
5197 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; | |
5198 FastCloneShallowArrayStub stub(mode, DONT_TRACK_ALLOCATION_SITE, length); | |
5199 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | |
5200 } else if (instr->hydrogen()->depth() > 1) { | |
5201 __ PushHeapObject(literals); | |
5202 __ Push(Smi::FromInt(instr->hydrogen()->literal_index())); | |
5203 __ Push(isolate()->factory()->empty_fixed_array()); | |
5204 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); | |
5205 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { | |
5206 __ PushHeapObject(literals); | |
5207 __ Push(Smi::FromInt(instr->hydrogen()->literal_index())); | |
5208 __ Push(isolate()->factory()->empty_fixed_array()); | |
5209 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); | |
5210 } else { | |
5211 __ LoadHeapObject(rax, literals); | |
5212 __ Move(rbx, Smi::FromInt(instr->hydrogen()->literal_index())); | |
5213 __ Move(rcx, isolate()->factory()->empty_fixed_array()); | |
5214 FastCloneShallowArrayStub::Mode mode = | |
5215 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS | |
5216 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS | |
5217 : FastCloneShallowArrayStub::CLONE_ELEMENTS; | |
5218 FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); | |
5219 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | |
5220 } | |
5221 } | |
5222 | |
5223 | |
5224 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { | 5164 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { |
5225 ASSERT(ToRegister(instr->value()).is(rax)); | 5165 ASSERT(ToRegister(instr->value()).is(rax)); |
5226 __ push(rax); | 5166 __ push(rax); |
5227 CallRuntime(Runtime::kToFastProperties, 1, instr); | 5167 CallRuntime(Runtime::kToFastProperties, 1, instr); |
5228 } | 5168 } |
5229 | 5169 |
5230 | 5170 |
5231 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { | 5171 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) { |
5232 Label materialized; | 5172 Label materialized; |
5233 // Registers will be used as follows: | 5173 // Registers will be used as follows: |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5666 FixedArray::kHeaderSize - kPointerSize)); | 5606 FixedArray::kHeaderSize - kPointerSize)); |
5667 __ bind(&done); | 5607 __ bind(&done); |
5668 } | 5608 } |
5669 | 5609 |
5670 | 5610 |
5671 #undef __ | 5611 #undef __ |
5672 | 5612 |
5673 } } // namespace v8::internal | 5613 } } // namespace v8::internal |
5674 | 5614 |
5675 #endif // V8_TARGET_ARCH_X64 | 5615 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |