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 5451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5462 ASSERT(instr->hydrogen()->depth() == 1); | 5462 ASSERT(instr->hydrogen()->depth() == 1); |
5463 FastCloneShallowArrayStub::Mode mode = | 5463 FastCloneShallowArrayStub::Mode mode = |
5464 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; | 5464 FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS; |
5465 FastCloneShallowArrayStub stub(mode, length); | 5465 FastCloneShallowArrayStub stub(mode, length); |
5466 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 5466 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
5467 } else if (instr->hydrogen()->depth() > 1) { | 5467 } else if (instr->hydrogen()->depth() > 1) { |
5468 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); | 5468 CallRuntime(Runtime::kCreateArrayLiteral, 3, instr); |
5469 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { | 5469 } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
5470 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); | 5470 CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr); |
5471 } else { | 5471 } else { |
5472 FastCloneShallowArrayStub::Mode mode = | 5472 // TODO(mvstanton): I'm doing more work than necessary here by running |
5473 // CLONE_ANY_ELEMENTS instead of the more specific stub, but I'm doing it | |
5474 // just because I want to track allocation info. Alternative approach: quick | |
5475 // baking allocation tracking info into this field, instead just have it on | |
5476 // all the time? | |
danno
2013/01/10 22:58:59
Be careful (here and on other platforms). Original
mvstanton
2013/01/11 13:43:01
Done.
| |
5477 FastCloneShallowArrayStub::Mode mode = FastCloneShallowArrayStub:: | |
5478 CLONE_ANY_ELEMENTS_WITH_ALLOCATION_SITE_INFO; | |
5479 /* | |
5473 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS | 5480 boilerplate_elements_kind == FAST_DOUBLE_ELEMENTS |
5474 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS | 5481 ? FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS |
5475 : FastCloneShallowArrayStub::CLONE_ELEMENTS; | 5482 : FastCloneShallowArrayStub::CLONE_ELEMENTS; |
5483 */ | |
5476 FastCloneShallowArrayStub stub(mode, length); | 5484 FastCloneShallowArrayStub stub(mode, length); |
5477 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); | 5485 CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr); |
5478 } | 5486 } |
5479 } | 5487 } |
5480 | 5488 |
5481 | 5489 |
5482 void LCodeGen::EmitDeepCopy(Handle<JSObject> object, | 5490 void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
5483 Register result, | 5491 Register result, |
5484 Register source, | 5492 Register source, |
5485 int* offset) { | 5493 int* offset, |
5494 bool create_allocation_site_info) { | |
5486 ASSERT(!source.is(r2)); | 5495 ASSERT(!source.is(r2)); |
5487 ASSERT(!result.is(r2)); | 5496 ASSERT(!result.is(r2)); |
5488 | 5497 |
5489 // Only elements backing stores for non-COW arrays need to be copied. | 5498 // Only elements backing stores for non-COW arrays need to be copied. |
5490 Handle<FixedArrayBase> elements(object->elements()); | 5499 Handle<FixedArrayBase> elements(object->elements()); |
5491 bool has_elements = elements->length() > 0 && | 5500 bool has_elements = elements->length() > 0 && |
5492 elements->map() != isolate()->heap()->fixed_cow_array_map(); | 5501 elements->map() != isolate()->heap()->fixed_cow_array_map(); |
5493 | 5502 |
5494 // Increase the offset so that subsequent objects end up right after | 5503 // Increase the offset so that subsequent objects end up right after |
5495 // this object and its backing store. | 5504 // this object and its backing store. |
5496 int object_offset = *offset; | 5505 int object_offset = *offset; |
5497 int object_size = object->map()->instance_size(); | 5506 int object_size = object->map()->instance_size(); |
5498 int elements_offset = *offset + object_size; | 5507 int elements_offset = *offset + object_size; |
5508 if (create_allocation_site_info) { | |
5509 elements_offset += AllocationSiteInfo::kSize; | |
5510 } | |
5499 int elements_size = has_elements ? elements->Size() : 0; | 5511 int elements_size = has_elements ? elements->Size() : 0; |
5500 *offset += object_size + elements_size; | 5512 *offset += object_size + elements_size; |
5513 if (create_allocation_site_info) { | |
5514 *offset += AllocationSiteInfo::kSize; | |
5515 } | |
5501 | 5516 |
5502 // Copy object header. | 5517 // Copy object header. |
5503 ASSERT(object->properties()->length() == 0); | 5518 ASSERT(object->properties()->length() == 0); |
5504 int inobject_properties = object->map()->inobject_properties(); | 5519 int inobject_properties = object->map()->inobject_properties(); |
5505 int header_size = object_size - inobject_properties * kPointerSize; | 5520 int header_size = object_size - inobject_properties * kPointerSize; |
5506 for (int i = 0; i < header_size; i += kPointerSize) { | 5521 for (int i = 0; i < header_size; i += kPointerSize) { |
5507 if (has_elements && i == JSObject::kElementsOffset) { | 5522 if (has_elements && i == JSObject::kElementsOffset) { |
5508 __ add(r2, result, Operand(elements_offset)); | 5523 __ add(r2, result, Operand(elements_offset)); |
5509 } else { | 5524 } else { |
5510 __ ldr(r2, FieldMemOperand(source, i)); | 5525 __ ldr(r2, FieldMemOperand(source, i)); |
(...skipping 13 matching lines...) Expand all Loading... | |
5524 EmitDeepCopy(value_object, result, source, offset); | 5539 EmitDeepCopy(value_object, result, source, offset); |
5525 } else if (value->IsHeapObject()) { | 5540 } else if (value->IsHeapObject()) { |
5526 __ LoadHeapObject(r2, Handle<HeapObject>::cast(value)); | 5541 __ LoadHeapObject(r2, Handle<HeapObject>::cast(value)); |
5527 __ str(r2, FieldMemOperand(result, total_offset)); | 5542 __ str(r2, FieldMemOperand(result, total_offset)); |
5528 } else { | 5543 } else { |
5529 __ mov(r2, Operand(value)); | 5544 __ mov(r2, Operand(value)); |
5530 __ str(r2, FieldMemOperand(result, total_offset)); | 5545 __ str(r2, FieldMemOperand(result, total_offset)); |
5531 } | 5546 } |
5532 } | 5547 } |
5533 | 5548 |
5549 // Build Allocation Site Info if desired | |
5550 if (create_allocation_site_info) { | |
5551 __ mov(r2, Operand(Handle<Map>(isolate()->heap()-> | |
5552 allocation_site_info_map()))); | |
5553 __ str(r2, FieldMemOperand(result, object_size)); | |
5554 __ str(source, FieldMemOperand(result, object_size + kPointerSize)); | |
5555 } | |
5556 | |
5534 if (has_elements) { | 5557 if (has_elements) { |
5535 // Copy elements backing store header. | 5558 // Copy elements backing store header. |
5536 __ LoadHeapObject(source, elements); | 5559 __ LoadHeapObject(source, elements); |
5537 for (int i = 0; i < FixedArray::kHeaderSize; i += kPointerSize) { | 5560 for (int i = 0; i < FixedArray::kHeaderSize; i += kPointerSize) { |
5538 __ ldr(r2, FieldMemOperand(source, i)); | 5561 __ ldr(r2, FieldMemOperand(source, i)); |
5539 __ str(r2, FieldMemOperand(result, elements_offset + i)); | 5562 __ str(r2, FieldMemOperand(result, elements_offset + i)); |
5540 } | 5563 } |
5541 | 5564 |
5542 // Copy elements backing store content. | 5565 // Copy elements backing store content. |
5543 int elements_length = has_elements ? elements->length() : 0; | 5566 int elements_length = has_elements ? elements->length() : 0; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5610 __ jmp(&allocated); | 5633 __ jmp(&allocated); |
5611 | 5634 |
5612 __ bind(&runtime_allocate); | 5635 __ bind(&runtime_allocate); |
5613 __ mov(r0, Operand(Smi::FromInt(size))); | 5636 __ mov(r0, Operand(Smi::FromInt(size))); |
5614 __ push(r0); | 5637 __ push(r0); |
5615 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); | 5638 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr); |
5616 | 5639 |
5617 __ bind(&allocated); | 5640 __ bind(&allocated); |
5618 int offset = 0; | 5641 int offset = 0; |
5619 __ LoadHeapObject(r1, instr->hydrogen()->boilerplate()); | 5642 __ LoadHeapObject(r1, instr->hydrogen()->boilerplate()); |
5620 EmitDeepCopy(instr->hydrogen()->boilerplate(), r0, r1, &offset); | 5643 EmitDeepCopy(instr->hydrogen()->boilerplate(), r0, r1, &offset, |
5644 instr->hydrogen()->create_allocation_site_info()); | |
5621 ASSERT_EQ(size, offset); | 5645 ASSERT_EQ(size, offset); |
5622 } | 5646 } |
5623 | 5647 |
5624 | 5648 |
5625 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { | 5649 void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) { |
5626 Handle<FixedArray> literals(instr->environment()->closure()->literals()); | 5650 Handle<FixedArray> literals(instr->environment()->closure()->literals()); |
5627 Handle<FixedArray> constant_properties = | 5651 Handle<FixedArray> constant_properties = |
5628 instr->hydrogen()->constant_properties(); | 5652 instr->hydrogen()->constant_properties(); |
5629 | 5653 |
5630 // Set up the parameters to the stub/runtime call. | 5654 // Set up the parameters to the stub/runtime call. |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6084 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); | 6108 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); |
6085 __ ldr(result, FieldMemOperand(scratch, | 6109 __ ldr(result, FieldMemOperand(scratch, |
6086 FixedArray::kHeaderSize - kPointerSize)); | 6110 FixedArray::kHeaderSize - kPointerSize)); |
6087 __ bind(&done); | 6111 __ bind(&done); |
6088 } | 6112 } |
6089 | 6113 |
6090 | 6114 |
6091 #undef __ | 6115 #undef __ |
6092 | 6116 |
6093 } } // namespace v8::internal | 6117 } } // namespace v8::internal |
OLD | NEW |