diff --git a/src/ast/ast.h b/src/ast/ast.h index b122fdac80..bea1f369d1 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -13,7 +13,6 @@ #include "src/globals.h" #include "src/isolate.h" #include "src/label.h" -#include "src/list.h" #include "src/objects/literal-objects.h" #include "src/parsing/token.h" #include "src/runtime/runtime.h" diff --git a/src/builtins/builtins-array.cc b/src/builtins/builtins-array.cc index 73c9c7ef89..eee427868d 100644 --- a/src/builtins/builtins-array.cc +++ b/src/builtins/builtins-array.cc @@ -645,15 +645,8 @@ uint32_t EstimateElementCount(Handle array) { return element_count; } -// Used for sorting indices in a List. -int compareUInt32(const uint32_t* ap, const uint32_t* bp) { - uint32_t a = *ap; - uint32_t b = *bp; - return (a == b) ? 0 : (a < b) ? -1 : 1; -} - void CollectElementIndices(Handle object, uint32_t range, - List* indices) { + std::vector* indices) { Isolate* isolate = object->GetIsolate(); ElementsKind kind = object->GetElementsKind(); switch (kind) { @@ -667,7 +660,7 @@ void CollectElementIndices(Handle object, uint32_t range, if (range < length) length = range; for (uint32_t i = 0; i < length; i++) { if (!elements->get(i)->IsTheHole(isolate)) { - indices->Add(i); + indices->push_back(i); } } break; @@ -684,7 +677,7 @@ void CollectElementIndices(Handle object, uint32_t range, if (range < length) length = range; for (uint32_t i = 0; i < length; i++) { if (!elements->is_the_hole(i)) { - indices->Add(i); + indices->push_back(i); } } break; @@ -700,7 +693,7 @@ void CollectElementIndices(Handle object, uint32_t range, DCHECK(k->IsNumber()); uint32_t index = static_cast(k->Number()); if (index < range) { - indices->Add(index); + indices->push_back(index); } }); break; @@ -716,10 +709,10 @@ void CollectElementIndices(Handle object, uint32_t range, length = range; // We will add all indices, so we might as well clear it first // and avoid duplicates. - indices->Clear(); + indices->clear(); } for (uint32_t i = 0; i < length; i++) { - indices->Add(i); + indices->push_back(i); } if (length == range) return; // All indices accounted for already. break; @@ -732,7 +725,7 @@ void CollectElementIndices(Handle object, uint32_t range, ElementsAccessor* accessor = object->GetElementsAccessor(); for (uint32_t i = 0; i < range; i++) { if (accessor->HasElement(raw_object, i, elements)) { - indices->Add(i); + indices->push_back(i); } } break; @@ -747,12 +740,12 @@ void CollectElementIndices(Handle object, uint32_t range, uint32_t i = 0; uint32_t limit = Min(length, range); for (; i < limit; i++) { - indices->Add(i); + indices->push_back(i); } ElementsAccessor* accessor = object->GetElementsAccessor(); for (; i < range; i++) { if (accessor->HasElement(*object, i)) { - indices->Add(i); + indices->push_back(i); } } break; @@ -889,13 +882,15 @@ bool IterateElements(Isolate* isolate, Handle receiver, case DICTIONARY_ELEMENTS: { Handle dict(array->element_dictionary()); - List indices(dict->Capacity() / 2); + std::vector indices; + indices.reserve(dict->Capacity() / 2); + // Collect all indices in the object and the prototypes less // than length. This might introduce duplicates in the indices list. CollectElementIndices(array, length, &indices); - indices.Sort(&compareUInt32); - int n = indices.length(); - FOR_WITH_HANDLE_SCOPE(isolate, int, j = 0, j, j < n, (void)0, { + std::sort(indices.begin(), indices.end()); + size_t n = indices.size(); + FOR_WITH_HANDLE_SCOPE(isolate, size_t, j = 0, j, j < n, (void)0, { uint32_t index = indices[j]; Handle element; ASSIGN_RETURN_ON_EXCEPTION_VALUE( diff --git a/src/builtins/builtins-math.cc b/src/builtins/builtins-math.cc index 0898c69c98..d390b5db31 100644 --- a/src/builtins/builtins-math.cc +++ b/src/builtins/builtins-math.cc @@ -21,7 +21,8 @@ BUILTIN(MathHypot) { DCHECK_LT(0, length); double max = 0; bool one_arg_is_nan = false; - List abs_values(length); + std::vector abs_values; + abs_values.reserve(length); for (int i = 0; i < length; i++) { Handle x = args.at(i + 1); ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, x, Object::ToNumber(x)); @@ -30,7 +31,7 @@ BUILTIN(MathHypot) { if (std::isnan(abs_value)) { one_arg_is_nan = true; } else { - abs_values.Add(abs_value); + abs_values.push_back(abs_value); if (max < abs_value) { max = abs_value; } @@ -55,7 +56,7 @@ BUILTIN(MathHypot) { double sum = 0; double compensation = 0; for (int i = 0; i < length; i++) { - double n = abs_values.at(i) / max; + double n = abs_values[i] / max; double summand = n * n - compensation; double preliminary = sum + summand; compensation = (preliminary - sum) - summand; diff --git a/src/builtins/builtins-string.cc b/src/builtins/builtins-string.cc index a51640695e..47874aba96 100644 --- a/src/builtins/builtins-string.cc +++ b/src/builtins/builtins-string.cc @@ -56,7 +56,8 @@ BUILTIN(StringFromCodePoint) { // Optimistically assume that the resulting String contains only one byte // characters. - List one_byte_buffer(length); + std::vector one_byte_buffer; + one_byte_buffer.reserve(length); uc32 code = 0; int index; for (index = 0; index < length; index++) { @@ -67,22 +68,24 @@ BUILTIN(StringFromCodePoint) { if (code > String::kMaxOneByteCharCode) { break; } - one_byte_buffer.Add(code); + one_byte_buffer.push_back(code); } if (index == length) { - RETURN_RESULT_OR_FAILURE(isolate, isolate->factory()->NewStringFromOneByte( - one_byte_buffer.ToConstVector())); + RETURN_RESULT_OR_FAILURE( + isolate, isolate->factory()->NewStringFromOneByte(Vector( + one_byte_buffer.data(), one_byte_buffer.size()))); } - List two_byte_buffer(length - index); + std::vector two_byte_buffer; + two_byte_buffer.reserve(length - index); while (true) { if (code <= static_cast(unibrow::Utf16::kMaxNonSurrogateCharCode)) { - two_byte_buffer.Add(code); + two_byte_buffer.push_back(code); } else { - two_byte_buffer.Add(unibrow::Utf16::LeadSurrogate(code)); - two_byte_buffer.Add(unibrow::Utf16::TrailSurrogate(code)); + two_byte_buffer.push_back(unibrow::Utf16::LeadSurrogate(code)); + two_byte_buffer.push_back(unibrow::Utf16::TrailSurrogate(code)); } if (++index == length) { @@ -97,13 +100,12 @@ BUILTIN(StringFromCodePoint) { Handle result; ASSIGN_RETURN_FAILURE_ON_EXCEPTION( isolate, result, - isolate->factory()->NewRawTwoByteString(one_byte_buffer.length() + - two_byte_buffer.length())); + isolate->factory()->NewRawTwoByteString( + static_cast(one_byte_buffer.size() + two_byte_buffer.size()))); - CopyChars(result->GetChars(), one_byte_buffer.ToConstVector().start(), - one_byte_buffer.length()); - CopyChars(result->GetChars() + one_byte_buffer.length(), - two_byte_buffer.ToConstVector().start(), two_byte_buffer.length()); + CopyChars(result->GetChars(), one_byte_buffer.data(), one_byte_buffer.size()); + CopyChars(result->GetChars() + one_byte_buffer.size(), two_byte_buffer.data(), + two_byte_buffer.size()); return *result; } diff --git a/src/compiler-dispatcher/optimizing-compile-dispatcher.h b/src/compiler-dispatcher/optimizing-compile-dispatcher.h index 5b4ad8a4d6..d1d295f063 100644 --- a/src/compiler-dispatcher/optimizing-compile-dispatcher.h +++ b/src/compiler-dispatcher/optimizing-compile-dispatcher.h @@ -7,13 +7,13 @@ #include +#include "src/allocation.h" #include "src/base/atomicops.h" #include "src/base/platform/condition-variable.h" #include "src/base/platform/mutex.h" #include "src/base/platform/platform.h" #include "src/flags.h" #include "src/globals.h" -#include "src/list.h" namespace v8 { namespace internal { diff --git a/src/debug/debug.cc b/src/debug/debug.cc index b19edf9766..fd6d9b87fd 100644 --- a/src/debug/debug.cc +++ b/src/debug/debug.cc @@ -791,9 +791,9 @@ void Debug::PrepareStepOnThrow() { while (!it.done()) { JavaScriptFrame* frame = it.frame(); if (frame->LookupExceptionHandlerInTable(nullptr, nullptr) > 0) break; - List infos; + std::vector infos; frame->GetFunctions(&infos); - current_frame_count -= infos.length(); + current_frame_count -= infos.size(); it.Advance(); } @@ -942,10 +942,11 @@ void Debug::PrepareStep(StepAction step_action) { Deoptimizer::DeoptimizeFunction(frame->function()); } HandleScope scope(isolate_); - List> infos; + std::vector> infos; frame->GetFunctions(&infos); - for (; !infos.is_empty(); current_frame_count--) { - Handle info = infos.RemoveLast(); + for (; !infos.empty(); current_frame_count--) { + Handle info = infos.back(); + infos.pop_back(); if (in_current_frame) { // We want to skip out, so skip the current frame. in_current_frame = false; @@ -1075,8 +1076,6 @@ bool Debug::PrepareFunctionForBreakPoints(Handle shared) { GarbageCollectionReason::kDebugger); DCHECK(shared->is_compiled()); - - List> functions; { // TODO(yangguo): with bytecode, we still walk the heap to find all // optimized code for the function to deoptimize. We can probably be @@ -1098,11 +1097,6 @@ bool Debug::PrepareFunctionForBreakPoints(Handle shared) { } } - for (Handle const function : functions) { - function->ReplaceCode(shared->code()); - JSFunction::EnsureLiterals(function); - } - // Update PCs on the stack to point to recompiled code. RedirectActiveFunctions redirect_visitor(*shared); redirect_visitor.VisitThread(isolate_, isolate_->thread_local_top()); @@ -1154,7 +1148,7 @@ bool Debug::GetPossibleBreakpoints(Handle