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 4667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4678 PushSafepointRegistersScope scope(this); | 4678 PushSafepointRegistersScope scope(this); |
4679 __ push(Immediate(Smi::FromInt(instance_size))); | 4679 __ push(Immediate(Smi::FromInt(instance_size))); |
4680 CallRuntimeFromDeferred( | 4680 CallRuntimeFromDeferred( |
4681 Runtime::kAllocateInNewSpace, 1, instr, instr->context()); | 4681 Runtime::kAllocateInNewSpace, 1, instr, instr->context()); |
4682 __ StoreToSafepointRegisterSlot(result, eax); | 4682 __ StoreToSafepointRegisterSlot(result, eax); |
4683 } | 4683 } |
4684 | 4684 |
4685 | 4685 |
4686 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | 4686 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
4687 ASSERT(ToRegister(instr->context()).is(esi)); | 4687 ASSERT(ToRegister(instr->context()).is(esi)); |
4688 Heap* heap = isolate()->heap(); | 4688 Handle<FixedArray> literals(instr->environment()->closure()->literals()); |
4689 ElementsKind boilerplate_elements_kind = | 4689 ElementsKind boilerplate_elements_kind = |
4690 instr->hydrogen()->boilerplate_elements_kind(); | 4690 instr->hydrogen()->boilerplate_elements_kind(); |
4691 | 4691 |
4692 // Deopt if the array literal boilerplate ElementsKind is of a type different | 4692 // Deopt if the array literal boilerplate ElementsKind is of a type different |
4693 // than the expected one. The check isn't necessary if the boilerplate has | 4693 // than the expected one. The check isn't necessary if the boilerplate has |
4694 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. | 4694 // already been converted to TERMINAL_FAST_ELEMENTS_KIND. |
4695 if (CanTransitionToMoreGeneralFastElementsKind( | 4695 if (CanTransitionToMoreGeneralFastElementsKind( |
4696 boilerplate_elements_kind, true)) { | 4696 boilerplate_elements_kind, true)) { |
4697 __ LoadHeapObject(eax, instr->hydrogen()->boilerplate_object()); | 4697 __ LoadHeapObject(eax, instr->hydrogen()->boilerplate_object()); |
4698 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 4698 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
4699 // Load the map's "bit field 2". We only need the first byte, | 4699 // Load the map's "bit field 2". We only need the first byte, |
4700 // but the following masking takes care of that anyway. | 4700 // but the following masking takes care of that anyway. |
4701 __ mov(ebx, FieldOperand(ebx, Map::kBitField2Offset)); | 4701 __ mov(ebx, FieldOperand(ebx, Map::kBitField2Offset)); |
4702 // Retrieve elements_kind from bit field 2. | 4702 // Retrieve elements_kind from bit field 2. |
4703 __ and_(ebx, Map::kElementsKindMask); | 4703 __ and_(ebx, Map::kElementsKindMask); |
4704 __ cmp(ebx, boilerplate_elements_kind << Map::kElementsKindShift); | 4704 __ cmp(ebx, boilerplate_elements_kind << Map::kElementsKindShift); |
4705 DeoptimizeIf(not_equal, instr->environment()); | 4705 DeoptimizeIf(not_equal, instr->environment()); |
4706 } | 4706 } |
4707 | 4707 |
4708 // Set up the parameters to the stub/runtime call. | 4708 // Set up the parameters to the stub/runtime call. |
4709 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 4709 __ PushHeapObject(literals); |
4710 __ push(FieldOperand(eax, JSFunction::kLiteralsOffset)); | |
4711 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); | 4710 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); |
4712 // Boilerplate already exists, constant elements are never accessed. | 4711 // Boilerplate already exists, constant elements are never accessed. |
4713 // Pass an empty fixed array. | 4712 // Pass an empty fixed array. |
4714 __ push(Immediate(Handle<FixedArray>(heap->empty_fixed_array()))); | 4713 __ push(Immediate(isolate()->factory()->empty_fixed_array())); |
4715 | 4714 |
4716 // Pick the right runtime function or stub to call. | 4715 // Pick the right runtime function or stub to call. |
4717 int length = instr->hydrogen()->length(); | 4716 int length = instr->hydrogen()->length(); |
4718 if (instr->hydrogen()->IsCopyOnWrite()) { | 4717 if (instr->hydrogen()->IsCopyOnWrite()) { |
4719 ASSERT(instr->hydrogen()->depth() == 1); | 4718 ASSERT(instr->hydrogen()->depth() == 1); |
4720 FastCloneShallowArrayStub::Mode mode = | 4719 FastCloneShallowArrayStub::Mode mode = |
4721 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; | 4720 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; |
4722 FastCloneShallowArrayStub stub(mode, length); | 4721 FastCloneShallowArrayStub stub(mode, length); |
4723 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 4722 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
4724 } else if (instr->hydrogen()->depth() > 1) { | 4723 } else if (instr->hydrogen()->depth() > 1) { |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5333 FixedArray::kHeaderSize - kPointerSize)); | 5332 FixedArray::kHeaderSize - kPointerSize)); |
5334 __ bind(&done); | 5333 __ bind(&done); |
5335 } | 5334 } |
5336 | 5335 |
5337 | 5336 |
5338 #undef __ | 5337 #undef __ |
5339 | 5338 |
5340 } } // namespace v8::internal | 5339 } } // namespace v8::internal |
5341 | 5340 |
5342 #endif // V8_TARGET_ARCH_IA32 | 5341 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |