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

Unified Diff: src/heap.cc

Issue 760002: Minor refactorings to use some recently added methods. (Closed)
Patch Set: Created 10 years, 9 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/compilation-cache.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index fbe04640db0e7eed77b09d347469d14bdb3a4125..505429a466e0b19e708650c591d31dc050822d2b 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -2571,11 +2571,9 @@ Object* Heap::CopyJSObject(JSObject* source) {
reinterpret_cast<Object**>(source->address()),
object_size);
// Update write barrier for all fields that lie beyond the header.
- for (int offset = JSObject::kHeaderSize;
- offset < object_size;
- offset += kPointerSize) {
- RecordWrite(clone_address, offset);
- }
+ RecordWrites(clone_address,
+ JSObject::kHeaderSize,
+ object_size - JSObject::kHeaderSize);
} else {
clone = new_space_.AllocateRaw(object_size);
if (clone->IsFailure()) return clone;
@@ -2906,12 +2904,9 @@ Object* Heap::AllocateFixedArray(int length) {
reinterpret_cast<Array*>(result)->set_map(fixed_array_map());
FixedArray* array = FixedArray::cast(result);
array->set_length(length);
- Object* value = undefined_value();
// Initialize body.
- for (int index = 0; index < length; index++) {
- ASSERT(!Heap::InNewSpace(value)); // value = undefined
- array->set(index, value, SKIP_WRITE_BARRIER);
- }
+ ASSERT(!Heap::InNewSpace(undefined_value()));
+ MemsetPointer(array->data_start(), undefined_value(), length);
}
return result;
}
@@ -2963,11 +2958,8 @@ Object* Heap::AllocateFixedArray(int length, PretenureFlag pretenure) {
reinterpret_cast<Array*>(result)->set_map(fixed_array_map());
FixedArray* array = FixedArray::cast(result);
array->set_length(length);
- Object* value = undefined_value();
- for (int index = 0; index < length; index++) {
- ASSERT(!Heap::InNewSpace(value)); // value = undefined
- array->set(index, value, SKIP_WRITE_BARRIER);
- }
+ ASSERT(!Heap::InNewSpace(undefined_value()));
+ MemsetPointer(array->data_start(), undefined_value(), length);
return array;
}
@@ -2994,9 +2986,7 @@ Object* Heap::AllocateFixedArrayWithHoles(int length) {
array->set_length(length);
// Initialize body.
ASSERT(!Heap::InNewSpace(the_hole_value()));
- MemsetPointer(HeapObject::RawField(array, FixedArray::kHeaderSize),
- the_hole_value(),
- length);
+ MemsetPointer(array->data_start(), the_hole_value(), length);
}
return result;
}
« no previous file with comments | « src/compilation-cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698