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 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1318 // Make sure this is a RegExp that actually contains code. | 1318 // Make sure this is a RegExp that actually contains code. |
1319 if (re->TypeTagUnchecked() != JSRegExp::IRREGEXP) return; | 1319 if (re->TypeTagUnchecked() != JSRegExp::IRREGEXP) return; |
1320 | 1320 |
1321 Object* code = re->DataAtUnchecked(JSRegExp::code_index(is_ascii)); | 1321 Object* code = re->DataAtUnchecked(JSRegExp::code_index(is_ascii)); |
1322 if (!code->IsSmi() && | 1322 if (!code->IsSmi() && |
1323 HeapObject::cast(code)->map()->instance_type() == CODE_TYPE) { | 1323 HeapObject::cast(code)->map()->instance_type() == CODE_TYPE) { |
1324 // Save a copy that can be reinstated if we need the code again. | 1324 // Save a copy that can be reinstated if we need the code again. |
1325 re->SetDataAtUnchecked(JSRegExp::saved_code_index(is_ascii), | 1325 re->SetDataAtUnchecked(JSRegExp::saved_code_index(is_ascii), |
1326 code, | 1326 code, |
1327 heap); | 1327 heap); |
| 1328 |
| 1329 // Saving a copy might create a pointer into compaction candidate |
| 1330 // that was not observed by marker. This might happen if JSRegExp data |
| 1331 // was marked through the compilation cache before marker reached JSRegExp |
| 1332 // object. |
| 1333 FixedArray* data = FixedArray::cast(re->data()); |
| 1334 Object** slot = data->data_start() + JSRegExp::saved_code_index(is_ascii); |
| 1335 heap->mark_compact_collector()-> |
| 1336 RecordSlot(slot, slot, code); |
| 1337 |
1328 // Set a number in the 0-255 range to guarantee no smi overflow. | 1338 // Set a number in the 0-255 range to guarantee no smi overflow. |
1329 re->SetDataAtUnchecked(JSRegExp::code_index(is_ascii), | 1339 re->SetDataAtUnchecked(JSRegExp::code_index(is_ascii), |
1330 Smi::FromInt(heap->sweep_generation() & 0xff), | 1340 Smi::FromInt(heap->sweep_generation() & 0xff), |
1331 heap); | 1341 heap); |
1332 } else if (code->IsSmi()) { | 1342 } else if (code->IsSmi()) { |
1333 int value = Smi::cast(code)->value(); | 1343 int value = Smi::cast(code)->value(); |
1334 // The regexp has not been compiled yet or there was a compilation error. | 1344 // The regexp has not been compiled yet or there was a compilation error. |
1335 if (value == JSRegExp::kUninitializedValue || | 1345 if (value == JSRegExp::kUninitializedValue || |
1336 value == JSRegExp::kCompilationErrorValue) { | 1346 value == JSRegExp::kCompilationErrorValue) { |
1337 return; | 1347 return; |
(...skipping 2759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4097 while (buffer != NULL) { | 4107 while (buffer != NULL) { |
4098 SlotsBuffer* next_buffer = buffer->next(); | 4108 SlotsBuffer* next_buffer = buffer->next(); |
4099 DeallocateBuffer(buffer); | 4109 DeallocateBuffer(buffer); |
4100 buffer = next_buffer; | 4110 buffer = next_buffer; |
4101 } | 4111 } |
4102 *buffer_address = NULL; | 4112 *buffer_address = NULL; |
4103 } | 4113 } |
4104 | 4114 |
4105 | 4115 |
4106 } } // namespace v8::internal | 4116 } } // namespace v8::internal |
OLD | NEW |