| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "v8.h" | 5 #include "v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
| 8 | 8 |
| 9 #include "codegen.h" | 9 #include "codegen.h" |
| 10 #include "deoptimizer.h" | 10 #include "deoptimizer.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 int additional_comments = | 60 int additional_comments = |
| 61 (min_padding + comment_reloc_size - 1) / comment_reloc_size; | 61 (min_padding + comment_reloc_size - 1) / comment_reloc_size; |
| 62 // Actual padding size. | 62 // Actual padding size. |
| 63 int padding = additional_comments * comment_reloc_size; | 63 int padding = additional_comments * comment_reloc_size; |
| 64 // Allocate new relocation info and copy old relocation to the end | 64 // Allocate new relocation info and copy old relocation to the end |
| 65 // of the new relocation info array because relocation info is | 65 // of the new relocation info array because relocation info is |
| 66 // written and read backwards. | 66 // written and read backwards. |
| 67 Factory* factory = isolate->factory(); | 67 Factory* factory = isolate->factory(); |
| 68 Handle<ByteArray> new_reloc = | 68 Handle<ByteArray> new_reloc = |
| 69 factory->NewByteArray(reloc_length + padding, TENURED); | 69 factory->NewByteArray(reloc_length + padding, TENURED); |
| 70 OS::MemCopy(new_reloc->GetDataStartAddress() + padding, | 70 MemCopy(new_reloc->GetDataStartAddress() + padding, |
| 71 code->relocation_info()->GetDataStartAddress(), | 71 code->relocation_info()->GetDataStartAddress(), reloc_length); |
| 72 reloc_length); | |
| 73 // Create a relocation writer to write the comments in the padding | 72 // Create a relocation writer to write the comments in the padding |
| 74 // space. Use position 0 for everything to ensure short encoding. | 73 // space. Use position 0 for everything to ensure short encoding. |
| 75 RelocInfoWriter reloc_info_writer( | 74 RelocInfoWriter reloc_info_writer( |
| 76 new_reloc->GetDataStartAddress() + padding, 0); | 75 new_reloc->GetDataStartAddress() + padding, 0); |
| 77 intptr_t comment_string | 76 intptr_t comment_string |
| 78 = reinterpret_cast<intptr_t>(RelocInfo::kFillerCommentString); | 77 = reinterpret_cast<intptr_t>(RelocInfo::kFillerCommentString); |
| 79 RelocInfo rinfo(0, RelocInfo::COMMENT, comment_string, NULL); | 78 RelocInfo rinfo(0, RelocInfo::COMMENT, comment_string, NULL); |
| 80 for (int i = 0; i < additional_comments; ++i) { | 79 for (int i = 0; i < additional_comments; ++i) { |
| 81 #ifdef DEBUG | 80 #ifdef DEBUG |
| 82 byte* pos_before = reloc_info_writer.pos(); | 81 byte* pos_before = reloc_info_writer.pos(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 ASSERT(prev_call_address == NULL || | 154 ASSERT(prev_call_address == NULL || |
| 156 call_address >= prev_call_address + patch_size()); | 155 call_address >= prev_call_address + patch_size()); |
| 157 ASSERT(call_address + patch_size() <= code->instruction_end()); | 156 ASSERT(call_address + patch_size() <= code->instruction_end()); |
| 158 #ifdef DEBUG | 157 #ifdef DEBUG |
| 159 prev_call_address = call_address; | 158 prev_call_address = call_address; |
| 160 #endif | 159 #endif |
| 161 } | 160 } |
| 162 | 161 |
| 163 // Move the relocation info to the beginning of the byte array. | 162 // Move the relocation info to the beginning of the byte array. |
| 164 int new_reloc_size = reloc_end_address - reloc_info_writer.pos(); | 163 int new_reloc_size = reloc_end_address - reloc_info_writer.pos(); |
| 165 OS::MemMove( | 164 MemMove(code->relocation_start(), reloc_info_writer.pos(), new_reloc_size); |
| 166 code->relocation_start(), reloc_info_writer.pos(), new_reloc_size); | |
| 167 | 165 |
| 168 // The relocation info is in place, update the size. | 166 // The relocation info is in place, update the size. |
| 169 reloc_info->set_length(new_reloc_size); | 167 reloc_info->set_length(new_reloc_size); |
| 170 | 168 |
| 171 // Handle the junk part after the new relocation info. We will create | 169 // Handle the junk part after the new relocation info. We will create |
| 172 // a non-live object in the extra space at the end of the former reloc info. | 170 // a non-live object in the extra space at the end of the former reloc info. |
| 173 Address junk_address = reloc_info->address() + reloc_info->Size(); | 171 Address junk_address = reloc_info->address() + reloc_info->Size(); |
| 174 ASSERT(junk_address <= reloc_end_address); | 172 ASSERT(junk_address <= reloc_end_address); |
| 175 isolate->heap()->CreateFillerObjectAt(junk_address, | 173 isolate->heap()->CreateFillerObjectAt(junk_address, |
| 176 reloc_end_address - junk_address); | 174 reloc_end_address - junk_address); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 UNREACHABLE(); | 397 UNREACHABLE(); |
| 400 } | 398 } |
| 401 | 399 |
| 402 | 400 |
| 403 #undef __ | 401 #undef __ |
| 404 | 402 |
| 405 | 403 |
| 406 } } // namespace v8::internal | 404 } } // namespace v8::internal |
| 407 | 405 |
| 408 #endif // V8_TARGET_ARCH_X87 | 406 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |