[cleanup] Fix some -Wshadow warnings

Bug: v8:12244,v8:12245
Change-Id: I5890c4a95da6ea8098a0f7d8a90f503a89704d45
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3254003
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77662}
This commit is contained in:
Ng Zhi An 2021-10-29 16:41:02 -07:00 committed by V8 LUCI CQ
parent 1250f6ad36
commit 5ed3770b9f
6 changed files with 52 additions and 47 deletions

View File

@ -220,12 +220,11 @@ void PatchFunctions(v8::Local<v8::Context> context, const char* source_a,
result->message = scope.Escape(result->message);
}
} else {
v8::debug::LiveEditResult result;
v8::debug::LiveEditResult r;
LiveEdit::PatchScript(
i_isolate, i_script_a,
i_isolate->factory()->NewStringFromAsciiChecked(source_b), false,
&result);
CHECK_EQ(result.status, v8::debug::LiveEditResult::OK);
i_isolate->factory()->NewStringFromAsciiChecked(source_b), false, &r);
CHECK_EQ(r.status, v8::debug::LiveEditResult::OK);
}
}
} // anonymous namespace
@ -416,6 +415,8 @@ TEST(LiveEditPatchFunctions) {
" };\n"
"}\n");
CompileRunChecked(env->GetIsolate(), "var new_closure = ChooseAnimal(3, 4);");
{
v8::Local<v8::String> call_result =
CompileRunChecked(env->GetIsolate(), "new_closure()").As<v8::String>();
v8::String::Utf8Value new_result_utf8(env->GetIsolate(), call_result);
@ -424,14 +425,15 @@ TEST(LiveEditPatchFunctions) {
CompileRunChecked(env->GetIsolate(), "old_closure()").As<v8::String>();
v8::String::Utf8Value old_result_utf8(env->GetIsolate(), call_result);
CHECK_NOT_NULL(strstr(*old_result_utf8, "Cat2"));
}
// Update const literals.
PatchFunctions(context, "function foo() { return 'a' + 'b'; }",
"function foo() { return 'c' + 'b'; }");
{
v8::Local<v8::String> result =
v8::Local<v8::String> result_str =
CompileRunChecked(env->GetIsolate(), "foo()").As<v8::String>();
v8::String::Utf8Value new_result_utf8(env->GetIsolate(), result);
v8::String::Utf8Value new_result_utf8(env->GetIsolate(), result_str);
CHECK_NOT_NULL(strstr(*new_result_utf8, "cb"));
}
@ -508,9 +510,9 @@ TEST(LiveEditCompileError) {
strstr(*result_message, "Uncaught SyntaxError: Unexpected token ')'"));
{
v8::Local<v8::String> result =
v8::Local<v8::String> result_str =
CompileRunChecked(env->GetIsolate(), "ChooseAnimal()").As<v8::String>();
v8::String::Utf8Value new_result_utf8(env->GetIsolate(), result);
v8::String::Utf8Value new_result_utf8(env->GetIsolate(), result_str);
CHECK_NOT_NULL(strstr(*new_result_utf8, "Cat"));
}
@ -550,11 +552,11 @@ TEST(LiveEditFunctionExpression) {
&result);
CHECK_EQ(result.status, debug::LiveEditResult::OK);
{
v8::Local<v8::String> result =
v8::Local<v8::String> result_str =
f->Call(context, context->Global(), 0, nullptr)
.ToLocalChecked()
.As<v8::String>();
v8::String::Utf8Value new_result_utf8(env->GetIsolate(), result);
v8::String::Utf8Value new_result_utf8(env->GetIsolate(), result_str);
CHECK_NOT_NULL(strstr(*new_result_utf8, "Capybara"));
}
}

View File

