| 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 4071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4082 } | 4082 } |
| 4083 } | 4083 } |
| 4084 jmp(gc_required); | 4084 jmp(gc_required); |
| 4085 return; | 4085 return; |
| 4086 } | 4086 } |
| 4087 ASSERT(!result.is(result_end)); | 4087 ASSERT(!result.is(result_end)); |
| 4088 | 4088 |
| 4089 // Load address of new object into result. | 4089 // Load address of new object into result. |
| 4090 LoadAllocationTopHelper(result, scratch, flags); | 4090 LoadAllocationTopHelper(result, scratch, flags); |
| 4091 | 4091 |
| 4092 if (isolate()->heap_profiler()->is_tracking_allocations()) { | |
| 4093 RecordObjectAllocation(isolate(), result, object_size); | |
| 4094 } | |
| 4095 | |
| 4096 // Align the next allocation. Storing the filler map without checking top is | 4092 // Align the next allocation. Storing the filler map without checking top is |
| 4097 // safe in new-space because the limit of the heap is aligned there. | 4093 // safe in new-space because the limit of the heap is aligned there. |
| 4098 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { | 4094 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { |
| 4099 testq(result, Immediate(kDoubleAlignmentMask)); | 4095 testq(result, Immediate(kDoubleAlignmentMask)); |
| 4100 Check(zero, kAllocationIsNotDoubleAligned); | 4096 Check(zero, kAllocationIsNotDoubleAligned); |
| 4101 } | 4097 } |
| 4102 | 4098 |
| 4103 // Calculate new top and bail out if new space is exhausted. | 4099 // Calculate new top and bail out if new space is exhausted. |
| 4104 ExternalReference allocation_limit = | 4100 ExternalReference allocation_limit = |
| 4105 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | 4101 AllocationUtils::GetAllocationLimitReference(isolate(), flags); |
| 4106 | 4102 |
| 4107 Register top_reg = result_end.is_valid() ? result_end : result; | 4103 Register top_reg = result_end.is_valid() ? result_end : result; |
| 4108 | 4104 |
| 4109 if (!top_reg.is(result)) { | 4105 if (!top_reg.is(result)) { |
| 4110 movq(top_reg, result); | 4106 movq(top_reg, result); |
| 4111 } | 4107 } |
| 4112 addq(top_reg, Immediate(object_size)); | 4108 addq(top_reg, Immediate(object_size)); |
| 4113 j(carry, gc_required); | 4109 j(carry, gc_required); |
| 4114 Operand limit_operand = ExternalOperand(allocation_limit); | 4110 Operand limit_operand = ExternalOperand(allocation_limit); |
| 4115 cmpq(top_reg, limit_operand); | 4111 cmpq(top_reg, limit_operand); |
| 4116 j(above, gc_required); | 4112 j(above, gc_required); |
| 4117 | 4113 |
| 4114 if (isolate()->heap_profiler()->is_tracking_allocations()) { |
| 4115 RecordObjectAllocation(result, object_size); |
| 4116 } |
| 4117 |
| 4118 // Update allocation top. | 4118 // Update allocation top. |
| 4119 UpdateAllocationTopHelper(top_reg, scratch, flags); | 4119 UpdateAllocationTopHelper(top_reg, scratch, flags); |
| 4120 | 4120 |
| 4121 bool tag_result = (flags & TAG_OBJECT) != 0; | 4121 bool tag_result = (flags & TAG_OBJECT) != 0; |
| 4122 if (top_reg.is(result)) { | 4122 if (top_reg.is(result)) { |
| 4123 if (tag_result) { | 4123 if (tag_result) { |
| 4124 subq(result, Immediate(object_size - kHeapObjectTag)); | 4124 subq(result, Immediate(object_size - kHeapObjectTag)); |
| 4125 } else { | 4125 } else { |
| 4126 subq(result, Immediate(object_size)); | 4126 subq(result, Immediate(object_size)); |
| 4127 } | 4127 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4165 // object_size is left unchanged by this function. | 4165 // object_size is left unchanged by this function. |
| 4166 } | 4166 } |
| 4167 jmp(gc_required); | 4167 jmp(gc_required); |
| 4168 return; | 4168 return; |
| 4169 } | 4169 } |
| 4170 ASSERT(!result.is(result_end)); | 4170 ASSERT(!result.is(result_end)); |
| 4171 | 4171 |
| 4172 // Load address of new object into result. | 4172 // Load address of new object into result. |
| 4173 LoadAllocationTopHelper(result, scratch, flags); | 4173 LoadAllocationTopHelper(result, scratch, flags); |
| 4174 | 4174 |
| 4175 if (isolate()->heap_profiler()->is_tracking_allocations()) { | |
| 4176 RecordObjectAllocation(isolate(), result, object_size); | |
| 4177 } | |
| 4178 | |
| 4179 // Align the next allocation. Storing the filler map without checking top is | 4175 // Align the next allocation. Storing the filler map without checking top is |
| 4180 // safe in new-space because the limit of the heap is aligned there. | 4176 // safe in new-space because the limit of the heap is aligned there. |
| 4181 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { | 4177 if (((flags & DOUBLE_ALIGNMENT) != 0) && FLAG_debug_code) { |
| 4182 testq(result, Immediate(kDoubleAlignmentMask)); | 4178 testq(result, Immediate(kDoubleAlignmentMask)); |
| 4183 Check(zero, kAllocationIsNotDoubleAligned); | 4179 Check(zero, kAllocationIsNotDoubleAligned); |
| 4184 } | 4180 } |
| 4185 | 4181 |
| 4186 // Calculate new top and bail out if new space is exhausted. | 4182 // Calculate new top and bail out if new space is exhausted. |
| 4187 ExternalReference allocation_limit = | 4183 ExternalReference allocation_limit = |
| 4188 AllocationUtils::GetAllocationLimitReference(isolate(), flags); | 4184 AllocationUtils::GetAllocationLimitReference(isolate(), flags); |
| 4189 if (!object_size.is(result_end)) { | 4185 if (!object_size.is(result_end)) { |
| 4190 movq(result_end, object_size); | 4186 movq(result_end, object_size); |
| 4191 } | 4187 } |
| 4192 addq(result_end, result); | 4188 addq(result_end, result); |
| 4193 j(carry, gc_required); | 4189 j(carry, gc_required); |
| 4194 Operand limit_operand = ExternalOperand(allocation_limit); | 4190 Operand limit_operand = ExternalOperand(allocation_limit); |
| 4195 cmpq(result_end, limit_operand); | 4191 cmpq(result_end, limit_operand); |
| 4196 j(above, gc_required); | 4192 j(above, gc_required); |
| 4197 | 4193 |
| 4194 if (isolate()->heap_profiler()->is_tracking_allocations()) { |
| 4195 RecordObjectAllocation(result, object_size); |
| 4196 } |
| 4197 |
| 4198 // Update allocation top. | 4198 // Update allocation top. |
| 4199 UpdateAllocationTopHelper(result_end, scratch, flags); | 4199 UpdateAllocationTopHelper(result_end, scratch, flags); |
| 4200 | 4200 |
| 4201 // Tag the result if requested. | 4201 // Tag the result if requested. |
| 4202 if ((flags & TAG_OBJECT) != 0) { | 4202 if ((flags & TAG_OBJECT) != 0) { |
| 4203 addq(result, Immediate(kHeapObjectTag)); | 4203 addq(result, Immediate(kHeapObjectTag)); |
| 4204 } | 4204 } |
| 4205 } | 4205 } |
| 4206 | 4206 |
| 4207 | 4207 |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4929 movq(kScratchRegister, new_space_start); | 4929 movq(kScratchRegister, new_space_start); |
| 4930 cmpq(scratch_reg, kScratchRegister); | 4930 cmpq(scratch_reg, kScratchRegister); |
| 4931 j(less, no_memento_found); | 4931 j(less, no_memento_found); |
| 4932 cmpq(scratch_reg, ExternalOperand(new_space_allocation_top)); | 4932 cmpq(scratch_reg, ExternalOperand(new_space_allocation_top)); |
| 4933 j(greater, no_memento_found); | 4933 j(greater, no_memento_found); |
| 4934 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), | 4934 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), |
| 4935 Heap::kAllocationMementoMapRootIndex); | 4935 Heap::kAllocationMementoMapRootIndex); |
| 4936 } | 4936 } |
| 4937 | 4937 |
| 4938 | 4938 |
| 4939 void MacroAssembler::RecordObjectAllocation(Isolate* isolate, | 4939 void MacroAssembler::RecordObjectAllocation(Register object, |
| 4940 Register object, | |
| 4941 Register object_size) { | 4940 Register object_size) { |
| 4942 FrameScope frame(this, StackFrame::EXIT); | 4941 FrameScope frame(this, StackFrame::EXIT); |
| 4943 PushSafepointRegisters(); | 4942 PushSafepointRegisters(); |
| 4944 PrepareCallCFunction(3); | 4943 Push(object); |
| 4945 // In case object is rdx | 4944 shl(object_size, Immediate(kSmiShift)); |
| 4946 movq(kScratchRegister, object); | 4945 push(object_size); |
| 4947 movq(arg_reg_3, object_size); | 4946 CallExternalReference( |
| 4948 movq(arg_reg_2, kScratchRegister); | 4947 ExternalReference::record_object_allocation_function(isolate()), |
| 4949 movq(arg_reg_1, isolate, RelocInfo::EXTERNAL_REFERENCE); | 4948 2); |
| 4950 CallCFunction( | |
| 4951 ExternalReference::record_object_allocation_function(isolate), 3); | |
| 4952 PopSafepointRegisters(); | 4949 PopSafepointRegisters(); |
| 4953 } | 4950 } |
| 4954 | 4951 |
| 4955 | 4952 |
| 4956 void MacroAssembler::RecordObjectAllocation(Isolate* isolate, | 4953 void MacroAssembler::RecordObjectAllocation(Register object, |
| 4957 Register object, | |
| 4958 int object_size) { | 4954 int object_size) { |
| 4959 FrameScope frame(this, StackFrame::EXIT); | 4955 FrameScope frame(this, StackFrame::EXIT); |
| 4960 PushSafepointRegisters(); | 4956 PushSafepointRegisters(); |
| 4961 PrepareCallCFunction(3); | 4957 Push(object); |
| 4962 movq(arg_reg_2, object); | 4958 Push(Smi::FromInt(object_size)); |
| 4963 movq(arg_reg_3, Immediate(object_size)); | 4959 CallExternalReference( |
| 4964 movq(arg_reg_1, isolate, RelocInfo::EXTERNAL_REFERENCE); | 4960 ExternalReference::record_object_allocation_function(isolate()), |
| 4965 CallCFunction( | 4961 2); |
| 4966 ExternalReference::record_object_allocation_function(isolate), 3); | |
| 4967 PopSafepointRegisters(); | 4962 PopSafepointRegisters(); |
| 4968 } | 4963 } |
| 4969 | 4964 |
| 4970 | 4965 |
| 4971 } } // namespace v8::internal | 4966 } } // namespace v8::internal |
| 4972 | 4967 |
| 4973 #endif // V8_TARGET_ARCH_X64 | 4968 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |