DCHECK_EQ(0, reservations_[NEW_SPACE].length());
STATIC_ASSERT(NEW_SPACE == 0);
int current_space = NEW_SPACE;
- for (const auto& r : res) {
+ for (int i = 0; i < res.length(); i++) {
+ SerializedData::Reservation r(0);
+ memcpy(&r, res.start() + i, sizeof(r));
reservations_[current_space].Add({r.chunk_size(), NULL, NULL});
if (r.is_last()) current_space++;
}
// Fix up strings from serialized user code.
if (deserializing_user_code()) obj = ProcessNewObjectFromSerializedCode(obj);
- *write_back = obj;
+ Object* write_back_obj = obj;
+ UnalignedCopy(write_back, &write_back_obj);
#ifdef DEBUG
if (obj->IsCode()) {
DCHECK(space_number == CODE_SPACE || space_number == LO_SPACE);
current = reinterpret_cast<Object**>(location_of_branch_data); \
current_was_incremented = true; \
} else { \
- *current = new_object; \
+ UnalignedCopy(current, &new_object); \
} \
} \
if (emit_write_barrier && write_barrier_needed) { \
int root_id = RootArrayConstantFromByteCode(data);
Object* object = isolate->heap()->roots_array_start()[root_id];
DCHECK(!isolate->heap()->InNewSpace(object));
- *current++ = object;
+ UnalignedCopy(current++, &object);
break;
}
reinterpret_cast<intptr_t>(current) + skip);
Object* object = isolate->heap()->roots_array_start()[root_id];
DCHECK(!isolate->heap()->InNewSpace(object));
- *current++ = object;
+ UnalignedCopy(current++, &object);
break;
}
int repeats = source_.GetInt();
Object* object = current[-1];
DCHECK(!isolate->heap()->InNewSpace(object));
- for (int i = 0; i < repeats; i++) current[i] = object;
- current += repeats;
+ for (int i = 0; i < repeats; i++) UnalignedCopy(current++, &object);
break;
}
case kFixedRepeat + 13:
case kFixedRepeat + 14: {
int repeats = RepeatsForCode(data);
- Object* object = current[-1];
+ Object* object;
+ UnalignedCopy(&object, current - 1);
DCHECK(!isolate->heap()->InNewSpace(object));
- for (int i = 0; i < repeats; i++) current[i] = object;
- current += repeats;
+ for (int i = 0; i < repeats; i++) UnalignedCopy(current++, &object);
break;
}
new NativesExternalStringResource(isolate->bootstrapper(),
source_vector.start(),
source_vector.length());
- *current++ = reinterpret_cast<Object*>(resource);
+ Object* resource_obj = reinterpret_cast<Object*>(resource);
+ UnalignedCopy(current++, &resource_obj);
break;
}
FOUR_CASES(kHotObject)
FOUR_CASES(kHotObject + 4) {
int index = data & kHotObjectIndexMask;
- *current = hot_objects_.Get(index);
- if (write_barrier_needed && isolate->heap()->InNewSpace(*current)) {
+ Object* hot_object = hot_objects_.Get(index);
+ UnalignedCopy(current, &hot_object);
+ if (write_barrier_needed && isolate->heap()->InNewSpace(hot_object)) {
Address current_address = reinterpret_cast<Address>(current);
isolate->heap()->RecordWrite(
current_object_address,
protected:
void SetHeaderValue(int offset, int value) {
- reinterpret_cast<int*>(data_)[offset] = value;
+ memcpy(reinterpret_cast<int*>(data_) + offset, &value, sizeof(value));
}
int GetHeaderValue(int offset) const {
- return reinterpret_cast<const int*>(data_)[offset];
+ int value;
+ memcpy(&value, reinterpret_cast<int*>(data_) + offset, sizeof(value));
+ return value;
}
void AllocateData(int size);
bool ReserveSpace();
+ void UnalignedCopy(Object** dest, Object** src) {
+ memcpy(dest, src, sizeof(*src));
+ }
+
// Allocation sites are present in the snapshot, and must be linked into
// a list at deserialization time.
void RelinkAllocationSite(AllocationSite* site);