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

Side by Side Diff: src/objects.cc

Issue 1410833009: [heap] Simplify zapping of old optimized code maps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 11066 matching lines...) Expand 10 before | Expand all | Expand 10 after
11077 return; 11077 return;
11078 } 11078 }
11079 11079
11080 // Copy old optimized code map and append one new entry. 11080 // Copy old optimized code map and append one new entry.
11081 new_code_map = isolate->factory()->CopyFixedArrayAndGrow( 11081 new_code_map = isolate->factory()->CopyFixedArrayAndGrow(
11082 old_code_map, kEntryLength, TENURED); 11082 old_code_map, kEntryLength, TENURED);
11083 // TODO(mstarzinger): Temporary workaround. The allocation above might have 11083 // TODO(mstarzinger): Temporary workaround. The allocation above might have
11084 // flushed the optimized code map and the copy we created is full of holes. 11084 // flushed the optimized code map and the copy we created is full of holes.
11085 // For now we just give up on adding the entry and pretend it got flushed. 11085 // For now we just give up on adding the entry and pretend it got flushed.
11086 if (shared->optimized_code_map()->IsSmi()) return; 11086 if (shared->optimized_code_map()->IsSmi()) return;
11087 int old_length = old_code_map->length(); 11087 entry = old_code_map->length();
11088 // Zap the old map to avoid any stale entries. Note that this is required
11089 // for correctness because entries are being treated weakly by the GC.
11090 MemsetPointer(old_code_map->data_start(), isolate->heap()->the_hole_value(),
11091 old_length);
11092 entry = old_length;
11093 } 11088 }
11094 new_code_map->set(entry + kContextOffset, *native_context); 11089 new_code_map->set(entry + kContextOffset, *native_context);
11095 new_code_map->set(entry + kCachedCodeOffset, *code); 11090 new_code_map->set(entry + kCachedCodeOffset, *code);
11096 new_code_map->set(entry + kLiteralsOffset, *literals); 11091 new_code_map->set(entry + kLiteralsOffset, *literals);
11097 new_code_map->set(entry + kOsrAstIdOffset, Smi::FromInt(osr_ast_id.ToInt())); 11092 new_code_map->set(entry + kOsrAstIdOffset, Smi::FromInt(osr_ast_id.ToInt()));
11098 11093
11099 #ifdef DEBUG 11094 #ifdef DEBUG
11100 for (int i = kEntriesStart; i < new_code_map->length(); i += kEntryLength) { 11095 for (int i = kEntriesStart; i < new_code_map->length(); i += kEntryLength) {
11101 DCHECK(new_code_map->get(i + kContextOffset)->IsNativeContext()); 11096 DCHECK(new_code_map->get(i + kContextOffset)->IsNativeContext());
11102 Object* code = new_code_map->get(i + kCachedCodeOffset); 11097 Object* code = new_code_map->get(i + kCachedCodeOffset);
11103 if (code != isolate->heap()->undefined_value()) { 11098 if (code != isolate->heap()->undefined_value()) {
11104 DCHECK(code->IsCode()); 11099 DCHECK(code->IsCode());
11105 DCHECK(Code::cast(code)->kind() == Code::OPTIMIZED_FUNCTION); 11100 DCHECK(Code::cast(code)->kind() == Code::OPTIMIZED_FUNCTION);
11106 } 11101 }
11107 DCHECK(new_code_map->get(i + kLiteralsOffset)->IsFixedArray()); 11102 DCHECK(new_code_map->get(i + kLiteralsOffset)->IsFixedArray());
11108 DCHECK(new_code_map->get(i + kOsrAstIdOffset)->IsSmi()); 11103 DCHECK(new_code_map->get(i + kOsrAstIdOffset)->IsSmi());
11109 } 11104 }
11110 #endif 11105 #endif
11111 11106
11112 if (Heap::ShouldZapGarbage()) { 11107 // Zap any old optimized code map.
11113 // Zap any old optimized code map for heap-verifier. 11108 if (!shared->optimized_code_map()->IsSmi()) {
11114 if (!shared->optimized_code_map()->IsSmi()) { 11109 FixedArray* old_code_map = FixedArray::cast(shared->optimized_code_map());
11115 FixedArray* old_code_map = FixedArray::cast(shared->optimized_code_map()); 11110 old_code_map->FillWithHoles(0, old_code_map->length());
11116 old_code_map->FillWithHoles(0, old_code_map->length());
11117 }
11118 } 11111 }
11119 11112
11120 shared->set_optimized_code_map(*new_code_map); 11113 shared->set_optimized_code_map(*new_code_map);
11121 } 11114 }
11122 11115
11123 11116
11124 void SharedFunctionInfo::ClearOptimizedCodeMap() { 11117 void SharedFunctionInfo::ClearOptimizedCodeMap() {
11125 if (Heap::ShouldZapGarbage()) { 11118 // Zap any old optimized code map.
11126 // Zap any old optimized code map for heap-verifier. 11119 if (!optimized_code_map()->IsSmi()) {
11127 if (!optimized_code_map()->IsSmi()) { 11120 FixedArray* old_code_map = FixedArray::cast(optimized_code_map());
11128 FixedArray* old_code_map = FixedArray::cast(optimized_code_map()); 11121 old_code_map->FillWithHoles(0, old_code_map->length());
11129 old_code_map->FillWithHoles(0, old_code_map->length());
11130 }
11131 } 11122 }
11132 11123
11133 set_optimized_code_map(Smi::FromInt(0)); 11124 set_optimized_code_map(Smi::FromInt(0));
11134 } 11125 }
11135 11126
11136 11127
11137 void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code, 11128 void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code,
11138 const char* reason) { 11129 const char* reason) {
11139 DisallowHeapAllocation no_gc; 11130 DisallowHeapAllocation no_gc;
11140 if (optimized_code_map()->IsSmi()) return; 11131 if (optimized_code_map()->IsSmi()) return;
(...skipping 6752 matching lines...) Expand 10 before | Expand all | Expand 10 after
17893 if (cell->value() != *new_value) { 17884 if (cell->value() != *new_value) {
17894 cell->set_value(*new_value); 17885 cell->set_value(*new_value);
17895 Isolate* isolate = cell->GetIsolate(); 17886 Isolate* isolate = cell->GetIsolate();
17896 cell->dependent_code()->DeoptimizeDependentCodeGroup( 17887 cell->dependent_code()->DeoptimizeDependentCodeGroup(
17897 isolate, DependentCode::kPropertyCellChangedGroup); 17888 isolate, DependentCode::kPropertyCellChangedGroup);
17898 } 17889 }
17899 } 17890 }
17900 17891
17901 } // namespace internal 17892 } // namespace internal
17902 } // namespace v8 17893 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698