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 <iomanip> | 5 #include <iomanip> |
| 6 #include <sstream> | 6 #include <sstream> |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
| (...skipping 9572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9583 int old_length; | 9583 int old_length; |
| 9584 if (value->IsSmi()) { | 9584 if (value->IsSmi()) { |
| 9585 // No optimized code map. | 9585 // No optimized code map. |
| 9586 DCHECK_EQ(0, Smi::cast(*value)->value()); | 9586 DCHECK_EQ(0, Smi::cast(*value)->value()); |
| 9587 // Create 3 entries per context {context, code, literals}. | 9587 // Create 3 entries per context {context, code, literals}. |
| 9588 new_code_map = isolate->factory()->NewFixedArray(kInitialLength); | 9588 new_code_map = isolate->factory()->NewFixedArray(kInitialLength); |
| 9589 old_length = kEntriesStart; | 9589 old_length = kEntriesStart; |
| 9590 } else { | 9590 } else { |
| 9591 // Copy old map and append one new entry. | 9591 // Copy old map and append one new entry. |
| 9592 Handle<FixedArray> old_code_map = Handle<FixedArray>::cast(value); | 9592 Handle<FixedArray> old_code_map = Handle<FixedArray>::cast(value); |
| 9593 DCHECK_EQ(-1, shared->SearchOptimizedCodeMap(*native_context, osr_ast_id)); | 9593 DCHECK(!shared->SearchOptimizedCodeMap(*native_context, osr_ast_id).code); |
| 9594 old_length = old_code_map->length(); | 9594 old_length = old_code_map->length(); |
| 9595 new_code_map = FixedArray::CopySize( | 9595 new_code_map = FixedArray::CopySize( |
| 9596 old_code_map, old_length + kEntryLength); | 9596 old_code_map, old_length + kEntryLength); |
| 9597 // Zap the old map for the sake of the heap verifier. | 9597 // Zap the old map for the sake of the heap verifier. |
| 9598 if (Heap::ShouldZapGarbage()) { | 9598 if (Heap::ShouldZapGarbage()) { |
| 9599 Object** data = old_code_map->data_start(); | 9599 Object** data = old_code_map->data_start(); |
| 9600 MemsetPointer(data, isolate->heap()->the_hole_value(), old_length); | 9600 MemsetPointer(data, isolate->heap()->the_hole_value(), old_length); |
| 9601 } | 9601 } |
| 9602 } | 9602 } |
| 9603 new_code_map->set(old_length + kContextOffset, *native_context); | 9603 new_code_map->set(old_length + kContextOffset, *native_context); |
| 9604 new_code_map->set(old_length + kCachedCodeOffset, *code); | 9604 new_code_map->set(old_length + kCachedCodeOffset, *code); |
| 9605 new_code_map->set(old_length + kLiteralsOffset, *literals); | 9605 new_code_map->set(old_length + kLiteralsOffset, *literals); |
| 9606 new_code_map->set(old_length + kOsrAstIdOffset, | 9606 new_code_map->set(old_length + kOsrAstIdOffset, |
| 9607 Smi::FromInt(osr_ast_id.ToInt())); | 9607 Smi::FromInt(osr_ast_id.ToInt())); |
| 9608 | 9608 |
| 9609 #ifdef DEBUG | 9609 #ifdef DEBUG |
| 9610 for (int i = kEntriesStart; i < new_code_map->length(); i += kEntryLength) { | 9610 for (int i = kEntriesStart; i < new_code_map->length(); i += kEntryLength) { |
| 9611 DCHECK(new_code_map->get(i + kContextOffset)->IsNativeContext()); | 9611 DCHECK(new_code_map->get(i + kContextOffset)->IsNativeContext()); |
| 9612 DCHECK(new_code_map->get(i + kCachedCodeOffset)->IsCode()); | 9612 DCHECK(new_code_map->get(i + kCachedCodeOffset)->IsCode()); |
| 9613 DCHECK(Code::cast(new_code_map->get(i + kCachedCodeOffset))->kind() == | 9613 DCHECK(Code::cast(new_code_map->get(i + kCachedCodeOffset))->kind() == |
| 9614 Code::OPTIMIZED_FUNCTION); | 9614 Code::OPTIMIZED_FUNCTION); |
| 9615 DCHECK(new_code_map->get(i + kLiteralsOffset)->IsFixedArray()); | 9615 DCHECK(new_code_map->get(i + kLiteralsOffset)->IsFixedArray()); |
| 9616 DCHECK(new_code_map->get(i + kOsrAstIdOffset)->IsSmi()); | 9616 DCHECK(new_code_map->get(i + kOsrAstIdOffset)->IsSmi()); |
| 9617 } | 9617 } |
| 9618 #endif | 9618 #endif |
| 9619 shared->set_optimized_code_map(*new_code_map); | 9619 shared->set_optimized_code_map(*new_code_map); |
| 9620 } | 9620 } |
| 9621 | 9621 |
| 9622 | 9622 |
| 9623 FixedArray* SharedFunctionInfo::GetLiteralsFromOptimizedCodeMap(int index) { | |
| 9624 DCHECK(index > kEntriesStart); | |
| 9625 FixedArray* code_map = FixedArray::cast(optimized_code_map()); | |
| 9626 FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1)); | |
| 9627 DCHECK_NOT_NULL(cached_literals); | |
| 9628 return cached_literals; | |
| 9629 } | |
| 9630 | |
| 9631 | |
| 9632 Code* SharedFunctionInfo::GetCodeFromOptimizedCodeMap(int index) { | |
| 9633 DCHECK(index > kEntriesStart); | |
| 9634 FixedArray* code_map = FixedArray::cast(optimized_code_map()); | |
| 9635 Code* code = Code::cast(code_map->get(index)); | |
| 9636 DCHECK_NOT_NULL(code); | |
| 9637 return code; | |
| 9638 } | |
| 9639 | |
| 9640 | |
| 9641 void SharedFunctionInfo::ClearOptimizedCodeMap() { | 9623 void SharedFunctionInfo::ClearOptimizedCodeMap() { |
| 9642 FixedArray* code_map = FixedArray::cast(optimized_code_map()); | 9624 FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
| 9643 | 9625 |
| 9644 // If the next map link slot is already used then the function was | 9626 // If the next map link slot is already used then the function was |
| 9645 // enqueued with code flushing and we remove it now. | 9627 // enqueued with code flushing and we remove it now. |
| 9646 if (!code_map->get(kNextMapIndex)->IsUndefined()) { | 9628 if (!code_map->get(kNextMapIndex)->IsUndefined()) { |
| 9647 CodeFlusher* flusher = GetHeap()->mark_compact_collector()->code_flusher(); | 9629 CodeFlusher* flusher = GetHeap()->mark_compact_collector()->code_flusher(); |
| 9648 flusher->EvictOptimizedCodeMap(this); | 9630 flusher->EvictOptimizedCodeMap(this); |
| 9649 } | 9631 } |
| 9650 | 9632 |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10605 opt_count() >= FLAG_max_opt_count) { | 10587 opt_count() >= FLAG_max_opt_count) { |
| 10606 // Re-enable optimizations if they were disabled due to opt_count limit. | 10588 // Re-enable optimizations if they were disabled due to opt_count limit. |
| 10607 set_optimization_disabled(false); | 10589 set_optimization_disabled(false); |
| 10608 } | 10590 } |
| 10609 set_opt_count(0); | 10591 set_opt_count(0); |
| 10610 set_deopt_count(0); | 10592 set_deopt_count(0); |
| 10611 } | 10593 } |
| 10612 } | 10594 } |
| 10613 | 10595 |
| 10614 | 10596 |
| 10615 int SharedFunctionInfo::SearchOptimizedCodeMap(Context* native_context, | 10597 CodeAndLiterals SharedFunctionInfo::SearchOptimizedCodeMap( |
| 10616 BailoutId osr_ast_id) { | 10598 Context* native_context, BailoutId osr_ast_id) { |
| 10617 DisallowHeapAllocation no_gc; | 10599 DisallowHeapAllocation no_gc; |
| 10618 DCHECK(native_context->IsNativeContext()); | 10600 DCHECK(native_context->IsNativeContext()); |
| 10619 if (!FLAG_cache_optimized_code) return -1; | 10601 if (!FLAG_cache_optimized_code) return {nullptr, nullptr}; |
| 10620 Object* value = optimized_code_map(); | 10602 Object* value = optimized_code_map(); |
| 10621 if (!value->IsSmi()) { | 10603 if (!value->IsSmi()) { |
| 10622 FixedArray* optimized_code_map = FixedArray::cast(value); | 10604 FixedArray* optimized_code_map = FixedArray::cast(value); |
| 10623 int length = optimized_code_map->length(); | 10605 int length = optimized_code_map->length(); |
| 10624 Smi* osr_ast_id_smi = Smi::FromInt(osr_ast_id.ToInt()); | 10606 Smi* osr_ast_id_smi = Smi::FromInt(osr_ast_id.ToInt()); |
| 10625 for (int i = kEntriesStart; i < length; i += kEntryLength) { | 10607 for (int i = kEntriesStart; i < length; i += kEntryLength) { |
| 10626 if (optimized_code_map->get(i + kContextOffset) == native_context && | 10608 if (optimized_code_map->get(i + kContextOffset) == native_context && |
| 10627 optimized_code_map->get(i + kOsrAstIdOffset) == osr_ast_id_smi) { | 10609 optimized_code_map->get(i + kOsrAstIdOffset) == osr_ast_id_smi) { |
| 10628 return i + kCachedCodeOffset; | 10610 return {Code::cast(optimized_code_map->get(i + kCachedCodeOffset)), |
|
jochen (gone - plz use gerrit)
2015/07/13 07:11:50
fyi, this syntax is forbidden by chromium's C++ st
Michael Starzinger
2015/07/13 07:43:31
Can we haz presubmit check then?
| |
| 10611 FixedArray::cast(optimized_code_map->get(i + kLiteralsOffset))}; | |
| 10629 } | 10612 } |
| 10630 } | 10613 } |
| 10631 if (FLAG_trace_opt) { | 10614 if (FLAG_trace_opt) { |
| 10632 PrintF("[didn't find optimized code in optimized code map for "); | 10615 PrintF("[didn't find optimized code in optimized code map for "); |
| 10633 ShortPrint(); | 10616 ShortPrint(); |
| 10634 PrintF("]\n"); | 10617 PrintF("]\n"); |
| 10635 } | 10618 } |
| 10636 } | 10619 } |
| 10637 return -1; | 10620 return {nullptr, nullptr}; |
| 10638 } | 10621 } |
| 10639 | 10622 |
| 10640 | 10623 |
| 10641 #define DECLARE_TAG(ignore1, name, ignore2) name, | 10624 #define DECLARE_TAG(ignore1, name, ignore2) name, |
| 10642 const char* const VisitorSynchronization::kTags[ | 10625 const char* const VisitorSynchronization::kTags[ |
| 10643 VisitorSynchronization::kNumberOfSyncTags] = { | 10626 VisitorSynchronization::kNumberOfSyncTags] = { |
| 10644 VISITOR_SYNCHRONIZATION_TAGS_LIST(DECLARE_TAG) | 10627 VISITOR_SYNCHRONIZATION_TAGS_LIST(DECLARE_TAG) |
| 10645 }; | 10628 }; |
| 10646 #undef DECLARE_TAG | 10629 #undef DECLARE_TAG |
| 10647 | 10630 |
| (...skipping 5587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 16235 Handle<Object> new_value) { | 16218 Handle<Object> new_value) { |
| 16236 if (cell->value() != *new_value) { | 16219 if (cell->value() != *new_value) { |
| 16237 cell->set_value(*new_value); | 16220 cell->set_value(*new_value); |
| 16238 Isolate* isolate = cell->GetIsolate(); | 16221 Isolate* isolate = cell->GetIsolate(); |
| 16239 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16222 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 16240 isolate, DependentCode::kPropertyCellChangedGroup); | 16223 isolate, DependentCode::kPropertyCellChangedGroup); |
| 16241 } | 16224 } |
| 16242 } | 16225 } |
| 16243 } // namespace internal | 16226 } // namespace internal |
| 16244 } // namespace v8 | 16227 } // namespace v8 |
| OLD | NEW |