| Index: src/runtime.cc
|
| diff --git a/src/runtime.cc b/src/runtime.cc
|
| index 888f665d21c8d8ab126a7d0ff9703d534094d5aa..4958094c3af46303c47aed8a87a06222e11429e0 100644
|
| --- a/src/runtime.cc
|
| +++ b/src/runtime.cc
|
| @@ -15015,6 +15015,45 @@ RUNTIME_FUNCTION(Runtime_InternalArrayConstructor) {
|
| }
|
|
|
|
|
| +RUNTIME_FUNCTION(Runtime_GrowArrayElements) {
|
| + HandleScope scope(isolate);
|
| + ASSERT(args.length() == 3);
|
| + CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
|
| + CONVERT_SMI_ARG_CHECKED(key, 1);
|
| +
|
| + Handle<FixedArrayBase> elements(object->elements());
|
| + uint32_t capacity = static_cast<uint32_t>(elements->length());
|
| + uint32_t unsigned_key = static_cast<uint32_t>(key);
|
| +
|
| + if (unsigned_key >= capacity) {
|
| + if ((unsigned_key - capacity) < JSObject::kMaxGap) {
|
| + uint32_t new_capacity = JSObject::NewElementsCapacity(capacity);
|
| + if (object->ShouldConvertToSlowElements(new_capacity)) {
|
| + JSObject::NormalizeElements(object);
|
| + return Smi::FromInt(0);
|
| + }
|
| + Handle<FixedArrayBase> new_elems;
|
| + ElementsKind kind = object->GetElementsKind();
|
| + if (IsFastDoubleElementsKind(kind)) {
|
| + new_elems = isolate->factory()->NewFixedDoubleArray(new_capacity);
|
| + } else {
|
| + new_elems = isolate->factory()->NewFixedArray(new_capacity);
|
| + }
|
| + ElementsAccessor* accessor = object->GetElementsAccessor();
|
| + accessor->CopyElements(object, new_elems, kind);
|
| + Handle<Map> same_map = JSObject::GetElementsTransitionMap(object, kind);
|
| + object->SetMapAndElements(object, same_map, new_elems);
|
| + } else {
|
| + JSObject::NormalizeElements(object);
|
| + return Smi::FromInt(0);
|
| + }
|
| + }
|
| +
|
| + // On success, return the fixed array elements.
|
| + return object->elements();
|
| +}
|
| +
|
| +
|
| RUNTIME_FUNCTION(Runtime_MaxSmi) {
|
| ASSERT(args.length() == 0);
|
| return Smi::FromInt(Smi::kMaxValue);
|
|
|