Commit 9611ceaf authored by Ng Zhi An's avatar Ng Zhi An Committed by V8 LUCI CQ

[cctest] Fix -Wshadow warnings in cctest/heap

No functionality change expected.

Most scopes are renamed new_scope or new_handle_scope. For some test
cases the outer scope is renamed to outer_scope since there are
multiple inner scopes.

Bug: v8:12244,v8:12245
Change-Id: I85953617e54f2140fa88c593eb7c186b570fdd04
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3227266Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77442}
parent 5333d90e
......@@ -188,7 +188,7 @@ TEST(ArrayBuffer_UnregisterDuringSweep) {
Handle<JSArrayBuffer> buf = v8::Utils::OpenHandle(*ab);
{
v8::HandleScope handle_scope(isolate);
v8::HandleScope new_handle_scope(isolate);
// Allocate another buffer on the same page to force processing a
// non-empty set of buffers in the last GC.
Local<v8::ArrayBuffer> ab2 = v8::ArrayBuffer::New(isolate, 100);
......@@ -226,7 +226,7 @@ TEST(ArrayBuffer_NonLivePromotion) {
Handle<FixedArray> root =
heap->isolate()->factory()->NewFixedArray(1, AllocationType::kOld);
{
v8::HandleScope handle_scope(isolate);
v8::HandleScope new_handle_scope(isolate);
Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 100);
Handle<JSArrayBuffer> buf = v8::Utils::OpenHandle(*ab);
root->set(0, *buf); // Buffer that should not be promoted as live.
......@@ -264,7 +264,7 @@ TEST(ArrayBuffer_LivePromotion) {
Handle<FixedArray> root =
heap->isolate()->factory()->NewFixedArray(1, AllocationType::kOld);
{
v8::HandleScope handle_scope(isolate);
v8::HandleScope new_handle_scope(isolate);
Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 100);
Handle<JSArrayBuffer> buf = v8::Utils::OpenHandle(*ab);
root->set(0, *buf); // Buffer that should be promoted as live.
......@@ -305,7 +305,7 @@ TEST(ArrayBuffer_SemiSpaceCopyThenPagePromotion) {
Handle<FixedArray> root =
heap->isolate()->factory()->NewFixedArray(1, AllocationType::kOld);
{
v8::HandleScope handle_scope(isolate);
v8::HandleScope new_handle_scope(isolate);
Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 100);
Handle<JSArrayBuffer> buf = v8::Utils::OpenHandle(*ab);
root->set(0, *buf); // Buffer that should be promoted as live.
......@@ -343,7 +343,7 @@ TEST(ArrayBuffer_PagePromotion) {
heap->isolate()->factory()->NewFixedArray(1, AllocationType::kOld);
ArrayBufferExtension* extension;
{
v8::HandleScope handle_scope(isolate);
v8::HandleScope new_handle_scope(isolate);
Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(isolate, 100);
Handle<JSArrayBuffer> buf = v8::Utils::OpenHandle(*ab);
extension = buf->extension();
......
......@@ -366,7 +366,7 @@ TEST(TracedGlobalInStdVector) {
std::vector<v8::TracedGlobal<v8::Object>> vec;
{
v8::HandleScope scope(isolate);
v8::HandleScope new_scope(isolate);
vec.emplace_back(isolate, v8::Object::New(isolate));
}
CHECK(!vec[0].IsEmpty());
......@@ -378,7 +378,7 @@ TEST(TracedGlobalCopyWithDestructor) {
ManualGCScope manual_gc;
CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::HandleScope outer_scope(isolate);
i::GlobalHandles* global_handles = CcTest::i_isolate()->global_handles();
const size_t initial_count = global_handles->handles_count();
......@@ -415,7 +415,7 @@ TEST(TracedGlobalCopyNoDestructor) {
ManualGCScope manual_gc;
CcTest::InitializeVM();
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
v8::HandleScope outer_scope(isolate);
i::GlobalHandles* global_handles = CcTest::i_isolate()->global_handles();
const size_t initial_count = global_handles->handles_count();
......@@ -453,7 +453,7 @@ TEST(TracedGlobalInStdUnorderedMap) {
std::unordered_map<int, v8::TracedGlobal<v8::Object>> map;
{
v8::HandleScope scope(isolate);
v8::HandleScope new_scope(isolate);
map.emplace(std::piecewise_construct, std::forward_as_tuple(1),
std::forward_as_tuple(isolate, v8::Object::New(isolate)));
}
......@@ -652,7 +652,7 @@ TEST(TracedGlobalIteration) {
traced->SetWrapperClassId(57);
TracedGlobalVisitor visitor;
{
v8::HandleScope scope(isolate);
v8::HandleScope new_scope(isolate);
tracer.IterateTracedGlobalHandles(&visitor);
}
CHECK_EQ(1, visitor.count());
......@@ -684,7 +684,7 @@ TEST(TracedGlobalSetFinalizationCallbackScavenge) {
ConstructJSApiObject(isolate, isolate->GetCurrentContext(), traced.get());
CHECK(!traced->IsEmpty());
{
v8::HandleScope scope(isolate);
v8::HandleScope new_scope(isolate);
auto local = traced->Get(isolate);
local->SetAlignedPointerInInternalField(0, reinterpret_cast<void*>(0x4));
local->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(0x8));
......@@ -706,7 +706,7 @@ TEST(TracedGlobalSetFinalizationCallbackMarkSweep) {
ConstructJSApiObject(isolate, isolate->GetCurrentContext(), traced.get());
CHECK(!traced->IsEmpty());
{
v8::HandleScope scope(isolate);
v8::HandleScope new_scope(isolate);
auto local = traced->Get(isolate);
local->SetAlignedPointerInInternalField(0, reinterpret_cast<void*>(0x4));
local->SetAlignedPointerInInternalField(1, reinterpret_cast<void*>(0x8));
......@@ -725,7 +725,7 @@ TEST(TracePrologueCallingIntoV8WriteBarrier) {
v8::HandleScope scope(isolate);
v8::Global<v8::Array> global;
{
v8::HandleScope scope(isolate);
v8::HandleScope new_scope(isolate);
auto local = v8::Array::New(isolate, 10);
global.Reset(isolate, local);
}
......@@ -750,7 +750,7 @@ TEST(TracedGlobalWithDestructor) {
const size_t initial_count = global_handles->handles_count();
auto* traced = new v8::TracedGlobal<v8::Object>();
{
v8::HandleScope scope(isolate);
v8::HandleScope new_scope(isolate);
v8::Local<v8::Object> object(ConstructTraceableJSApiObject(
isolate->GetCurrentContext(), nullptr, nullptr));
CHECK(traced->IsEmpty());
......@@ -778,7 +778,7 @@ TEST(TracedGlobalNoDestructor) {
char* memory = new char[sizeof(v8::TracedReference<v8::Value>)];
auto* traced = new (memory) v8::TracedReference<v8::Value>();
{
v8::HandleScope scope(isolate);
v8::HandleScope new_scope(isolate);
v8::Local<v8::Value> object(ConstructTraceableJSApiObject(
isolate->GetCurrentContext(), nullptr, nullptr));
CHECK(traced->IsEmpty());
......
......@@ -1131,7 +1131,7 @@ TEST(TestBytecodeFlushing) {
// This compile will add the code to the compilation cache.
{
v8::HandleScope scope(isolate);
v8::HandleScope new_scope(isolate);
CompileRun(source);
}
......@@ -1350,7 +1350,7 @@ TEST(TestOptimizeAfterBytecodeFlushingCandidate) {
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
Factory* factory = isolate->factory();
v8::HandleScope scope(CcTest::isolate());
v8::HandleScope outer_scope(CcTest::isolate());
const char* source =
"function foo() {"
" var x = 42;"
......@@ -1476,7 +1476,7 @@ TEST(CompilationCacheCachingBehavior) {
CompilationCache* compilation_cache = isolate->compilation_cache();
LanguageMode language_mode = construct_language_mode(FLAG_use_strict);
v8::HandleScope scope(CcTest::isolate());
v8::HandleScope outer_scope(CcTest::isolate());
const char* raw_source =
"function foo() {"
" var x = 42;"
......@@ -1595,7 +1595,7 @@ TEST(TestInternalWeakLists) {
// Create a handle scope so no function objects get stuck in the outer
// handle scope.
HandleScope scope(isolate);
HandleScope new_scope(isolate);
OptimizeEmptyFunction("f1");
OptimizeEmptyFunction("f2");
OptimizeEmptyFunction("f3");
......@@ -3459,7 +3459,7 @@ void ReleaseStackTraceDataTest(v8::Isolate* isolate, const char* source,
v8::HandleScope scope(isolate);
SourceResource* resource = new SourceResource(i::StrDup(source));
{
v8::HandleScope scope(isolate);
v8::HandleScope new_scope(isolate);
v8::Local<v8::Context> ctx = isolate->GetCurrentContext();
v8::Local<v8::String> source_string =
v8::String::NewExternalOneByte(isolate, resource).ToLocalChecked();
......@@ -4490,7 +4490,7 @@ TEST(WeakFunctionInConstructor) {
v8::Persistent<v8::Object> garbage;
{
v8::HandleScope scope(isolate);
v8::HandleScope new_scope(isolate);
const char* source =
" (function() {"
" function hat() { this.x = 5; }"
......@@ -4543,7 +4543,7 @@ void CheckWeakness(const char* source) {
v8::HandleScope scope(isolate);
v8::Persistent<v8::Object> garbage;
{
v8::HandleScope scope(isolate);
v8::HandleScope new_scope(isolate);
garbage.Reset(isolate, CompileRun(env.local(), source)
.ToLocalChecked()
->ToObject(env.local())
......@@ -4763,13 +4763,13 @@ TEST(MonomorphicStaysMonomorphicAfterGC) {
"};");
Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC");
{
v8::HandleScope scope(CcTest::isolate());
v8::HandleScope new_scope(CcTest::isolate());
CompileRun("(testIC())");
}
CcTest::CollectAllGarbage();
CheckIC(loadIC, 0, MONOMORPHIC);
{
v8::HandleScope scope(CcTest::isolate());
v8::HandleScope new_scope(CcTest::isolate());
CompileRun("(testIC())");
}
CheckIC(loadIC, 0, MONOMORPHIC);
......@@ -4802,13 +4802,13 @@ TEST(PolymorphicStaysPolymorphicAfterGC) {
"};");
Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC");
{
v8::HandleScope scope(CcTest::isolate());
v8::HandleScope new_scope(CcTest::isolate());
CompileRun("(testIC())");
}
CcTest::CollectAllGarbage();
CheckIC(loadIC, 0, POLYMORPHIC);
{
v8::HandleScope scope(CcTest::isolate());
v8::HandleScope new_scope(CcTest::isolate());
CompileRun("(testIC())");
}
CheckIC(loadIC, 0, POLYMORPHIC);
......@@ -5625,7 +5625,7 @@ TEST(Regress598319) {
root = isolate->factory()->NewFixedArray(1, AllocationType::kOld);
{
// Temporary scope to avoid getting any other objects into the root set.
v8::HandleScope scope(CcTest::isolate());
v8::HandleScope new_scope(CcTest::isolate());
Handle<FixedArray> tmp = isolate->factory()->NewFixedArray(
number_of_objects, AllocationType::kOld);
root->set(0, *tmp);
......@@ -5695,7 +5695,7 @@ TEST(Regress598319) {
{
// Shift by 1, effectively moving one white object across the progress
// bar, meaning that we will miss marking it.
v8::HandleScope scope(CcTest::isolate());
v8::HandleScope new_scope(CcTest::isolate());
Handle<JSArray> js_array = isolate->factory()->NewJSArrayWithElements(
Handle<FixedArray>(arr.get(), isolate));
js_array->GetElementsAccessor()->Shift(js_array).Check();
......@@ -5711,7 +5711,7 @@ TEST(Regress598319) {
i::IncrementalMarking::NO_GC_VIA_STACK_GUARD,
StepOrigin::kV8);
if (marking->IsReadyToOverApproximateWeakClosure()) {
SafepointScope scope(heap);
SafepointScope safepoint_scope(heap);
marking->FinalizeIncrementally();
}
}
......@@ -5801,7 +5801,7 @@ TEST(Regress615489) {
marking->Step(kStepSizeInMs, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD,
StepOrigin::kV8);
if (marking->IsReadyToOverApproximateWeakClosure()) {
SafepointScope scope(heap);
SafepointScope safepoint_scope(heap);
marking->FinalizeIncrementally();
}
}
......@@ -5864,7 +5864,7 @@ TEST(Regress631969) {
marking->Step(kStepSizeInMs, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD,
StepOrigin::kV8);
if (marking->IsReadyToOverApproximateWeakClosure()) {
SafepointScope scope(heap);
SafepointScope safepoint_scope(heap);
marking->FinalizeIncrementally();
}
}
......@@ -6044,7 +6044,7 @@ TEST(ContinuousRightTrimFixedArrayInBlackArea) {
for (int j = 0; j < 10; j++) {
previous -= kTaggedSize * i;
isolate->heap()->RightTrimFixedArray(*array, i);
HeapObject filler = HeapObject::FromAddress(previous);
filler = HeapObject::FromAddress(previous);
CHECK(filler.IsFreeSpaceOrFiller());
CHECK(marking_state->IsWhite(filler));
}
......@@ -6142,7 +6142,7 @@ TEST(YoungGenerationLargeObjectAllocationReleaseScavenger) {
if (!isolate->serializer_enabled()) return;
{
HandleScope scope(isolate);
HandleScope new_scope(isolate);
for (int i = 0; i < 10; i++) {
Handle<FixedArray> array_small = isolate->factory()->NewFixedArray(20000);
MemoryChunk* chunk = MemoryChunk::FromHeapObject(*array_small);
......@@ -6458,7 +6458,7 @@ HEAP_TEST(Regress670675) {
}
i::IncrementalMarking* marking = CcTest::heap()->incremental_marking();
if (marking->IsStopped()) {
SafepointScope scope(heap);
SafepointScope safepoint_scope(heap);
marking->Start(i::GarbageCollectionReason::kTesting);
}
size_t array_length = 128 * KB;
......@@ -6677,7 +6677,7 @@ HEAP_TEST(Regress779503) {
}
{
HandleScope handle_scope(isolate);
HandleScope new_scope(isolate);
// The FixedArray in old space serves as space for slots.
Handle<FixedArray> fixed_array =
isolate->factory()->NewFixedArray(kArraySize, AllocationType::kOld);
......
......@@ -219,7 +219,7 @@ HEAP_TEST(InvalidatedSlotsRightTrimFixedArray) {
trimmed->set(i, *evacuated);
}
{
HandleScope scope(isolate);
HandleScope new_scope(isolate);
Handle<HeapObject> dead = factory->NewFixedArray(1);
for (int i = 1; i < trimmed->length(); i++) {
trimmed->set(i, *dead);
......@@ -257,7 +257,7 @@ HEAP_TEST(InvalidatedSlotsRightTrimLargeFixedArray) {
trimmed->set(i, *evacuated);
}
{
HandleScope scope(isolate);
HandleScope new_scope(isolate);
Handle<HeapObject> dead = factory->NewFixedArray(1);
for (int i = 1; i < trimmed->length(); i++) {
trimmed->set(i, *dead);
......@@ -289,7 +289,7 @@ HEAP_TEST(InvalidatedSlotsLeftTrimFixedArray) {
trimmed->set(i, *evacuated);
}
{
HandleScope scope(isolate);
HandleScope new_scope(isolate);
Handle<HeapObject> dead = factory->NewFixedArray(1);
for (int i = 1; i < trimmed->length(); i++) {
trimmed->set(i, *dead);
......@@ -339,7 +339,7 @@ HEAP_TEST(InvalidatedSlotsFastToSlow) {
Object::SetProperty(isolate, obj, prop_name3, evacuated).Check();
{
HandleScope scope(isolate);
HandleScope new_scope(isolate);
Handle<HeapObject> dead = factory->NewFixedArray(1);
Object::SetProperty(isolate, obj, prop_name1, dead).Check();
Object::SetProperty(isolate, obj, prop_name2, dead).Check();
......
......@@ -173,12 +173,12 @@ void AllocateInSharedHeap(Isolate* shared_isolate) {
const int kKeptAliveArrays = 1000;
for (int i = 0; i < kNumIterations * 100; i++) {
HandleScope scope(i_client_isolate);
HandleScope new_scope(i_client_isolate);
Handle<FixedArray> array = i_client_isolate->factory()->NewFixedArray(
100, AllocationType::kSharedOld);
if (i < kKeptAliveArrays) {
// Keep some of those arrays alive across GCs.
arrays.push_back(scope.CloseAndEscape(array));
arrays.push_back(new_scope.CloseAndEscape(array));
}
}
......
......@@ -344,7 +344,7 @@ TEST(OldLargeObjectSpace) {
{
AllocationResult allocation = lo->AllocateRaw(lo_size);
if (allocation.IsRetry()) break;
HeapObject ho = HeapObject::cast(allocation.ToObjectChecked());
ho = HeapObject::cast(allocation.ToObjectChecked());
Handle<HeapObject> keep_alive(ho, isolate);
}
}
......
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