| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index dfcb29b6027aafbdfab53181fecb10d5f52b542c..3451239f555a0cc8a114addb5f9afc11b6c814d8 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -9031,14 +9031,52 @@ void SharedFunctionInfo::InstallFromOptimizedCodeMap(JSFunction* function,
|
| }
|
|
|
|
|
| -void SharedFunctionInfo::ClearOptimizedCodeMap(const char* reason) {
|
| +void SharedFunctionInfo::ClearOptimizedCodeMap(Code* optimized_code,
|
| + const char* reason) {
|
| if (!optimized_code_map()->IsSmi()) {
|
| - if (FLAG_trace_opt) {
|
| - PrintF("[clearing optimizing code map (%s) for ", reason);
|
| - ShortPrint();
|
| - PrintF("]\n");
|
| + if (optimized_code == NULL || true) {
|
| + if (FLAG_trace_opt) {
|
| + PrintF("[clearing entire optimizing code map (%s) for ", reason);
|
| + ShortPrint();
|
| + PrintF("]\n");
|
| + }
|
| + set_optimized_code_map(Smi::FromInt(0));
|
| + } else {
|
| + int i;
|
| + bool removed_entry = false;
|
| + FixedArray* code_map = FixedArray::cast(optimized_code_map());
|
| + for (i = 0; i < code_map->length(); i += kEntryLength) {
|
| + ASSERT(code_map->get(i)->IsNativeContext());
|
| + if (Code::cast(code_map->get(i + 1)) == optimized_code) {
|
| + if (FLAG_trace_opt) {
|
| + PrintF("[clearing optimizing code map (%s) for ", reason);
|
| + ShortPrint();
|
| + PrintF("]\n");
|
| + }
|
| + removed_entry = true;
|
| + break;
|
| + }
|
| + }
|
| + while (i < (code_map->length() - kEntryLength)) {
|
| + code_map->set(i, code_map->get(i + 1 + kEntryLength));
|
| + code_map->set(i + 1, code_map->get(i + 2 + kEntryLength));
|
| + code_map->set(i + 2, code_map->get(i + 3 + kEntryLength));
|
| + i += kEntryLength;
|
| + }
|
| + if (removed_entry) {
|
| + Heap* heap = GetHeap();
|
| + int new_length = code_map->length() - kEntryLength;
|
| + if (new_length == 0) {
|
| + set_optimized_code_map(Smi::FromInt(0));
|
| + return;
|
| + }
|
| + Address filler_start = reinterpret_cast<Address>(
|
| + code_map->GetFirstElementAddress() + new_length);
|
| + heap->CreateFillerObjectAt(filler_start,
|
| + kEntryLength * kPointerSize);
|
| + code_map->set_length(new_length);
|
| + }
|
| }
|
| - set_optimized_code_map(Smi::FromInt(0));
|
| }
|
| }
|
|
|
|
|