I like the heap pointer iterator! Looks good overall, small suggestions below.

https://codereview.chromium.org/304143002/diff/20001/src/factory.cc
File src/factory.cc (right):

https://codereview.chromium.org/304143002/diff/20001/src/factory.cc#newcode134
src/factory.cc:134: Handle<ConstantPoolArray>
Factory::NewExtendedConstantPoolArray(
Instead of passing this long list arguments around, what if we introduce
a class NumberOfEntries that stores "int number_of_entries[4]"?

The this function would look like:
NewExtendedConstantPoolArray(NumberOfEntries small, NumberOfEntries
extended);

Constant pool would have a method:
NumberOfEntries ConstantPoolArray::number_of_entries(Section section);

This would also simplify SizeFor* methods.

https://codereview.chromium.org/304143002/diff/20001/src/objects-inl.h
File src/objects-inl.h (right):

https://codereview.chromium.org/304143002/diff/20001/src/objects-inl.h#newcode2237
src/objects-inl.h:2237: int index = 0;
How about iterating over types and sections in this and other functions?

Something like this (modulo needs enum casts):

for (int s = 0; s <= section; ++s) {
  for (int t = 0; t < type; ++t) {
    index += number_of_entries(t, s);
  }
}

https://codereview.chromium.org/304143002/diff/20001/src/objects-inl.h#newcode2317
src/objects-inl.h:2317: if (index >= first_index(INT64, section) &&
int t = 0;

while (last_index(t, section) < index) ++t;

return t;

https://codereview.chromium.org/304143002/diff/20001/src/objects.cc
File src/objects.cc (right):

https://codereview.chromium.org/304143002/diff/20001/src/objects.cc#newcode9980
src/objects.cc:9980: if (number_of_entries(CODE_PTR, SMALL_SECTION) > 0)
{
Type type[] = {CODE_PTR, HEAP_PTR};
Address value[] = {<illegal builtin entry>, <undefined>};

for (int section = 0; section <= final_section(); ++section) {
  for (int i = 0; i < 2; ++i) {
    if (number_of_entries(type[i], section) > 0) {
      int offset = OffsetOfElementAt(first_index(type[i], section));
      MemsetPointer(
        HeapObject::RawField(this, offset),
        value[i],
        number_of_entries(type[i], section));
    }
  }
}

https://codereview.chromium.org/304143002/diff/20001/src/objects.h
File src/objects.h (right):

https://codereview.chromium.org/304143002/diff/20001/src/objects.h#newcode3265
src/objects.h:3265: offset += kInt64Size * Min(Max(0, index -
first_index(INT64, section)),
int t = 0;
while (last_index(t, section) < index) {
   offset += entry_size(t) * number_of_entries(t, section);
   ++t;
}
offset += entry_size(type) * (index - first_index(t, section));

https://codereview.chromium.org/304143002/

--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to