Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 11397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11408 } | 11408 } |
| 11409 | 11409 |
| 11410 | 11410 |
| 11411 void SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap( | 11411 void SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap( |
| 11412 Handle<SharedFunctionInfo> shared, Handle<Code> code) { | 11412 Handle<SharedFunctionInfo> shared, Handle<Code> code) { |
| 11413 Isolate* isolate = shared->GetIsolate(); | 11413 Isolate* isolate = shared->GetIsolate(); |
| 11414 if (isolate->serializer_enabled()) return; | 11414 if (isolate->serializer_enabled()) return; |
| 11415 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); | 11415 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); |
| 11416 // Empty code maps are unsupported. | 11416 // Empty code maps are unsupported. |
| 11417 if (shared->OptimizedCodeMapIsCleared()) return; | 11417 if (shared->OptimizedCodeMapIsCleared()) return; |
| 11418 shared->optimized_code_map()->set(kSharedCodeIndex, *code); | 11418 Handle<WeakCell> cell = isolate->factory()->NewWeakCell(code); |
| 11419 shared->optimized_code_map()->set(kSharedCodeIndex, *cell); | |
| 11419 } | 11420 } |
| 11420 | 11421 |
| 11421 | 11422 |
| 11422 void SharedFunctionInfo::AddToOptimizedCodeMap( | 11423 void SharedFunctionInfo::AddToOptimizedCodeMap( |
| 11423 Handle<SharedFunctionInfo> shared, Handle<Context> native_context, | 11424 Handle<SharedFunctionInfo> shared, Handle<Context> native_context, |
| 11424 Handle<HeapObject> code, Handle<LiteralsArray> literals, | 11425 Handle<HeapObject> code, Handle<LiteralsArray> literals, |
| 11425 BailoutId osr_ast_id) { | 11426 BailoutId osr_ast_id) { |
| 11426 Isolate* isolate = shared->GetIsolate(); | 11427 Isolate* isolate = shared->GetIsolate(); |
| 11427 if (isolate->serializer_enabled()) return; | 11428 if (isolate->serializer_enabled()) return; |
| 11428 DCHECK(*code == isolate->heap()->undefined_value() || | 11429 DCHECK(*code == isolate->heap()->undefined_value() || |
| 11429 !shared->SearchOptimizedCodeMap(*native_context, osr_ast_id).code); | 11430 !shared->SearchOptimizedCodeMap(*native_context, osr_ast_id).code); |
| 11430 DCHECK(*code == isolate->heap()->undefined_value() || | 11431 DCHECK(*code == isolate->heap()->undefined_value() || |
| 11431 Code::cast(*code)->kind() == Code::OPTIMIZED_FUNCTION); | 11432 Code::cast(*code)->kind() == Code::OPTIMIZED_FUNCTION); |
| 11432 DCHECK(native_context->IsNativeContext()); | 11433 DCHECK(native_context->IsNativeContext()); |
| 11433 STATIC_ASSERT(kEntryLength == 4); | 11434 STATIC_ASSERT(kEntryLength == 4); |
| 11434 Handle<FixedArray> new_code_map; | 11435 Handle<FixedArray> new_code_map; |
| 11435 int entry; | 11436 int entry; |
| 11437 | |
| 11436 if (shared->OptimizedCodeMapIsCleared()) { | 11438 if (shared->OptimizedCodeMapIsCleared()) { |
| 11437 new_code_map = isolate->factory()->NewFixedArray(kInitialLength, TENURED); | 11439 new_code_map = isolate->factory()->NewFixedArray(kInitialLength, TENURED); |
| 11440 new_code_map->set(kSharedCodeIndex, *isolate->factory()->empty_weak_cell(), | |
| 11441 SKIP_WRITE_BARRIER); | |
| 11438 entry = kEntriesStart; | 11442 entry = kEntriesStart; |
| 11439 } else { | 11443 } else { |
| 11440 Handle<FixedArray> old_code_map(shared->optimized_code_map(), isolate); | 11444 Handle<FixedArray> old_code_map(shared->optimized_code_map(), isolate); |
| 11441 entry = shared->SearchOptimizedCodeMapEntry(*native_context, osr_ast_id); | 11445 entry = shared->SearchOptimizedCodeMapEntry(*native_context, osr_ast_id); |
| 11442 if (entry > kSharedCodeIndex) { | 11446 if (entry > kSharedCodeIndex) { |
| 11443 // Found an existing context-specific entry, it must not contain any code. | 11447 // Found an existing context-specific entry, it must not contain any code. |
| 11444 DCHECK_EQ(isolate->heap()->undefined_value(), | 11448 DCHECK(WeakCell::cast(old_code_map->get(entry + kCachedCodeOffset)) |
| 11445 old_code_map->get(entry + kCachedCodeOffset)); | 11449 ->cleared()); |
| 11446 // Just set the code and literals to the entry. | 11450 // Just set the code and literals to the entry. |
| 11447 old_code_map->set(entry + kCachedCodeOffset, *code); | 11451 Handle<WeakCell> code_cell = code->IsUndefined() |
| 11448 old_code_map->set(entry + kLiteralsOffset, *literals); | 11452 ? isolate->factory()->empty_weak_cell() |
| 11453 : isolate->factory()->NewWeakCell(code); | |
| 11454 Handle<WeakCell> literals_cell = | |
| 11455 isolate->factory()->NewWeakCell(literals); | |
| 11456 old_code_map->set(entry + kCachedCodeOffset, *code_cell); | |
| 11457 old_code_map->set(entry + kLiteralsOffset, *literals_cell); | |
| 11449 return; | 11458 return; |
| 11450 } | 11459 } |
| 11451 | 11460 |
| 11452 // Copy old optimized code map and append one new entry. | 11461 // Can we reuse an entry? |
| 11453 new_code_map = isolate->factory()->CopyFixedArrayAndGrow( | 11462 DCHECK(entry < kEntriesStart); |
|
Michael Starzinger
2015/12/01 12:36:10
nit: DCHECK_LT
| |
| 11454 old_code_map, kEntryLength, TENURED); | 11463 int length = old_code_map->length(); |
| 11455 // TODO(mstarzinger): Temporary workaround. The allocation above might have | 11464 for (int i = kEntriesStart; i < length; i += kEntryLength) { |
| 11456 // flushed the optimized code map and the copy we created is full of holes. | 11465 if (WeakCell::cast(old_code_map->get(i + kContextOffset))->cleared()) { |
| 11457 // For now we just give up on adding the entry and pretend it got flushed. | 11466 entry = i; |
| 11458 if (shared->OptimizedCodeMapIsCleared()) return; | 11467 break; |
| 11459 entry = old_code_map->length(); | 11468 } |
| 11469 } | |
| 11470 | |
| 11471 if (entry < kEntriesStart) { | |
| 11472 // Copy old optimized code map and append one new entry. | |
| 11473 new_code_map = isolate->factory()->CopyFixedArrayAndGrow( | |
| 11474 old_code_map, kEntryLength, TENURED); | |
| 11475 // TODO(mstarzinger): Temporary workaround. The allocation above might | |
| 11476 // have flushed the optimized code map and the copy we created is full of | |
| 11477 // holes. For now we just give up on adding the entry and pretend it got | |
| 11478 // flushed. | |
| 11479 if (shared->OptimizedCodeMapIsCleared()) return; | |
| 11480 entry = old_code_map->length(); | |
| 11481 } | |
| 11460 } | 11482 } |
| 11461 new_code_map->set(entry + kContextOffset, *native_context); | 11483 |
| 11462 new_code_map->set(entry + kCachedCodeOffset, *code); | 11484 Handle<WeakCell> code_cell = code->IsUndefined() |
| 11463 new_code_map->set(entry + kLiteralsOffset, *literals); | 11485 ? isolate->factory()->empty_weak_cell() |
| 11486 : isolate->factory()->NewWeakCell(code); | |
| 11487 Handle<WeakCell> literals_cell = isolate->factory()->NewWeakCell(literals); | |
| 11488 WeakCell* context_cell = native_context->self_weak_cell(); | |
| 11489 | |
| 11490 new_code_map->set(entry + kContextOffset, context_cell); | |
| 11491 new_code_map->set(entry + kCachedCodeOffset, *code_cell); | |
| 11492 new_code_map->set(entry + kLiteralsOffset, *literals_cell); | |
| 11464 new_code_map->set(entry + kOsrAstIdOffset, Smi::FromInt(osr_ast_id.ToInt())); | 11493 new_code_map->set(entry + kOsrAstIdOffset, Smi::FromInt(osr_ast_id.ToInt())); |
| 11465 | 11494 |
| 11466 #ifdef DEBUG | 11495 #ifdef DEBUG |
| 11467 for (int i = kEntriesStart; i < new_code_map->length(); i += kEntryLength) { | 11496 for (int i = kEntriesStart; i < new_code_map->length(); i += kEntryLength) { |
| 11468 DCHECK(new_code_map->get(i + kContextOffset)->IsNativeContext()); | 11497 WeakCell* cell = WeakCell::cast(new_code_map->get(i + kContextOffset)); |
| 11469 Object* code = new_code_map->get(i + kCachedCodeOffset); | 11498 DCHECK(cell->cleared() || cell->value()->IsNativeContext()); |
| 11470 if (code != isolate->heap()->undefined_value()) { | 11499 cell = WeakCell::cast(new_code_map->get(i + kCachedCodeOffset)); |
| 11471 DCHECK(code->IsCode()); | 11500 DCHECK(cell->cleared() || |
| 11472 DCHECK(Code::cast(code)->kind() == Code::OPTIMIZED_FUNCTION); | 11501 (cell->value()->IsCode() && |
| 11473 } | 11502 Code::cast(cell->value())->kind() == Code::OPTIMIZED_FUNCTION)); |
| 11474 DCHECK(new_code_map->get(i + kLiteralsOffset)->IsFixedArray()); | 11503 cell = WeakCell::cast(new_code_map->get(i + kLiteralsOffset)); |
| 11504 DCHECK(cell->cleared() || cell->value()->IsFixedArray()); | |
| 11475 DCHECK(new_code_map->get(i + kOsrAstIdOffset)->IsSmi()); | 11505 DCHECK(new_code_map->get(i + kOsrAstIdOffset)->IsSmi()); |
| 11476 } | 11506 } |
| 11477 #endif | 11507 #endif |
| 11478 | 11508 |
| 11479 // Zap any old optimized code map. | 11509 // Zap any old optimized code map. |
| 11480 if (!shared->OptimizedCodeMapIsCleared()) { | 11510 if (!shared->OptimizedCodeMapIsCleared()) { |
| 11481 FixedArray* old_code_map = shared->optimized_code_map(); | 11511 FixedArray* old_code_map = shared->optimized_code_map(); |
| 11482 old_code_map->FillWithHoles(0, old_code_map->length()); | 11512 old_code_map->FillWithHoles(0, old_code_map->length()); |
| 11483 } | 11513 } |
| 11484 | 11514 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 11501 void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code, | 11531 void SharedFunctionInfo::EvictFromOptimizedCodeMap(Code* optimized_code, |
| 11502 const char* reason) { | 11532 const char* reason) { |
| 11503 DisallowHeapAllocation no_gc; | 11533 DisallowHeapAllocation no_gc; |
| 11504 if (OptimizedCodeMapIsCleared()) return; | 11534 if (OptimizedCodeMapIsCleared()) return; |
| 11505 | 11535 |
| 11506 Heap* heap = GetHeap(); | 11536 Heap* heap = GetHeap(); |
| 11507 FixedArray* code_map = optimized_code_map(); | 11537 FixedArray* code_map = optimized_code_map(); |
| 11508 int dst = kEntriesStart; | 11538 int dst = kEntriesStart; |
| 11509 int length = code_map->length(); | 11539 int length = code_map->length(); |
| 11510 for (int src = kEntriesStart; src < length; src += kEntryLength) { | 11540 for (int src = kEntriesStart; src < length; src += kEntryLength) { |
| 11511 DCHECK(code_map->get(src)->IsNativeContext()); | 11541 DCHECK(WeakCell::cast(code_map->get(src))->cleared() || |
| 11512 if (code_map->get(src + kCachedCodeOffset) == optimized_code) { | 11542 WeakCell::cast(code_map->get(src))->value()->IsNativeContext()); |
| 11543 if (WeakCell::cast(code_map->get(src + kCachedCodeOffset))->value() == | |
| 11544 optimized_code) { | |
| 11513 BailoutId osr(Smi::cast(code_map->get(src + kOsrAstIdOffset))->value()); | 11545 BailoutId osr(Smi::cast(code_map->get(src + kOsrAstIdOffset))->value()); |
| 11514 if (FLAG_trace_opt) { | 11546 if (FLAG_trace_opt) { |
| 11515 PrintF("[evicting entry from optimizing code map (%s) for ", reason); | 11547 PrintF("[evicting entry from optimizing code map (%s) for ", reason); |
| 11516 ShortPrint(); | 11548 ShortPrint(); |
| 11517 if (osr.IsNone()) { | 11549 if (osr.IsNone()) { |
| 11518 PrintF("]\n"); | 11550 PrintF("]\n"); |
| 11519 } else { | 11551 } else { |
| 11520 PrintF(" (osr ast id %d)]\n", osr.ToInt()); | 11552 PrintF(" (osr ast id %d)]\n", osr.ToInt()); |
| 11521 } | 11553 } |
| 11522 } | 11554 } |
| 11523 if (!osr.IsNone()) { | 11555 if (!osr.IsNone()) { |
| 11524 // Evict the src entry by not copying it to the dst entry. | 11556 // Evict the src entry by not copying it to the dst entry. |
| 11525 continue; | 11557 continue; |
| 11526 } | 11558 } |
| 11527 // In case of non-OSR entry just clear the code in order to proceed | 11559 // In case of non-OSR entry just clear the code in order to proceed |
| 11528 // sharing literals. | 11560 // sharing literals. |
| 11529 code_map->set_undefined(src + kCachedCodeOffset); | 11561 code_map->set(src + kCachedCodeOffset, heap->empty_weak_cell(), |
| 11562 SKIP_WRITE_BARRIER); | |
| 11530 } | 11563 } |
| 11531 | 11564 |
| 11532 // Keep the src entry by copying it to the dst entry. | 11565 // Keep the src entry by copying it to the dst entry. |
| 11533 if (dst != src) { | 11566 if (dst != src) { |
| 11534 code_map->set(dst + kContextOffset, code_map->get(src + kContextOffset)); | 11567 code_map->set(dst + kContextOffset, code_map->get(src + kContextOffset)); |
| 11535 code_map->set(dst + kCachedCodeOffset, | 11568 code_map->set(dst + kCachedCodeOffset, |
| 11536 code_map->get(src + kCachedCodeOffset)); | 11569 code_map->get(src + kCachedCodeOffset)); |
| 11537 code_map->set(dst + kLiteralsOffset, | 11570 code_map->set(dst + kLiteralsOffset, |
| 11538 code_map->get(src + kLiteralsOffset)); | 11571 code_map->get(src + kLiteralsOffset)); |
| 11539 code_map->set(dst + kOsrAstIdOffset, | 11572 code_map->set(dst + kOsrAstIdOffset, |
| 11540 code_map->get(src + kOsrAstIdOffset)); | 11573 code_map->get(src + kOsrAstIdOffset)); |
| 11541 } | 11574 } |
| 11542 dst += kEntryLength; | 11575 dst += kEntryLength; |
| 11543 } | 11576 } |
| 11544 if (code_map->get(kSharedCodeIndex) == optimized_code) { | 11577 if (WeakCell::cast(code_map->get(kSharedCodeIndex))->value() == |
| 11578 optimized_code) { | |
| 11545 // Evict context-independent code as well. | 11579 // Evict context-independent code as well. |
| 11546 code_map->set_undefined(kSharedCodeIndex); | 11580 code_map->set(kSharedCodeIndex, heap->empty_weak_cell(), |
| 11581 SKIP_WRITE_BARRIER); | |
| 11547 if (FLAG_trace_opt) { | 11582 if (FLAG_trace_opt) { |
| 11548 PrintF("[evicting entry from optimizing code map (%s) for ", reason); | 11583 PrintF("[evicting entry from optimizing code map (%s) for ", reason); |
| 11549 ShortPrint(); | 11584 ShortPrint(); |
| 11550 PrintF(" (context-independent code)]\n"); | 11585 PrintF(" (context-independent code)]\n"); |
| 11551 } | 11586 } |
| 11552 } | 11587 } |
| 11553 if (dst != length) { | 11588 if (dst != length) { |
| 11554 // Always trim even when array is cleared because of heap verifier. | 11589 // Always trim even when array is cleared because of heap verifier. |
| 11555 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(code_map, | 11590 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(code_map, |
| 11556 length - dst); | 11591 length - dst); |
| 11557 if (code_map->length() == kEntriesStart && | 11592 if (code_map->length() == kEntriesStart && |
| 11558 code_map->get(kSharedCodeIndex)->IsUndefined()) { | 11593 WeakCell::cast(code_map->get(kSharedCodeIndex))->cleared()) { |
| 11559 ClearOptimizedCodeMap(); | 11594 ClearOptimizedCodeMap(); |
| 11560 } | 11595 } |
| 11561 } | 11596 } |
| 11562 } | 11597 } |
| 11563 | 11598 |
| 11564 | 11599 |
| 11565 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) { | 11600 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) { |
| 11566 FixedArray* code_map = optimized_code_map(); | 11601 FixedArray* code_map = optimized_code_map(); |
| 11567 DCHECK(shrink_by % kEntryLength == 0); | 11602 DCHECK(shrink_by % kEntryLength == 0); |
| 11568 DCHECK(shrink_by <= code_map->length() - kEntriesStart); | 11603 DCHECK(shrink_by <= code_map->length() - kEntriesStart); |
| 11569 // Always trim even when array is cleared because of heap verifier. | 11604 // Always trim even when array is cleared because of heap verifier. |
| 11570 GetHeap()->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(code_map, | 11605 GetHeap()->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(code_map, |
| 11571 shrink_by); | 11606 shrink_by); |
| 11572 if (code_map->length() == kEntriesStart && | 11607 if (code_map->length() == kEntriesStart && |
| 11573 code_map->get(kSharedCodeIndex)->IsUndefined()) { | 11608 WeakCell::cast(code_map->get(kSharedCodeIndex))->cleared()) { |
| 11574 ClearOptimizedCodeMap(); | 11609 ClearOptimizedCodeMap(); |
| 11575 } | 11610 } |
| 11576 } | 11611 } |
| 11577 | 11612 |
| 11578 | 11613 |
| 11579 static void GetMinInobjectSlack(Map* map, void* data) { | 11614 static void GetMinInobjectSlack(Map* map, void* data) { |
| 11580 int slack = map->unused_property_fields(); | 11615 int slack = map->unused_property_fields(); |
| 11581 if (*reinterpret_cast<int*>(data) > slack) { | 11616 if (*reinterpret_cast<int*>(data) > slack) { |
| 11582 *reinterpret_cast<int*>(data) = slack; | 11617 *reinterpret_cast<int*>(data) = slack; |
| 11583 } | 11618 } |
| (...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12788 | 12823 |
| 12789 int SharedFunctionInfo::SearchOptimizedCodeMapEntry(Context* native_context, | 12824 int SharedFunctionInfo::SearchOptimizedCodeMapEntry(Context* native_context, |
| 12790 BailoutId osr_ast_id) { | 12825 BailoutId osr_ast_id) { |
| 12791 DisallowHeapAllocation no_gc; | 12826 DisallowHeapAllocation no_gc; |
| 12792 DCHECK(native_context->IsNativeContext()); | 12827 DCHECK(native_context->IsNativeContext()); |
| 12793 if (!OptimizedCodeMapIsCleared()) { | 12828 if (!OptimizedCodeMapIsCleared()) { |
| 12794 FixedArray* optimized_code_map = this->optimized_code_map(); | 12829 FixedArray* optimized_code_map = this->optimized_code_map(); |
| 12795 int length = optimized_code_map->length(); | 12830 int length = optimized_code_map->length(); |
| 12796 Smi* osr_ast_id_smi = Smi::FromInt(osr_ast_id.ToInt()); | 12831 Smi* osr_ast_id_smi = Smi::FromInt(osr_ast_id.ToInt()); |
| 12797 for (int i = kEntriesStart; i < length; i += kEntryLength) { | 12832 for (int i = kEntriesStart; i < length; i += kEntryLength) { |
| 12798 if (optimized_code_map->get(i + kContextOffset) == native_context && | 12833 if (WeakCell::cast(optimized_code_map->get(i + kContextOffset)) |
| 12834 ->value() == native_context && | |
| 12799 optimized_code_map->get(i + kOsrAstIdOffset) == osr_ast_id_smi) { | 12835 optimized_code_map->get(i + kOsrAstIdOffset) == osr_ast_id_smi) { |
| 12800 return i; | 12836 return i; |
| 12801 } | 12837 } |
| 12802 } | 12838 } |
| 12803 Object* shared_code = optimized_code_map->get(kSharedCodeIndex); | 12839 Object* shared_code = |
| 12840 WeakCell::cast(optimized_code_map->get(kSharedCodeIndex))->value(); | |
| 12804 if (shared_code->IsCode() && osr_ast_id.IsNone()) { | 12841 if (shared_code->IsCode() && osr_ast_id.IsNone()) { |
| 12805 return kSharedCodeIndex; | 12842 return kSharedCodeIndex; |
| 12806 } | 12843 } |
| 12807 } | 12844 } |
| 12808 return -1; | 12845 return -1; |
| 12809 } | 12846 } |
| 12810 | 12847 |
| 12811 | 12848 |
| 12812 CodeAndLiterals SharedFunctionInfo::SearchOptimizedCodeMap( | 12849 CodeAndLiterals SharedFunctionInfo::SearchOptimizedCodeMap( |
| 12813 Context* native_context, BailoutId osr_ast_id) { | 12850 Context* native_context, BailoutId osr_ast_id) { |
| 12814 CodeAndLiterals result = {nullptr, nullptr}; | 12851 CodeAndLiterals result = {nullptr, nullptr}; |
| 12815 int entry = SearchOptimizedCodeMapEntry(native_context, osr_ast_id); | 12852 int entry = SearchOptimizedCodeMapEntry(native_context, osr_ast_id); |
| 12816 if (entry != kNotFound) { | 12853 if (entry != kNotFound) { |
| 12817 FixedArray* code_map = optimized_code_map(); | 12854 FixedArray* code_map = optimized_code_map(); |
| 12818 if (entry == kSharedCodeIndex) { | 12855 if (entry == kSharedCodeIndex) { |
| 12819 result = {Code::cast(code_map->get(kSharedCodeIndex)), nullptr}; | 12856 // We know the weak cell isn't cleared because we made sure of it in |
| 12820 | 12857 // SearchOptimizedCodeMapEntry and performed no allocations since that |
| 12858 // call. | |
| 12859 result = { | |
| 12860 Code::cast(WeakCell::cast(code_map->get(kSharedCodeIndex))->value()), | |
| 12861 nullptr}; | |
| 12821 } else { | 12862 } else { |
| 12822 DCHECK_LE(entry + kEntryLength, code_map->length()); | 12863 DCHECK_LE(entry + kEntryLength, code_map->length()); |
| 12823 Object* code = code_map->get(entry + kCachedCodeOffset); | 12864 WeakCell* cell = WeakCell::cast(code_map->get(entry + kCachedCodeOffset)); |
| 12824 result = {code->IsUndefined() ? nullptr : Code::cast(code), | 12865 WeakCell* literals_cell = |
| 12825 LiteralsArray::cast(code_map->get(entry + kLiteralsOffset))}; | 12866 WeakCell::cast(code_map->get(entry + kLiteralsOffset)); |
| 12867 | |
| 12868 result = {cell->cleared() ? nullptr : Code::cast(cell->value()), | |
| 12869 literals_cell->cleared() | |
| 12870 ? nullptr | |
| 12871 : LiteralsArray::cast(literals_cell->value())}; | |
| 12826 } | 12872 } |
| 12827 } | 12873 } |
| 12828 if (FLAG_trace_opt && !OptimizedCodeMapIsCleared() && | 12874 if (FLAG_trace_opt && !OptimizedCodeMapIsCleared() && |
| 12829 result.code == nullptr) { | 12875 result.code == nullptr) { |
| 12830 PrintF("[didn't find optimized code in optimized code map for "); | 12876 PrintF("[didn't find optimized code in optimized code map for "); |
| 12831 ShortPrint(); | 12877 ShortPrint(); |
| 12832 PrintF("]\n"); | 12878 PrintF("]\n"); |
| 12833 } | 12879 } |
| 12834 return result; | 12880 return result; |
| 12835 } | 12881 } |
| (...skipping 5738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 18574 if (cell->value() != *new_value) { | 18620 if (cell->value() != *new_value) { |
| 18575 cell->set_value(*new_value); | 18621 cell->set_value(*new_value); |
| 18576 Isolate* isolate = cell->GetIsolate(); | 18622 Isolate* isolate = cell->GetIsolate(); |
| 18577 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 18623 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 18578 isolate, DependentCode::kPropertyCellChangedGroup); | 18624 isolate, DependentCode::kPropertyCellChangedGroup); |
| 18579 } | 18625 } |
| 18580 } | 18626 } |
| 18581 | 18627 |
| 18582 } // namespace internal | 18628 } // namespace internal |
| 18583 } // namespace v8 | 18629 } // namespace v8 |
| OLD | NEW |