| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/snapshot/deserializer.h" | 5 #include "src/snapshot/deserializer.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/assembler-inl.h" | 8 #include "src/assembler-inl.h" |
| 9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
| 10 #include "src/external-reference-table.h" | 10 #include "src/external-reference-table.h" |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 UnalignedCopy(write_back, &write_back_obj); | 455 UnalignedCopy(write_back, &write_back_obj); |
| 456 #ifdef DEBUG | 456 #ifdef DEBUG |
| 457 if (obj->IsCode()) { | 457 if (obj->IsCode()) { |
| 458 DCHECK(space_number == CODE_SPACE || space_number == LO_SPACE); | 458 DCHECK(space_number == CODE_SPACE || space_number == LO_SPACE); |
| 459 } else { | 459 } else { |
| 460 DCHECK(space_number != CODE_SPACE); | 460 DCHECK(space_number != CODE_SPACE); |
| 461 } | 461 } |
| 462 #endif // DEBUG | 462 #endif // DEBUG |
| 463 } | 463 } |
| 464 | 464 |
| 465 Address Deserializer::DecodeExternalReference(uint32_t reference_id) { |
| 466 if (!(reference_id & ExternalReferenceTable::kSpecialIdMask)) |
| 467 return external_reference_table_->address(reference_id); |
| 468 const uint32_t special_flags = |
| 469 reference_id & ExternalReferenceTable::kSpecialIdMask; |
| 470 Deoptimizer::BailoutType deopt_type; |
| 471 switch (special_flags) { |
| 472 case ExternalReferenceTable::kEagerDeoptFlag: |
| 473 deopt_type = Deoptimizer::EAGER; |
| 474 break; |
| 475 case ExternalReferenceTable::kLazyDeoptFlag: |
| 476 deopt_type = Deoptimizer::LAZY; |
| 477 break; |
| 478 case ExternalReferenceTable::kSoftDeoptFlag: |
| 479 deopt_type = Deoptimizer::SOFT; |
| 480 break; |
| 481 default: |
| 482 CHECK(false); |
| 483 return nullptr; |
| 484 } |
| 485 int entry_id = reference_id & ~ExternalReferenceTable::kSpecialIdMask; |
| 486 max_deopt_entry_ids_[deopt_type] = |
| 487 std::max(max_deopt_entry_ids_[deopt_type], entry_id); |
| 488 return Deoptimizer::GetDeoptimizationEntry( |
| 489 isolate_, entry_id, deopt_type, Deoptimizer::CALCULATE_ENTRY_ADDRESS); |
| 490 } |
| 465 // We know the space requirements before deserialization and can | 491 // We know the space requirements before deserialization and can |
| 466 // pre-allocate that reserved space. During deserialization, all we need | 492 // pre-allocate that reserved space. During deserialization, all we need |
| 467 // to do is to bump up the pointer for each space in the reserved | 493 // to do is to bump up the pointer for each space in the reserved |
| 468 // space. This is also used for fixing back references. | 494 // space. This is also used for fixing back references. |
| 469 // We may have to split up the pre-allocation into several chunks | 495 // We may have to split up the pre-allocation into several chunks |
| 470 // because it would not fit onto a single page. We do not have to keep | 496 // because it would not fit onto a single page. We do not have to keep |
| 471 // track of when to move to the next chunk. An opcode will signal this. | 497 // track of when to move to the next chunk. An opcode will signal this. |
| 472 // Since multiple large objects cannot be folded into one large object | 498 // Since multiple large objects cannot be folded into one large object |
| 473 // space allocation, we have to do an actual allocation when deserializing | 499 // space allocation, we have to do an actual allocation when deserializing |
| 474 // each large object. Instead of tracking offset for back references, we | 500 // each large object. Instead of tracking offset for back references, we |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 hot_objects_.Add(HeapObject::cast(new_object)); \ | 587 hot_objects_.Add(HeapObject::cast(new_object)); \ |
| 562 } else if (where == kPartialSnapshotCache) { \ | 588 } else if (where == kPartialSnapshotCache) { \ |
| 563 int cache_index = source_.GetInt(); \ | 589 int cache_index = source_.GetInt(); \ |
| 564 new_object = isolate->partial_snapshot_cache()->at(cache_index); \ | 590 new_object = isolate->partial_snapshot_cache()->at(cache_index); \ |
| 565 emit_write_barrier = isolate->heap()->InNewSpace(new_object); \ | 591 emit_write_barrier = isolate->heap()->InNewSpace(new_object); \ |
| 566 } else if (where == kExternalReference) { \ | 592 } else if (where == kExternalReference) { \ |
| 567 int skip = source_.GetInt(); \ | 593 int skip = source_.GetInt(); \ |
| 568 current = reinterpret_cast<Object**>( \ | 594 current = reinterpret_cast<Object**>( \ |
| 569 reinterpret_cast<Address>(current) + skip); \ | 595 reinterpret_cast<Address>(current) + skip); \ |
| 570 uint32_t reference_id = static_cast<uint32_t>(source_.GetInt()); \ | 596 uint32_t reference_id = static_cast<uint32_t>(source_.GetInt()); \ |
| 571 Address address = external_reference_table_->address(reference_id); \ | 597 Address address = DecodeExternalReference(reference_id); \ |
| 572 new_object = reinterpret_cast<Object*>(address); \ | 598 new_object = reinterpret_cast<Object*>(address); \ |
| 573 } else if (where == kAttachedReference) { \ | 599 } else if (where == kAttachedReference) { \ |
| 574 int index = source_.GetInt(); \ | 600 int index = source_.GetInt(); \ |
| 575 new_object = *attached_objects_[index]; \ | 601 new_object = *attached_objects_[index]; \ |
| 576 emit_write_barrier = isolate->heap()->InNewSpace(new_object); \ | 602 emit_write_barrier = isolate->heap()->InNewSpace(new_object); \ |
| 577 } else { \ | 603 } else { \ |
| 578 DCHECK(where == kBuiltin); \ | 604 DCHECK(where == kBuiltin); \ |
| 579 DCHECK(deserializing_user_code()); \ | 605 DCHECK(deserializing_user_code()); \ |
| 580 int builtin_id = source_.GetInt(); \ | 606 int builtin_id = source_.GetInt(); \ |
| 581 DCHECK_LE(0, builtin_id); \ | 607 DCHECK_LE(0, builtin_id); \ |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 | 916 |
| 891 default: | 917 default: |
| 892 CHECK(false); | 918 CHECK(false); |
| 893 } | 919 } |
| 894 } | 920 } |
| 895 CHECK_EQ(limit, current); | 921 CHECK_EQ(limit, current); |
| 896 return true; | 922 return true; |
| 897 } | 923 } |
| 898 } // namespace internal | 924 } // namespace internal |
| 899 } // namespace v8 | 925 } // namespace v8 |
| OLD | NEW |