Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: runtime/vm/raw_object_snapshot.cc

Issue 1925153003: Undo "Don't include an object header for instructions in the text section." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/native_entry.h" 5 #include "vm/native_entry.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/snapshot.h" 8 #include "vm/snapshot.h"
9 #include "vm/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 ASSERT(Snapshot::IsFull(kind)); 1351 ASSERT(Snapshot::IsFull(kind));
1352 1352
1353 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0)); 1353 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0));
1354 reader->AddBackRef(object_id, &result, kIsDeserialized); 1354 reader->AddBackRef(object_id, &result, kIsDeserialized);
1355 1355
1356 result.set_compile_timestamp(0); 1356 result.set_compile_timestamp(0);
1357 result.set_state_bits(reader->Read<int32_t>()); 1357 result.set_state_bits(reader->Read<int32_t>());
1358 result.set_lazy_deopt_pc_offset(-1); 1358 result.set_lazy_deopt_pc_offset(-1);
1359 1359
1360 int32_t text_offset = reader->Read<int32_t>(); 1360 int32_t text_offset = reader->Read<int32_t>();
1361 int32_t instructions_size = reader->Read<int32_t>(); 1361 RawInstructions* instr = reinterpret_cast<RawInstructions*>(
1362 uword entry_point = reader->GetInstructionsAt(text_offset); 1362 reader->GetInstructionsAt(text_offset) + kHeapObjectTag);
1363 uword entry_point = Instructions::EntryPoint(instr);
1363 1364
1364 #if defined(DEBUG) 1365 #if defined(DEBUG)
1366 ASSERT(instr->IsMarked());
1367 ASSERT(instr->IsVMHeapObject());
1365 uword expected_check = reader->Read<uword>(); 1368 uword expected_check = reader->Read<uword>();
1369 intptr_t instructions_size = Utils::RoundUp(instr->size_,
1370 OS::PreferredCodeAlignment());
1366 uword actual_check = Checksum(entry_point, instructions_size); 1371 uword actual_check = Checksum(entry_point, instructions_size);
1367 ASSERT(expected_check == actual_check); 1372 ASSERT(expected_check == actual_check);
1368 #endif 1373 #endif
1369 1374
1370 result.StoreNonPointer(&result.raw_ptr()->entry_point_, entry_point); 1375 result.StoreNonPointer(&result.raw_ptr()->entry_point_, entry_point);
1371 1376
1372 result.StorePointer(reinterpret_cast<RawSmi*const*>( 1377 result.StorePointer(&result.raw_ptr()->active_instructions_, instr);
1373 &result.raw_ptr()->instructions_), 1378 result.StorePointer(&result.raw_ptr()->instructions_, instr);
1374 Smi::New(instructions_size));
1375 1379
1376 (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference); 1380 (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference);
1377 result.StorePointer(reinterpret_cast<RawObject*const*>( 1381 result.StorePointer(reinterpret_cast<RawObject*const*>(
1378 &result.raw_ptr()->object_pool_), 1382 &result.raw_ptr()->object_pool_),
1379 reader->PassiveObjectHandle()->raw()); 1383 reader->PassiveObjectHandle()->raw());
1380 1384
1381 (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference); 1385 (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference);
1382 result.StorePointer(&result.raw_ptr()->owner_, 1386 result.StorePointer(&result.raw_ptr()->owner_,
1383 reader->PassiveObjectHandle()->raw()); 1387 reader->PassiveObjectHandle()->raw());
1384 1388
(...skipping 23 matching lines...) Expand all
1408 Array::null()); 1412 Array::null());
1409 result.StorePointer(&result.raw_ptr()->var_descriptors_, 1413 result.StorePointer(&result.raw_ptr()->var_descriptors_,
1410 LocalVarDescriptors::null()); 1414 LocalVarDescriptors::null());
1411 result.StorePointer(&result.raw_ptr()->inlined_metadata_, 1415 result.StorePointer(&result.raw_ptr()->inlined_metadata_,
1412 Array::null()); 1416 Array::null());
1413 result.StorePointer(&result.raw_ptr()->comments_, 1417 result.StorePointer(&result.raw_ptr()->comments_,
1414 Array::null()); 1418 Array::null());
1415 result.StorePointer(&result.raw_ptr()->return_address_metadata_, 1419 result.StorePointer(&result.raw_ptr()->return_address_metadata_,
1416 Object::null()); 1420 Object::null());
1417 1421
1418 ASSERT(result.Size() == instructions_size);
1419 ASSERT(result.EntryPoint() == entry_point);
1420
1421 return result.raw(); 1422 return result.raw();
1422 } 1423 }
1423 1424
1424 1425
1425 void RawCode::WriteTo(SnapshotWriter* writer, 1426 void RawCode::WriteTo(SnapshotWriter* writer,
1426 intptr_t object_id, 1427 intptr_t object_id,
1427 Snapshot::Kind kind, 1428 Snapshot::Kind kind,
1428 bool as_reference) { 1429 bool as_reference) {
1429 ASSERT(Snapshot::IncludesCode(kind)); 1430 ASSERT(Snapshot::IncludesCode(kind));
1430 ASSERT(Snapshot::IsFull(kind)); 1431 ASSERT(Snapshot::IsFull(kind));
1431 1432
1432 intptr_t pointer_offsets_length = 1433 intptr_t pointer_offsets_length =
1433 Code::PtrOffBits::decode(ptr()->state_bits_); 1434 Code::PtrOffBits::decode(ptr()->state_bits_);
1434 if (pointer_offsets_length != 0) { 1435 if (pointer_offsets_length != 0) {
1435 // Should only be IA32. 1436 // Should only be IA32.
1436 FATAL("Cannot serialize code with embedded pointers"); 1437 FATAL("Cannot serialize code with embedded pointers");
1437 } 1438 }
1438 1439
1439 // Write out the serialization header value for this object. 1440 // Write out the serialization header value for this object.
1440 writer->WriteInlinedObjectHeader(object_id); 1441 writer->WriteInlinedObjectHeader(object_id);
1441 1442
1442 // Write out the class and tags information. 1443 // Write out the class and tags information.
1443 writer->WriteVMIsolateObject(kCodeCid); 1444 writer->WriteVMIsolateObject(kCodeCid);
1444 writer->WriteTags(writer->GetObjectTags(this)); 1445 writer->WriteTags(writer->GetObjectTags(this));
1445 1446
1446 // Write out all the non object fields. 1447 // Write out all the non object fields.
1447 writer->Write<int32_t>(ptr()->state_bits_); 1448 writer->Write<int32_t>(ptr()->state_bits_);
1448 1449
1450 // No disabled code in precompilation.
1451 ASSERT(ptr()->instructions_ == ptr()->active_instructions_);
1452
1449 RawInstructions* instr = ptr()->instructions_; 1453 RawInstructions* instr = ptr()->instructions_;
1450 intptr_t size = instr->ptr()->size_;
1451 int32_t text_offset = writer->GetInstructionsId(instr, this); 1454 int32_t text_offset = writer->GetInstructionsId(instr, this);
1452 writer->Write<int32_t>(text_offset); 1455 writer->Write<int32_t>(text_offset);
1453 writer->Write<int32_t>(size); 1456
1454 #if defined(DEBUG) 1457 #if defined(DEBUG)
1455 uword entry = ptr()->entry_point_; 1458 uword entry = ptr()->entry_point_;
1456 uword check = Checksum(entry, size); 1459 intptr_t instructions_size = Utils::RoundUp(instr->size_,
1460 OS::PreferredCodeAlignment());
1461 uword check = Checksum(entry, instructions_size);
1457 writer->Write<uword>(check); 1462 writer->Write<uword>(check);
1458 #endif 1463 #endif
1459 1464
1460 writer->WriteObjectImpl(ptr()->object_pool_, kAsReference); 1465 writer->WriteObjectImpl(ptr()->object_pool_, kAsReference);
1461 writer->WriteObjectImpl(ptr()->owner_, kAsReference); 1466 writer->WriteObjectImpl(ptr()->owner_, kAsReference);
1462 writer->WriteObjectImpl(ptr()->exception_handlers_, kAsReference); 1467 writer->WriteObjectImpl(ptr()->exception_handlers_, kAsReference);
1463 writer->WriteObjectImpl(ptr()->pc_descriptors_, kAsReference); 1468 writer->WriteObjectImpl(ptr()->pc_descriptors_, kAsReference);
1464 writer->WriteObjectImpl(ptr()->code_source_map_, kAsReference); 1469 writer->WriteObjectImpl(ptr()->code_source_map_, kAsReference);
1465 writer->WriteObjectImpl(ptr()->stackmaps_, kAsReference); 1470 writer->WriteObjectImpl(ptr()->stackmaps_, kAsReference);
1466 } 1471 }
(...skipping 2228 matching lines...) Expand 10 before | Expand all | Expand 10 after
3695 // We do not allow objects with native fields in an isolate message. 3700 // We do not allow objects with native fields in an isolate message.
3696 writer->SetWriteException(Exceptions::kArgument, 3701 writer->SetWriteException(Exceptions::kArgument,
3697 "Illegal argument in isolate message" 3702 "Illegal argument in isolate message"
3698 " : (object is a UserTag)"); 3703 " : (object is a UserTag)");
3699 } else { 3704 } else {
3700 UNREACHABLE(); 3705 UNREACHABLE();
3701 } 3706 }
3702 } 3707 }
3703 3708
3704 } // namespace dart 3709 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698