Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 00721c2d1bbe1b08e95c134083f9e9d998c3ad9d..88ee3976d60fe7c7db5a1ae5b2b5eb231338cf9a 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -10177,22 +10177,68 @@ bool ArrayList::IsFull() { |
| return kFirstIndex + Length() == capacity; |
| } |
| +namespace { |
| -Handle<ArrayList> ArrayList::EnsureSpace(Handle<ArrayList> array, int length) { |
| +Handle<FixedArray> EnsureSpaceInFixedArray(Handle<FixedArray> array, |
| + int length) { |
| int capacity = array->length(); |
| - bool empty = (capacity == 0); |
| - if (capacity < kFirstIndex + length) { |
| + if (capacity < length) { |
| Isolate* isolate = array->GetIsolate(); |
| - int new_capacity = kFirstIndex + length; |
| + int new_capacity = length; |
| new_capacity = new_capacity + Max(new_capacity / 2, 2); |
| int grow_by = new_capacity - capacity; |
| array = Handle<ArrayList>::cast( |
| isolate->factory()->CopyFixedArrayAndGrow(array, grow_by)); |
| - if (empty) array->SetLength(0); |
| } |
| return array; |
| } |
| +} // namespace |
| + |
| +Handle<ArrayList> ArrayList::EnsureSpace(Handle<ArrayList> array, int length) { |
| + const bool empty = (array->length() == 0); |
| + auto ret = Handle<ArrayList>::cast( |
| + EnsureSpaceInFixedArray(array, kFirstIndex + length)); |
| + if (empty) ret->SetLength(0); |
| + return ret; |
| +} |
| + |
| +Handle<FrameArray> FrameArray::Allocate(Isolate* isolate, |
|
Toon Verwaest
2016/08/23 13:14:08
So I guess I'm suggesting that a FrameArray should
jgruber
2016/08/23 15:32:13
Yes they're very similar. There doesn't seem to be
|
| + int number_of_frames) { |
| + DCHECK(0 <= number_of_frames); |
|
Toon Verwaest
2016/08/23 13:14:08
DCHECK_LE(0, number_of_frames);
jgruber
2016/08/23 15:32:13
Done.
|
| + Factory* factory = isolate->factory(); |
| + Handle<FixedArray> result = |
| + factory->NewFixedArrayWithHoles(LengthFor(number_of_frames)); |
| + return Handle<FrameArray>::cast(result); |
| +} |
| + |
| +Handle<FrameArray> FrameArray::AppendJSFrame( |
| + Handle<FrameArray> in, int frame_ix, Handle<Object> receiver, |
| + Handle<JSFunction> function, Handle<AbstractCode> code, int offset) { |
| + Handle<FrameArray> array = EnsureSpace(in, LengthFor(frame_ix + 1)); |
| + array->SetReceiver(frame_ix, *receiver); |
| + array->SetFunction(frame_ix, *function); |
| + array->SetCode(frame_ix, *code); |
| + array->SetOffset(frame_ix, Smi::FromInt(offset)); |
| + return array; |
| +} |
| + |
| +Handle<FrameArray> FrameArray::AppendWasmFrame( |
| + Handle<FrameArray> in, int frame_ix, Handle<Object> wasm_object, |
| + int wasm_function_index, Handle<AbstractCode> code, int offset) { |
| + Handle<FrameArray> array = EnsureSpace(in, LengthFor(frame_ix + 1)); |
| + array->SetWasmObject(frame_ix, *wasm_object); |
| + array->SetWasmFunctionIndex(frame_ix, Smi::FromInt(wasm_function_index)); |
| + array->SetCode(frame_ix, *code); |
| + array->SetOffset(frame_ix, Smi::FromInt(offset)); |
| + return array; |
| +} |
| + |
| +Handle<FrameArray> FrameArray::EnsureSpace(Handle<FrameArray> array, |
| + int length) { |
| + return Handle<FrameArray>::cast(EnsureSpaceInFixedArray(array, length)); |
| +} |
| + |
| Handle<DescriptorArray> DescriptorArray::Allocate(Isolate* isolate, |
| int number_of_descriptors, |
| int slack, |