Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Unified Diff: src/serialize.h

Issue 674883002: Tweaks to the code serializer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix large object back references Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/serialize.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/serialize.h
diff --git a/src/serialize.h b/src/serialize.h
index 3766801f0bb53676dd30bee135b79be99c50cae2..ae6446270b0870aeb3ce062fb8db9bb354f07dbc 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -189,16 +189,26 @@ class BackReference {
public:
explicit BackReference(uint32_t bitfield) : bitfield_(bitfield) {}
- BackReference(AllocationSpace space, uint32_t chunk_index,
- uint32_t chunk_offset) {
- DCHECK(IsAligned(chunk_offset, kObjectAlignment));
- bitfield_ = SpaceBits::encode(space) | ChunkIndexBits::encode(chunk_index) |
- ChunkOffsetBits::encode(chunk_offset >> kObjectAlignmentBits);
+ BackReference() : bitfield_(kInvalidValue) {}
+
+ static BackReference SourceReference() { return BackReference(kSourceValue); }
+
+ static BackReference LargeObjectReference(uint32_t index) {
+ return BackReference(SpaceBits::encode(LO_SPACE) |
+ ChunkOffsetBits::encode(index));
}
- BackReference() : bitfield_(kInvalidValue) {}
+ static BackReference Reference(AllocationSpace space, uint32_t chunk_index,
+ uint32_t chunk_offset) {
+ DCHECK(IsAligned(chunk_offset, kObjectAlignment));
+ DCHECK_NE(LO_SPACE, space);
+ return BackReference(
+ SpaceBits::encode(space) | ChunkIndexBits::encode(chunk_index) |
+ ChunkOffsetBits::encode(chunk_offset >> kObjectAlignmentBits));
+ }
bool is_valid() const { return bitfield_ != kInvalidValue; }
+ bool is_source() const { return bitfield_ == kSourceValue; }
AllocationSpace space() const {
DCHECK(is_valid());
@@ -224,6 +234,7 @@ class BackReference {
private:
static const uint32_t kInvalidValue = 0xFFFFFFFF;
+ static const uint32_t kSourceValue = 0xFFFFFFFE;
static const int kChunkOffsetSize = kPageSizeBits - kObjectAlignmentBits;
static const int kChunkIndexSize = 32 - kChunkOffsetSize - kSpaceTagSize;
@@ -263,6 +274,10 @@ class BackReferenceMap : public AddressMapBase {
SetValue(entry, b.bitfield());
}
+ void AddSourceString(String* string) {
+ Add(string, BackReference::SourceReference());
+ }
+
private:
DisallowHeapAllocation no_allocation_;
HashMap* map_;
@@ -700,7 +715,9 @@ class CodeSerializer : public Serializer {
: Serializer(isolate, sink),
source_(source),
main_code_(main_code),
- num_internalized_strings_(0) {}
+ num_internalized_strings_(0) {
+ back_reference_map_.AddSourceString(source);
+ }
virtual void SerializeObject(HeapObject* o, HowToCode how_to_code,
WhereToPoint where_to_point, int skip);
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698