@@ -182,7 +182,8 @@ KernelLoader::KernelLoader(Program* program)
182
182
external_name_class_(Class::Handle(Z)),
183
183
external_name_field_(Field::Handle(Z)),
184
184
potential_natives_(GrowableObjectArray::Handle(Z)),
185
- potential_extension_libraries_(GrowableObjectArray::Handle(Z)) {
185
+ potential_extension_libraries_(GrowableObjectArray::Handle(Z)),
186
+ pragma_class_(Class::Handle(Z)) {
186
187
if (!program->is_single_program ()) {
187
188
FATAL (
188
189
" Trying to load a concatenated dill file at a time where that is "
@@ -283,6 +284,12 @@ void KernelLoader::InitializeFields() {
283
284
Z,
284
285
reader.ExternalDataFromTo (reader.offset (), reader.offset () + end_offset));
285
286
287
+ // Create a view of the constants table. The trailing ComponentIndex is
288
+ // negligible in size.
289
+ const ExternalTypedData& constants_table = ExternalTypedData::Handle (
290
+ Z, reader.ExternalDataFromTo (program_->constant_table_offset (),
291
+ program_->kernel_data_size ()));
292
+
286
293
// Copy the canonical names into the VM's heap. Encode them as unsigned, so
287
294
// the parent indexes are adjusted when extracted.
288
295
reader.set_offset (program_->name_table_offset ());
@@ -303,8 +310,9 @@ void KernelLoader::InitializeFields() {
303
310
Z, reader.ExternalDataFromTo (program_->metadata_mappings_offset (),
304
311
program_->string_table_offset ()));
305
312
306
- kernel_program_info_ = KernelProgramInfo::New (
307
- offsets, data, names, metadata_payloads, metadata_mappings, scripts);
313
+ kernel_program_info_ =
314
+ KernelProgramInfo::New (offsets, data, names, metadata_payloads,
315
+ metadata_mappings, constants_table, scripts);
308
316
309
317
H.InitFromKernelProgramInfo (kernel_program_info_);
310
318
@@ -335,7 +343,8 @@ KernelLoader::KernelLoader(const Script& script,
335
343
external_name_class_(Class::Handle(Z)),
336
344
external_name_field_(Field::Handle(Z)),
337
345
potential_natives_(GrowableObjectArray::Handle(Z)),
338
- potential_extension_libraries_(GrowableObjectArray::Handle(Z)) {
346
+ potential_extension_libraries_(GrowableObjectArray::Handle(Z)),
347
+ pragma_class_(Class::Handle(Z)) {
339
348
ASSERT (T.active_class_ == &active_class_);
340
349
T.finalize_ = false ;
341
350
@@ -588,6 +597,7 @@ RawObject* KernelLoader::LoadProgram(bool process_pending_classes) {
588
597
// c) update all scripts with the constants array
589
598
ASSERT (kernel_program_info_.constants () == Array::null ());
590
599
kernel_program_info_.set_constants (constants);
600
+ kernel_program_info_.set_constants_table (ExternalTypedData::Handle (Z));
591
601
592
602
NameIndex main = program_->main_method ();
593
603
if (main == -1 ) {
@@ -1335,7 +1345,6 @@ void KernelLoader::ReadProcedureAnnotations(intptr_t annotation_count,
1335
1345
*is_potential_native = false ;
1336
1346
*has_pragma_annotation = false ;
1337
1347
String& detected_name = String::Handle (Z);
1338
- Class& pragma_class = Class::Handle (Z, I->object_store ()->pragma_class ());
1339
1348
for (intptr_t i = 0 ; i < annotation_count; ++i) {
1340
1349
const intptr_t tag = helper_.PeekTag ();
1341
1350
if (tag == kConstructorInvocation || tag == kConstConstructorInvocation ) {
@@ -1361,10 +1370,8 @@ void KernelLoader::ReadProcedureAnnotations(intptr_t annotation_count,
1361
1370
// constants in the annotation list to later.
1362
1371
*is_potential_native = true ;
1363
1372
1364
- if (program_ == nullptr ) {
1365
- helper_.SkipExpression ();
1366
- continue ;
1367
- }
1373
+ ASSERT (kernel_program_info_.constants_table () !=
1374
+ ExternalTypedData::null ());
1368
1375
1369
1376
// For pragma annotations, we seek into the constants table and peek
1370
1377
// into the Kernel representation of the constant.
@@ -1376,13 +1383,16 @@ void KernelLoader::ReadProcedureAnnotations(intptr_t annotation_count,
1376
1383
1377
1384
const intptr_t offset_in_constant_table = helper_.ReadUInt ();
1378
1385
1379
- AlternativeReadingScope scope (&helper_.reader_ ,
1380
- program_->constant_table_offset ());
1386
+ AlternativeReadingScope scope (
1387
+ &helper_.reader_ ,
1388
+ &ExternalTypedData::Handle (Z,
1389
+ kernel_program_info_.constants_table ()),
1390
+ 0 );
1381
1391
1382
1392
// Seek into the position within the constant table where we can inspect
1383
1393
// this constant's Kernel representation.
1384
1394
helper_.ReadUInt (); // skip constant table size
1385
- helper_.SetOffset (helper_. ReaderOffset () + offset_in_constant_table);
1395
+ helper_.SkipBytes ( offset_in_constant_table);
1386
1396
uint8_t tag = helper_.ReadTag ();
1387
1397
if (tag == kInstanceConstant ) {
1388
1398
*has_pragma_annotation =
@@ -1396,6 +1406,9 @@ void KernelLoader::ReadProcedureAnnotations(intptr_t annotation_count,
1396
1406
// Obtain `dart:_internal::ExternalName.name`.
1397
1407
EnsureExternalClassIsLookedUp ();
1398
1408
1409
+ // Obtain `dart:_internal::pragma`.
1410
+ EnsurePragmaClassIsLookedUp ();
1411
+
1399
1412
const intptr_t constant_table_index = helper_.ReadUInt ();
1400
1413
const Object& constant =
1401
1414
Object::Handle (constant_table.GetOrDie (constant_table_index));
@@ -1404,7 +1417,7 @@ void KernelLoader::ReadProcedureAnnotations(intptr_t annotation_count,
1404
1417
Instance::Handle (Instance::RawCast (constant.raw ()));
1405
1418
*native_name =
1406
1419
String::RawCast (instance.GetField (external_name_field_));
1407
- } else if (constant.clazz () == pragma_class .raw ()) {
1420
+ } else if (constant.clazz () == pragma_class_ .raw ()) {
1408
1421
*has_pragma_annotation = true ;
1409
1422
}
1410
1423
ASSERT (constant_table.Release ().raw () == constant_table_array.raw ());
0 commit comments