| 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 9490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9501 } | 9501 } |
| 9502 | 9502 |
| 9503 | 9503 |
| 9504 void SharedFunctionInfo::AddToOptimizedCodeMap( | 9504 void SharedFunctionInfo::AddToOptimizedCodeMap( |
| 9505 Handle<SharedFunctionInfo> shared, | 9505 Handle<SharedFunctionInfo> shared, |
| 9506 Handle<Context> native_context, | 9506 Handle<Context> native_context, |
| 9507 Handle<Code> code, | 9507 Handle<Code> code, |
| 9508 Handle<FixedArray> literals, | 9508 Handle<FixedArray> literals, |
| 9509 BailoutId osr_ast_id) { | 9509 BailoutId osr_ast_id) { |
| 9510 Isolate* isolate = shared->GetIsolate(); | 9510 Isolate* isolate = shared->GetIsolate(); |
| 9511 DCHECK(!shared->SearchOptimizedCodeMap(*native_context, osr_ast_id).code); |
| 9511 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); | 9512 DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION); |
| 9512 DCHECK(native_context->IsNativeContext()); | 9513 DCHECK(native_context->IsNativeContext()); |
| 9513 STATIC_ASSERT(kEntryLength == 4); | 9514 STATIC_ASSERT(kEntryLength == 4); |
| 9514 Handle<FixedArray> new_code_map; | 9515 Handle<FixedArray> new_code_map; |
| 9515 Handle<Object> value(shared->optimized_code_map(), isolate); | 9516 Handle<Object> value(shared->optimized_code_map(), isolate); |
| 9516 int old_length; | 9517 int old_length; |
| 9517 if (value->IsSmi()) { | 9518 if (value->IsSmi()) { |
| 9518 // No optimized code map. | 9519 // No optimized code map. |
| 9519 DCHECK_EQ(0, Smi::cast(*value)->value()); | 9520 DCHECK_EQ(0, Smi::cast(*value)->value()); |
| 9520 new_code_map = isolate->factory()->NewFixedArray(kInitialLength); | 9521 new_code_map = isolate->factory()->NewFixedArray(kInitialLength, TENURED); |
| 9521 old_length = kEntriesStart; | 9522 old_length = kEntriesStart; |
| 9522 } else { | 9523 } else { |
| 9523 // Copy old map and append one new entry. | 9524 // Copy old optimized code map and append one new entry. |
| 9524 Handle<FixedArray> old_code_map = Handle<FixedArray>::cast(value); | 9525 Handle<FixedArray> old_code_map = Handle<FixedArray>::cast(value); |
| 9525 DCHECK(!shared->SearchOptimizedCodeMap(*native_context, osr_ast_id).code); | 9526 new_code_map = isolate->factory()->CopyFixedArrayAndGrow( |
| 9526 new_code_map = | 9527 old_code_map, kEntryLength, TENURED); |
| 9527 isolate->factory()->CopyFixedArrayAndGrow(old_code_map, kEntryLength); | |
| 9528 old_length = old_code_map->length(); | 9528 old_length = old_code_map->length(); |
| 9529 // Zap the old map for the sake of the heap verifier. | 9529 // Zap the old map to avoid any stale entries. Note that this is required |
| 9530 if (Heap::ShouldZapGarbage()) { | 9530 // for correctness because entries are being treated weakly by the GC. |
| 9531 Object** data = old_code_map->data_start(); | 9531 MemsetPointer(old_code_map->data_start(), isolate->heap()->the_hole_value(), |
| 9532 MemsetPointer(data, isolate->heap()->the_hole_value(), old_length); | 9532 old_length); |
| 9533 } | |
| 9534 } | 9533 } |
| 9535 new_code_map->set(old_length + kContextOffset, *native_context); | 9534 new_code_map->set(old_length + kContextOffset, *native_context); |
| 9536 new_code_map->set(old_length + kCachedCodeOffset, *code); | 9535 new_code_map->set(old_length + kCachedCodeOffset, *code); |
| 9537 new_code_map->set(old_length + kLiteralsOffset, *literals); | 9536 new_code_map->set(old_length + kLiteralsOffset, *literals); |
| 9538 new_code_map->set(old_length + kOsrAstIdOffset, | 9537 new_code_map->set(old_length + kOsrAstIdOffset, |
| 9539 Smi::FromInt(osr_ast_id.ToInt())); | 9538 Smi::FromInt(osr_ast_id.ToInt())); |
| 9540 | 9539 |
| 9541 #ifdef DEBUG | 9540 #ifdef DEBUG |
| 9542 for (int i = kEntriesStart; i < new_code_map->length(); i += kEntryLength) { | 9541 for (int i = kEntriesStart; i < new_code_map->length(); i += kEntryLength) { |
| 9543 DCHECK(new_code_map->get(i + kContextOffset)->IsNativeContext()); | 9542 DCHECK(new_code_map->get(i + kContextOffset)->IsNativeContext()); |
| (...skipping 6318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15862 if (cell->value() != *new_value) { | 15861 if (cell->value() != *new_value) { |
| 15863 cell->set_value(*new_value); | 15862 cell->set_value(*new_value); |
| 15864 Isolate* isolate = cell->GetIsolate(); | 15863 Isolate* isolate = cell->GetIsolate(); |
| 15865 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 15864 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 15866 isolate, DependentCode::kPropertyCellChangedGroup); | 15865 isolate, DependentCode::kPropertyCellChangedGroup); |
| 15867 } | 15866 } |
| 15868 } | 15867 } |
| 15869 | 15868 |
| 15870 } // namespace internal | 15869 } // namespace internal |
| 15871 } // namespace v8 | 15870 } // namespace v8 |
| OLD | NEW |