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 @@
#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"
......
......@@ -645,15 +645,8 @@ uint32_t EstimateElementCount(Handle<JSArray> array) {
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,
List<uint32_t>* indices) {
std::vector<uint32_t>* indices) {
Isolate* isolate = object->GetIsolate();
ElementsKind kind = object->GetElementsKind();
switch (kind) {
......@@ -667,7 +660,7 @@ void CollectElementIndices(Handle<JSObject> 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<JSObject> 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<JSObject> object, uint32_t range,
DCHECK(k->IsNumber());
uint32_t index = static_cast<uint32_t>(k->Number());
if (index < range) {
indices->Add(index);
indices->push_back(index);
}
});
break;
......@@ -716,10 +709,10 @@ void CollectElementIndices(Handle<JSObject> 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<JSObject> 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<JSObject> 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<JSReceiver> receiver,
case DICTIONARY_ELEMENTS: {
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
// 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<Object> element;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
......
......@@ -21,7 +21,8 @@ BUILTIN(MathHypot) {
DCHECK_LT(0, length);
double max = 0;
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++) {
Handle<Object> 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;
......
......@@ -56,7 +56,8 @@ BUILTIN(StringFromCodePoint) {
// Optimistically assume that the resulting String contains only one byte
// characters.
List<uint8_t> one_byte_buffer(length);
std::vector<uint8_t> 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<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) {
if (code <= static_cast<uc32>(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<SeqTwoByteString> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
isolate->factory()->NewRawTwoByteString(one_byte_buffer.length() +
two_byte_buffer.length()));
isolate->factory()->NewRawTwoByteString(
static_cast<int>(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;
}
......
......@@ -7,13 +7,13 @@
#include <queue>
#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 {
......
......@@ -791,9 +791,9 @@ void Debug::PrepareStepOnThrow() {
while (!it.done()) {
JavaScriptFrame* frame = it.frame();
if (frame->LookupExceptionHandlerInTable(nullptr, nullptr) > 0) break;
List<SharedFunctionInfo*> infos;
std::vector<SharedFunctionInfo*> 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<Handle<SharedFunctionInfo>> infos;
std::vector<Handle<SharedFunctionInfo>> infos;
frame->GetFunctions(&infos);
for (; !infos.is_empty(); current_frame_count--) {
Handle<SharedFunctionInfo> info = infos.RemoveLast();
for (; !infos.empty(); current_frame_count--) {
Handle<SharedFunctionInfo> 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<SharedFunctionInfo> shared) {
GarbageCollectionReason::kDebugger);
DCHECK(shared->is_compiled());
List<Handle<JSFunction>> 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<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.
RedirectActiveFunctions redirect_visitor(*shared);
redirect_visitor.VisitThread(isolate_, isolate_->thread_local_top());
......@@ -1154,7 +1148,7 @@ bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
while (true) {
HandleScope scope(isolate_);
List<Handle<SharedFunctionInfo>> candidates;
std::vector<Handle<SharedFunctionInfo>> candidates;
SharedFunctionInfo::ScriptIterator iterator(script);
for (SharedFunctionInfo* info = iterator.Next(); info != nullptr;
info = iterator.Next()) {
......@@ -1164,27 +1158,27 @@ bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
}
if (!info->IsSubjectToDebugging()) 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;
for (int i = 0; i < candidates.length(); ++i) {
for (const auto& candidate : candidates) {
// Code that cannot be compiled lazily are internal and not debuggable.
DCHECK(candidates[i]->allows_lazy_compilation());
if (!candidates[i]->is_compiled()) {
if (!Compiler::Compile(candidates[i], Compiler::CLEAR_EXCEPTION)) {
DCHECK(candidate->allows_lazy_compilation());
if (!candidate->is_compiled()) {
if (!Compiler::Compile(candidate, Compiler::CLEAR_EXCEPTION)) {
return false;
} else {
was_compiled = true;
}
}
if (!EnsureBreakInfo(candidates[i])) return false;
if (!EnsureBreakInfo(candidate)) return false;
}
if (was_compiled) continue;
for (int i = 0; i < candidates.length(); ++i) {
CHECK(candidates[i]->HasBreakInfo());
Handle<DebugInfo> debug_info(candidates[i]->GetDebugInfo());
for (const auto& candidate : candidates) {
CHECK(candidate->HasBreakInfo());
Handle<DebugInfo> debug_info(candidate->GetDebugInfo());
FindBreakablePositions(debug_info, start_position, end_position,
locations);
}
......@@ -1596,7 +1590,7 @@ bool Debug::IsExceptionBlackboxed(bool uncaught) {
bool Debug::IsFrameBlackboxed(JavaScriptFrame* frame) {
HandleScope scope(isolate_);
List<Handle<SharedFunctionInfo>> infos;
std::vector<Handle<SharedFunctionInfo>> infos;
frame->GetFunctions(&infos);
for (const auto& info : infos) {
if (!IsBlackboxed(info)) return false;
......@@ -1925,9 +1919,9 @@ int Debug::CurrentFrameCount() {
int counter = 0;
while (!it.done()) {
if (it.frame()->is_optimized()) {
List<SharedFunctionInfo*> infos;
std::vector<SharedFunctionInfo*> infos;
OptimizedFrame::cast(it.frame())->GetFunctions(&infos);
counter += infos.length();
counter += infos.size();
} else {
counter++;
}
......
......@@ -944,9 +944,9 @@ bool JavaScriptFrame::IsConstructor() const {
bool JavaScriptFrame::HasInlinedFrames() const {
List<SharedFunctionInfo*> functions(1);
std::vector<SharedFunctionInfo*> functions;
GetFunctions(&functions);
return functions.length() > 1;
return functions.size() > 1;
}
......@@ -977,18 +977,19 @@ Address JavaScriptFrame::GetCallerStackPointer() const {
return fp() + StandardFrameConstants::kCallerSPOffset;
}
void JavaScriptFrame::GetFunctions(List<SharedFunctionInfo*>* functions) const {
DCHECK(functions->length() == 0);
functions->Add(function()->shared());
void JavaScriptFrame::GetFunctions(
std::vector<SharedFunctionInfo*>* functions) const {
DCHECK(functions->empty());
functions->push_back(function()->shared());
}
void JavaScriptFrame::GetFunctions(
List<Handle<SharedFunctionInfo>>* functions) const {
DCHECK(functions->length() == 0);
List<SharedFunctionInfo*> raw_functions;
std::vector<Handle<SharedFunctionInfo>>* functions) const {
DCHECK(functions->empty());
std::vector<SharedFunctionInfo*> raw_functions;
GetFunctions(&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 {
}
}
void OptimizedFrame::GetFunctions(List<SharedFunctionInfo*>* functions) const {
DCHECK(functions->length() == 0);
void OptimizedFrame::GetFunctions(
std::vector<SharedFunctionInfo*>* functions) const {
DCHECK(functions->empty());
DCHECK(is_optimized());
// Delegate to JS frame in absence of turbofan deoptimization.
......@@ -1530,7 +1532,7 @@ void OptimizedFrame::GetFunctions(List<SharedFunctionInfo*>* functions) const {
// The second operand of the frame points to the function.
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.
it.Skip(Translation::NumberOfOperandsFor(opcode) - 2);
......
......@@ -737,9 +737,9 @@ class JavaScriptFrame : public StandardFrame {
Code* unchecked_code() const override;
// 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
// returns data associated with the handler site specific to the frame type:
......@@ -827,7 +827,7 @@ class OptimizedFrame : public JavaScriptFrame {
// Return a list with {SharedFunctionInfo} objects of this frame.
// The functions are ordered bottom-to-top (i.e. functions.last()
// is the top-most activation)
void GetFunctions(List<SharedFunctionInfo*>* functions) const override;
void GetFunctions(std::vector<SharedFunctionInfo*>* functions) const override;
void Summarize(
List<FrameSummary>* frames,
......
......@@ -964,7 +964,7 @@ class Isolate {
total_regexp_code_generated_ += size;
}
List<int>* regexp_indices() { return &regexp_indices_; }
std::vector<int>* regexp_indices() { return &regexp_indices_; }
unibrow::Mapping<unibrow::Ecma262Canonicalize>*
interp_canonicalize_mapping() {
......@@ -1482,7 +1482,7 @@ class Isolate {
unibrow::Mapping<unibrow::Ecma262Canonicalize>
regexp_macro_assembler_canonicalize_;
RegExpStack* regexp_stack_;
List<int> regexp_indices_;
std::vector<int> regexp_indices_;
DateCache* date_cache_;
CallInterfaceDescriptorData* call_descriptor_data_;
AccessCompilerData* access_compiler_data_;
......
......@@ -13,7 +13,6 @@
#include <memory>
#include "src/handles.h"
#include "src/list.h"
namespace v8 {
namespace internal {
......
......@@ -18,7 +18,6 @@
#include "src/field-index.h"
#include "src/flags.h"
#include "src/interpreter/bytecode-register.h"
#include "src/list.h"
#include "src/messages.h"
#include "src/property-details.h"
#include "src/unicode-decoder.h"
......
......@@ -27,7 +27,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) {
CHECK(script_value->value()->IsScript());
Handle<Script> script = Handle<Script>(Script::cast(script_value->value()));
List<Handle<SharedFunctionInfo> > found;
std::vector<Handle<SharedFunctionInfo>> found;
Heap* heap = isolate->heap();
{
HeapIterator iterator(heap);
......@@ -36,12 +36,13 @@ RUNTIME_FUNCTION(Runtime_LiveEditFindSharedFunctionInfosForScript) {
if (!heap_obj->IsSharedFunctionInfo()) continue;
SharedFunctionInfo* shared = SharedFunctionInfo::cast(heap_obj);
if (shared->script() != *script) continue;
found.Add(Handle<SharedFunctionInfo>(shared));
found.push_back(Handle<SharedFunctionInfo>(shared));
}
}
Handle<FixedArray> result = isolate->factory()->NewFixedArray(found.length());
for (int i = 0; i < found.length(); ++i) {
int found_size = static_cast<int>(found.size());
Handle<FixedArray> result = isolate->factory()->NewFixedArray(found_size);
for (int i = 0; i < found_size; ++i) {
Handle<SharedFunctionInfo> shared = found[i];
SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(isolate);
Handle<String> name(shared->name(), isolate);
......
......@@ -387,7 +387,7 @@ void CompiledReplacement::Apply(ReplacementStringBuilder* builder,
}
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);
// Collect indices of pattern in subject using memchr.
// Stop after finding at most limit values.
......@@ -398,20 +398,20 @@ void FindOneByteStringIndices(Vector<const uint8_t> subject, uint8_t pattern,
pos = reinterpret_cast<const uint8_t*>(
memchr(pos, pattern, subject_end - pos));
if (pos == NULL) return;
indices->Add(static_cast<int>(pos - subject_start));
indices->push_back(static_cast<int>(pos - subject_start));
pos++;
limit--;
}
}
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);
const uc16* subject_start = subject.start();
const uc16* subject_end = subject_start + subject.length();
for (const uc16* pos = subject_start; pos < subject_end && limit > 0; pos++) {
if (*pos == pattern) {
indices->Add(static_cast<int>(pos - subject_start));
indices->push_back(static_cast<int>(pos - subject_start));
limit--;
}
}
......@@ -419,8 +419,8 @@ void FindTwoByteStringIndices(const Vector<const uc16> subject, uc16 pattern,
template <typename SubjectChar, typename PatternChar>
void FindStringIndices(Isolate* isolate, Vector<const SubjectChar> subject,
Vector<const PatternChar> pattern, List<int>* indices,
unsigned int limit) {
Vector<const PatternChar> pattern,
std::vector<int>* indices, unsigned int limit) {
DCHECK(limit > 0);
// Collect indices of pattern in subject.
// Stop after finding at most limit values.
......@@ -430,14 +430,14 @@ void FindStringIndices(Isolate* isolate, Vector<const SubjectChar> subject,
while (limit > 0) {
index = search.Search(subject, index);
if (index < 0) return;
indices->Add(index);
indices->push_back(index);
index += pattern_length;
limit--;
}
}
void FindStringIndicesDispatch(Isolate* isolate, String* subject,
String* pattern, List<int>* indices,
String* pattern, std::vector<int>* indices,
unsigned int limit) {
{
DisallowHeapAllocation no_gc;
......@@ -488,9 +488,9 @@ void FindStringIndicesDispatch(Isolate* isolate, String* subject,
}
namespace {
List<int>* GetRewoundRegexpIndicesList(Isolate* isolate) {
List<int>* list = isolate->regexp_indices();
list->Rewind(0);
std::vector<int>* GetRewoundRegexpIndicesList(Isolate* isolate) {
std::vector<int>* list = isolate->regexp_indices();
list->clear();
return list;
}
......@@ -498,8 +498,11 @@ void TruncateRegexpIndicesList(Isolate* isolate) {
// Same size as smallest zone segment, preserving behavior from the
// runtime zone.
static const int kMaxRegexpIndicesListCapacity = 8 * KB;
if (isolate->regexp_indices()->capacity() > kMaxRegexpIndicesListCapacity) {
isolate->regexp_indices()->Clear(); // Throw away backing storage
std::vector<int>* indicies = isolate->regexp_indices();
if (indicies->capacity() > kMaxRegexpIndicesListCapacity) {
// Throw away backing storage.
indicies->clear();
indicies->shrink_to_fit();
}
}
} // namespace
......@@ -511,7 +514,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
DCHECK(subject->IsFlat());
DCHECK(replacement->IsFlat());
List<int>* indices = GetRewoundRegexpIndicesList(isolate);
std::vector<int>* indices = GetRewoundRegexpIndicesList(isolate);
DCHECK_EQ(JSRegExp::ATOM, pattern_regexp->TypeTag());
String* pattern =
......@@ -522,13 +525,12 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
FindStringIndicesDispatch(isolate, *subject, pattern, indices, 0xffffffff);
int matches = indices->length();
if (matches == 0) return *subject;
if (indices->empty()) return *subject;
// Detect integer overflow.
int64_t result_len_64 = (static_cast<int64_t>(replacement_len) -
static_cast<int64_t>(pattern_len)) *
static_cast<int64_t>(matches) +
static_cast<int64_t>(indices->size()) +
static_cast<int64_t>(subject_len);
int result_len;
if (result_len_64 > static_cast<int64_t>(String::kMaxLength)) {
......@@ -554,12 +556,12 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, untyped_res, maybe_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.
if (subject_pos < indices->at(i)) {
if (subject_pos < index) {
String::WriteToFlat(*subject, result->GetChars() + result_pos,
subject_pos, indices->at(i));
result_pos += indices->at(i) - subject_pos;
subject_pos, index);
result_pos += index - subject_pos;
}
// Replace match.
......@@ -569,7 +571,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
result_pos += replacement_len;
}
subject_pos = indices->at(i) + pattern_len;
subject_pos = index + pattern_len;
}
// Add remaining subject content at the end.
if (subject_pos < subject_len) {
......@@ -577,8 +579,7 @@ MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString(
subject_len);
}
int32_t match_indices[] = {indices->at(matches - 1),
indices->at(matches - 1) + pattern_len};
int32_t match_indices[] = {indices->back(), indices->back() + pattern_len};
RegExpImpl::SetLastMatchInfo(last_match_info, subject, 0, match_indices);
TruncateRegexpIndicesList(isolate);
......@@ -854,18 +855,18 @@ RUNTIME_FUNCTION(Runtime_StringSplit) {
subject = String::Flatten(subject);
pattern = String::Flatten(pattern);
List<int>* indices = GetRewoundRegexpIndicesList(isolate);
std::vector<int>* indices = GetRewoundRegexpIndicesList(isolate);
FindStringIndicesDispatch(isolate, *subject, *pattern, indices, limit);
if (static_cast<uint32_t>(indices->length()) < limit) {
indices->Add(subject_length);
if (static_cast<uint32_t>(indices->size()) < limit) {
indices->push_back(subject_length);
}
// The list indices now contains the end of each part to create.
// Create JSArray of substrings separated by separator.
int part_count = indices->length();
int part_count = static_cast<int>(indices->size());
Handle<JSArray> result =
isolate->factory()->NewJSArray(PACKED_ELEMENTS, part_count, part_count,
......
......@@ -348,10 +348,10 @@ std::unique_ptr<Handle<Object>[]> GetCallerArguments(Isolate* isolate,
// Find frame containing arguments passed to the caller.
JavaScriptFrameIterator it(isolate);
JavaScriptFrame* frame = it.frame();
List<SharedFunctionInfo*> functions(2);
std::vector<SharedFunctionInfo*> functions;
frame->GetFunctions(&functions);
if (functions.length() > 1) {
int inlined_jsframe_index = functions.length() - 1;
if (functions.size() > 1) {
int inlined_jsframe_index = static_cast<int>(functions.size()) - 1;
TranslatedState translated_values(frame);
translated_values.Prepare(frame->fp());
......
......@@ -10,7 +10,6 @@
#include "src/assembler.h"
#include "src/base/platform/platform.h"
#include "src/flags.h"
#include "src/list.h"
#include "src/msan.h"
#include "src/snapshot/natives.h"
#include "src/snapshot/partial-serializer.h"
......
......@@ -5,8 +5,6 @@
#include "src/snapshot/natives.h"
#include "src/base/logging.h"
#include "src/list.h"
#include "src/list-inl.h"
#include "src/snapshot/snapshot-source-sink.h"
#include "src/vector.h"
......
......@@ -19,7 +19,6 @@
#include "src/base/macros.h"
#include "src/base/platform/platform.h"
#include "src/globals.h"
#include "src/list.h"
#include "src/vector.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