Reviewers: mvstanton,
Description:
Use back reference map to find references to global proxy.
[email protected]
Please review this at https://codereview.chromium.org/825933004/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+20, -14 lines):
M src/serialize.h
M src/serialize.cc
Index: src/serialize.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index
8d6d5508252450a24ef5810b414fa59f5c66fc84..1f85ae5b37f7c62a8911b817ac04737441e7f7d7
100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -1405,7 +1405,7 @@ void PartialSerializer::Serialize(Object** o) {
if ((*o)->IsContext()) {
Context* context = Context::cast(*o);
global_object_ = context->global_object();
- global_proxy_ = context->global_proxy();
+ back_reference_map()->AddGlobalProxy(context->global_proxy());
}
VisitPointer(o);
SerializeOutdatedContextsAsFixedArray();
@@ -1562,8 +1562,14 @@ bool Serializer::SerializeKnownObject(HeapObject*
obj, HowToCode how_to_code,
FlushSkip(skip);
if (FLAG_trace_serializer) PrintF(" Encoding source object\n");
DCHECK(how_to_code == kPlain && where_to_point == kStartOfObject);
- sink_->Put(kAttachedReference + how_to_code +
where_to_point, "Source");
- sink_->PutInt(kSourceObjectReference, "kSourceObjectIndex");
+ sink_->Put(kAttachedReference + kPlain + kStartOfObject, "Source");
+ sink_->PutInt(kSourceObjectReference, "kSourceObjectReference");
+ } else if (back_reference.is_global_proxy()) {
+ FlushSkip(skip);
+ if (FLAG_trace_serializer) PrintF(" Encoding global proxy\n");
+ DCHECK(how_to_code == kPlain && where_to_point == kStartOfObject);
+ sink_->Put(kAttachedReference + kPlain + kStartOfObject, "Global
Proxy");
+ sink_->PutInt(kGlobalProxyReference, "kGlobalProxyReference");
} else {
if (FLAG_trace_serializer) {
PrintF(" Encoding back reference to: ");
@@ -1696,14 +1702,6 @@ void PartialSerializer::SerializeObject(HeapObject*
obj, HowToCode how_to_code,
FlushSkip(skip);
- if (obj == global_proxy_) {
- FlushSkip(skip);
- DCHECK(how_to_code == kPlain && where_to_point == kStartOfObject);
- sink_->Put(kAttachedReference + how_to_code +
where_to_point, "Reference");
- sink_->PutInt(kGlobalProxyReference, "kGlobalProxyReferenceIndex");
- return;
- }
-
// Object has not yet been serialized. Serialize it here.
ObjectSerializer serializer(this, obj, sink_, how_to_code,
where_to_point);
serializer.Serialize();
Index: src/serialize.h
diff --git a/src/serialize.h b/src/serialize.h
index
53dc6eb87376707b9240d71a846d05f2b8aac93e..cc267aa5fa21ea9fa1cf9a54a3b2aea586ffac49
100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -193,6 +193,10 @@ class BackReference {
static BackReference SourceReference() { return
BackReference(kSourceValue); }
+ static BackReference GlobalProxyReference() {
+ return BackReference(kGlobalProxyValue);
+ }
+
static BackReference LargeObjectReference(uint32_t index) {
return BackReference(SpaceBits::encode(LO_SPACE) |
ChunkOffsetBits::encode(index));
@@ -209,6 +213,7 @@ class BackReference {
bool is_valid() const { return bitfield_ != kInvalidValue; }
bool is_source() const { return bitfield_ == kSourceValue; }
+ bool is_global_proxy() const { return bitfield_ == kGlobalProxyValue; }
AllocationSpace space() const {
DCHECK(is_valid());
@@ -235,6 +240,7 @@ class BackReference {
private:
static const uint32_t kInvalidValue = 0xFFFFFFFF;
static const uint32_t kSourceValue = 0xFFFFFFFE;
+ static const uint32_t kGlobalProxyValue = 0xFFFFFFFD;
static const int kChunkOffsetSize = kPageSizeBits - kObjectAlignmentBits;
static const int kChunkIndexSize = 32 - kChunkOffsetSize - kSpaceTagSize;
@@ -278,6 +284,10 @@ class BackReferenceMap : public AddressMapBase {
Add(string, BackReference::SourceReference());
}
+ void AddGlobalProxy(HeapObject* global_proxy) {
+ Add(global_proxy, BackReference::GlobalProxyReference());
+ }
+
private:
DisallowHeapAllocation no_allocation_;
HashMap* map_;
@@ -751,8 +761,7 @@ class PartialSerializer : public Serializer {
: Serializer(isolate, sink),
startup_serializer_(startup_snapshot_serializer),
outdated_contexts_(0),
- global_object_(NULL),
- global_proxy_(NULL) {
+ global_object_(NULL) {
InitializeCodeAddressMap();
}
@@ -781,7 +790,6 @@ class PartialSerializer : public Serializer {
Serializer* startup_serializer_;
List<BackReference> outdated_contexts_;
Object* global_object_;
- Object* global_proxy_;
DISALLOW_COPY_AND_ASSIGN(PartialSerializer);
};
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.