Reviewers: Toon Verwaest,
Description:
Move FillWithHoles FixedArray and FixedDoubleArray functions to the given
classes.
BUG=
Please review this at https://codereview.chromium.org/216873004/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+24, -19 lines):
M src/builtins.cc
M src/objects.h
M src/objects-inl.h
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index
e460a8f39300beb9ef5963c3833f9ca27c6b5321..3d3913b457b4c68f59e6a1172f6a51ce27f44f86
100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -207,19 +207,6 @@ static void MoveDoubleElements(FixedDoubleArray* dst,
}
-static void FillWithHoles(Heap* heap, FixedArray* dst, int from, int to) {
- ASSERT(dst->map() != heap->fixed_cow_array_map());
- MemsetPointer(dst->data_start() + from, heap->the_hole_value(), to -
from);
-}
-
-
-static void FillWithHoles(FixedDoubleArray* dst, int from, int to) {
- for (int i = from; i < to; i++) {
- dst->set_the_hole(i);
- }
-}
-
-
static FixedArrayBase* LeftTrimFixedArray(Heap* heap,
FixedArrayBase* elms,
int to_trim) {
@@ -901,12 +888,12 @@ BUILTIN(ArraySplice) {
Handle<FixedDoubleArray> elms =
Handle<FixedDoubleArray>::cast(elms_obj);
MoveDoubleElements(*elms, 0, *elms, delta, len - delta);
- FillWithHoles(*elms, len - delta, len);
+ elms->FillWithHoles(len - delta, len);
} else {
Handle<FixedArray> elms = Handle<FixedArray>::cast(elms_obj);
DisallowHeapAllocation no_gc;
heap->MoveElements(*elms, 0, delta, len - delta);
- FillWithHoles(heap, *elms, len - delta, len);
+ elms->FillWithHoles(len - delta, len);
}
}
elms_changed = true;
@@ -917,14 +904,14 @@ BUILTIN(ArraySplice) {
MoveDoubleElements(*elms, actual_start + item_count,
*elms, actual_start + actual_delete_count,
(len - actual_delete_count - actual_start));
- FillWithHoles(*elms, new_length, len);
+ elms->FillWithHoles(new_length, len);
} else {
Handle<FixedArray> elms = Handle<FixedArray>::cast(elms_obj);
DisallowHeapAllocation no_gc;
heap->MoveElements(*elms, actual_start + item_count,
actual_start + actual_delete_count,
(len - actual_delete_count - actual_start));
- FillWithHoles(heap, *elms, new_length, len);
+ elms->FillWithHoles(new_length, len);
}
}
} else if (item_count > actual_delete_count) {
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index
c358ee6584525e4415aacce8615efd687acda79e..32feaa8feef9c86d1b0230841200fe237369da9e
100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -2208,6 +2208,18 @@ bool FixedDoubleArray::is_the_hole(int index) {
}
+double* FixedDoubleArray::data_start() {
+ return reinterpret_cast<double*>(FIELD_ADDR(this, kHeaderSize));
+}
+
+
+void FixedDoubleArray::FillWithHoles(int from, int to) {
+ for (int i = from; i < to; i++) {
+ set_the_hole(i);
+ }
+}
+
+
SMI_ACCESSORS(
ConstantPoolArray, first_code_ptr_index, kFirstCodePointerIndexOffset)
SMI_ACCESSORS(
@@ -2401,8 +2413,10 @@ void FixedArray::set_the_hole(int index) {
}
-double* FixedDoubleArray::data_start() {
- return reinterpret_cast<double*>(FIELD_ADDR(this, kHeaderSize));
+void FixedArray::FillWithHoles(int from, int to) {
+ for (int i = from; i < to; i++) {
+ set_the_hole(i);
+ }
}
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index
edb7903cc24582fe4b631bb530a6bdaf232376eb..2f8208b7c6532ebd6dffb787f8cb0a1d9abfaa21
100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -3033,6 +3033,8 @@ class FixedArray: public FixedArrayBase {
// Gives access to raw memory which stores the array's data.
inline Object** data_start();
+ inline void FillWithHoles(int from, int to);
+
// Shrink length and insert filler objects.
void Shrink(int length);
@@ -3141,6 +3143,8 @@ class FixedDoubleArray: public FixedArrayBase {
// Gives access to raw memory which stores the array's data.
inline double* data_start();
+ inline void FillWithHoles(int from, int to);
+
// Code Generation support.
static int OffsetOfElementAt(int index) { return SizeFor(index); }
--
--
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.