Skip to content

Commit 787a43e

Browse files
rmacnak-googlecommit-bot@chromium.org
authored andcommitted
[vm] Fix some missing private name mangling in the kernel reader.
Bug: #32345 Bug: #33326 Bug: #33345 Change-Id: I89fb8f0332ef6f9f40de59c219af2a7c23e5943f Reviewed-on: https://dart-review.googlesource.com/58400 Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Vyacheslav Egorov <[email protected]> Reviewed-by: Alexander Markov <[email protected]>
1 parent 1cf348b commit 787a43e

File tree

5 files changed

+25
-19
lines changed

5 files changed

+25
-19
lines changed

runtime/lib/mirrors_impl.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,8 @@ class _LocalFunctionTypeMirror extends _LocalClassMirror
793793
List<ParameterMirror> _parameters;
794794
List<ParameterMirror> get parameters {
795795
if (_parameters == null) {
796-
_parameters = _FunctionTypeMirror_parameters(_functionReflectee);
796+
_parameters = _FunctionTypeMirror_parameters(_functionReflectee)
797+
.cast<ParameterMirror>();
797798
_parameters = new UnmodifiableListView<ParameterMirror>(_parameters);
798799
}
799800
return _parameters;

runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ intptr_t BytecodeMetadataHelper::ReadPoolEntries(const Function& function,
12811281

12821282
closure.SetParameterTypeAt(pos, type);
12831283
closure.SetParameterNameAt(pos,
1284-
H.DartSymbolObfuscate(helper.name_index_));
1284+
H.DartIdentifier(lib, helper.name_index_));
12851285
}
12861286

12871287
intptr_t named_parameter_count_check = builder_->ReadListLength();
@@ -1298,7 +1298,7 @@ intptr_t BytecodeMetadataHelper::ReadPoolEntries(const Function& function,
12981298

12991299
closure.SetParameterTypeAt(pos, type);
13001300
closure.SetParameterNameAt(pos,
1301-
H.DartSymbolObfuscate(helper.name_index_));
1301+
H.DartIdentifier(lib, helper.name_index_));
13021302
}
13031303

13041304
function_node_helper.SetJustRead(FunctionNodeHelper::kNamedParameters);
@@ -3973,10 +3973,10 @@ void StreamingConstantEvaluator::EvaluateStringConcatenation() {
39733973
}
39743974

