| Index: src/objects.cc
|
| ===================================================================
|
| --- src/objects.cc (revision 1168)
|
| +++ src/objects.cc (working copy)
|
| @@ -587,7 +587,7 @@
|
| }
|
|
|
|
|
| -Object* String::Flatten(StringShape shape) {
|
| +Object* String::TryFlatten(StringShape shape) {
|
| #ifdef DEBUG
|
| // Do not attempt to flatten in debug mode when allocation is not
|
| // allowed. This is to avoid an assertion failure when allocating.
|
| @@ -604,11 +604,11 @@
|
| // SlicedStrings.
|
| String* buf = ss->buffer();
|
| ASSERT(!buf->IsSlicedString());
|
| - Object* ok = buf->Flatten(StringShape(buf));
|
| + Object* ok = buf->TryFlatten(StringShape(buf));
|
| if (ok->IsFailure()) return ok;
|
| - // Under certain circumstances (TryFlatten fails in String::Slice)
|
| - // we can have a cons string under a slice. In this case we need
|
| - // to get the flat string out of the cons!
|
| + // Under certain circumstances (TryFlattenIfNotFlat fails in
|
| + // String::Slice) we can have a cons string under a slice.
|
| + // In this case we need to get the flat string out of the cons!
|
| if (StringShape(String::cast(ok)).IsCons()) {
|
| ss->set_buffer(ConsString::cast(ok)->first());
|
| }
|
| @@ -1947,7 +1947,7 @@
|
| }
|
| new_map->set_unused_property_fields(0);
|
|
|
| - // We have now sucessfully allocated all the necessary objects.
|
| + // We have now successfully allocated all the necessary objects.
|
| // Changes can now be made with the guarantee that all of them take effect.
|
| set_map(new_map);
|
| map()->set_instance_descriptors(Heap::empty_descriptor_array());
|
| @@ -2413,8 +2413,8 @@
|
| return Heap::undefined_value();
|
| }
|
|
|
| - // TryFlatten before operating on the string.
|
| - name->TryFlatten(StringShape(name));
|
| + // Try to flatten before operating on the string.
|
| + name->TryFlattenIfNotFlat(StringShape(name));
|
|
|
| // Make sure name is not an index.
|
| uint32_t index;
|
| @@ -2424,7 +2424,7 @@
|
| // callback overwriting in this object or it's prototype chain.
|
| // This mechanism is needed for instance in a browser setting, where
|
| // certain accessors such as window.location should not be allowed
|
| - // to be overwriten because allowing overwriting could potentially
|
| + // to be overwritten because allowing overwriting could potentially
|
| // cause security problems.
|
| LookupResult callback_result;
|
| LookupCallback(name, &callback_result);
|
| @@ -3065,9 +3065,7 @@
|
| // doesn't make Utf8Length faster, but it is very likely that
|
| // the string will be accessed later (for example by WriteUtf8)
|
| // so it's still a good idea.
|
| - if (!IsFlat(shape)) {
|
| - TryFlatten(shape); // shape is now no longer valid.
|
| - }
|
| + TryFlattenIfNotFlat(shape); // shape is now no longer valid.
|
| Access<StringInputBuffer> buffer(&string_input_buffer);
|
| buffer->Reset(0, this);
|
| int result = 0;
|
| @@ -5160,6 +5158,7 @@
|
| uint32_t new_length = 0;
|
| if (IsJSArray()) {
|
| CHECK(Array::IndexFromObject(JSArray::cast(this)->length(), &new_length));
|
| + JSArray::cast(this)->set_length(Smi::FromInt(new_length));
|
| } else {
|
| new_length = Dictionary::cast(elements())->max_number_key() + 1;
|
| }
|
| @@ -5695,10 +5694,10 @@
|
| // Fill in the names of local properties into the supplied storage. The main
|
| // purpose of this function is to provide reflection information for the object
|
| // mirrors.
|
| -void JSObject::GetLocalPropertyNames(FixedArray* storage) {
|
| - ASSERT(storage->length() ==
|
| - NumberOfLocalProperties(static_cast<PropertyAttributes>(NONE)));
|
| - int index = 0;
|
| +void JSObject::GetLocalPropertyNames(FixedArray* storage, int index) {
|
| + ASSERT(storage->length() >=
|
| + NumberOfLocalProperties(static_cast<PropertyAttributes>(NONE)) -
|
| + index);
|
| if (HasFastProperties()) {
|
| for (DescriptorReader r(map()->instance_descriptors());
|
| !r.eos();
|
| @@ -5707,7 +5706,7 @@
|
| storage->set(index++, r.GetKey());
|
| }
|
| }
|
| - ASSERT(storage->length() == index);
|
| + ASSERT(storage->length() >= index);
|
| } else {
|
| property_dictionary()->CopyKeysTo(storage);
|
| }
|
|
|