| 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 9613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9624 if (!code_map->get(kNextMapIndex)->IsUndefined()) { | 9624 if (!code_map->get(kNextMapIndex)->IsUndefined()) { |
| 9625 CodeFlusher* flusher = GetHeap()->mark_compact_collector()->code_flusher(); | 9625 CodeFlusher* flusher = GetHeap()->mark_compact_collector()->code_flusher(); |
| 9626 flusher->EvictOptimizedCodeMap(this); | 9626 flusher->EvictOptimizedCodeMap(this); |
| 9627 } | 9627 } |
| 9628 | 9628 |
| 9629 ASSERT(code_map->get(kNextMapIndex)->IsUndefined()); | 9629 ASSERT(code_map->get(kNextMapIndex)->IsUndefined()); |
| 9630 set_optimized_code_map(Smi::FromInt(0)); | 9630 set_optimized_code_map(Smi::FromInt(0)); |
| 9631 } | 9631 } |
| 9632 | 9632 |
| 9633 | 9633 |
| 9634 void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code, | 9634 void SharedFunctionInfo::EvictFromOptimizedCodeMap(Context* context, |
| 9635 const char* reason) { | 9635 const char* reason) { |
| 9636 ASSERT(context->IsNativeContext()); |
| 9636 if (optimized_code_map()->IsSmi()) return; | 9637 if (optimized_code_map()->IsSmi()) return; |
| 9637 | 9638 |
| 9638 int i; | |
| 9639 bool removed_entry = false; | |
| 9640 FixedArray* code_map = FixedArray::cast(optimized_code_map()); | 9639 FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
| 9641 for (i = kEntriesStart; i < code_map->length(); i += kEntryLength) { | 9640 int dst = kEntriesStart; |
| 9642 ASSERT(code_map->get(i)->IsNativeContext()); | 9641 int length = code_map->length(); |
| 9643 if (Code::cast(code_map->get(i + 1)) == optimized_code) { | 9642 for (int src = kEntriesStart; src < length; src += kEntryLength) { |
| 9643 Context* context_key = Context::cast(code_map->get(src)); |
| 9644 ASSERT(context->IsNativeContext()); |
| 9645 if (context_key == context) { |
| 9644 if (FLAG_trace_opt) { | 9646 if (FLAG_trace_opt) { |
| 9645 PrintF("[evicting entry from optimizing code map (%s) for ", reason); | 9647 PrintF("[evicting entry from optimizing code map (%s) for ", reason); |
| 9646 ShortPrint(); | 9648 ShortPrint(); |
| 9647 PrintF("]\n"); | 9649 BailoutId osr(Smi::cast(code_map->get(src + kOsrAstIdOffset))->value()); |
| 9650 if (osr.IsNone()) { |
| 9651 PrintF("]\n"); |
| 9652 } else { |
| 9653 PrintF(" (osr ast id %d)]\n", osr.ToInt()); |
| 9654 } |
| 9648 } | 9655 } |
| 9649 removed_entry = true; | 9656 continue; |
| 9650 break; | |
| 9651 } | 9657 } |
| 9658 if (dst != src) { |
| 9659 code_map->set(dst + kContextOffset, |
| 9660 code_map->get(src + kContextOffset)); |
| 9661 code_map->set(dst + kCachedCodeOffset, |
| 9662 code_map->get(src + kCachedCodeOffset)); |
| 9663 code_map->set(dst + kLiteralsOffset, |
| 9664 code_map->get(src + kLiteralsOffset)); |
| 9665 code_map->set(dst + kOsrAstIdOffset, |
| 9666 code_map->get(src + kOsrAstIdOffset)); |
| 9667 } |
| 9668 dst += kEntryLength; |
| 9652 } | 9669 } |
| 9653 while (i < (code_map->length() - kEntryLength)) { | 9670 if (dst != length) { |
| 9654 code_map->set(i + kContextOffset, | |
| 9655 code_map->get(i + kContextOffset + kEntryLength)); | |
| 9656 code_map->set(i + kCachedCodeOffset, | |
| 9657 code_map->get(i + kCachedCodeOffset + kEntryLength)); | |
| 9658 code_map->set(i + kLiteralsOffset, | |
| 9659 code_map->get(i + kLiteralsOffset + kEntryLength)); | |
| 9660 code_map->set(i + kOsrAstIdOffset, | |
| 9661 code_map->get(i + kOsrAstIdOffset + kEntryLength)); | |
| 9662 i += kEntryLength; | |
| 9663 } | |
| 9664 if (removed_entry) { | |
| 9665 // Always trim even when array is cleared because of heap verifier. | 9671 // Always trim even when array is cleared because of heap verifier. |
| 9666 RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), code_map, kEntryLength); | 9672 RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), code_map, length - dst); |
| 9667 if (code_map->length() == kEntriesStart) { | 9673 if (code_map->length() == kEntriesStart) ClearOptimizedCodeMap(); |
| 9668 ClearOptimizedCodeMap(); | |
| 9669 } | |
| 9670 } | 9674 } |
| 9671 } | 9675 } |
| 9672 | 9676 |
| 9673 | 9677 |
| 9674 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) { | 9678 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) { |
| 9675 FixedArray* code_map = FixedArray::cast(optimized_code_map()); | 9679 FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
| 9676 ASSERT(shrink_by % kEntryLength == 0); | 9680 ASSERT(shrink_by % kEntryLength == 0); |
| 9677 ASSERT(shrink_by <= code_map->length() - kEntriesStart); | 9681 ASSERT(shrink_by <= code_map->length() - kEntriesStart); |
| 9678 // Always trim even when array is cleared because of heap verifier. | 9682 // Always trim even when array is cleared because of heap verifier. |
| 9679 RightTrimFixedArray<FROM_GC>(GetHeap(), code_map, shrink_by); | 9683 RightTrimFixedArray<FROM_GC>(GetHeap(), code_map, shrink_by); |
| (...skipping 6812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16492 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16496 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16493 static const char* error_messages_[] = { | 16497 static const char* error_messages_[] = { |
| 16494 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16498 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16495 }; | 16499 }; |
| 16496 #undef ERROR_MESSAGES_TEXTS | 16500 #undef ERROR_MESSAGES_TEXTS |
| 16497 return error_messages_[reason]; | 16501 return error_messages_[reason]; |
| 16498 } | 16502 } |
| 16499 | 16503 |
| 16500 | 16504 |
| 16501 } } // namespace v8::internal | 16505 } } // namespace v8::internal |
| OLD | NEW |