@ -56,7 +56,7 @@ class LocalHandlesThread final : public v8::base::Thread {
sema_started_->Signal();
{
ParkedScope scope(&local_heap);
ParkedScope parked_scope(&local_heap);
sema_gc_finished_->Wait();
}

View File

@ -54,7 +54,7 @@ class PersistentHandlesThread final : public v8::base::Thread {
sema_started_->Signal();
{
ParkedScope scope(&local_heap);
ParkedScope parked_scope(&local_heap);
sema_gc_finished_->Wait();
}

View File

@ -2498,7 +2498,7 @@ static void SerializerCodeEventListener(const v8::JitCodeEvent* event) {
}
v8::ScriptCompiler::CachedData* CompileRunAndProduceCache(
const char* source, CodeCacheType cacheType = CodeCacheType::kLazy) {
const char* js_source, CodeCacheType cacheType = CodeCacheType::kLazy) {
v8::ScriptCompiler::CachedData* cache;
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
@ -2509,7 +2509,7 @@ v8::ScriptCompiler::CachedData* CompileRunAndProduceCache(
v8::Local<v8::Context> context = v8::Context::New(isolate1);
v8::Context::Scope context_scope(context);
v8::Local<v8::String> source_str = v8_str(source);
v8::Local<v8::String> source_str = v8_str(js_source);
v8::ScriptOrigin origin(isolate1, v8_str("test"));
v8::ScriptCompiler::Source source(source_str, origin);
v8::ScriptCompiler::CompileOptions options;
@ -2550,8 +2550,8 @@ v8::ScriptCompiler::CachedData* CompileRunAndProduceCache(
}
TEST(CodeSerializerIsolates) {
const char* source = "function f() { return 'abc'; }; f() + 'def'";
v8::ScriptCompiler::CachedData* cache = CompileRunAndProduceCache(source);
const char* js_source = "function f() { return 'abc'; }; f() + 'def'";
v8::ScriptCompiler::CachedData* cache = CompileRunAndProduceCache(js_source);
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
@ -2565,7 +2565,7 @@ TEST(CodeSerializerIsolates) {
v8::Local<v8::Context> context = v8::Context::New(isolate2);
v8::Context::Scope context_scope(context);
v8::Local<v8::String> source_str = v8_str(source);
v8::Local<v8::String> source_str = v8_str(js_source);
v8::ScriptOrigin origin(isolate2, v8_str("test"));
v8::ScriptCompiler::Source source(source_str, origin, cache);
v8::Local<v8::UnboundScript> script;
@ -2589,7 +2589,7 @@ TEST(CodeSerializerIsolates) {
}
TEST(CodeSerializerIsolatesEager) {
const char* source =
const char* js_source =
"function f() {"
" return function g() {"
" return 'abc';"
@ -2597,7 +2597,7 @@ TEST(CodeSerializerIsolatesEager) {
"}"
"f()() + 'def'";
v8::ScriptCompiler::CachedData* cache =
CompileRunAndProduceCache(source, CodeCacheType::kEager);
CompileRunAndProduceCache(js_source, CodeCacheType::kEager);
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
@ -2611,7 +2611,7 @@ TEST(CodeSerializerIsolatesEager) {
v8::Local<v8::Context> context = v8::Context::New(isolate2);
v8::Context::Scope context_scope(context);
v8::Local<v8::String> source_str = v8_str(source);
v8::Local<v8::String> source_str = v8_str(js_source);
v8::ScriptOrigin origin(isolate2, v8_str("test"));
v8::ScriptCompiler::Source source(source_str, origin, cache);
v8::Local<v8::UnboundScript> script;
@ -2639,9 +2639,9 @@ TEST(CodeSerializerAfterExecute) {
// to always optimize breaks this test.
bool prev_always_opt_value = FLAG_always_opt;
FLAG_always_opt = false;
const char* source = "function f() { return 'abc'; }; f() + 'def'";
const char* js_source = "function f() { return 'abc'; }; f() + 'def'";
v8::ScriptCompiler::CachedData* cache =
CompileRunAndProduceCache(source, CodeCacheType::kAfterExecute);
CompileRunAndProduceCache(js_source, CodeCacheType::kAfterExecute);
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
@ -2654,7 +2654,7 @@ TEST(CodeSerializerAfterExecute) {
v8::Local<v8::Context> context = v8::Context::New(isolate2);
v8::Context::Scope context_scope(context);
v8::Local<v8::String> source_str = v8_str(source);
v8::Local<v8::String> source_str = v8_str(js_source);
v8::ScriptOrigin origin(isolate2, v8_str("test"));
v8::ScriptCompiler::Source source(source_str, origin, cache);
v8::Local<v8::UnboundScript> script;
@ -2690,8 +2690,8 @@ TEST(CodeSerializerAfterExecute) {
}
TEST(CodeSerializerFlagChange) {
const char* source = "function f() { return 'abc'; }; f() + 'def'";
v8::ScriptCompiler::CachedData* cache = CompileRunAndProduceCache(source);
const char* js_source = "function f() { return 'abc'; }; f() + 'def'";
v8::ScriptCompiler::CachedData* cache = CompileRunAndProduceCache(js_source);
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
@ -2705,7 +2705,7 @@ TEST(CodeSerializerFlagChange) {
v8::Local<v8::Context> context = v8::Context::New(isolate2);
v8::Context::Scope context_scope(context);
v8::Local<v8::String> source_str = v8_str(source);
v8::Local<v8::String> source_str = v8_str(js_source);
v8::ScriptOrigin origin(isolate2, v8_str("test"));
v8::ScriptCompiler::Source source(source_str, origin, cache);
v8::ScriptCompiler::CompileUnboundScript(
@ -2717,8 +2717,8 @@ TEST(CodeSerializerFlagChange) {
}
TEST(CodeSerializerBitFlip) {
const char* source = "function f() { return 'abc'; }; f() + 'def'";
v8::ScriptCompiler::CachedData* cache = CompileRunAndProduceCache(source);
const char* js_source = "function f() { return 'abc'; }; f() + 'def'";
v8::ScriptCompiler::CachedData* cache = CompileRunAndProduceCache(js_source);
// Arbitrary bit flip.
int arbitrary_spot = 237;
@ -2734,7 +2734,7 @@ TEST(CodeSerializerBitFlip) {
v8::Local<v8::Context> context = v8::Context::New(isolate2);
v8::Context::Scope context_scope(context);
v8::Local<v8::String> source_str = v8_str(source);
v8::Local<v8::String> source_str = v8_str(js_source);
v8::ScriptOrigin origin(isolate2, v8_str("test"));
v8::ScriptCompiler::Source source(source_str, origin, cache);
v8::ScriptCompiler::CompileUnboundScript(

View File

@ -33,14 +33,14 @@ struct Tests {
using ValueIterator = Types::ValueVector::iterator;
Isolate* isolate;
HandleScope scope;
HandleScope tests_scope;
CanonicalHandleScope canonical;
Zone zone;
Types T;
Tests()
: isolate(CcTest::InitIsolateOnce()),
scope(isolate),
tests_scope(isolate),
canonical(isolate),
zone(isolate->allocator(), ZONE_NAME),
T(&zone, isolate, isolate->random_number_generator()) {}

View File

@ -87,6 +87,8 @@ TEST(BitSetComputer) {
CHECK_EQ(0, BoolComputer::index(0, 8));
CHECK_EQ(100, BoolComputer::index(100, 8));
CHECK_EQ(1, BoolComputer::index(0, 40));
{
uint32_t data = 0;
data = BoolComputer::encode(data, 1, true);
data = BoolComputer::encode(data, 4, true);
@ -95,6 +97,7 @@ TEST(BitSetComputer) {
CHECK(!BoolComputer::decode(data, 0));
CHECK(!BoolComputer::decode(data, 2));
CHECK(!BoolComputer::decode(data, 3));
}
// Lets store 2 bits per item with 3000 items and verify the values are
// correct.