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 2478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2489 instr, | 2489 instr, |
2490 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); | 2490 RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS); |
2491 LEnvironment* env = instr->GetDeferredLazyDeoptimizationEnvironment(); | 2491 LEnvironment* env = instr->GetDeferredLazyDeoptimizationEnvironment(); |
2492 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); | 2492 safepoints_.RecordLazyDeoptimizationIndex(env->deoptimization_index()); |
2493 // Put the result value into the result register slot and | 2493 // Put the result value into the result register slot and |
2494 // restore all registers. | 2494 // restore all registers. |
2495 __ StoreToSafepointRegisterSlot(result, result); | 2495 __ StoreToSafepointRegisterSlot(result, result); |
2496 } | 2496 } |
2497 | 2497 |
2498 | 2498 |
| 2499 void LCodeGen::DoInstanceSize(LInstanceSize* instr) { |
| 2500 Register object = ToRegister(instr->object()); |
| 2501 Register result = ToRegister(instr->result()); |
| 2502 __ lw(result, FieldMemOperand(object, HeapObject::kMapOffset)); |
| 2503 __ lbu(result, FieldMemOperand(result, Map::kInstanceSizeOffset)); |
| 2504 } |
| 2505 |
| 2506 |
2499 void LCodeGen::DoCmpT(LCmpT* instr) { | 2507 void LCodeGen::DoCmpT(LCmpT* instr) { |
2500 Token::Value op = instr->op(); | 2508 Token::Value op = instr->op(); |
2501 | 2509 |
2502 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); | 2510 Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); |
2503 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2511 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2504 // On MIPS there is no need for a "no inlined smi code" marker (nop). | 2512 // On MIPS there is no need for a "no inlined smi code" marker (nop). |
2505 | 2513 |
2506 Condition condition = ComputeCompareCondition(op); | 2514 Condition condition = ComputeCompareCondition(op); |
2507 // A minor optimization that relies on LoadRoot always emitting one | 2515 // A minor optimization that relies on LoadRoot always emitting one |
2508 // instruction. | 2516 // instruction. |
(...skipping 2759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5268 : LDeferredCode(codegen), instr_(instr) { } | 5276 : LDeferredCode(codegen), instr_(instr) { } |
5269 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); } | 5277 virtual void Generate() { codegen()->DoDeferredAllocate(instr_); } |
5270 virtual LInstruction* instr() { return instr_; } | 5278 virtual LInstruction* instr() { return instr_; } |
5271 private: | 5279 private: |
5272 LAllocate* instr_; | 5280 LAllocate* instr_; |
5273 }; | 5281 }; |
5274 | 5282 |
5275 DeferredAllocate* deferred = | 5283 DeferredAllocate* deferred = |
5276 new(zone()) DeferredAllocate(this, instr); | 5284 new(zone()) DeferredAllocate(this, instr); |
5277 | 5285 |
5278 Register size = ToRegister(instr->size()); | |
5279 Register result = ToRegister(instr->result()); | 5286 Register result = ToRegister(instr->result()); |
5280 Register scratch = ToRegister(instr->temp1()); | 5287 Register scratch = ToRegister(instr->temp1()); |
5281 Register scratch2 = ToRegister(instr->temp2()); | 5288 Register scratch2 = ToRegister(instr->temp2()); |
5282 | 5289 |
5283 HAllocate* original_instr = instr->hydrogen(); | 5290 // Allocate memory for the object. |
5284 if (original_instr->size()->IsConstant()) { | 5291 AllocationFlags flags = TAG_OBJECT; |
5285 UNREACHABLE(); | 5292 if (instr->hydrogen()->MustAllocateDoubleAligned()) { |
5286 } else { | 5293 flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT); |
5287 // Allocate memory for the object. | 5294 } |
5288 AllocationFlags flags = TAG_OBJECT; | 5295 if (instr->size()->IsConstantOperand()) { |
5289 if (original_instr->MustAllocateDoubleAligned()) { | 5296 int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); |
5290 flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT); | |
5291 } | |
5292 __ AllocateInNewSpace(size, | 5297 __ AllocateInNewSpace(size, |
5293 result, | 5298 result, |
5294 scratch, | 5299 scratch, |
5295 scratch2, | 5300 scratch2, |
5296 deferred->entry(), | 5301 deferred->entry(), |
5297 TAG_OBJECT); | 5302 flags); |
| 5303 } else { |
| 5304 Register size = ToRegister(instr->size()); |
| 5305 __ AllocateInNewSpace(size, |
| 5306 result, |
| 5307 scratch, |
| 5308 scratch2, |
| 5309 deferred->entry(), |
| 5310 flags); |
5298 } | 5311 } |
5299 | 5312 |
5300 __ bind(deferred->exit()); | 5313 __ bind(deferred->exit()); |
5301 } | 5314 } |
5302 | 5315 |
5303 | 5316 |
5304 void LCodeGen::DoDeferredAllocate(LAllocate* instr) { | 5317 void LCodeGen::DoDeferredAllocate(LAllocate* instr) { |
5305 Register size = ToRegister(instr->size()); | 5318 Register size = ToRegister(instr->size()); |
5306 Register result = ToRegister(instr->result()); | 5319 Register result = ToRegister(instr->result()); |
5307 | 5320 |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5538 } | 5551 } |
5539 | 5552 |
5540 | 5553 |
5541 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { | 5554 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { |
5542 ASSERT(ToRegister(instr->result()).is(v0)); | 5555 ASSERT(ToRegister(instr->result()).is(v0)); |
5543 Handle<FixedArray> literals(instr->environment()->closure()->literals()); | 5556 Handle<FixedArray> literals(instr->environment()->closure()->literals()); |
5544 Handle<FixedArray> constant_properties = | 5557 Handle<FixedArray> constant_properties = |
5545 instr->hydrogen()->constant_properties(); | 5558 instr->hydrogen()->constant_properties(); |
5546 | 5559 |
5547 // Set up the parameters to the stub/runtime call. | 5560 // Set up the parameters to the stub/runtime call. |
5548 __ LoadHeapObject(t0, literals); | 5561 __ LoadHeapObject(a3, literals); |
5549 __ li(a3, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); | 5562 __ li(a2, Operand(Smi::FromInt(instr->hydrogen()->literal_index()))); |
5550 __ li(a2, Operand(constant_properties)); | 5563 __ li(a1, Operand(constant_properties)); |
5551 int flags = instr->hydrogen()->fast_elements() | 5564 int flags = instr->hydrogen()->fast_elements() |
5552 ? ObjectLiteral::kFastElements | 5565 ? ObjectLiteral::kFastElements |
5553 : ObjectLiteral::kNoFlags; | 5566 : ObjectLiteral::kNoFlags; |
5554 __ li(a1, Operand(Smi::FromInt(flags))); | 5567 __ li(a0, Operand(Smi::FromInt(flags))); |
5555 __ Push(t0, a3, a2, a1); | |
5556 | 5568 |
5557 // Pick the right runtime function or stub to call. | 5569 // Pick the right runtime function or stub to call. |
5558 int properties_count = constant_properties->length() / 2; | 5570 int properties_count = constant_properties->length() / 2; |
5559 if (instr->hydrogen()->depth() > 1) { | 5571 if (instr->hydrogen()->depth() > 1) { |
| 5572 __ Push(a3, a2, a1, a0); |
5560 CallRuntime(Runtime::kCreateObjectLiteral, 4, instr); | 5573 CallRuntime(Runtime::kCreateObjectLiteral, 4, instr); |
5561 } else if (flags != ObjectLiteral::kFastElements || | 5574 } else if (flags != ObjectLiteral::kFastElements || |
5562 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { | 5575 properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { |
| 5576 __ Push(a3, a2, a1, a0); |
5563 CallRuntime(Runtime::kCreateObjectLiteralShallow, 4, instr); | 5577 CallRuntime(Runtime::kCreateObjectLiteralShallow, 4, instr); |
5564 } else { | 5578 } else { |
5565 FastCloneShallowObjectStub stub(properties_count); | 5579 FastCloneShallowObjectStub stub(properties_count); |
5566 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 5580 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
5567 } | 5581 } |
5568 } | 5582 } |
5569 | 5583 |
5570 | 5584 |
5571 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { | 5585 void LCodeGen::DoToFastProperties(LToFastProperties* instr) { |
5572 ASSERT(ToRegister(instr->value()).is(a0)); | 5586 ASSERT(ToRegister(instr->value()).is(a0)); |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6038 __ Subu(scratch, result, scratch); | 6052 __ Subu(scratch, result, scratch); |
6039 __ lw(result, FieldMemOperand(scratch, | 6053 __ lw(result, FieldMemOperand(scratch, |
6040 FixedArray::kHeaderSize - kPointerSize)); | 6054 FixedArray::kHeaderSize - kPointerSize)); |
6041 __ bind(&done); | 6055 __ bind(&done); |
6042 } | 6056 } |
6043 | 6057 |
6044 | 6058 |
6045 #undef __ | 6059 #undef __ |
6046 | 6060 |
6047 } } // namespace v8::internal | 6061 } } // namespace v8::internal |
OLD | NEW |