OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2091 | 2091 |
2092 // Load address of new object into result. | 2092 // Load address of new object into result. |
2093 LoadAllocationTopHelper(result, scratch, flags); | 2093 LoadAllocationTopHelper(result, scratch, flags); |
2094 | 2094 |
2095 // Calculate new top and bail out if new space is exhausted. | 2095 // Calculate new top and bail out if new space is exhausted. |
2096 ExternalReference new_space_allocation_limit = | 2096 ExternalReference new_space_allocation_limit = |
2097 ExternalReference::new_space_allocation_limit_address(); | 2097 ExternalReference::new_space_allocation_limit_address(); |
2098 | 2098 |
2099 Register top_reg = result_end.is_valid() ? result_end : result; | 2099 Register top_reg = result_end.is_valid() ? result_end : result; |
2100 | 2100 |
2101 if (top_reg.is(result)) { | 2101 if (!top_reg.is(result)) { |
2102 addq(top_reg, Immediate(object_size)); | 2102 movq(top_reg, result); |
2103 } else { | |
2104 lea(top_reg, Operand(result, object_size)); | |
2105 } | 2103 } |
| 2104 addq(top_reg, Immediate(object_size)); |
| 2105 j(carry, gc_required); |
2106 movq(kScratchRegister, new_space_allocation_limit); | 2106 movq(kScratchRegister, new_space_allocation_limit); |
2107 cmpq(top_reg, Operand(kScratchRegister, 0)); | 2107 cmpq(top_reg, Operand(kScratchRegister, 0)); |
2108 j(above, gc_required); | 2108 j(above, gc_required); |
2109 | 2109 |
2110 // Update allocation top. | 2110 // Update allocation top. |
2111 UpdateAllocationTopHelper(top_reg, scratch); | 2111 UpdateAllocationTopHelper(top_reg, scratch); |
2112 | 2112 |
2113 if (top_reg.is(result)) { | 2113 if (top_reg.is(result)) { |
2114 if ((flags & TAG_OBJECT) != 0) { | 2114 if ((flags & TAG_OBJECT) != 0) { |
2115 subq(result, Immediate(object_size - kHeapObjectTag)); | 2115 subq(result, Immediate(object_size - kHeapObjectTag)); |
(...skipping 29 matching lines...) Expand all Loading... |
2145 return; | 2145 return; |
2146 } | 2146 } |
2147 ASSERT(!result.is(result_end)); | 2147 ASSERT(!result.is(result_end)); |
2148 | 2148 |
2149 // Load address of new object into result. | 2149 // Load address of new object into result. |
2150 LoadAllocationTopHelper(result, scratch, flags); | 2150 LoadAllocationTopHelper(result, scratch, flags); |
2151 | 2151 |
2152 // Calculate new top and bail out if new space is exhausted. | 2152 // Calculate new top and bail out if new space is exhausted. |
2153 ExternalReference new_space_allocation_limit = | 2153 ExternalReference new_space_allocation_limit = |
2154 ExternalReference::new_space_allocation_limit_address(); | 2154 ExternalReference::new_space_allocation_limit_address(); |
2155 lea(result_end, Operand(result, element_count, element_size, header_size)); | 2155 |
| 2156 // We assume that element_count*element_size + header_size does not |
| 2157 // overflow. |
| 2158 lea(result_end, Operand(element_count, element_size, header_size)); |
| 2159 addq(result_end, result); |
| 2160 j(carry, gc_required); |
2156 movq(kScratchRegister, new_space_allocation_limit); | 2161 movq(kScratchRegister, new_space_allocation_limit); |
2157 cmpq(result_end, Operand(kScratchRegister, 0)); | 2162 cmpq(result_end, Operand(kScratchRegister, 0)); |
2158 j(above, gc_required); | 2163 j(above, gc_required); |
2159 | 2164 |
2160 // Update allocation top. | 2165 // Update allocation top. |
2161 UpdateAllocationTopHelper(result_end, scratch); | 2166 UpdateAllocationTopHelper(result_end, scratch); |
2162 | 2167 |
2163 // Tag the result if requested. | 2168 // Tag the result if requested. |
2164 if ((flags & TAG_OBJECT) != 0) { | 2169 if ((flags & TAG_OBJECT) != 0) { |
2165 addq(result, Immediate(kHeapObjectTag)); | 2170 addq(result, Immediate(kHeapObjectTag)); |
(...skipping 25 matching lines...) Expand all Loading... |
2191 // Load address of new object into result. | 2196 // Load address of new object into result. |
2192 LoadAllocationTopHelper(result, scratch, flags); | 2197 LoadAllocationTopHelper(result, scratch, flags); |
2193 | 2198 |
2194 // Calculate new top and bail out if new space is exhausted. | 2199 // Calculate new top and bail out if new space is exhausted. |
2195 ExternalReference new_space_allocation_limit = | 2200 ExternalReference new_space_allocation_limit = |
2196 ExternalReference::new_space_allocation_limit_address(); | 2201 ExternalReference::new_space_allocation_limit_address(); |
2197 if (!object_size.is(result_end)) { | 2202 if (!object_size.is(result_end)) { |
2198 movq(result_end, object_size); | 2203 movq(result_end, object_size); |
2199 } | 2204 } |
2200 addq(result_end, result); | 2205 addq(result_end, result); |
| 2206 j(carry, gc_required); |
2201 movq(kScratchRegister, new_space_allocation_limit); | 2207 movq(kScratchRegister, new_space_allocation_limit); |
2202 cmpq(result_end, Operand(kScratchRegister, 0)); | 2208 cmpq(result_end, Operand(kScratchRegister, 0)); |
2203 j(above, gc_required); | 2209 j(above, gc_required); |
2204 | 2210 |
2205 // Update allocation top. | 2211 // Update allocation top. |
2206 UpdateAllocationTopHelper(result_end, scratch); | 2212 UpdateAllocationTopHelper(result_end, scratch); |
2207 | 2213 |
2208 // Tag the result if requested. | 2214 // Tag the result if requested. |
2209 if ((flags & TAG_OBJECT) != 0) { | 2215 if ((flags & TAG_OBJECT) != 0) { |
2210 addq(result, Immediate(kHeapObjectTag)); | 2216 addq(result, Immediate(kHeapObjectTag)); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2472 CPU::FlushICache(address_, size_); | 2478 CPU::FlushICache(address_, size_); |
2473 | 2479 |
2474 // Check that the code was patched as expected. | 2480 // Check that the code was patched as expected. |
2475 ASSERT(masm_.pc_ == address_ + size_); | 2481 ASSERT(masm_.pc_ == address_ + size_); |
2476 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2482 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
2477 } | 2483 } |
2478 | 2484 |
2479 } } // namespace v8::internal | 2485 } } // namespace v8::internal |
2480 | 2486 |
2481 #endif // V8_TARGET_ARCH_X64 | 2487 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |