Commit 42ccbd33 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[cleanup] Replace List with std::vector in runtime and builtins.

Bug: v8:6333
Change-Id: Iad2fdb7670dd01d19ed25c48a0091969cddb01c8
Reviewed-on: https://chromium-review.googlesource.com/632257Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47592}
parent 2d8a3c82
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "src/globals.h" #include "src/globals.h"
#include "src/isolate.h" #include "src/isolate.h"
#include "src/label.h" #include "src/label.h"
#include "src/list.h"
#include "src/objects/literal-objects.h" #include "src/objects/literal-objects.h"
#include "src/parsing/token.h" #include "src/parsing/token.h"
#include "src/runtime/runtime.h" #include "src/runtime/runtime.h"
......
...@@ -645,15 +645,8 @@ uint32_t EstimateElementCount(Handle<JSArray> array) { ...@@ -645,15 +645,8 @@ uint32_t EstimateElementCount(Handle<JSArray> array) {
return element_count; return element_count;
} }
// Used for sorting indices in a List<uint32_t>.
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<JSObject> object, uint32_t range, void CollectElementIndices(Handle<JSObject> object, uint32_t range,
List<uint32_t>* indices) { std::vector<uint32_t>* indices) {
Isolate* isolate = object->GetIsolate(); Isolate* isolate = object->GetIsolate();
ElementsKind kind = object->GetElementsKind(); ElementsKind kind = object->GetElementsKind();
switch (kind) { switch (kind) {
...@@ -667,7 +660,7 @@ void CollectElementIndices(Handle<JSObject> object, uint32_t range, ...@@ -667,7 +660,7 @@ void CollectElementIndices(Handle<JSObject> object, uint32_t range,
if (range < length) length = range; if (range < length) length = range;
for (uint32_t i = 0; i < length; i++) { for (uint32_t i = 0; i < length; i++) {
if (!elements->get(i)->IsTheHole(isolate)) { if (!elements->get(i)->IsTheHole(isolate)) {
indices->Add(i); indices->push_back(i);
} }
} }
break; break;
...@@ -684,7 +677,7 @@ void CollectElementIndices(Handle<JSObject> object, uint32_t range, ...@@ -684,7 +677,7 @@ void CollectElementIndices(Handle<JSObject> object, uint32_t range,
if (range < length) length = range; if (range < length) length = range;
for (uint32_t i = 0; i < length; i++) { for (uint32_t i = 0; i < length; i++) {
if (!elements->is_the_hole(i)) { if (!elements->is_the_hole(i)) {
indices->Add(i); indices->push_back(i);
} }
} }
break; break;
...@@ -700,7 +693,7 @@ void CollectElementIndices(Handle<JSObject> object, uint32_t range, ...@@ -700,7 +693,7 @@ void CollectElementIndices(Handle<JSObject> object, uint32_t range,
DCHECK(k->IsNumber()); DCHECK(k->IsNumber());
uint32_t index = static_cast<uint32_t>(k->Number()); uint32_t index = static_cast<uint32_t>(k->Number());
if (index < range) { if (index < range) {
indices->Add(index); indices->push_back(index);
} }
}); });
break; break;
...@@ -716,10 +709,10 @@ void CollectElementIndices(Handle<JSObject> object, uint32_t range, ...@@ -716,10 +709,10 @@ void CollectElementIndices(Handle<JSObject> object, uint32_t range,
length = range; length = range;
// We will add all indices, so we might as well clear it first // We will add all indices, so we might as well clear it first
// and avoid duplicates. // and avoid duplicates.
indices->Clear(); indices->clear();
} }
for (uint32_t i = 0; i < length; i++) { for (uint32_t i = 0; i < length; i++) {
indices->Add(i); indices->push_back(i);
} }
if (length == range) return; // All indices accounted for already. if (length == range) return; // All indices accounted for already.
break; break;
...@@ -732,7 +725,7 @@ void CollectElementIndices(Handle<JSObject> object, uint32_t range, ...@@ -732,7 +725,7 @@ void CollectElementIndices(Handle<JSObject> object, uint32_t range,
ElementsAccessor* accessor = object->GetElementsAccessor(); ElementsAccessor* accessor = object->GetElementsAccessor();
for (uint32_t i = 0; i < range; i++) { for (uint32_t i = 0; i < range; i++) {
if (accessor->HasElement(raw_object, i, elements)) { if (accessor->HasElement(raw_object, i, elements)) {
indices->Add(i); indices->push_back(i);
} }
} }
break; break;
...@@ -747,12 +740,12 @@ void CollectElementIndices(Handle<JSObject> object, uint32_t range, ...@@ -747,12 +740,12 @@ void CollectElementIndices(Handle<JSObject> object, uint32_t range,
uint32_t i = 0; uint32_t i = 0;
uint32_t limit = Min(length, range); uint32_t limit = Min(length, range);
for (; i < limit; i++) { for (; i < limit; i++) {
indices->Add(i); indices->push_back(i);
} }
ElementsAccessor* accessor = object->GetElementsAccessor(); ElementsAccessor* accessor = object->GetElementsAccessor();
for (; i < range; i++) { for (; i < range; i++) {
if (accessor->HasElement(*object, i)) { if (accessor->HasElement(*object, i)) {
indices->Add(i); indices->push_back(i);
} }
} }
break; break;
...@@ -889,13 +882,15 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver, ...@@ -889,13 +882,15 @@ bool IterateElements(Isolate* isolate, Handle<JSReceiver> receiver,
case DICTIONARY_ELEMENTS: { case DICTIONARY_ELEMENTS: {
Handle<SeededNumberDictionary> dict(array->element_dictionary()); Handle<SeededNumberDictionary> dict(array->element_dictionary());
List<uint32_t> indices(dict->Capacity() / 2); std::vector<uint32_t> indices;
indices.reserve(dict->Capacity() / 2);
// Collect all indices in the object and the prototypes less // Collect all indices in the object and the prototypes less
// than length. This might introduce duplicates in the indices list. // than length. This might introduce duplicates in the indices list.
CollectElementIndices(array, length, &indices); CollectElementIndices(array, length, &indices);
indices.Sort(&compareUInt32); std::sort(indices.begin(), indices.end());
int n = indices.length(); size_t n = indices.size();
FOR_WITH_HANDLE_SCOPE(isolate, int, j = 0, j, j < n, (void)0, { FOR_WITH_HANDLE_SCOPE(isolate, size_t, j = 0, j, j < n, (void)0, {
uint32_t index = indices[j]; uint32_t index = indices[j];
Handle<Object> element; Handle<Object> element;
ASSIGN_RETURN_ON_EXCEPTION_VALUE( ASSIGN_RETURN_ON_EXCEPTION_VALUE(
......
...@@ -21,7 +21,8 @@ BUILTIN(MathHypot) { ...@@ -21,7 +21,8 @@ BUILTIN(MathHypot) {
DCHECK_LT(0, length); DCHECK_LT(0, length);
double max = 0; double max = 0;
bool one_arg_is_nan = false; bool one_arg_is_nan = false;
List<double> abs_values(length); std::vector<double> abs_values;
abs_values.reserve(length);
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
Handle<Object> x = args.at(i + 1); Handle<Object> x = args.at(i + 1);
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, x, Object::ToNumber(x)); ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, x, Object::ToNumber(x));
...@@ -30,7 +31,7 @@ BUILTIN(MathHypot) { ...@@ -30,7 +31,7 @@ BUILTIN(MathHypot) {
if (std::isnan(abs_value)) { if (std::isnan(abs_value)) {
one_arg_is_nan = true; one_arg_is_nan = true;
} else { } else {
abs_values.Add(abs_value); abs_values.push_back(abs_value);
if (max < abs_value) { if (max < abs_value) {
max = abs_value; max = abs_value;
} }
...@@ -55,7 +56,7 @@ BUILTIN(MathHypot) { ...@@ -55,7 +56,7 @@ BUILTIN(MathHypot) {
double sum = 0; double sum = 0;
double compensation = 0; double compensation = 0;
for (int i = 0; i < length; i++) { 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 summand = n * n - compensation;
double preliminary = sum + summand; double preliminary = sum + summand;
compensation = (preliminary - sum) - summand; compensation = (preliminary - sum) - summand;
......
...@@ -56,7 +56,8 @@ BUILTIN(StringFromCodePoint) { ...@@ -56,7 +56,8 @@ BUILTIN(StringFromCodePoint) {
// Optimistically assume that the resulting String contains only one byte // Optimistically assume that the resulting String contains only one byte
// characters. // characters.
List<uint8_t> one_byte_buffer(length); std::vector<uint8_t> one_byte_buffer;
one_byte_buffer.reserve(length);
uc32 code = 0; uc32 code = 0;
int index; int index;
for (index = 0; index < length; index++) { for (index = 0; index < length; index++) {
...@@ -67,22 +68,24 @@ BUILTIN(StringFromCodePoint) { ...@@ -67,22 +68,24 @@ BUILTIN(StringFromCodePoint) {
if (code > String::kMaxOneByteCharCode) { if (code > String::kMaxOneByteCharCode) {
break; break;
} }
one_byte_buffer.Add(code); one_byte_buffer.push_back(code);
} }
if (index == length) { if (index == length) {
RETURN_RESULT_OR_FAILURE(isolate, isolate->factory()->NewStringFromOneByte( RETURN_RESULT_OR_FAILURE(
one_byte_buffer.ToConstVector())); isolate, isolate->factory()->NewStringFromOneByte(Vector<uint8_t>(
one_byte_buffer.data(), one_byte_buffer.size())));
} }
List<uc16> two_byte_buffer(length - index); std::vector<uc16> two_byte_buffer;
two_byte_buffer.reserve(length - index);
while (true) { while (true) {
if (code <= static_cast<uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)) { if (code <= static_cast<uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)) {
two_byte_buffer.Add(code); two_byte_buffer.push_back(code);
} else { } else {
two_byte_buffer.Add(unibrow::Utf16::LeadSurrogate(code)); two_byte_buffer.push_back(unibrow::Utf16::LeadSurrogate(code));
two_byte_buffer.Add(unibrow::Utf16::TrailSurrogate(code)); two_byte_buffer.push_back(unibrow::Utf16::TrailSurrogate(code));
} }
if (++index == length) { if (++index == length) {
...@@ -97,13 +100,12 @@ BUILTIN(StringFromCodePoint) { ...@@ -97,13 +100,12 @@ BUILTIN(StringFromCodePoint) {
Handle<SeqTwoByteString> result; Handle<SeqTwoByteString> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result, isolate, result,
isolate->factory()->NewRawTwoByteString(one_byte_buffer.length() + isolate->factory()->NewRawTwoByteString(
two_byte_buffer.length())); static_cast<int>(one_byte_buffer.size() + two_byte_buffer.size())));
CopyChars(result->GetChars(), one_byte_buffer.ToConstVector().start(), CopyChars(result->GetChars(), one_byte_buffer.data(), one_byte_buffer.size());
one_byte_buffer.length()); CopyChars(result->GetChars() + one_byte_buffer.size(), two_byte_buffer.data(),
CopyChars(result->GetChars() + one_byte_buffer.length(), two_byte_buffer.size());
two_byte_buffer.ToConstVector().start(), two_byte_buffer.length());
return *result; return *result;
} }
......
...@@ -7,13 +7,13 @@ ...@@ -7,13 +7,13 @@
#include <queue> #include <queue>
#include "src/allocation.h"
#include "src/base/atomicops.h" #include "src/base/atomicops.h"
#include "src/base/platform/condition-variable.h" #include "src/base/platform/condition-variable.h"
#include "src/base/platform/mutex.h" #include "src/base/platform/mutex.h"
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/flags.h" #include "src/flags.h"
#include "src/globals.h" #include "src/globals.h"
#include "src/list.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -791,9 +791,9 @@ void Debug::PrepareStepOnThrow() { ...@@ -791,9 +791,9 @@ void Debug::PrepareStepOnThrow() {
while (!it.done()) { while (!it.done()) {
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
if (frame->LookupExceptionHandlerInTable(nullptr, nullptr) > 0) break; if (frame->LookupExceptionHandlerInTable(nullptr, nullptr) > 0) break;
List<SharedFunctionInfo*> infos; std::vector<SharedFunctionInfo*> infos;
frame->GetFunctions(&infos); frame->GetFunctions(&infos);
current_frame_count -= infos.length(); current_frame_count -= infos.size();
it.Advance(); it.Advance();
} }
...@@ -942,10 +942,11 @@ void Debug::PrepareStep(StepAction step_action) { ...@@ -942,10 +942,11 @@ void Debug::PrepareStep(StepAction step_action) {
Deoptimizer::DeoptimizeFunction(frame->function()); Deoptimizer::DeoptimizeFunction(frame->function());
} }
HandleScope scope(isolate_); HandleScope scope(isolate_);
List<Handle<SharedFunctionInfo>> infos; std::vector<Handle<SharedFunctionInfo>> infos;
frame->GetFunctions(&infos); frame->GetFunctions(&infos);
for (; !infos.is_empty(); current_frame_count--) { for (; !infos.empty(); current_frame_count--) {
Handle<SharedFunctionInfo> info = infos.RemoveLast(); Handle<SharedFunctionInfo> info = infos.back();
infos.pop_back();
if (in_current_frame) { if (in_current_frame) {
// We want to skip out, so skip the current frame. // We want to skip out, so skip the current frame.
in_current_frame = false; in_current_frame = false;
...@@ -1075,8 +1076,6 @@ bool Debug::PrepareFunctionForBreakPoints(Handle<SharedFunctionInfo> shared) { ...@@ -1075,8 +1076,6 @@ bool Debug::PrepareFunctionForBreakPoints(Handle<SharedFunctionInfo> shared) {
GarbageCollectionReason::kDebugger); GarbageCollectionReason::kDebugger);
DCHECK(shared->is_compiled()); DCHECK(shared->is_compiled());
List<Handle<JSFunction>> functions;
{ {
// TODO(yangguo): with bytecode, we still walk the heap to find all // TODO(yangguo): with bytecode, we still walk the heap to find all
// optimized code for the function to deoptimize. We can probably be // optimized code for the function to deoptimize. We can probably be
...@@ -1098,11 +1097,6 @@ bool Debug::PrepareFunctionForBreakPoints(Handle<SharedFunctionInfo> shared) { ...@@ -1098,11 +1097,6 @@ bool Debug::PrepareFunctionForBreakPoints(Handle<SharedFunctionInfo> shared) {
} }
} }
for (Handle<JSFunction> const function : functions) {
function->ReplaceCode(shared->code());
JSFunction::EnsureLiterals(function);
}
// Update PCs on the stack to point to recompiled code. // Update PCs on the stack to point to recompiled code.
RedirectActiveFunctions redirect_visitor(*shared); RedirectActiveFunctions redirect_visitor(*shared);
redirect_visitor.VisitThread(isolate_, isolate_->thread_local_top()); redirect_visitor.VisitThread(isolate_, isolate_->thread_local_top());
...@@ -1154,7 +1148,7 @@ bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position, ...@@ -1154,7 +1148,7 @@ bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
while (true) { while (true) {
HandleScope scope(isolate_); HandleScope scope(isolate_);
List<Handle<SharedFunctionInfo>> candidates; std::vector<Handle<SharedFunctionInfo>> candidates;
SharedFunctionInfo::ScriptIterator iterator(script); SharedFunctionInfo::ScriptIterator iterator(script);
for (SharedFunctionInfo* info = iterator.Next(); info != nullptr; for (SharedFunctionInfo* info = iterator.Next(); info != nullptr;
info = iterator.Next()) { info = iterator.Next()) {
...@@ -1164,27 +1158,27 @@ bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position, ...@@ -1164,27 +1158,27 @@ bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
} }
if (!info->IsSubjectToDebugging()) continue; if (!info->IsSubjectToDebugging()) continue;
if (!info->is_compiled() && !info->allows_lazy_compilation()) continue; if (!info->is_compiled() && !info->allows_lazy_compilation()) continue;
candidates.Add(i::handle(info)); candidates.push_back(i::handle(info));
} }
bool was_compiled = false; bool was_compiled = false;
for (int i = 0; i < candidates.length(); ++i) { for (const auto& candidate : candidates) {
// Code that cannot be compiled lazily are internal and not debuggable. // Code that cannot be compiled lazily are internal and not debuggable.
DCHECK(candidates[i]->allows_lazy_compilation()); DCHECK(candidate->allows_lazy_compilation());
if (!candidates[i]->is_compiled()) { if (!candidate->is_compiled()) {
if (!Compiler::Compile(candidates[i], Compiler::CLEAR_EXCEPTION)) { if (!Compiler::Compile(candidate, Compiler::CLEAR_EXCEPTION)) {
return false; return false;
} else { } else {
was_compiled = true; was_compiled = true;
} }
} }
if (!EnsureBreakInfo(candidates[i])) return false; if (!EnsureBreakInfo(candidate)) return false;
} }
if (was_compiled) continue; if (was_compiled) continue;
for (int i = 0; i < candidates.length(); ++i) { for (const auto& candidate : candidates) {
CHECK(candidates[i]->HasBreakInfo()); CHECK(candidate->HasBreakInfo());
Handle<DebugInfo> debug_info(candidates[i]->GetDebugInfo()); Handle<DebugInfo> debug_info(candidate->GetDebugInfo());
FindBreakablePositions(debug_info, start_position, end_position, FindBreakablePositions(debug_info, start_position, end_position,
locations); locations);
} }
...@@ -1596,7 +1590,7 @@ bool Debug::IsExceptionBlackboxed(bool uncaught) { ...@@ -1596,7 +1590,7 @@ bool Debug::IsExceptionBlackboxed(bool uncaught) {
bool Debug::IsFrameBlackboxed(JavaScriptFrame* frame) { bool Debug::IsFrameBlackboxed(JavaScriptFrame* frame) {
HandleScope scope(isolate_); HandleScope scope(isolate_);
List<Handle<SharedFunctionInfo>> infos; std::vector<Handle<SharedFunctionInfo>> infos;
frame->GetFunctions(&infos); frame->GetFunctions(&infos);
for (const auto& info : infos) { for (const auto& info : infos) {
if (!IsBlackboxed(info)) return false; if (!IsBlackboxed(info)) return false;
...@@ -1925,9 +1919,9 @@ int Debug::CurrentFrameCount() { ...@@ -1925,9 +1919,9 @@ int Debug::CurrentFrameCount() {
int counter = 0; int counter = 0;
while (!it.done()) { while (!it.done()) {
if (it.frame()->is_optimized()) { if (it.frame()->is_optimized()) {
List<SharedFunctionInfo*> infos; std::vector<SharedFunctionInfo*> infos;
OptimizedFrame::cast(it.frame())->GetFunctions(&infos); OptimizedFrame::cast(it.frame())->GetFunctions(&infos);
counter += infos.length(); counter += infos.size();
} else { } else {
counter++; counter++;
} }
......
...@@ -944,9 +944,9 @@ bool JavaScriptFrame::IsConstructor() const { ...@@ -944,9 +944,9 @@ bool JavaScriptFrame::IsConstructor() const {
bool JavaScriptFrame::HasInlinedFrames() const { bool JavaScriptFrame::HasInlinedFrames() const {
List<SharedFunctionInfo*> functions(1); std::vector<SharedFunctionInfo*> functions;
GetFunctions(&functions); GetFunctions(&functions);
return functions.length() > 1; return functions.size() > 1;
} }
...@@ -977,18 +977,19 @@ Address JavaScriptFrame::GetCallerStackPointer() const { ...@@ -977,18 +977,19 @@ Address JavaScriptFrame::GetCallerStackPointer() const {
return fp() + StandardFrameConstants::kCallerSPOffset; return fp() + StandardFrameConstants::kCallerSPOffset;
} }
void JavaScriptFrame::GetFunctions(List<SharedFunctionInfo*>* functions) const { void JavaScriptFrame::GetFunctions(
DCHECK(functions->length() == 0); std::vector<SharedFunctionInfo*>* functions) const {
functions->Add(function()->shared()); DCHECK(functions->empty());
functions->push_back(function()->shared());
} }
void JavaScriptFrame::GetFunctions( void JavaScriptFrame::GetFunctions(
List<Handle<SharedFunctionInfo>>* functions) const { std::vector<Handle<SharedFunctionInfo>>* functions) const {
DCHECK(functions->length() == 0); DCHECK(functions->empty());
List<SharedFunctionInfo*> raw_functions; std::vector<SharedFunctionInfo*> raw_functions;
GetFunctions(&raw_functions); GetFunctions(&raw_functions);
for (const auto& raw_function : raw_functions) { for (const auto& raw_function : raw_functions) {
functions->Add(Handle<SharedFunctionInfo>(raw_function)); functions->push_back(Handle<SharedFunctionInfo>(raw_function));
} }
} }
...@@ -1493,8 +1494,9 @@ Object* OptimizedFrame::receiver() const { ...@@ -1493,8 +1494,9 @@ Object* OptimizedFrame::receiver() const {
} }
} }
void OptimizedFrame::GetFunctions(List<SharedFunctionInfo*>* functions) const { void OptimizedFrame::GetFunctions(
DCHECK(functions->length() == 0); std::vector<SharedFunctionInfo*>* functions) const {
DCHECK(functions->empty());
DCHECK(is_optimized()); DCHECK(is_optimized());
// Delegate to JS frame in absence of turbofan deoptimization. // Delegate to JS frame in absence of turbofan deoptimization.
...@@ -1530,7 +1532,7 @@ void OptimizedFrame::GetFunctions(List<SharedFunctionInfo*>* functions) const { ...@@ -1530,7 +1532,7 @@ void OptimizedFrame::GetFunctions(List<SharedFunctionInfo*>* functions) const {
// The second operand of the frame points to the function. // The second operand of the frame points to the function.
Object* shared = literal_array->get(it.Next()); Object* shared = literal_array->get(it.Next());
functions->Add(SharedFunctionInfo::cast(shared)); functions->push_back(SharedFunctionInfo::cast(shared));
// Skip over remaining operands to advance to the next opcode. // Skip over remaining operands to advance to the next opcode.
it.Skip(Translation::NumberOfOperandsFor(opcode) - 2); it.Skip(Translation::NumberOfOperandsFor(opcode) - 2);
......
...@@ -737,9 +737,9 @@ class JavaScriptFrame : public StandardFrame { ...@@ -737,9 +737,9 @@ class JavaScriptFrame : public StandardFrame {
Code* unchecked_code() const override; Code* unchecked_code() const override;
// Return a list with {SharedFunctionInfo} objects of this frame. // Return a list with {SharedFunctionInfo} objects of this frame.
virtual void GetFunctions(List<SharedFunctionInfo*>* functions) const; virtual void GetFunctions(std::vector<SharedFunctionInfo*>* functions) const;
void GetFunctions(List<Handle<SharedFunctionInfo>>* functions) const; void GetFunctions(std::vector<Handle<SharedFunctionInfo>>* functions) const;
// Lookup exception handler for current {pc}, returns -1 if none found. Also // Lookup exception handler for current {pc}, returns -1 if none found. Also
// returns data associated with the handler site specific to the frame type: // returns data associated with the handler site specific to the frame type:
...@@ -827,7 +827,7 @@ class OptimizedFrame : public JavaScriptFrame { ...@@ -827,7 +827,7 @@ class OptimizedFrame : public JavaScriptFrame {
// Return a list with {SharedFunctionInfo} objects of this frame. // Return a list with {SharedFunctionInfo} objects of this frame.
// The functions are ordered bottom-to-top (i.e. functions.last() // The functions are ordered bottom-to-top (i.e. functions.last()
// is the top-most activation) // is the top-most activation)
void GetFunctions(List<SharedFunctionInfo*>* functions) const override; void GetFunctions(std::vector<SharedFunctionInfo*>* functions) const override;
void Summarize( void Summarize(
List<FrameSummary>* frames, List<FrameSummary>* frames,
......
...@@ -964,7 +964,7 @@ class Isolate { ...@@ -964,7 +964,7 @@ class Isolate {
total_regexp_code_generated_ += size; total_regexp_code_generated_ += size;
} }
List<int>* regexp_indices() { return &regexp_indices_; } std::vector<int>* regexp_indices() { return &regexp_indices_; }
unibrow::Mapping<unibrow::Ecma262Canonicalize>* unibrow::Mapping<unibrow::Ecma262Canonicalize>*
interp_canonicalize_mapping() { interp_canonicalize_mapping() {
...@@ -1482,7 +1482,7 @@ class Isolate { ...@@ -1482,7 +1482,7 @@ class Isolate {
unibrow::Mapping<unibrow::Ecma262Canonicalize> unibrow::Mapping<unibrow::Ecma262Canonicalize>
regexp_macro_assembler_canonicalize_; regexp_macro_assembler_canonicalize_;
RegExpStack* regexp_stack_; RegExpStack* regexp_stack_;
List<int> regexp_indices_; std::vector<int> regexp_indices_;
DateCache* date_cache_; DateCache* date_cache_;
CallInterfaceDescriptorData* call_descriptor_data_; CallInterfaceDescriptorData* call_descriptor_data_;
AccessCompilerData* access_compiler_data_; AccessCompilerData* access_compiler_data_;
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <memory> #include <memory>
#include "src/handles.h" #include "src/handles.h"
#include "src/list.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "src/field-index.h" #include "src/field-index.h"
#include "src/flags.h" #include "src/flags.h"
#include "src/interpreter/bytecode-register.h" #include "src/interpreter/bytecode-register.h"
#include "src/list.h"
#include "src/messages.h" #include "src/messages.h"
#include "src/property-details.h" #include "src/property-details.h"
#include "src/unicode-decoder.h" #include "src/unicode-decoder.h"
......
...@@ -27,7 +27,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) { ...@@ -27,7 +27,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) {
CHECK(script_value->value()->IsScript()); CHECK(script_value->value()->IsScript());
Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); Handle<Script> script = Handle<Script>(Script::cast(script_value->value()));
List<Handle<SharedFunctionInfo> > found; std::vector<Handle<SharedFunctionInfo>> found;
Heap* heap = isolate->heap(); Heap* heap = isolate->heap();
{ {
HeapIterator iterator(heap); HeapIterator iterator(heap);
...@@ -36,12 +36,13 @@ RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) { ...@@ -36,12 +36,13 @@ RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) {
if (!heap_obj->IsSharedFunctionInfo()) continue; if (!heap_obj->IsSharedFunctionInfo()) continue;
SharedFunctionInfo* shared = SharedFunctionInfo::cast(heap_obj); SharedFunctionInfo* shared = SharedFunctionInfo::cast(heap_obj);
if (shared->script() != *script) continue; if (shared->script() != *script) continue;
found.Add(Handle<SharedFunctionInfo>(shared)); found.push_back(Handle<SharedFunctionInfo>(shared));
} }
} }
Handle<FixedArray> result = isolate->factory()->NewFixedArray(found.length()); int found_size = static_cast<int>(found.size());
for (int i = 0; i < found.length(); ++i) { Handle<FixedArray> result = isolate->factory()->NewFixedArray(found_size);
for (int i = 0; i < found_size; ++i) {
Handle<SharedFunctionInfo> shared = found[i]; Handle<SharedFunctionInfo> shared = found[i];
SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(isolate); SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(isolate);
Handle<String> name(shared->name(), isolate); Handle<String> name(shared->name(), isolate);
......
...@@ -387,7 +387,7 @@ void CompiledReplacement::Apply(ReplacementStringBuilder* builder, ...@@ -387,7 +387,7 @@ void CompiledReplacement::Apply(ReplacementStringBuilder* builder,
} }
void FindOneByteStringIndices(Vector<const uint8_t> subject, uint8_t pattern, void FindOneByteStringIndices(Vector<const uint8_t> subject, uint8_t pattern,
List<int>* indices, unsigned int limit) { std::vector<int>* indices, unsigned int limit) {
DCHECK(limit > 0); DCHECK(limit > 0);
// Collect indices of pattern in subject using memchr. // Collect indices of pattern in subject using memchr.
// Stop after finding at most limit values. // Stop after finding at most limit values.
...@@ -398,20 +398,20 @@ void FindOneByteStringIndices(Vector<const uint8_t> subject, uint8_t pattern, ...@@ -398,20 +398,20 @@ void FindOneByteStringIndices(Vector<const uint8_t> subject, uint8_t pattern,
pos = reinterpret_cast<const uint8_t*>( pos = reinterpret_cast<const uint8_t*>(
memchr(pos, pattern, subject_end - pos)); memchr(pos, pattern, subject_end - pos));
if (pos == NULL) return; if (pos == NULL) return;
indices->Add(static_cast<int>(pos - subject_start)); indices->push_back(static_cast<int>(pos - subject_start));
pos++; pos++;
limit--; limit--;
} }
} }
void FindTwoByteStringIndices(const Vector<const uc16> subject, uc16 pattern, void FindTwoByteStringIndices(const Vector<const uc16> subject, uc16 pattern,
List<int>* indices, unsigned int limit) { std::vector<int>* indices, unsigned int limit) {
DCHECK(limit > 0); DCHECK(limit > 0);
const uc16* subject_start = subject.start(); const uc16* subject_start = subject.start();
const uc16* subject_end = subject_start + subject.length(); const uc16* subject_end = subject_start + subject.length();
for (const uc16* pos = subject_start; pos < subject_end && limit > 0; pos++) { for (const uc16* pos = subject_start; pos < subject_end && limit > 0; pos++) {
if (*pos == pattern) { if (*pos == pattern) {
indices->Add(static_cast<int>(pos - subject_start)); indices->push_back(static_cast<int>(pos - subject_start));
limit--; limit--;
} }
} }
...@@ -419,8 +419,8 @@ void FindTwoByteStringIndices(const Vector<const uc16> subject, uc16 pattern, ...@@ -419,8 +419,8 @@ void FindTwoByteStringIndices(const Vector<const uc16> subject, uc16 pattern,
template <typename SubjectChar, typename PatternChar> template <typename SubjectChar, typename PatternChar>
void FindStringIndices(Isolate* isolate, Vector<const SubjectChar> subject, void FindStringIndices(Isolate* isolate, Vector<const SubjectChar> subject,
Vector<const PatternChar> pattern, List<int>* indices, Vector<const PatternChar> pattern,
unsigned int limit) { std::vector<int>* indices, unsigned int limit) {
DCHECK(limit > 0); DCHECK(limit > 0);
// Collect indices of pattern in subject. // Collect indices of pattern in subject.
// Stop after finding at most limit values. // Stop after finding at most limit values.
...@@ -430,14 +430,14 @@ void FindStringIndices(Isolate* isolate, Vector<const SubjectChar> subject, ...@@ -430,14 +430,14 @@ void FindStringIndices(Isolate* isolate, Vector<const SubjectChar> subject,
while (limit > 0) { while (limit > 0) {
index = search.Search(subject, index); index = search.Search(subject, index);
if (index < 0) return; if (index < 0) return;
indices->Add(index); indices->push_back(index);
index += pattern_length; index += pattern_length;
limit--; limit--;
} }
} }
void FindStringIndicesDispatch(Isolate* isolate, String* subject, void FindStringIndicesDispatch(Isolate* isolate, String* subject,
String* pattern, List<int>* indices, String* pattern, std::vector<int>* indices,
unsigned int limit) { unsigned int limit) {
{ {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
...@@ -488,9 +488,9 @@ void FindStringIndicesDispatch(Isolate* isolate, String* subject, ...@@ -488,9 +488,9 @@ void FindStringIndicesDispatch(Isolate* isolate, String* subject,
} }
namespace { namespace {
List<int>* GetRewoundRegexpIndicesList(Isolate* isolate) { std::vector<int>* GetRewoundRegexpIndicesList(Isolate* isolate) {
List<int>* list = isolate->regexp_indices(); std::vector<int>* list = isolate->regexp_indices();
list->Rewind(0); list->clear();
return list; return list;
} }
...@@ -498,8 +498,11 @@ void TruncateRegexpIndicesList(Isolate* isolate) { ...@@ -498,8 +498,11 @@ void TruncateRegexpIndicesList(Isolate* isolate) {
// Same size as smallest zone segment, preserving behavior from the // Same size as smallest zone segment, preserving behavior from the
// runtime zone. // runtime zone.
static const int kMaxRegexpIndicesListCapacity = 8 * KB; static const int kMaxRegexpIndicesListCapacity = 8 * KB;
if (isolate->regexp_indices()->capacity() > kMaxRegexpIndicesListCapacity) { std::vector<int>* indicies = isolate->regexp_indices();
isolate->regexp_indices()->Clear(); // Throw away backing storage if (indicies->capacity() > kMaxRegexpIndicesListCapacity) {
// Throw away backing storage.
indicies->clear();
indicies->shrink_to_fit();
} }
} }
} // namespace } // namespace
...@@ -511,7 +514,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString( ...@@ -511,7 +514,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
DCHECK(subject->IsFlat()); DCHECK(subject->IsFlat());
DCHECK(replacement->IsFlat()); DCHECK(replacement->IsFlat());
List<int>* indices = GetRewoundRegexpIndicesList(isolate); std::vector<int>* indices = GetRewoundRegexpIndicesList(isolate);
DCHECK_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag()); DCHECK_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag());
String* pattern = String* pattern =
...@@ -522,13 +525,12 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString( ...@@ -522,13 +525,12 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
FindStringIndicesDispatch(isolate, *subject, pattern, indices, 0xffffffff); FindStringIndicesDispatch(isolate, *subject, pattern, indices, 0xffffffff);
int matches = indices->length(); if (indices->empty()) return *subject;
if (matches == 0) return *subject;
// Detect integer overflow. // Detect integer overflow.
int64_t result_len_64 = (static_cast<int64_t>(replacement_len) - int64_t result_len_64 = (static_cast<int64_t>(replacement_len) -
static_cast<int64_t>(pattern_len)) * static_cast<int64_t>(pattern_len)) *
static_cast<int64_t>(matches) + static_cast<int64_t>(indices->size()) +
static_cast<int64_t>(subject_len); static_cast<int64_t>(subject_len);
int result_len; int result_len;
if (result_len_64 > static_cast<int64_t>(String::kMaxLength)) { if (result_len_64 > static_cast<int64_t>(String::kMaxLength)) {
...@@ -554,12 +556,12 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString( ...@@ -554,12 +556,12 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, untyped_res, maybe_res); ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, untyped_res, maybe_res);
Handle<ResultSeqString> result = Handle<ResultSeqString>::cast(untyped_res); Handle<ResultSeqString> result = Handle<ResultSeqString>::cast(untyped_res);
for (int i = 0; i < matches; i++) { for (int index : *indices) {
// Copy non-matched subject content. // Copy non-matched subject content.
if (subject_pos < indices->at(i)) { if (subject_pos < index) {
String::WriteToFlat(*subject, result->GetChars() + result_pos, String::WriteToFlat(*subject, result->GetChars() + result_pos,
subject_pos, indices->at(i)); subject_pos, index);
result_pos += indices->at(i) - subject_pos; result_pos += index - subject_pos;
} }
// Replace match. // Replace match.
...@@ -569,7 +571,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString( ...@@ -569,7 +571,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
result_pos += replacement_len; result_pos += replacement_len;
} }
subject_pos = indices->at(i) + pattern_len; subject_pos = index + pattern_len;
} }
// Add remaining subject content at the end. // Add remaining subject content at the end.
if (subject_pos < subject_len) { if (subject_pos < subject_len) {
...@@ -577,8 +579,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString( ...@@ -577,8 +579,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
subject_len); subject_len);
} }
int32_t match_indices[] = {indices->at(matches - 1), int32_t match_indices[] = {indices->back(), indices->back() + pattern_len};
indices->at(matches - 1) + pattern_len};
RegExpImpl::SetLastMatchInfo(last_match_info, subject, 0, match_indices); RegExpImpl::SetLastMatchInfo(last_match_info, subject, 0, match_indices);
TruncateRegexpIndicesList(isolate); TruncateRegexpIndicesList(isolate);
...@@ -854,18 +855,18 @@ RUNTIME_FUNCTION(Runtime_StringSplit) { ...@@ -854,18 +855,18 @@ RUNTIME_FUNCTION(Runtime_StringSplit) {
subject = String::Flatten(subject); subject = String::Flatten(subject);
pattern = String::Flatten(pattern); pattern = String::Flatten(pattern);
List<int>* indices = GetRewoundRegexpIndicesList(isolate); std::vector<int>* indices = GetRewoundRegexpIndicesList(isolate);
FindStringIndicesDispatch(isolate, *subject, *pattern, indices, limit); FindStringIndicesDispatch(isolate, *subject, *pattern, indices, limit);
if (static_cast<uint32_t>(indices->length()) < limit) { if (static_cast<uint32_t>(indices->size()) < limit) {
indices->Add(subject_length); indices->push_back(subject_length);
} }
// The list indices now contains the end of each part to create. // The list indices now contains the end of each part to create.
// Create JSArray of substrings separated by separator. // Create JSArray of substrings separated by separator.
int part_count = indices->length(); int part_count = static_cast<int>(indices->size());
Handle<JSArray> result = Handle<JSArray> result =
isolate->factory()->NewJSArray(PACKED_ELEMENTS, part_count, part_count, isolate->factory()->NewJSArray(PACKED_ELEMENTS, part_count, part_count,
......
...@@ -348,10 +348,10 @@ std::unique_ptr<Handle<Object>[]> GetCallerArguments(Isolate* isolate, ...@@ -348,10 +348,10 @@ std::unique_ptr<Handle<Object>[]> GetCallerArguments(Isolate* isolate,
// Find frame containing arguments passed to the caller. // Find frame containing arguments passed to the caller.
JavaScriptFrameIterator it(isolate); JavaScriptFrameIterator it(isolate);
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
List<SharedFunctionInfo*> functions(2); std::vector<SharedFunctionInfo*> functions;
frame->GetFunctions(&functions); frame->GetFunctions(&functions);
if (functions.length() > 1) { if (functions.size() > 1) {
int inlined_jsframe_index = functions.length() - 1; int inlined_jsframe_index = static_cast<int>(functions.size()) - 1;
TranslatedState translated_values(frame); TranslatedState translated_values(frame);
translated_values.Prepare(frame->fp()); translated_values.Prepare(frame->fp());
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "src/assembler.h" #include "src/assembler.h"
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/flags.h" #include "src/flags.h"
#include "src/list.h"
#include "src/msan.h" #include "src/msan.h"
#include "src/snapshot/natives.h" #include "src/snapshot/natives.h"
#include "src/snapshot/partial-serializer.h" #include "src/snapshot/partial-serializer.h"
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#include "src/snapshot/natives.h" #include "src/snapshot/natives.h"
#include "src/base/logging.h" #include "src/base/logging.h"
#include "src/list.h"
#include "src/list-inl.h"
#include "src/snapshot/snapshot-source-sink.h" #include "src/snapshot/snapshot-source-sink.h"
#include "src/vector.h" #include "src/vector.h"
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "src/base/macros.h" #include "src/base/macros.h"
#include "src/base/platform/platform.h" #include "src/base/platform/platform.h"
#include "src/globals.h" #include "src/globals.h"
#include "src/list.h"
#include "src/vector.h" #include "src/vector.h"
#include "src/zone/zone.h" #include "src/zone/zone.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment