| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 11624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11635 } else { | 11635 } else { |
| 11636 Handle<FixedArray> old_code_map(shared->optimized_code_map(), isolate); | 11636 Handle<FixedArray> old_code_map(shared->optimized_code_map(), isolate); |
| 11637 entry = shared->SearchOptimizedCodeMapEntry(*native_context, osr_ast_id); | 11637 entry = shared->SearchOptimizedCodeMapEntry(*native_context, osr_ast_id); |
| 11638 if (entry > kSharedCodeIndex) { | 11638 if (entry > kSharedCodeIndex) { |
| 11639 // Just set the code and literals of the entry. | 11639 // Just set the code and literals of the entry. |
| 11640 if (!code.is_null()) { | 11640 if (!code.is_null()) { |
| 11641 Handle<WeakCell> code_cell = | 11641 Handle<WeakCell> code_cell = |
| 11642 isolate->factory()->NewWeakCell(code.ToHandleChecked()); | 11642 isolate->factory()->NewWeakCell(code.ToHandleChecked()); |
| 11643 old_code_map->set(entry + kCachedCodeOffset, *code_cell); | 11643 old_code_map->set(entry + kCachedCodeOffset, *code_cell); |
| 11644 } | 11644 } |
| 11645 if (literals->literals_count() == 0) { | 11645 Handle<WeakCell> literals_cell = |
| 11646 old_code_map->set(entry + kLiteralsOffset, *literals); | 11646 isolate->factory()->NewWeakCell(literals); |
| 11647 } else { | 11647 old_code_map->set(entry + kLiteralsOffset, *literals_cell); |
| 11648 Handle<WeakCell> literals_cell = | |
| 11649 isolate->factory()->NewWeakCell(literals); | |
| 11650 old_code_map->set(entry + kLiteralsOffset, *literals_cell); | |
| 11651 } | |
| 11652 return; | 11648 return; |
| 11653 } | 11649 } |
| 11654 | 11650 |
| 11655 // Can we reuse an entry? | 11651 // Can we reuse an entry? |
| 11656 DCHECK(entry < kEntriesStart); | 11652 DCHECK(entry < kEntriesStart); |
| 11657 int length = old_code_map->length(); | 11653 int length = old_code_map->length(); |
| 11658 for (int i = kEntriesStart; i < length; i += kEntryLength) { | 11654 for (int i = kEntriesStart; i < length; i += kEntryLength) { |
| 11659 if (WeakCell::cast(old_code_map->get(i + kContextOffset))->cleared()) { | 11655 if (WeakCell::cast(old_code_map->get(i + kContextOffset))->cleared()) { |
| 11660 new_code_map = old_code_map; | 11656 new_code_map = old_code_map; |
| 11661 entry = i; | 11657 entry = i; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 11672 // holes. For now we just give up on adding the entry and pretend it got | 11668 // holes. For now we just give up on adding the entry and pretend it got |
| 11673 // flushed. | 11669 // flushed. |
| 11674 if (shared->OptimizedCodeMapIsCleared()) return; | 11670 if (shared->OptimizedCodeMapIsCleared()) return; |
| 11675 entry = old_code_map->length(); | 11671 entry = old_code_map->length(); |
| 11676 } | 11672 } |
| 11677 } | 11673 } |
| 11678 | 11674 |
| 11679 Handle<WeakCell> code_cell = | 11675 Handle<WeakCell> code_cell = |
| 11680 code.is_null() ? isolate->factory()->empty_weak_cell() | 11676 code.is_null() ? isolate->factory()->empty_weak_cell() |
| 11681 : isolate->factory()->NewWeakCell(code.ToHandleChecked()); | 11677 : isolate->factory()->NewWeakCell(code.ToHandleChecked()); |
| 11678 Handle<WeakCell> literals_cell = isolate->factory()->NewWeakCell(literals); |
| 11682 WeakCell* context_cell = native_context->self_weak_cell(); | 11679 WeakCell* context_cell = native_context->self_weak_cell(); |
| 11683 | 11680 |
| 11684 new_code_map->set(entry + kContextOffset, context_cell); | 11681 new_code_map->set(entry + kContextOffset, context_cell); |
| 11685 new_code_map->set(entry + kCachedCodeOffset, *code_cell); | 11682 new_code_map->set(entry + kCachedCodeOffset, *code_cell); |
| 11686 | 11683 new_code_map->set(entry + kLiteralsOffset, *literals_cell); |
| 11687 if (literals->literals_count() == 0) { | |
| 11688 new_code_map->set(entry + kLiteralsOffset, *literals); | |
| 11689 } else { | |
| 11690 Handle<WeakCell> literals_cell = isolate->factory()->NewWeakCell(literals); | |
| 11691 new_code_map->set(entry + kLiteralsOffset, *literals_cell); | |
| 11692 } | |
| 11693 | |
| 11694 new_code_map->set(entry + kOsrAstIdOffset, Smi::FromInt(osr_ast_id.ToInt())); | 11684 new_code_map->set(entry + kOsrAstIdOffset, Smi::FromInt(osr_ast_id.ToInt())); |
| 11695 | 11685 |
| 11696 #ifdef DEBUG | 11686 #ifdef DEBUG |
| 11697 for (int i = kEntriesStart; i < new_code_map->length(); i += kEntryLength) { | 11687 for (int i = kEntriesStart; i < new_code_map->length(); i += kEntryLength) { |
| 11698 WeakCell* cell = WeakCell::cast(new_code_map->get(i + kContextOffset)); | 11688 WeakCell* cell = WeakCell::cast(new_code_map->get(i + kContextOffset)); |
| 11699 DCHECK(cell->cleared() || cell->value()->IsNativeContext()); | 11689 DCHECK(cell->cleared() || cell->value()->IsNativeContext()); |
| 11700 cell = WeakCell::cast(new_code_map->get(i + kCachedCodeOffset)); | 11690 cell = WeakCell::cast(new_code_map->get(i + kCachedCodeOffset)); |
| 11701 DCHECK(cell->cleared() || | 11691 DCHECK(cell->cleared() || |
| 11702 (cell->value()->IsCode() && | 11692 (cell->value()->IsCode() && |
| 11703 Code::cast(cell->value())->kind() == Code::OPTIMIZED_FUNCTION)); | 11693 Code::cast(cell->value())->kind() == Code::OPTIMIZED_FUNCTION)); |
| 11704 Object* lits = new_code_map->get(i + kLiteralsOffset); | 11694 cell = WeakCell::cast(new_code_map->get(i + kLiteralsOffset)); |
| 11705 if (lits->IsWeakCell()) { | 11695 DCHECK(cell->cleared() || cell->value()->IsFixedArray()); |
| 11706 cell = WeakCell::cast(lits); | |
| 11707 DCHECK(cell->cleared() || | |
| 11708 (cell->value()->IsLiteralsArray() && | |
| 11709 LiteralsArray::cast(cell->value())->literals_count() > 0)); | |
| 11710 } else { | |
| 11711 DCHECK(lits->IsLiteralsArray() && | |
| 11712 LiteralsArray::cast(lits)->literals_count() == 0); | |
| 11713 } | |
| 11714 DCHECK(new_code_map->get(i + kOsrAstIdOffset)->IsSmi()); | 11696 DCHECK(new_code_map->get(i + kOsrAstIdOffset)->IsSmi()); |
| 11715 } | 11697 } |
| 11716 #endif | 11698 #endif |
| 11717 | 11699 |
| 11718 FixedArray* old_code_map = shared->optimized_code_map(); | 11700 FixedArray* old_code_map = shared->optimized_code_map(); |
| 11719 if (old_code_map != *new_code_map) { | 11701 if (old_code_map != *new_code_map) { |
| 11720 shared->set_optimized_code_map(*new_code_map); | 11702 shared->set_optimized_code_map(*new_code_map); |
| 11721 } | 11703 } |
| 11722 } | 11704 } |
| 11723 | 11705 |
| (...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13354 if (entry == kSharedCodeIndex) { | 13336 if (entry == kSharedCodeIndex) { |
| 13355 // We know the weak cell isn't cleared because we made sure of it in | 13337 // We know the weak cell isn't cleared because we made sure of it in |
| 13356 // SearchOptimizedCodeMapEntry and performed no allocations since that | 13338 // SearchOptimizedCodeMapEntry and performed no allocations since that |
| 13357 // call. | 13339 // call. |
| 13358 result = { | 13340 result = { |
| 13359 Code::cast(WeakCell::cast(code_map->get(kSharedCodeIndex))->value()), | 13341 Code::cast(WeakCell::cast(code_map->get(kSharedCodeIndex))->value()), |
| 13360 nullptr}; | 13342 nullptr}; |
| 13361 } else { | 13343 } else { |
| 13362 DCHECK_LE(entry + kEntryLength, code_map->length()); | 13344 DCHECK_LE(entry + kEntryLength, code_map->length()); |
| 13363 WeakCell* cell = WeakCell::cast(code_map->get(entry + kCachedCodeOffset)); | 13345 WeakCell* cell = WeakCell::cast(code_map->get(entry + kCachedCodeOffset)); |
| 13364 Object* lits = code_map->get(entry + kLiteralsOffset); | 13346 WeakCell* literals_cell = |
| 13365 LiteralsArray* literals = nullptr; | 13347 WeakCell::cast(code_map->get(entry + kLiteralsOffset)); |
| 13366 if (lits->IsWeakCell()) { | 13348 |
| 13367 WeakCell* literal_cell = WeakCell::cast(lits); | |
| 13368 if (!literal_cell->cleared()) { | |
| 13369 literals = LiteralsArray::cast(literal_cell->value()); | |
| 13370 } | |
| 13371 } else { | |
| 13372 literals = LiteralsArray::cast(lits); | |
| 13373 } | |
| 13374 result = {cell->cleared() ? nullptr : Code::cast(cell->value()), | 13349 result = {cell->cleared() ? nullptr : Code::cast(cell->value()), |
| 13375 literals}; | 13350 literals_cell->cleared() |
| 13351 ? nullptr |
| 13352 : LiteralsArray::cast(literals_cell->value())}; |
| 13376 } | 13353 } |
| 13377 } | 13354 } |
| 13378 return result; | 13355 return result; |
| 13379 } | 13356 } |
| 13380 | 13357 |
| 13381 | 13358 |
| 13382 #define DECLARE_TAG(ignore1, name, ignore2) name, | 13359 #define DECLARE_TAG(ignore1, name, ignore2) name, |
| 13383 const char* const VisitorSynchronization::kTags[ | 13360 const char* const VisitorSynchronization::kTags[ |
| 13384 VisitorSynchronization::kNumberOfSyncTags] = { | 13361 VisitorSynchronization::kNumberOfSyncTags] = { |
| 13385 VISITOR_SYNCHRONIZATION_TAGS_LIST(DECLARE_TAG) | 13362 VISITOR_SYNCHRONIZATION_TAGS_LIST(DECLARE_TAG) |
| (...skipping 5573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18959 | 18936 |
| 18960 Object* data_obj = | 18937 Object* data_obj = |
| 18961 constructor->shared()->get_api_func_data()->access_check_info(); | 18938 constructor->shared()->get_api_func_data()->access_check_info(); |
| 18962 if (data_obj->IsUndefined(isolate)) return nullptr; | 18939 if (data_obj->IsUndefined(isolate)) return nullptr; |
| 18963 | 18940 |
| 18964 return AccessCheckInfo::cast(data_obj); | 18941 return AccessCheckInfo::cast(data_obj); |
| 18965 } | 18942 } |
| 18966 | 18943 |
| 18967 } // namespace internal | 18944 } // namespace internal |
| 18968 } // namespace v8 | 18945 } // namespace v8 |
| OLD | NEW |