Commit 5426000a authored by Ng Zhi An's avatar Ng Zhi An Committed by V8 LUCI CQ

[debug] Fix -Wshadow warnings

Bug: v8:12244,v8:12245
Change-Id: I68aeaf1f30a03295ef76bb07037e809ed91f6977
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3266009Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77775}
parent 933f41e1
...@@ -70,14 +70,15 @@ Local<String> GetFunctionDescription(Local<Function> function) { ...@@ -70,14 +70,15 @@ Local<String> GetFunctionDescription(Local<Function> function) {
i::Handle<i::JSBoundFunction>::cast(receiver))); i::Handle<i::JSBoundFunction>::cast(receiver)));
} }
if (receiver->IsJSFunction()) { if (receiver->IsJSFunction()) {
auto function = i::Handle<i::JSFunction>::cast(receiver); auto js_function = i::Handle<i::JSFunction>::cast(receiver);
#if V8_ENABLE_WEBASSEMBLY #if V8_ENABLE_WEBASSEMBLY
if (function->shared().HasWasmExportedFunctionData()) { if (js_function->shared().HasWasmExportedFunctionData()) {
auto isolate = function->GetIsolate(); auto isolate = js_function->GetIsolate();
auto func_index = auto func_index =
function->shared().wasm_exported_function_data().function_index(); js_function->shared().wasm_exported_function_data().function_index();
auto instance = i::handle( auto instance = i::handle(
function->shared().wasm_exported_function_data().instance(), isolate); js_function->shared().wasm_exported_function_data().instance(),
isolate);
if (instance->module()->origin == i::wasm::kWasmOrigin) { if (instance->module()->origin == i::wasm::kWasmOrigin) {
// For asm.js functions, we can still print the source // For asm.js functions, we can still print the source
// code (hopefully), so don't bother with them here. // code (hopefully), so don't bother with them here.
...@@ -91,7 +92,7 @@ Local<String> GetFunctionDescription(Local<Function> function) { ...@@ -91,7 +92,7 @@ Local<String> GetFunctionDescription(Local<Function> function) {
} }
} }
#endif // V8_ENABLE_WEBASSEMBLY #endif // V8_ENABLE_WEBASSEMBLY
return Utils::ToLocal(i::JSFunction::ToString(function)); return Utils::ToLocal(i::JSFunction::ToString(js_function));
} }
return Utils::ToLocal( return Utils::ToLocal(
receiver->GetIsolate()->factory()->function_native_code_string()); receiver->GetIsolate()->factory()->function_native_code_string());
...@@ -148,13 +149,13 @@ void CollectPrivateMethodsAndAccessorsFromContext( ...@@ -148,13 +149,13 @@ void CollectPrivateMethodsAndAccessorsFromContext(
} // namespace } // namespace
bool GetPrivateMembers(Local<Context> context, Local<Object> value, bool GetPrivateMembers(Local<Context> context, Local<Object> object,
std::vector<Local<Value>>* names_out, std::vector<Local<Value>>* names_out,
std::vector<Local<Value>>* values_out) { std::vector<Local<Value>>* values_out) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate());
LOG_API(isolate, debug, GetPrivateMembers); LOG_API(isolate, debug, GetPrivateMembers);
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
i::Handle<i::JSReceiver> receiver = Utils::OpenHandle(*value); i::Handle<i::JSReceiver> receiver = Utils::OpenHandle(*object);
i::Handle<i::JSArray> names; i::Handle<i::JSArray> names;
i::Handle<i::FixedArray> values; i::Handle<i::FixedArray> values;
...@@ -179,8 +180,8 @@ bool GetPrivateMembers(Local<Context> context, Local<Object> value, ...@@ -179,8 +180,8 @@ bool GetPrivateMembers(Local<Context> context, Local<Object> value,
isolate, value, i::Object::GetProperty(isolate, receiver, key), isolate, value, i::Object::GetProperty(isolate, receiver, key),
false); false);
i::Handle<i::Context> context(i::Context::cast(*value), isolate); i::Handle<i::Context> value_context(i::Context::cast(*value), isolate);
i::Handle<i::ScopeInfo> scope_info(context->scope_info(), isolate); i::Handle<i::ScopeInfo> scope_info(value_context->scope_info(), isolate);
// At least one slot contains the brand symbol so it does not count. // At least one slot contains the brand symbol so it does not count.
private_entries_count += (scope_info->ContextLocalCount() - 1); private_entries_count += (scope_info->ContextLocalCount() - 1);
} else { } else {
...@@ -196,8 +197,8 @@ bool GetPrivateMembers(Local<Context> context, Local<Object> value, ...@@ -196,8 +197,8 @@ bool GetPrivateMembers(Local<Context> context, Local<Object> value,
if (shared->is_class_constructor() && if (shared->is_class_constructor() &&
shared->has_static_private_methods_or_accessors()) { shared->has_static_private_methods_or_accessors()) {
has_static_private_methods_or_accessors = true; has_static_private_methods_or_accessors = true;
i::Handle<i::Context> context(func->context(), isolate); i::Handle<i::Context> func_context(func->context(), isolate);
i::Handle<i::ScopeInfo> scope_info(context->scope_info(), isolate); i::Handle<i::ScopeInfo> scope_info(func_context->scope_info(), isolate);
int local_count = scope_info->ContextLocalCount(); int local_count = scope_info->ContextLocalCount();
for (int j = 0; j < local_count; ++j) { for (int j = 0; j < local_count; ++j) {
i::VariableMode mode = scope_info->ContextLocalMode(j); i::VariableMode mode = scope_info->ContextLocalMode(j);
...@@ -218,10 +219,11 @@ bool GetPrivateMembers(Local<Context> context, Local<Object> value, ...@@ -218,10 +219,11 @@ bool GetPrivateMembers(Local<Context> context, Local<Object> value,
values_out->reserve(private_entries_count); values_out->reserve(private_entries_count);
if (has_static_private_methods_or_accessors) { if (has_static_private_methods_or_accessors) {
i::Handle<i::Context> context(i::JSFunction::cast(*receiver).context(), i::Handle<i::Context> recevier_context(
isolate); i::JSFunction::cast(*receiver).context(), isolate);
CollectPrivateMethodsAndAccessorsFromContext( CollectPrivateMethodsAndAccessorsFromContext(isolate, recevier_context,
isolate, context, i::IsStaticFlag::kStatic, names_out, values_out); i::IsStaticFlag::kStatic,
names_out, values_out);
} }
for (int i = 0; i < keys->length(); ++i) { for (int i = 0; i < keys->length(); ++i) {
...@@ -234,9 +236,10 @@ bool GetPrivateMembers(Local<Context> context, Local<Object> value, ...@@ -234,9 +236,10 @@ bool GetPrivateMembers(Local<Context> context, Local<Object> value,
if (key->is_private_brand()) { if (key->is_private_brand()) {
DCHECK(value->IsContext()); DCHECK(value->IsContext());
i::Handle<i::Context> context(i::Context::cast(*value), isolate); i::Handle<i::Context> value_context(i::Context::cast(*value), isolate);
CollectPrivateMethodsAndAccessorsFromContext( CollectPrivateMethodsAndAccessorsFromContext(isolate, value_context,
isolate, context, i::IsStaticFlag::kNotStatic, names_out, values_out); i::IsStaticFlag::kNotStatic,
names_out, values_out);
} else { // Private fields } else { // Private fields
i::Handle<i::String> name( i::Handle<i::String> name(
i::String::cast(i::Symbol::cast(*key).description()), isolate); i::String::cast(i::Symbol::cast(*key).description()), isolate);
...@@ -1005,10 +1008,10 @@ void GlobalLexicalScopeNames(v8::Local<v8::Context> v8_context, ...@@ -1005,10 +1008,10 @@ void GlobalLexicalScopeNames(v8::Local<v8::Context> v8_context,
context->global_object().native_context().script_context_table(), context->global_object().native_context().script_context_table(),
isolate); isolate);
for (int i = 0; i < table->used(kAcquireLoad); i++) { for (int i = 0; i < table->used(kAcquireLoad); i++) {
i::Handle<i::Context> context = i::Handle<i::Context> script_context =
i::ScriptContextTable::GetContext(isolate, table, i); i::ScriptContextTable::GetContext(isolate, table, i);
DCHECK(context->IsScriptContext()); DCHECK(script_context->IsScriptContext());
i::Handle<i::ScopeInfo> scope_info(context->scope_info(), isolate); i::Handle<i::ScopeInfo> scope_info(script_context->scope_info(), isolate);
int local_count = scope_info->ContextLocalCount(); int local_count = scope_info->ContextLocalCount();
for (int j = 0; j < local_count; ++j) { for (int j = 0; j < local_count; ++j) {
i::String name = scope_info->ContextLocalName(j); i::String name = scope_info->ContextLocalName(j);
......
...@@ -1179,14 +1179,14 @@ void Debug::PrepareStep(StepAction step_action) { ...@@ -1179,14 +1179,14 @@ void Debug::PrepareStep(StepAction step_action) {
return; return;
} }
#endif // V8_ENABLE_WEBASSEMBLY #endif // V8_ENABLE_WEBASSEMBLY
JavaScriptFrame* frame = JavaScriptFrame::cast(frames_it.frame()); JavaScriptFrame* js_frame = JavaScriptFrame::cast(frames_it.frame());
if (last_step_action() == StepInto) { if (last_step_action() == StepInto) {
// Deoptimize frame to ensure calls are checked for step-in. // Deoptimize frame to ensure calls are checked for step-in.
Deoptimizer::DeoptimizeFunction(frame->function()); Deoptimizer::DeoptimizeFunction(js_frame->function());
} }
HandleScope scope(isolate_); HandleScope inner_scope(isolate_);
std::vector<Handle<SharedFunctionInfo>> infos; std::vector<Handle<SharedFunctionInfo>> infos;
frame->GetFunctions(&infos); js_frame->GetFunctions(&infos);
for (; !infos.empty(); current_frame_count--) { for (; !infos.empty(); current_frame_count--) {
Handle<SharedFunctionInfo> info = infos.back(); Handle<SharedFunctionInfo> info = infos.back();
infos.pop_back(); infos.pop_back();
......
...@@ -1085,7 +1085,7 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script, ...@@ -1085,7 +1085,7 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
FixedArray constants = sfi->GetBytecodeArray(isolate).constant_pool(); FixedArray constants = sfi->GetBytecodeArray(isolate).constant_pool();
for (int i = 0; i < constants.length(); ++i) { for (int i = 0; i < constants.length(); ++i) {
if (!constants.get(i).IsSharedFunctionInfo()) continue; if (!constants.get(i).IsSharedFunctionInfo()) continue;
FunctionData* data = nullptr; data = nullptr;
if (!function_data_map.Lookup(SharedFunctionInfo::cast(constants.get(i)), if (!function_data_map.Lookup(SharedFunctionInfo::cast(constants.get(i)),
&data)) { &data)) {
continue; continue;
...@@ -1158,11 +1158,12 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script, ...@@ -1158,11 +1158,12 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
// unique. // unique.
DisallowGarbageCollection no_gc; DisallowGarbageCollection no_gc;
SharedFunctionInfo::ScriptIterator it(isolate, *new_script); SharedFunctionInfo::ScriptIterator script_it(isolate, *new_script);
std::set<int> start_positions; std::set<int> start_positions;
for (SharedFunctionInfo sfi = it.Next(); !sfi.is_null(); sfi = it.Next()) { for (SharedFunctionInfo sfi = script_it.Next(); !sfi.is_null();
sfi = script_it.Next()) {
DCHECK_EQ(sfi.script(), *new_script); DCHECK_EQ(sfi.script(), *new_script);
DCHECK_EQ(sfi.function_literal_id(), it.CurrentIndex()); DCHECK_EQ(sfi.function_literal_id(), script_it.CurrentIndex());
// Don't check the start position of the top-level function, as it can // Don't check the start position of the top-level function, as it can
// overlap with a function in the script. // overlap with a function in the script.
if (sfi.is_toplevel()) { if (sfi.is_toplevel()) {
......
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