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