Commit 5ed3770b authored by Ng Zhi An's avatar Ng Zhi An Committed by V8 LUCI CQ

[cleanup] Fix some -Wshadow warnings

Bug: v8:12244,v8:12245
Change-Id: I5890c4a95da6ea8098a0f7d8a90f503a89704d45
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3254003Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77662}
parent 1250f6ad
...@@ -220,12 +220,11 @@ void PatchFunctions(v8::Local<v8::Context> context, const char* source_a, ...@@ -220,12 +220,11 @@ void PatchFunctions(v8::Local<v8::Context> context, const char* source_a,
result->message = scope.Escape(result->message); result->message = scope.Escape(result->message);
} }
} else { } else {
v8::debug::LiveEditResult result; v8::debug::LiveEditResult r;
LiveEdit::PatchScript( LiveEdit::PatchScript(
i_isolate, i_script_a, i_isolate, i_script_a,
i_isolate->factory()->NewStringFromAsciiChecked(source_b), false, i_isolate->factory()->NewStringFromAsciiChecked(source_b), false, &r);
&result); CHECK_EQ(r.status, v8::debug::LiveEditResult::OK);
CHECK_EQ(result.status, v8::debug::LiveEditResult::OK);
} }
} }
} // anonymous namespace } // anonymous namespace
...@@ -416,22 +415,25 @@ TEST(LiveEditPatchFunctions) { ...@@ -416,22 +415,25 @@ TEST(LiveEditPatchFunctions) {
" };\n" " };\n"
"}\n"); "}\n");
CompileRunChecked(env->GetIsolate(), "var new_closure = ChooseAnimal(3, 4);"); 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); v8::Local<v8::String> call_result =
CHECK_NOT_NULL(strstr(*new_result_utf8, "Capybara4")); CompileRunChecked(env->GetIsolate(), "new_closure()").As<v8::String>();
call_result = v8::String::Utf8Value new_result_utf8(env->GetIsolate(), call_result);
CompileRunChecked(env->GetIsolate(), "old_closure()").As<v8::String>(); CHECK_NOT_NULL(strstr(*new_result_utf8, "Capybara4"));
v8::String::Utf8Value old_result_utf8(env->GetIsolate(), call_result); call_result =
CHECK_NOT_NULL(strstr(*old_result_utf8, "Cat2")); 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. // Update const literals.
PatchFunctions(context, "function foo() { return 'a' + 'b'; }", PatchFunctions(context, "function foo() { return 'a' + 'b'; }",
"function foo() { return 'c' + 'b'; }"); "function foo() { return 'c' + 'b'; }");
{ {
v8::Local<v8::String> result = v8::Local<v8::String> result_str =
CompileRunChecked(env->GetIsolate(), "foo()").As<v8::String>(); 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")); CHECK_NOT_NULL(strstr(*new_result_utf8, "cb"));
} }
...@@ -508,9 +510,9 @@ TEST(LiveEditCompileError) { ...@@ -508,9 +510,9 @@ TEST(LiveEditCompileError) {
strstr(*result_message, "Uncaught SyntaxError: Unexpected token ')'")); 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>(); 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")); CHECK_NOT_NULL(strstr(*new_result_utf8, "Cat"));
} }
...@@ -550,11 +552,11 @@ TEST(LiveEditFunctionExpression) { ...@@ -550,11 +552,11 @@ TEST(LiveEditFunctionExpression) {
&result); &result);
CHECK_EQ(result.status, debug::LiveEditResult::OK); 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) f->Call(context, context->Global(), 0, nullptr)
.ToLocalChecked() .ToLocalChecked()
.As<v8::String>(); .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")); CHECK_NOT_NULL(strstr(*new_result_utf8, "Capybara"));
} }
} }
......
...@@ -56,7 +56,7 @@ class LocalHandlesThread final : public v8::base::Thread { ...@@ -56,7 +56,7 @@ class LocalHandlesThread final : public v8::base::Thread {
sema_started_->Signal(); sema_started_->Signal();
{ {
ParkedScope scope(&local_heap); ParkedScope parked_scope(&local_heap);
sema_gc_finished_->Wait(); sema_gc_finished_->Wait();
} }
......
...@@ -54,7 +54,7 @@ class PersistentHandlesThread final : public v8::base::Thread { ...@@ -54,7 +54,7 @@ class PersistentHandlesThread final : public v8::base::Thread {
sema_started_->Signal(); sema_started_->Signal();
{ {
ParkedScope scope(&local_heap); ParkedScope parked_scope(&local_heap);
sema_gc_finished_->Wait(); sema_gc_finished_->Wait();
} }
......
...@@ -2498,7 +2498,7 @@ static void SerializerCodeEventListener(const v8::JitCodeEvent* event) { ...@@ -2498,7 +2498,7 @@ static void SerializerCodeEventListener(const v8::JitCodeEvent* event) {
} }
v8::ScriptCompiler::CachedData* CompileRunAndProduceCache( v8::ScriptCompiler::CachedData* CompileRunAndProduceCache(
const char* source, CodeCacheType cacheType = CodeCacheType::kLazy) { const char* js_source, CodeCacheType cacheType = CodeCacheType::kLazy) {
v8::ScriptCompiler::CachedData* cache; v8::ScriptCompiler::CachedData* cache;
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
...@@ -2509,7 +2509,7 @@ v8::ScriptCompiler::CachedData* CompileRunAndProduceCache( ...@@ -2509,7 +2509,7 @@ v8::ScriptCompiler::CachedData* CompileRunAndProduceCache(
v8::Local<v8::Context> context = v8::Context::New(isolate1); v8::Local<v8::Context> context = v8::Context::New(isolate1);
v8::Context::Scope context_scope(context); 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::ScriptOrigin origin(isolate1, v8_str("test"));
v8::ScriptCompiler::Source source(source_str, origin); v8::ScriptCompiler::Source source(source_str, origin);
v8::ScriptCompiler::CompileOptions options; v8::ScriptCompiler::CompileOptions options;
...@@ -2550,8 +2550,8 @@ v8::ScriptCompiler::CachedData* CompileRunAndProduceCache( ...@@ -2550,8 +2550,8 @@ v8::ScriptCompiler::CachedData* CompileRunAndProduceCache(
} }
TEST(CodeSerializerIsolates) { TEST(CodeSerializerIsolates) {
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); v8::ScriptCompiler::CachedData* cache = CompileRunAndProduceCache(js_source);
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
...@@ -2565,7 +2565,7 @@ TEST(CodeSerializerIsolates) { ...@@ -2565,7 +2565,7 @@ TEST(CodeSerializerIsolates) {
v8::Local<v8::Context> context = v8::Context::New(isolate2); v8::Local<v8::Context> context = v8::Context::New(isolate2);
v8::Context::Scope context_scope(context); 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::ScriptOrigin origin(isolate2, v8_str("test"));
v8::ScriptCompiler::Source source(source_str, origin, cache); v8::ScriptCompiler::Source source(source_str, origin, cache);
v8::Local<v8::UnboundScript> script; v8::Local<v8::UnboundScript> script;
...@@ -2589,7 +2589,7 @@ TEST(CodeSerializerIsolates) { ...@@ -2589,7 +2589,7 @@ TEST(CodeSerializerIsolates) {
} }
TEST(CodeSerializerIsolatesEager) { TEST(CodeSerializerIsolatesEager) {
const char* source = const char* js_source =
"function f() {" "function f() {"
" return function g() {" " return function g() {"
" return 'abc';" " return 'abc';"
...@@ -2597,7 +2597,7 @@ TEST(CodeSerializerIsolatesEager) { ...@@ -2597,7 +2597,7 @@ TEST(CodeSerializerIsolatesEager) {
"}" "}"
"f()() + 'def'"; "f()() + 'def'";
v8::ScriptCompiler::CachedData* cache = v8::ScriptCompiler::CachedData* cache =
CompileRunAndProduceCache(source, CodeCacheType::kEager); CompileRunAndProduceCache(js_source, CodeCacheType::kEager);
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
...@@ -2611,7 +2611,7 @@ TEST(CodeSerializerIsolatesEager) { ...@@ -2611,7 +2611,7 @@ TEST(CodeSerializerIsolatesEager) {
v8::Local<v8::Context> context = v8::Context::New(isolate2); v8::Local<v8::Context> context = v8::Context::New(isolate2);
v8::Context::Scope context_scope(context); 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::ScriptOrigin origin(isolate2, v8_str("test"));
v8::ScriptCompiler::Source source(source_str, origin, cache); v8::ScriptCompiler::Source source(source_str, origin, cache);
v8::Local<v8::UnboundScript> script; v8::Local<v8::UnboundScript> script;
...@@ -2639,9 +2639,9 @@ TEST(CodeSerializerAfterExecute) { ...@@ -2639,9 +2639,9 @@ TEST(CodeSerializerAfterExecute) {
// to always optimize breaks this test. // to always optimize breaks this test.
bool prev_always_opt_value = FLAG_always_opt; bool prev_always_opt_value = FLAG_always_opt;
FLAG_always_opt = false; 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 = v8::ScriptCompiler::CachedData* cache =
CompileRunAndProduceCache(source, CodeCacheType::kAfterExecute); CompileRunAndProduceCache(js_source, CodeCacheType::kAfterExecute);
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
...@@ -2654,7 +2654,7 @@ TEST(CodeSerializerAfterExecute) { ...@@ -2654,7 +2654,7 @@ TEST(CodeSerializerAfterExecute) {
v8::Local<v8::Context> context = v8::Context::New(isolate2); v8::Local<v8::Context> context = v8::Context::New(isolate2);
v8::Context::Scope context_scope(context); 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::ScriptOrigin origin(isolate2, v8_str("test"));
v8::ScriptCompiler::Source source(source_str, origin, cache); v8::ScriptCompiler::Source source(source_str, origin, cache);
v8::Local<v8::UnboundScript> script; v8::Local<v8::UnboundScript> script;
...@@ -2690,8 +2690,8 @@ TEST(CodeSerializerAfterExecute) { ...@@ -2690,8 +2690,8 @@ TEST(CodeSerializerAfterExecute) {
} }
TEST(CodeSerializerFlagChange) { TEST(CodeSerializerFlagChange) {
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); v8::ScriptCompiler::CachedData* cache = CompileRunAndProduceCache(js_source);
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
...@@ -2705,7 +2705,7 @@ TEST(CodeSerializerFlagChange) { ...@@ -2705,7 +2705,7 @@ TEST(CodeSerializerFlagChange) {
v8::Local<v8::Context> context = v8::Context::New(isolate2); v8::Local<v8::Context> context = v8::Context::New(isolate2);
v8::Context::Scope context_scope(context); 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::ScriptOrigin origin(isolate2, v8_str("test"));
v8::ScriptCompiler::Source source(source_str, origin, cache); v8::ScriptCompiler::Source source(source_str, origin, cache);
v8::ScriptCompiler::CompileUnboundScript( v8::ScriptCompiler::CompileUnboundScript(
...@@ -2717,8 +2717,8 @@ TEST(CodeSerializerFlagChange) { ...@@ -2717,8 +2717,8 @@ TEST(CodeSerializerFlagChange) {
} }
TEST(CodeSerializerBitFlip) { TEST(CodeSerializerBitFlip) {
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); v8::ScriptCompiler::CachedData* cache = CompileRunAndProduceCache(js_source);
// Arbitrary bit flip. // Arbitrary bit flip.
int arbitrary_spot = 237; int arbitrary_spot = 237;
...@@ -2734,7 +2734,7 @@ TEST(CodeSerializerBitFlip) { ...@@ -2734,7 +2734,7 @@ TEST(CodeSerializerBitFlip) {
v8::Local<v8::Context> context = v8::Context::New(isolate2); v8::Local<v8::Context> context = v8::Context::New(isolate2);
v8::Context::Scope context_scope(context); 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::ScriptOrigin origin(isolate2, v8_str("test"));
v8::ScriptCompiler::Source source(source_str, origin, cache); v8::ScriptCompiler::Source source(source_str, origin, cache);
v8::ScriptCompiler::CompileUnboundScript( v8::ScriptCompiler::CompileUnboundScript(
......
...@@ -33,14 +33,14 @@ struct Tests { ...@@ -33,14 +33,14 @@ struct Tests {
using ValueIterator = Types::ValueVector::iterator; using ValueIterator = Types::ValueVector::iterator;
Isolate* isolate; Isolate* isolate;
HandleScope scope; HandleScope tests_scope;
CanonicalHandleScope canonical; CanonicalHandleScope canonical;
Zone zone; Zone zone;
Types T; Types T;
Tests() Tests()
: isolate(CcTest::InitIsolateOnce()), : isolate(CcTest::InitIsolateOnce()),
scope(isolate), tests_scope(isolate),
canonical(isolate), canonical(isolate),
zone(isolate->allocator(), ZONE_NAME), zone(isolate->allocator(), ZONE_NAME),
T(&zone, isolate, isolate->random_number_generator()) {} T(&zone, isolate, isolate->random_number_generator()) {}
......
...@@ -87,14 +87,17 @@ TEST(BitSetComputer) { ...@@ -87,14 +87,17 @@ TEST(BitSetComputer) {
CHECK_EQ(0, BoolComputer::index(0, 8)); CHECK_EQ(0, BoolComputer::index(0, 8));
CHECK_EQ(100, BoolComputer::index(100, 8)); CHECK_EQ(100, BoolComputer::index(100, 8));
CHECK_EQ(1, BoolComputer::index(0, 40)); CHECK_EQ(1, BoolComputer::index(0, 40));
uint32_t data = 0;
data = BoolComputer::encode(data, 1, true); {
data = BoolComputer::encode(data, 4, true); uint32_t data = 0;
CHECK(BoolComputer::decode(data, 1)); data = BoolComputer::encode(data, 1, true);
CHECK(BoolComputer::decode(data, 4)); data = BoolComputer::encode(data, 4, true);
CHECK(!BoolComputer::decode(data, 0)); CHECK(BoolComputer::decode(data, 1));
CHECK(!BoolComputer::decode(data, 2)); CHECK(BoolComputer::decode(data, 4));
CHECK(!BoolComputer::decode(data, 3)); 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 // Lets store 2 bits per item with 3000 items and verify the values are
// correct. // correct.
......
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