OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 9622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9633 | 9633 |
9634 ASSERT(code_map->get(kNextMapIndex)->IsUndefined()); | 9634 ASSERT(code_map->get(kNextMapIndex)->IsUndefined()); |
9635 set_optimized_code_map(Smi::FromInt(0)); | 9635 set_optimized_code_map(Smi::FromInt(0)); |
9636 } | 9636 } |
9637 | 9637 |
9638 | 9638 |
9639 void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code, | 9639 void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code, |
9640 const char* reason) { | 9640 const char* reason) { |
9641 if (optimized_code_map()->IsSmi()) return; | 9641 if (optimized_code_map()->IsSmi()) return; |
9642 | 9642 |
9643 int i; | |
9644 bool removed_entry = false; | |
9645 FixedArray* code_map = FixedArray::cast(optimized_code_map()); | 9643 FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
9646 for (i = kEntriesStart; i < code_map->length(); i += kEntryLength) { | 9644 int dst = kEntriesStart; |
9647 ASSERT(code_map->get(i)->IsNativeContext()); | 9645 int length = code_map->length(); |
9648 if (Code::cast(code_map->get(i + 1)) == optimized_code) { | 9646 for (int src = kEntriesStart; src < length; src += kEntryLength) { |
| 9647 ASSERT(code_map->get(src)->IsNativeContext()); |
| 9648 if (Code::cast(code_map->get(src + kCachedCodeOffset)) == optimized_code) { |
| 9649 // Evict the src entry by not copying it to the dst entry. |
9649 if (FLAG_trace_opt) { | 9650 if (FLAG_trace_opt) { |
9650 PrintF("[evicting entry from optimizing code map (%s) for ", reason); | 9651 PrintF("[evicting entry from optimizing code map (%s) for ", reason); |
9651 ShortPrint(); | 9652 ShortPrint(); |
9652 PrintF("]\n"); | 9653 BailoutId osr(Smi::cast(code_map->get(src + kOsrAstIdOffset))->value()); |
| 9654 if (osr.IsNone()) { |
| 9655 PrintF("]\n"); |
| 9656 } else { |
| 9657 PrintF(" (osr ast id %d)]\n", osr.ToInt()); |
| 9658 } |
9653 } | 9659 } |
9654 removed_entry = true; | 9660 } else { |
9655 break; | 9661 // Keep the src entry by copying it to the dst entry. |
| 9662 if (dst != src) { |
| 9663 code_map->set(dst + kContextOffset, |
| 9664 code_map->get(src + kContextOffset)); |
| 9665 code_map->set(dst + kCachedCodeOffset, |
| 9666 code_map->get(src + kCachedCodeOffset)); |
| 9667 code_map->set(dst + kLiteralsOffset, |
| 9668 code_map->get(src + kLiteralsOffset)); |
| 9669 code_map->set(dst + kOsrAstIdOffset, |
| 9670 code_map->get(src + kOsrAstIdOffset)); |
| 9671 } |
| 9672 dst += kEntryLength; |
9656 } | 9673 } |
9657 } | 9674 } |
9658 while (i < (code_map->length() - kEntryLength)) { | 9675 if (dst != length) { |
9659 code_map->set(i + kContextOffset, | |
9660 code_map->get(i + kContextOffset + kEntryLength)); | |
9661 code_map->set(i + kCachedCodeOffset, | |
9662 code_map->get(i + kCachedCodeOffset + kEntryLength)); | |
9663 code_map->set(i + kLiteralsOffset, | |
9664 code_map->get(i + kLiteralsOffset + kEntryLength)); | |
9665 code_map->set(i + kOsrAstIdOffset, | |
9666 code_map->get(i + kOsrAstIdOffset + kEntryLength)); | |
9667 i += kEntryLength; | |
9668 } | |
9669 if (removed_entry) { | |
9670 // Always trim even when array is cleared because of heap verifier. | 9676 // Always trim even when array is cleared because of heap verifier. |
9671 RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), code_map, kEntryLength); | 9677 RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), code_map, length - dst); |
9672 if (code_map->length() == kEntriesStart) { | 9678 if (code_map->length() == kEntriesStart) ClearOptimizedCodeMap(); |
9673 ClearOptimizedCodeMap(); | |
9674 } | |
9675 } | 9679 } |
9676 } | 9680 } |
9677 | 9681 |
9678 | 9682 |
9679 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) { | 9683 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) { |
9680 FixedArray* code_map = FixedArray::cast(optimized_code_map()); | 9684 FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
9681 ASSERT(shrink_by % kEntryLength == 0); | 9685 ASSERT(shrink_by % kEntryLength == 0); |
9682 ASSERT(shrink_by <= code_map->length() - kEntriesStart); | 9686 ASSERT(shrink_by <= code_map->length() - kEntriesStart); |
9683 // Always trim even when array is cleared because of heap verifier. | 9687 // Always trim even when array is cleared because of heap verifier. |
9684 RightTrimFixedArray<FROM_GC>(GetHeap(), code_map, shrink_by); | 9688 RightTrimFixedArray<FROM_GC>(GetHeap(), code_map, shrink_by); |
(...skipping 6812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16497 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16501 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16498 static const char* error_messages_[] = { | 16502 static const char* error_messages_[] = { |
16499 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16503 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16500 }; | 16504 }; |
16501 #undef ERROR_MESSAGES_TEXTS | 16505 #undef ERROR_MESSAGES_TEXTS |
16502 return error_messages_[reason]; | 16506 return error_messages_[reason]; |
16503 } | 16507 } |
16504 | 16508 |
16505 | 16509 |
16506 } } // namespace v8::internal | 16510 } } // namespace v8::internal |
OLD | NEW |