39753975
void StreamingConstantEvaluator::EvaluateSymbolLiteral() {
3976-
// The symbol value is read plain and obfuscated later.
3977-
const String& symbol_value = H.DartSymbolPlain(
3978-
builder_->ReadStringReference()); // read index into string table.
3979-
3976+
const Class& owner =
3977+
Class::Handle(Z, builder_->parsed_function()->function().Owner());
3978+
const Library& lib = Library::Handle(Z, owner.library());
3979+
String& symbol_value = H.DartIdentifier(lib, builder_->ReadStringReference());
39803980
const Class& symbol_class =
39813981
Class::ZoneHandle(Z, I->object_store()->symbol_class());
39823982
ASSERT(!symbol_class.IsNull());
@@ -10871,6 +10871,7 @@ void StreamingFlowGraphBuilder::LoadAndSetupTypeParameters(
1087110871

1087210872
// Step a) Create array of [TypeParameter] objects (without bound).
1087310873
type_parameters = TypeArguments::New(type_parameter_count);
10874+
const Library& lib = Library::Handle(Z, active_class->klass->library());
1087410875
{
1087510876
AlternativeReadingScope alt(&reader_);
1087610877
for (intptr_t i = 0; i < type_parameter_count; i++) {
@@ -10879,7 +10880,7 @@ void StreamingFlowGraphBuilder::LoadAndSetupTypeParameters(
1087910880
parameter = TypeParameter::New(
1088010881
set_on_class ? *active_class->klass : Class::Handle(Z),
1088110882
parameterized_function, i,
10882-
H.DartSymbolObfuscate(helper.name_index_), // read ith name index.
10883+
H.DartIdentifier(lib, helper.name_index_), // read ith name index.
1088310884
null_bound, TokenPosition::kNoSource);
1088410885
type_parameters.SetTypeAt(i, parameter);
1088510886
}
@@ -10984,6 +10985,7 @@ void StreamingFlowGraphBuilder::SetupFunctionParameters(
1098410985
pos++;
1098510986
}
1098610987

10988+
const Library& lib = Library::Handle(Z, active_class->klass->library());
1098710989
for (intptr_t i = 0; i < positional_parameter_count; ++i, ++pos) {
1098810990
// Read ith variable declaration.
1098910991
VariableDeclarationHelper helper(this);
@@ -10996,7 +10998,7 @@ void StreamingFlowGraphBuilder::SetupFunctionParameters(
1099610998

1099710999
function.SetParameterTypeAt(
1099811000
pos, type.IsMalformed() ? Type::dynamic_type() : type);
10999-
function.SetParameterNameAt(pos, H.DartSymbolObfuscate(helper.name_index_));
11001+
function.SetParameterNameAt(pos, H.DartIdentifier(lib, helper.name_index_));
1100011002
}
1100111003

1100211004
intptr_t named_parameter_count_check = ReadListLength(); // read list length.
@@ -11013,7 +11015,7 @@ void StreamingFlowGraphBuilder::SetupFunctionParameters(
1101311015

1101411016
function.SetParameterTypeAt(
1101511017
pos, type.IsMalformed() ? Type::dynamic_type() : type);
11016-
function.SetParameterNameAt(pos, H.DartSymbolObfuscate(helper.name_index_));
11018+
function.SetParameterNameAt(pos, H.DartIdentifier(lib, helper.name_index_));
1101711019
}
1101811020

1101911021
function_node_helper->SetJustRead(FunctionNodeHelper::kNamedParameters);

runtime/vm/compiler/frontend/kernel_to_il.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,13 @@ String& TranslationHelper::DartSymbolObfuscate(StringIndex string_index) const {
487487
return result;
488488
}
489489

490+
String& TranslationHelper::DartIdentifier(const Library& lib,
491+
StringIndex string_index) {
492+
String& name = DartString(string_index);
493+
ManglePrivateName(lib, &name);
494+
return name;
495+
}
496+
490497
const String& TranslationHelper::DartClassName(NameIndex kernel_class) {
491498
ASSERT(IsClass(kernel_class));
492499
String& name = DartString(CanonicalNameString(kernel_class));

runtime/vm/compiler/frontend/kernel_to_il.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ class TranslationHelper {
395395
const String& DartSymbolObfuscate(const char* content) const;
396396
String& DartSymbolObfuscate(StringIndex string_index) const;
397397

398+
String& DartIdentifier(const Library& lib, StringIndex string_index);
399+
398400
const String& DartClassName(NameIndex kernel_class);
399401

400402
const String& DartConstructorName(NameIndex constructor);

tests/lib_2/lib_2_kernel.status

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ mirrors/class_declarations_test/none: RuntimeError # Issue 31402 (Invocation arg
108108
mirrors/class_mirror_location_test: RuntimeError
109109
mirrors/constructor_kinds_test/01: RuntimeError
110110
mirrors/constructor_kinds_test/none: RuntimeError
111-
mirrors/constructor_private_name_test: RuntimeError
111+
mirrors/constructor_private_name_test: RuntimeError # Issue 33345 - Incorrect qualified symbol literal from kernel reader
112112
mirrors/constructors_test: CompileTimeError # Issue 31402 (Invocation arguments)
113113
mirrors/dart2js_mirrors_test: RuntimeError # 31916
114114
mirrors/deferred_mirrors_metadata_test: RuntimeError, CompileTimeError # Deferred loading kernel issue 28335.
@@ -123,11 +123,7 @@ mirrors/generic_f_bounded_mixin_application_test: RuntimeError
123123
mirrors/generic_function_typedef_test: RuntimeError
124124
mirrors/generic_interface_test/01: RuntimeError
125125
mirrors/generic_mixin_applications_test: RuntimeError
126-
mirrors/hot_get_field_test: RuntimeError
127-
mirrors/hot_set_field_test: RuntimeError
128126
mirrors/invocation_fuzz_test: RuntimeError, Crash
129-
mirrors/invoke_private_test: RuntimeError
130-
mirrors/invoke_private_wrong_library_test: RuntimeError
131127
mirrors/library_declarations_test/none: RuntimeError # Issue 31402 (Invocation arguments)
132128
mirrors/library_enumeration_deferred_loading_test: RuntimeError
133129
mirrors/library_exports_hidden_test: RuntimeError # Issue 33098
@@ -163,10 +159,8 @@ mirrors/other_declarations_location_test: RuntimeError # Issue 33325 (no source
163159
mirrors/parameter_annotation_mirror_test: RuntimeError
164160
mirrors/parameter_metadata_test: RuntimeError
165161
mirrors/parameter_of_mixin_app_constructor_test: RuntimeError # Issue 31402 (Invocation arguments)
166-
mirrors/private_class_field_test: RuntimeError
167-
mirrors/private_field_test: RuntimeError
168-
mirrors/private_symbol_test: RuntimeError
169-
mirrors/private_types_test: RuntimeError
162+
mirrors/private_symbol_test: RuntimeError # Issue 33326 - CFE/kernel invalid typedef substitution
163+
mirrors/private_types_test: RuntimeError # Issue 33326 - CFE/kernel invalid typedef substitution
170164
mirrors/redirecting_factory_different_type_test/01: MissingCompileTimeError
171165
mirrors/redirecting_factory_test/01: RuntimeError
172166
mirrors/redirecting_factory_test/02: RuntimeError

0 commit comments

Comments
 (0)