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 4062 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4073 // the constructor's prototype changes, but instance size and property | 4073 // the constructor's prototype changes, but instance size and property |
4074 // counts remain unchanged (if slack tracking finished). | 4074 // counts remain unchanged (if slack tracking finished). |
4075 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress()); | 4075 ASSERT(!constructor->shared()->IsInobjectSlackTrackingInProgress()); |
4076 __ AllocateInNewSpace(instance_size, | 4076 __ AllocateInNewSpace(instance_size, |
4077 result, | 4077 result, |
4078 no_reg, | 4078 no_reg, |
4079 scratch, | 4079 scratch, |
4080 deferred->entry(), | 4080 deferred->entry(), |
4081 TAG_OBJECT); | 4081 TAG_OBJECT); |
4082 | 4082 |
| 4083 __ bind(deferred->exit()); |
| 4084 if (FLAG_debug_code) { |
| 4085 Label is_in_new_space; |
| 4086 __ JumpIfInNewSpace(result, scratch, &is_in_new_space); |
| 4087 __ Abort("Allocated object is not in new-space"); |
| 4088 __ bind(&is_in_new_space); |
| 4089 } |
| 4090 |
4083 // Load the initial map. | 4091 // Load the initial map. |
4084 Register map = scratch; | 4092 Register map = scratch; |
4085 __ LoadHeapObject(scratch, constructor); | 4093 __ LoadHeapObject(scratch, constructor); |
4086 __ movq(map, FieldOperand(scratch, JSFunction::kPrototypeOrInitialMapOffset)); | 4094 __ movq(map, FieldOperand(scratch, JSFunction::kPrototypeOrInitialMapOffset)); |
4087 | 4095 |
4088 if (FLAG_debug_code) { | 4096 if (FLAG_debug_code) { |
4089 __ AbortIfSmi(map); | 4097 __ AbortIfSmi(map); |
4090 __ cmpb(FieldOperand(map, Map::kInstanceSizeOffset), | 4098 __ cmpb(FieldOperand(map, Map::kInstanceSizeOffset), |
4091 Immediate(instance_size >> kPointerSizeLog2)); | 4099 Immediate(instance_size >> kPointerSizeLog2)); |
4092 __ Assert(equal, "Unexpected instance size"); | 4100 __ Assert(equal, "Unexpected instance size"); |
(...skipping 14 matching lines...) Expand all Loading... |
4107 __ LoadRoot(scratch, Heap::kEmptyFixedArrayRootIndex); | 4115 __ LoadRoot(scratch, Heap::kEmptyFixedArrayRootIndex); |
4108 __ movq(FieldOperand(result, JSObject::kElementsOffset), scratch); | 4116 __ movq(FieldOperand(result, JSObject::kElementsOffset), scratch); |
4109 __ movq(FieldOperand(result, JSObject::kPropertiesOffset), scratch); | 4117 __ movq(FieldOperand(result, JSObject::kPropertiesOffset), scratch); |
4110 if (initial_map->inobject_properties() != 0) { | 4118 if (initial_map->inobject_properties() != 0) { |
4111 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | 4119 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
4112 for (int i = 0; i < initial_map->inobject_properties(); i++) { | 4120 for (int i = 0; i < initial_map->inobject_properties(); i++) { |
4113 int property_offset = JSObject::kHeaderSize + i * kPointerSize; | 4121 int property_offset = JSObject::kHeaderSize + i * kPointerSize; |
4114 __ movq(FieldOperand(result, property_offset), scratch); | 4122 __ movq(FieldOperand(result, property_offset), scratch); |
4115 } | 4123 } |
4116 } | 4124 } |
4117 | |
4118 __ bind(deferred->exit()); | |
4119 } | 4125 } |
4120 | 4126 |
4121 | 4127 |
4122 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) { | 4128 void LCodeGen::DoDeferredAllocateObject(LAllocateObject* instr) { |
4123 Register result = ToRegister(instr->result()); | 4129 Register result = ToRegister(instr->result()); |
4124 Handle<JSFunction> constructor = instr->hydrogen()->constructor(); | 4130 Handle<JSFunction> constructor = instr->hydrogen()->constructor(); |
| 4131 Handle<Map> initial_map(constructor->initial_map()); |
| 4132 int instance_size = initial_map->instance_size(); |
4125 | 4133 |
4126 // TODO(3095996): Get rid of this. For now, we need to make the | 4134 // TODO(3095996): Get rid of this. For now, we need to make the |
4127 // result register contain a valid pointer because it is already | 4135 // result register contain a valid pointer because it is already |
4128 // contained in the register pointer map. | 4136 // contained in the register pointer map. |
4129 __ Set(result, 0); | 4137 __ Set(result, 0); |
4130 | 4138 |
4131 PushSafepointRegistersScope scope(this); | 4139 PushSafepointRegistersScope scope(this); |
4132 __ PushHeapObject(constructor); | 4140 __ Push(Smi::FromInt(instance_size)); |
4133 CallRuntimeFromDeferred(Runtime::kNewObject, 1, instr); | 4141 CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr); |
4134 __ StoreToSafepointRegisterSlot(result, rax); | 4142 __ StoreToSafepointRegisterSlot(result, rax); |
4135 } | 4143 } |
4136 | 4144 |
4137 | 4145 |
4138 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { | 4146 void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) { |
4139 Heap* heap = isolate()->heap(); | 4147 Heap* heap = isolate()->heap(); |
4140 ElementsKind boilerplate_elements_kind = | 4148 ElementsKind boilerplate_elements_kind = |
4141 instr->hydrogen()->boilerplate_elements_kind(); | 4149 instr->hydrogen()->boilerplate_elements_kind(); |
4142 | 4150 |
4143 // Deopt if the array literal boilerplate ElementsKind is of a type different | 4151 // Deopt if the array literal boilerplate ElementsKind is of a type different |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4763 FixedArray::kHeaderSize - kPointerSize)); | 4771 FixedArray::kHeaderSize - kPointerSize)); |
4764 __ bind(&done); | 4772 __ bind(&done); |
4765 } | 4773 } |
4766 | 4774 |
4767 | 4775 |
4768 #undef __ | 4776 #undef __ |
4769 | 4777 |
4770 } } // namespace v8::internal | 4778 } } // namespace v8::internal |
4771 | 4779 |
4772 #endif // V8_TARGET_ARCH_X64 | 4780 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |