Chromium Code Reviews| Index: src/snapshot/serializer.cc |
| diff --git a/src/snapshot/serializer.cc b/src/snapshot/serializer.cc |
| index 025283b7b33ee0a20bf1b9800d31d2804ac86db4..3154fbc125962fdaeacef3db529239ccbacf63b8 100644 |
| --- a/src/snapshot/serializer.cc |
| +++ b/src/snapshot/serializer.cc |
| @@ -5,6 +5,7 @@ |
| #include "src/snapshot/serializer.h" |
| #include "src/assembler-inl.h" |
| +#include "src/deoptimizer.h" |
| #include "src/heap/heap-inl.h" |
| #include "src/macro-assembler.h" |
| #include "src/snapshot/natives.h" |
| @@ -334,6 +335,26 @@ bool Serializer::HasNotExceededFirstPageOfEachSpace() { |
| return true; |
| } |
| +bool Serializer::ObjectSerializer::TryEncodeDeoptimizationEntry( |
| + HowToCode how_to_code, Address target, int skip) { |
| + for (int bailout_type = 0; bailout_type <= Deoptimizer::kLastBailoutType; |
| + ++bailout_type) { |
| + int id = Deoptimizer::GetDeoptimizationId( |
| + serializer_->isolate(), target, |
| + static_cast<Deoptimizer::BailoutType>(bailout_type)); |
| + if (id == Deoptimizer::kNotDeoptimizationEntry) continue; |
| + if (how_to_code == kPlain) |
| + sink_->Put(kDeoptimizerEntryPlain, "DeoptimizationEntry"); |
|
Yang
2017/04/04 07:59:21
please use brackets with if-else. You could also u
Slava Chigrin
2017/04/04 10:12:24
Done.
|
| + else |
| + sink_->Put(kDeoptimizerEntryFromCode, "DeoptimizationEntry"); |
| + sink_->PutInt(skip, "SkipB4DeoptimizationEntry"); |
| + sink_->Put(bailout_type, "BailoutType"); |
| + sink_->PutInt(id, "EntryId"); |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| void Serializer::ObjectSerializer::SerializePrologue(AllocationSpace space, |
| int size, Map* map) { |
| if (serializer_->code_address_map_) { |
| @@ -611,9 +632,13 @@ void Serializer::ObjectSerializer::VisitEmbeddedPointer(RelocInfo* rinfo) { |
| void Serializer::ObjectSerializer::VisitExternalReference(Address* p) { |
| int skip = OutputRawData(reinterpret_cast<Address>(p), |
| kCanReturnSkipInsteadOfSkipping); |
| + Address target = *p; |
| + if (TryEncodeDeoptimizationEntry(kPlain, target, skip)) { |
|
Yang
2017/04/04 07:59:21
I'd prefer something like
if (!TryEncode...) {
..
Slava Chigrin
2017/04/04 10:12:24
Done.
|
| + bytes_processed_so_far_ += kPointerSize; |
| + return; |
| + } |
| sink_->Put(kExternalReference + kPlain + kStartOfObject, "ExternalRef"); |
| sink_->PutInt(skip, "SkipB4ExternalRef"); |
| - Address target = *p; |
| sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id"); |
| bytes_processed_so_far_ += kPointerSize; |
| } |
| @@ -622,9 +647,13 @@ void Serializer::ObjectSerializer::VisitExternalReference(RelocInfo* rinfo) { |
| int skip = OutputRawData(rinfo->target_address_address(), |
| kCanReturnSkipInsteadOfSkipping); |
| HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; |
| + Address target = rinfo->target_external_reference(); |
| + if (TryEncodeDeoptimizationEntry(how_to_code, target, skip)) { |
| + bytes_processed_so_far_ += rinfo->target_address_size(); |
|
Yang
2017/04/04 07:59:21
same here
Slava Chigrin
2017/04/04 10:12:24
Done.
|
| + return; |
| + } |
| sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef"); |
| sink_->PutInt(skip, "SkipB4ExternalRef"); |
| - Address target = rinfo->target_external_reference(); |
| DCHECK_NOT_NULL(target); // Code does not reference null. |
| sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id"); |
| bytes_processed_so_far_ += rinfo->target_address_size(); |
| @@ -658,9 +687,13 @@ void Serializer::ObjectSerializer::VisitRuntimeEntry(RelocInfo* rinfo) { |
| int skip = OutputRawData(rinfo->target_address_address(), |
| kCanReturnSkipInsteadOfSkipping); |
| HowToCode how_to_code = rinfo->IsCodedSpecially() ? kFromCode : kPlain; |
| + Address target = rinfo->target_address(); |
| + if (TryEncodeDeoptimizationEntry(how_to_code, target, skip)) { |
| + bytes_processed_so_far_ += rinfo->target_address_size(); |
|
Yang
2017/04/04 07:59:21
same here.
Slava Chigrin
2017/04/04 10:12:24
Done.
|
| + return; |
| + } |
| sink_->Put(kExternalReference + how_to_code + kStartOfObject, "ExternalRef"); |
| sink_->PutInt(skip, "SkipB4ExternalRef"); |
| - Address target = rinfo->target_address(); |
| sink_->PutInt(serializer_->EncodeExternalReference(target), "reference id"); |
| bytes_processed_so_far_ += rinfo->target_address_size(); |
| } |