OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 10000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10011 array = EnsureSpace(array, length + 2); | 10011 array = EnsureSpace(array, length + 2); |
10012 if (mode == kReloadLengthAfterAllocation) { | 10012 if (mode == kReloadLengthAfterAllocation) { |
10013 length = array->Length(); | 10013 length = array->Length(); |
10014 } | 10014 } |
10015 array->Set(length, *obj1); | 10015 array->Set(length, *obj1); |
10016 array->Set(length + 1, *obj2); | 10016 array->Set(length + 1, *obj2); |
10017 array->SetLength(length + 2); | 10017 array->SetLength(length + 2); |
10018 return array; | 10018 return array; |
10019 } | 10019 } |
10020 | 10020 |
| 10021 Handle<ArrayList> ArrayList::New(Isolate* isolate, int size) { |
| 10022 Handle<ArrayList> result = Handle<ArrayList>::cast( |
| 10023 isolate->factory()->NewFixedArray(size + kFirstIndex)); |
| 10024 result->SetLength(0); |
| 10025 return result; |
| 10026 } |
10021 | 10027 |
10022 bool ArrayList::IsFull() { | 10028 bool ArrayList::IsFull() { |
10023 int capacity = length(); | 10029 int capacity = length(); |
10024 return kFirstIndex + Length() == capacity; | 10030 return kFirstIndex + Length() == capacity; |
10025 } | 10031 } |
10026 | 10032 |
10027 namespace { | 10033 namespace { |
10028 | 10034 |
10029 Handle<FixedArray> EnsureSpaceInFixedArray(Handle<FixedArray> array, | 10035 Handle<FixedArray> EnsureSpaceInFixedArray(Handle<FixedArray> array, |
10030 int length) { | 10036 int length) { |
(...skipping 10162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20193 // depend on this. | 20199 // depend on this. |
20194 return DICTIONARY_ELEMENTS; | 20200 return DICTIONARY_ELEMENTS; |
20195 } | 20201 } |
20196 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20202 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20197 return kind; | 20203 return kind; |
20198 } | 20204 } |
20199 } | 20205 } |
20200 | 20206 |
20201 } // namespace internal | 20207 } // namespace internal |
20202 } // namespace v8 | 20208 } // namespace v8 |
OLD | NEW |