Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: src/objects.cc

Issue 177383004: Use native context as key when evicting from optimized code map (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fixed copy mechanism Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9607 matching lines...) Expand 10 before | Expand all | Expand 10 after
9618 if (!code_map->get(kNextMapIndex)->IsUndefined()) { 9618 if (!code_map->get(kNextMapIndex)->IsUndefined()) {
9619 CodeFlusher* flusher = GetHeap()->mark_compact_collector()->code_flusher(); 9619 CodeFlusher* flusher = GetHeap()->mark_compact_collector()->code_flusher();
9620 flusher->EvictOptimizedCodeMap(this); 9620 flusher->EvictOptimizedCodeMap(this);
9621 } 9621 }
9622 9622
9623 ASSERT(code_map->get(kNextMapIndex)->IsUndefined()); 9623 ASSERT(code_map->get(kNextMapIndex)->IsUndefined());
9624 set_optimized_code_map(Smi::FromInt(0)); 9624 set_optimized_code_map(Smi::FromInt(0));
9625 } 9625 }
9626 9626
9627 9627
9628 void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code, 9628 void SharedFunctionInfo::EvictFromOptimizedCodeMap(Context* context,
9629 const char* reason) { 9629 const char* reason) {
9630 ASSERT(context->IsNativeContext());
9630 if (optimized_code_map()->IsSmi()) return; 9631 if (optimized_code_map()->IsSmi()) return;
9631 9632
9632 int i;
9633 bool removed_entry = false;
9634 FixedArray* code_map = FixedArray::cast(optimized_code_map()); 9633 FixedArray* code_map = FixedArray::cast(optimized_code_map());
9635 for (i = kEntriesStart; i < code_map->length(); i += kEntryLength) { 9634 int dst = kEntriesStart;
9636 ASSERT(code_map->get(i)->IsNativeContext()); 9635 int length = code_map->length();
9637 if (Code::cast(code_map->get(i + 1)) == optimized_code) { 9636 for (int src = kEntriesStart; src < length; src += kEntryLength) {
9637 Context* context_key = Context::cast(code_map->get(src));
9638 ASSERT(context->IsNativeContext());
9639 if (context_key == context) {
9638 if (FLAG_trace_opt) { 9640 if (FLAG_trace_opt) {
9639 PrintF("[evicting entry from optimizing code map (%s) for ", reason); 9641 PrintF("[evicting entry from optimizing code map (%s) for ", reason);
9640 ShortPrint(); 9642 ShortPrint();
9641 PrintF("]\n"); 9643 BailoutId osr(Smi::cast(code_map->get(src + kOsrAstIdOffset))->value());
9644 if (osr.IsNone()) {
9645 PrintF("]\n");
9646 } else {
9647 PrintF(" (osr ast id %d)]\n", osr.ToInt());
9648 }
9642 } 9649 }
9643 removed_entry = true; 9650 continue;
9644 break;
9645 } 9651 }
9652 if (dst != src) {
9653 code_map->set(dst + kContextOffset,
9654 code_map->get(src + kContextOffset));
9655 code_map->set(dst + kCachedCodeOffset,
9656 code_map->get(src + kCachedCodeOffset));
9657 code_map->set(dst + kLiteralsOffset,
9658 code_map->get(src + kLiteralsOffset));
9659 code_map->set(dst + kOsrAstIdOffset,
9660 code_map->get(src + kOsrAstIdOffset));
9661 }
9662 dst += kEntryLength;
9646 } 9663 }
9647 while (i < (code_map->length() - kEntryLength)) { 9664 if (dst != length) {
9648 code_map->set(i + kContextOffset,
9649 code_map->get(i + kContextOffset + kEntryLength));
9650 code_map->set(i + kCachedCodeOffset,
9651 code_map->get(i + kCachedCodeOffset + kEntryLength));
9652 code_map->set(i + kLiteralsOffset,
9653 code_map->get(i + kLiteralsOffset + kEntryLength));
9654 code_map->set(i + kOsrAstIdOffset,
9655 code_map->get(i + kOsrAstIdOffset + kEntryLength));
9656 i += kEntryLength;
9657 }
9658 if (removed_entry) {
9659 // Always trim even when array is cleared because of heap verifier. 9665 // Always trim even when array is cleared because of heap verifier.
9660 RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), code_map, kEntryLength); 9666 RightTrimFixedArray<FROM_MUTATOR>(GetHeap(), code_map, length - dst);
9661 if (code_map->length() == kEntriesStart) { 9667 if (code_map->length() == kEntriesStart) ClearOptimizedCodeMap();
9662 ClearOptimizedCodeMap();
9663 }
9664 } 9668 }
9665 } 9669 }
9666 9670
9667 9671
9668 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) { 9672 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) {
9669 FixedArray* code_map = FixedArray::cast(optimized_code_map()); 9673 FixedArray* code_map = FixedArray::cast(optimized_code_map());
9670 ASSERT(shrink_by % kEntryLength == 0); 9674 ASSERT(shrink_by % kEntryLength == 0);
9671 ASSERT(shrink_by <= code_map->length() - kEntriesStart); 9675 ASSERT(shrink_by <= code_map->length() - kEntriesStart);
9672 // Always trim even when array is cleared because of heap verifier. 9676 // Always trim even when array is cleared because of heap verifier.
9673 RightTrimFixedArray<FROM_GC>(GetHeap(), code_map, shrink_by); 9677 RightTrimFixedArray<FROM_GC>(GetHeap(), code_map, shrink_by);
(...skipping 6810 matching lines...) Expand 10 before | Expand all | Expand 10 after
16484 #define ERROR_MESSAGES_TEXTS(C, T) T, 16488 #define ERROR_MESSAGES_TEXTS(C, T) T,
16485 static const char* error_messages_[] = { 16489 static const char* error_messages_[] = {
16486 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16490 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16487 }; 16491 };
16488 #undef ERROR_MESSAGES_TEXTS 16492 #undef ERROR_MESSAGES_TEXTS
16489 return error_messages_[reason]; 16493 return error_messages_[reason];
16490 } 16494 }
16491 16495
16492 16496
16493 } } // namespace v8::internal 16497 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698