Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 <iomanip> | 5 #include <iomanip> |
| 6 #include <sstream> | 6 #include <sstream> |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
| (...skipping 8259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8270 } | 8270 } |
| 8271 casted_result->set_last_used_index(target_index - 1 - kFirstIndex); | 8271 casted_result->set_last_used_index(target_index - 1 - kFirstIndex); |
| 8272 for (; target_index < result->length(); ++target_index) { | 8272 for (; target_index < result->length(); ++target_index) { |
| 8273 result->set(target_index, Smi::FromInt(0)); | 8273 result->set(target_index, Smi::FromInt(0)); |
| 8274 } | 8274 } |
| 8275 } | 8275 } |
| 8276 return casted_result; | 8276 return casted_result; |
| 8277 } | 8277 } |
| 8278 | 8278 |
| 8279 | 8279 |
| 8280 Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj) { | 8280 Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj, |
| 8281 AddMode mode) { | |
| 8281 int length = array->Length(); | 8282 int length = array->Length(); |
| 8282 array = EnsureSpace(array, length + 1); | 8283 array = EnsureSpace(array, length + 1); |
| 8284 if (mode == kReloadLengthAfterAllocation) { | |
| 8285 DCHECK(array->Length() <= length); | |
| 8286 length = array->Length(); | |
| 8287 } | |
| 8283 array->Set(length, *obj); | 8288 array->Set(length, *obj); |
| 8284 array->SetLength(length + 1); | 8289 array->SetLength(length + 1); |
| 8285 return array; | 8290 return array; |
| 8286 } | 8291 } |
| 8287 | 8292 |
| 8288 | 8293 |
| 8289 Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj1, | 8294 Handle<ArrayList> ArrayList::Add(Handle<ArrayList> array, Handle<Object> obj1, |
| 8290 Handle<Object> obj2) { | 8295 Handle<Object> obj2, AddMode mode) { |
| 8291 int length = array->Length(); | 8296 int length = array->Length(); |
| 8292 array = EnsureSpace(array, length + 2); | 8297 array = EnsureSpace(array, length + 2); |
| 8298 if (mode == kReloadLengthAfterAllocation) { | |
| 8299 length = array->Length(); | |
|
Erik Corry
2015/03/25 09:53:07
Missing DCHECK from the single-argument version.
| |
| 8300 } | |
| 8293 array->Set(length, *obj1); | 8301 array->Set(length, *obj1); |
| 8294 array->Set(length + 1, *obj2); | 8302 array->Set(length + 1, *obj2); |
| 8295 array->SetLength(length + 2); | 8303 array->SetLength(length + 2); |
| 8296 return array; | 8304 return array; |
| 8297 } | 8305 } |
| 8298 | 8306 |
| 8299 | 8307 |
| 8300 Handle<ArrayList> ArrayList::EnsureSpace(Handle<ArrayList> array, int length) { | 8308 Handle<ArrayList> ArrayList::EnsureSpace(Handle<ArrayList> array, int length) { |
| 8301 int capacity = array->length(); | 8309 int capacity = array->length(); |
|
Erik Corry
2015/03/25 09:53:07
// This is the length of the FixedArray
| |
| 8310 bool empty = (capacity == 0); | |
| 8302 if (capacity < kFirstIndex + length) { | 8311 if (capacity < kFirstIndex + length) { |
| 8303 capacity = kFirstIndex + length; | 8312 capacity = kFirstIndex + length; |
| 8304 capacity = capacity + Max(capacity / 2, 2); | 8313 capacity = capacity + Max(capacity / 2, 2); |
|
Erik Corry
2015/03/25 09:53:07
Division by 2 of a signed value can be an expensiv
| |
| 8305 array = Handle<ArrayList>::cast(FixedArray::CopySize(array, capacity)); | 8314 array = Handle<ArrayList>::cast(FixedArray::CopySize(array, capacity)); |
| 8315 if (empty) array->SetLength(0); | |
|
Erik Corry
2015/03/25 09:53:06
// This sets the length of the ArrayList, using th
| |
| 8306 } | 8316 } |
| 8307 return array; | 8317 return array; |
| 8308 } | 8318 } |
| 8309 | 8319 |
| 8310 | 8320 |
| 8311 Handle<DescriptorArray> DescriptorArray::Allocate(Isolate* isolate, | 8321 Handle<DescriptorArray> DescriptorArray::Allocate(Isolate* isolate, |
| 8312 int number_of_descriptors, | 8322 int number_of_descriptors, |
| 8313 int slack) { | 8323 int slack) { |
| 8314 DCHECK(0 <= number_of_descriptors); | 8324 DCHECK(0 <= number_of_descriptors); |
| 8315 Factory* factory = isolate->factory(); | 8325 Factory* factory = isolate->factory(); |
| (...skipping 8790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17106 CompilationInfo* info) { | 17116 CompilationInfo* info) { |
| 17107 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | 17117 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( |
| 17108 handle(cell->dependent_code(), info->isolate()), | 17118 handle(cell->dependent_code(), info->isolate()), |
| 17109 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); | 17119 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); |
| 17110 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 17120 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
| 17111 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 17121 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
| 17112 cell, info->zone()); | 17122 cell, info->zone()); |
| 17113 } | 17123 } |
| 17114 | 17124 |
| 17115 } } // namespace v8::internal | 17125 } } // namespace v8::internal |
| OLD | NEW |