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 4122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4133 // Check the holder map. | 4133 // Check the holder map. |
4134 __ lw(temp2, FieldMemOperand(temp1, HeapObject::kMapOffset)); | 4134 __ lw(temp2, FieldMemOperand(temp1, HeapObject::kMapOffset)); |
4135 DeoptimizeIf(ne, | 4135 DeoptimizeIf(ne, |
4136 instr->environment(), | 4136 instr->environment(), |
4137 temp2, | 4137 temp2, |
4138 Operand(Handle<Map>(current_prototype->map()))); | 4138 Operand(Handle<Map>(current_prototype->map()))); |
4139 } | 4139 } |
4140 | 4140 |
4141 | 4141 |
4142 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | 4142 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
4143 Handle<FixedArray> constant_elements = instr->hydrogen()->constant_elements(); | 4143 Heap* heap = isolate()->heap(); |
4144 ASSERT_EQ(2, constant_elements->length()); | 4144 ElementsKind boilerplate_elements_kind = |
4145 ElementsKind constant_elements_kind = | 4145 instr->hydrogen()->boilerplate_elements_kind(); |
4146 static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); | |
4147 | 4146 |
| 4147 // Deopt if the array literal boilerplate ElementsKind is of a type different |
| 4148 // than the expected one. The check isn't necessary if the boilerplate has |
| 4149 // already been converted to FAST_ELEMENTS. |
| 4150 if (boilerplate_elements_kind != FAST_ELEMENTS) { |
| 4151 LoadHeapObject(a1, instr->hydrogen()->boilerplate_object()); |
| 4152 // Load map into a2. |
| 4153 __ lw(a2, FieldMemOperand(a1, HeapObject::kMapOffset)); |
| 4154 // Load the map's "bit field 2". |
| 4155 __ lbu(a2, FieldMemOperand(a2, Map::kBitField2Offset)); |
| 4156 // Retrieve elements_kind from bit field 2. |
| 4157 __ Ext(a2, a2, Map::kElementsKindShift, Map::kElementsKindBitCount); |
| 4158 DeoptimizeIf(ne, |
| 4159 instr->environment(), |
| 4160 a2, |
| 4161 Operand(boilerplate_elements_kind)); |
| 4162 } |
4148 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 4163 __ lw(a3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
4149 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); | 4164 __ lw(a3, FieldMemOperand(a3, JSFunction::kLiteralsOffset)); |
4150 __ li(a2, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); | 4165 __ li(a2, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); |
4151 __ li(a1, Operand(constant_elements)); | 4166 // Boilerplate already exists, constant elements are never accessed. |
| 4167 // Pass an empty fixed array. |
| 4168 __ li(a1, Operand(Handle<FixedArray>(heap->empty_fixed_array()))); |
4152 __ Push(a3, a2, a1); | 4169 __ Push(a3, a2, a1); |
4153 | 4170 |
4154 // Pick the right runtime function or stub to call. | 4171 // Pick the right runtime function or stub to call. |
4155 int length = instr->hydrogen()->length(); | 4172 int length = instr->hydrogen()->length(); |
4156 if (instr->hydrogen()->IsCopyOnWrite()) { | 4173 if (instr->hydrogen()->IsCopyOnWrite()) { |
4157 ASSERT(instr->hydrogen()->depth() == 1); | 4174 ASSERT(instr->hydrogen()->depth() == 1); |
4158 FastCloneShallowArrayStub::Mode mode = | 4175 FastCloneShallowArrayStub::Mode mode = |
4159 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; | 4176 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; |
4160 FastCloneShallowArrayStub stub(mode, length); | 4177 FastCloneShallowArrayStub stub(mode, length); |
4161 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 4178 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
4162 } else if (instr->hydrogen()->depth() > 1) { | 4179 } else if (instr->hydrogen()->depth() > 1) { |
4163 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); | 4180 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); |
4164 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { | 4181 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
4165 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); | 4182 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); |
4166 } else { | 4183 } else { |
4167 FastCloneShallowArrayStub::Mode mode = | 4184 FastCloneShallowArrayStub::Mode mode = |
4168 constant_elements_kind == FAST_DOUBLE_ELEMENTS | 4185 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS |
4169 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS | 4186 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS |
4170 : FastCloneShallowArrayStub::CLONE_ELEMENTS; | 4187 : FastCloneShallowArrayStub::CLONE_ELEMENTS; |
4171 FastCloneShallowArrayStub stub(mode, length); | 4188 FastCloneShallowArrayStub stub(mode, length); |
4172 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 4189 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
4173 } | 4190 } |
4174 } | 4191 } |
4175 | 4192 |
4176 | 4193 |
4177 void LCodeGen::EmitDeepCopy(Handle<JSObject> object, | 4194 void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
4178 Register result, | 4195 Register result, |
4179 Register source, | 4196 Register source, |
4180 int* offset) { | 4197 int* offset) { |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4645 ASSERT(!environment->HasBeenRegistered()); | 4662 ASSERT(!environment->HasBeenRegistered()); |
4646 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); | 4663 RegisterEnvironmentForDeoptimization(environment, Safepoint::kNoLazyDeopt); |
4647 ASSERT(osr_pc_offset_ == -1); | 4664 ASSERT(osr_pc_offset_ == -1); |
4648 osr_pc_offset_ = masm()->pc_offset(); | 4665 osr_pc_offset_ = masm()->pc_offset(); |
4649 } | 4666 } |
4650 | 4667 |
4651 | 4668 |
4652 #undef __ | 4669 #undef __ |
4653 | 4670 |
4654 } } // namespace v8::internal | 4671 } } // namespace v8::internal |
OLD | NEW |