OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 4213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4224 } | 4224 } |
4225 | 4225 |
4226 // Check the holder map. | 4226 // Check the holder map. |
4227 __ ldr(temp2, FieldMemOperand(temp1, HeapObject::kMapOffset)); | 4227 __ ldr(temp2, FieldMemOperand(temp1, HeapObject::kMapOffset)); |
4228 __ cmp(temp2, Operand(Handle<Map>(current_prototype->map()))); | 4228 __ cmp(temp2, Operand(Handle<Map>(current_prototype->map()))); |
4229 DeoptimizeIf(ne, instr->environment()); | 4229 DeoptimizeIf(ne, instr->environment()); |
4230 } | 4230 } |
4231 | 4231 |
4232 | 4232 |
4233 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | 4233 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
4234 Handle<FixedArray> constant_elements = instr->hydrogen()->constant_elements(); | 4234 Heap* heap = isolate()->heap(); |
4235 ASSERT_EQ(2, constant_elements->length()); | 4235 ElementsKind boilerplate_elements_kind = |
4236 ElementsKind constant_elements_kind = | 4236 instr->hydrogen()->boilerplate_elements_kind(); |
4237 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | 4237 |
| 4238 // Deopt if the array literal boilerplate ElementsKind is of a type different |
| 4239 // than the expected one. The check isn't necessary if the boilerplate has |
| 4240 // already been converted to FAST_ELEMENTS. |
| 4241 if (boilerplate_elements_kind != FAST_ELEMENTS) { |
| 4242 LoadHeapObject(r1, instr->hydrogen()->boilerplate_object()); |
| 4243 // Load map into r2. |
| 4244 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); |
| 4245 // Load the map's "bit field 2". |
| 4246 __ ldrb(r2, FieldMemOperand(r2, Map::kBitField2Offset)); |
| 4247 // Retrieve elements_kind from bit field 2. |
| 4248 __ ubfx(r2, r2, Map::kElementsKindShift, Map::kElementsKindBitCount); |
| 4249 __ cmp(r2, Operand(boilerplate_elements_kind)); |
| 4250 DeoptimizeIf(ne, instr->environment()); |
| 4251 } |
4238 | 4252 |
4239 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 4253 __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
4240 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); | 4254 __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); |
4241 __ mov(r2, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); | 4255 __ mov(r2, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); |
4242 __ mov(r1, Operand(constant_elements)); | 4256 // Boilerplate already exists, constant elements are never accessed. |
| 4257 // Pass an empty fixed array. |
| 4258 __ mov(r1, Operand(Handle<FixedArray>(heap->empty_fixed_array()))); |
4243 __ Push(r3, r2, r1); | 4259 __ Push(r3, r2, r1); |
4244 | 4260 |
4245 // Pick the right runtime function or stub to call. | 4261 // Pick the right runtime function or stub to call. |
4246 int length = instr->hydrogen()->length(); | 4262 int length = instr->hydrogen()->length(); |
4247 if (instr->hydrogen()->IsCopyOnWrite()) { | 4263 if (instr->hydrogen()->IsCopyOnWrite()) { |
4248 ASSERT(instr->hydrogen()->depth() == 1); | 4264 ASSERT(instr->hydrogen()->depth() == 1); |
4249 FastCloneShallowArrayStub::Mode mode = | 4265 FastCloneShallowArrayStub::Mode mode = |
4250 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; | 4266 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; |
4251 FastCloneShallowArrayStub stub(mode, length); | 4267 FastCloneShallowArrayStub stub(mode, length); |
4252 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 4268 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
4253 } else if (instr->hydrogen()->depth() > 1) { | 4269 } else if (instr->hydrogen()->depth() > 1) { |
4254 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); | 4270 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); |
4255 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { | 4271 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
4256 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); | 4272 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); |
4257 } else { | 4273 } else { |
4258 FastCloneShallowArrayStub::Mode mode = | 4274 FastCloneShallowArrayStub::Mode mode = |
4259 constant_elements_kind == FAST_DOUBLE_ELEMENTS | 4275 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS |
4260 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS | 4276 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS |
4261 : FastCloneShallowArrayStub::CLONE_ELEMENTS; | 4277 : FastCloneShallowArrayStub::CLONE_ELEMENTS; |
4262 FastCloneShallowArrayStub stub(mode, length); | 4278 FastCloneShallowArrayStub stub(mode, length); |
4263 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 4279 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
4264 } | 4280 } |
4265 } | 4281 } |
4266 | 4282 |
4267 | 4283 |
4268 void LCodeGen::EmitDeepCopy(Handle<JSObject> object, | 4284 void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
4269 Register result, | 4285 Register result, |
4270 Register source, | 4286 Register source, |
4271 int* offset) { | 4287 int* offset) { |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4683 ASSERT(osr_pc_offset_ == -1); | 4699 ASSERT(osr_pc_offset_ == -1); |
4684 osr_pc_offset_ = masm()->pc_offset(); | 4700 osr_pc_offset_ = masm()->pc_offset(); |
4685 } | 4701 } |
4686 | 4702 |
4687 | 4703 |
4688 | 4704 |
4689 | 4705 |
4690 #undef __ | 4706 #undef __ |
4691 | 4707 |
4692 } } // namespace v8::internal | 4708 } } // namespace v8::internal |
OLD | NEW |