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 2637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2648 // Get the deoptimization index of the LLazyBailout-environment that | 2648 // Get the deoptimization index of the LLazyBailout-environment that |
2649 // corresponds to this instruction. | 2649 // corresponds to this instruction. |
2650 LEnvironment* env = instr->GetDeferredLazyDeoptimizationEnvironment(); | 2650 LEnvironment* env = instr->GetDeferredLazyDeoptimizationEnvironment(); |
2651 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); | 2651 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); |
2652 | 2652 |
2653 // Put the result value into the eax slot and restore all registers. | 2653 // Put the result value into the eax slot and restore all registers. |
2654 __ StoreToSafepointRegisterSlot(eax, eax); | 2654 __ StoreToSafepointRegisterSlot(eax, eax); |
2655 } | 2655 } |
2656 | 2656 |
2657 | 2657 |
| 2658 void LCodeGen::DoInstanceSize(LInstanceSize* instr) { |
| 2659 Register object = ToRegister(instr->object()); |
| 2660 Register result = ToRegister(instr->result()); |
| 2661 __ mov(result, FieldOperand(object, HeapObject::kMapOffset)); |
| 2662 __ movzx_b(result, FieldOperand(result, Map::kInstanceSizeOffset)); |
| 2663 } |
| 2664 |
| 2665 |
2658 void LCodeGen::DoCmpT(LCmpT* instr) { | 2666 void LCodeGen::DoCmpT(LCmpT* instr) { |
2659 Token::Value op = instr->op(); | 2667 Token::Value op = instr->op(); |
2660 | 2668 |
2661 Handle<Code> ic = CompareIC::GetUninitialized(op); | 2669 Handle<Code> ic = CompareIC::GetUninitialized(op); |
2662 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2670 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2663 | 2671 |
2664 Condition condition = ComputeCompareCondition(op); | 2672 Condition condition = ComputeCompareCondition(op); |
2665 Label true_value, done; | 2673 Label true_value, done; |
2666 __ test(eax, Operand(eax)); | 2674 __ test(eax, Operand(eax)); |
2667 __ j(condition, &true_value, Label::kNear); | 2675 __ j(condition, &true_value, Label::kNear); |
(...skipping 2784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5452 : LDeferredCode(codegen), instr_(instr) { } | 5460 : LDeferredCode(codegen), instr_(instr) { } |
5453 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); } | 5461 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); } |
5454 virtual LInstruction* instr() { return instr_; } | 5462 virtual LInstruction* instr() { return instr_; } |
5455 private: | 5463 private: |
5456 LAllocate* instr_; | 5464 LAllocate* instr_; |
5457 }; | 5465 }; |
5458 | 5466 |
5459 DeferredAllocate* deferred = | 5467 DeferredAllocate* deferred = |
5460 new(zone()) DeferredAllocate(this, instr); | 5468 new(zone()) DeferredAllocate(this, instr); |
5461 | 5469 |
5462 Register size = ToRegister(instr->size()); | |
5463 Register result = ToRegister(instr->result()); | 5470 Register result = ToRegister(instr->result()); |
5464 Register temp = ToRegister(instr->temp()); | 5471 Register temp = ToRegister(instr->temp()); |
5465 | 5472 |
5466 HAllocate* original_instr = instr->hydrogen(); | 5473 // Allocate memory for the object. |
5467 if (original_instr->size()->IsConstant()) { | 5474 AllocationFlags flags = TAG_OBJECT; |
5468 UNREACHABLE(); | 5475 if (instr->hydrogen()->MustAllocateDoubleAligned()) { |
| 5476 flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT); |
| 5477 } |
| 5478 if (instr->size()->IsConstantOperand()) { |
| 5479 int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); |
| 5480 __ AllocateInNewSpace(size, result, temp, no_reg, deferred->entry(), flags); |
5469 } else { | 5481 } else { |
5470 // Allocate memory for the object. | 5482 Register size = ToRegister(instr->size()); |
5471 AllocationFlags flags = TAG_OBJECT; | 5483 __ AllocateInNewSpace(size, result, temp, no_reg, deferred->entry(), flags); |
5472 if (original_instr->MustAllocateDoubleAligned()) { | |
5473 flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT); | |
5474 } | |
5475 __ AllocateInNewSpace(size, result, temp, no_reg, | |
5476 deferred->entry(), flags); | |
5477 } | 5484 } |
5478 | 5485 |
5479 __ bind(deferred->exit()); | 5486 __ bind(deferred->exit()); |
5480 } | 5487 } |
5481 | 5488 |
5482 | 5489 |
5483 void LCodeGen::DoDeferredAllocate(LAllocate* instr) { | 5490 void LCodeGen::DoDeferredAllocate(LAllocate* instr) { |
5484 Register size = ToRegister(instr->size()); | 5491 Register size = ToRegister(instr->size()); |
5485 Register result = ToRegister(instr->result()); | 5492 Register result = ToRegister(instr->result()); |
5486 | 5493 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5724 ASSERT_EQ(size, offset); | 5731 ASSERT_EQ(size, offset); |
5725 } | 5732 } |
5726 | 5733 |
5727 | 5734 |
5728 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { | 5735 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { |
5729 ASSERT(ToRegister(instr->context()).is(esi)); | 5736 ASSERT(ToRegister(instr->context()).is(esi)); |
5730 Handle<FixedArray> literals(instr->environment()->closure()->literals()); | 5737 Handle<FixedArray> literals(instr->environment()->closure()->literals()); |
5731 Handle<FixedArray> constant_properties = | 5738 Handle<FixedArray> constant_properties = |
5732 instr->hydrogen()->constant_properties(); | 5739 instr->hydrogen()->constant_properties(); |
5733 | 5740 |
5734 // Set up the parameters to the stub/runtime call. | |
5735 __ PushHeapObject(literals); | |
5736 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); | |
5737 __ push(Immediate(constant_properties)); | |
5738 int flags = instr->hydrogen()->fast_elements() | 5741 int flags = instr->hydrogen()->fast_elements() |
5739 ? ObjectLiteral::kFastElements | 5742 ? ObjectLiteral::kFastElements |
5740 : ObjectLiteral::kNoFlags; | 5743 : ObjectLiteral::kNoFlags; |
5741 flags |= instr->hydrogen()->has_function() | 5744 flags |= instr->hydrogen()->has_function() |
5742 ? ObjectLiteral::kHasFunction | 5745 ? ObjectLiteral::kHasFunction |
5743 : ObjectLiteral::kNoFlags; | 5746 : ObjectLiteral::kNoFlags; |
5744 __ push(Immediate(Smi::FromInt(flags))); | |
5745 | 5747 |
5746 // Pick the right runtime function or stub to call. | 5748 // Set up the parameters to the stub/runtime call and pick the right |
| 5749 // runtime function or stub to call. |
5747 int properties_count = constant_properties->length() / 2; | 5750 int properties_count = constant_properties->length() / 2; |
5748 if (instr->hydrogen()->depth() > 1) { | 5751 if (instr->hydrogen()->depth() > 1) { |
| 5752 __ PushHeapObject(literals); |
| 5753 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); |
| 5754 __ push(Immediate(constant_properties)); |
| 5755 __ push(Immediate(Smi::FromInt(flags))); |
5749 CallRuntime(Runtime::kCreateObjectLiteral, 4, instr); | 5756 CallRuntime(Runtime::kCreateObjectLiteral, 4, instr); |
5750 } else if (flags != ObjectLiteral::kFastElements || | 5757 } else if (flags != ObjectLiteral::kFastElements || |
5751 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { | 5758 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { |
| 5759 __ PushHeapObject(literals); |
| 5760 __ push(Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); |
| 5761 __ push(Immediate(constant_properties)); |
| 5762 __ push(Immediate(Smi::FromInt(flags))); |
5752 CallRuntime(Runtime::kCreateObjectLiteralShallow, 4, instr); | 5763 CallRuntime(Runtime::kCreateObjectLiteralShallow, 4, instr); |
5753 } else { | 5764 } else { |
| 5765 __ LoadHeapObject(eax, literals); |
| 5766 __ mov(ebx, Immediate(Smi::FromInt(instr->hydrogen()->literal_index()))); |
| 5767 __ mov(ecx, Immediate(constant_properties)); |
| 5768 __ mov(edx, Immediate(Smi::FromInt(flags))); |
5754 FastCloneShallowObjectStub stub(properties_count); | 5769 FastCloneShallowObjectStub stub(properties_count); |
5755 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 5770 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
5756 } | 5771 } |
5757 } | 5772 } |
5758 | 5773 |
5759 | 5774 |
5760 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { | 5775 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { |
5761 ASSERT(ToRegister(instr->value()).is(eax)); | 5776 ASSERT(ToRegister(instr->value()).is(eax)); |
5762 __ push(eax); | 5777 __ push(eax); |
5763 CallRuntime(Runtime::kToFastProperties, 1, instr); | 5778 CallRuntime(Runtime::kToFastProperties, 1, instr); |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6187 FixedArray::kHeaderSize - kPointerSize)); | 6202 FixedArray::kHeaderSize - kPointerSize)); |
6188 __ bind(&done); | 6203 __ bind(&done); |
6189 } | 6204 } |
6190 | 6205 |
6191 | 6206 |
6192 #undef __ | 6207 #undef __ |
6193 | 6208 |
6194 } } // namespace v8::internal | 6209 } } // namespace v8::internal |
6195 | 6210 |
6196 #endif // V8_TARGET_ARCH_IA32 | 6211 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |