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

Side by Side Diff: src/snapshot/deserializer.cc

Issue 1989203004: [serializer] fix deserializing cell targets in code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.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 | « no previous file | test/cctest/test-serialize.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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/snapshot/deserializer.h" 5 #include "src/snapshot/deserializer.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/external-reference-table.h" 8 #include "src/external-reference-table.h"
9 #include "src/heap/heap.h" 9 #include "src/heap/heap.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 DCHECK(where == kBuiltin); \ 500 DCHECK(where == kBuiltin); \
501 DCHECK(deserializing_user_code()); \ 501 DCHECK(deserializing_user_code()); \
502 int builtin_id = source_.GetInt(); \ 502 int builtin_id = source_.GetInt(); \
503 DCHECK_LE(0, builtin_id); \ 503 DCHECK_LE(0, builtin_id); \
504 DCHECK_LT(builtin_id, Builtins::builtin_count); \ 504 DCHECK_LT(builtin_id, Builtins::builtin_count); \
505 Builtins::Name name = static_cast<Builtins::Name>(builtin_id); \ 505 Builtins::Name name = static_cast<Builtins::Name>(builtin_id); \
506 new_object = isolate->builtins()->builtin(name); \ 506 new_object = isolate->builtins()->builtin(name); \
507 emit_write_barrier = false; \ 507 emit_write_barrier = false; \
508 } \ 508 } \
509 if (within == kInnerPointer) { \ 509 if (within == kInnerPointer) { \
510 if (space_number != CODE_SPACE || new_object->IsCode()) { \ 510 if (new_object->IsCode()) { \
511 Code* new_code_object = reinterpret_cast<Code*>(new_object); \ 511 Code* new_code_object = Code::cast(new_object); \
512 new_object = \ 512 new_object = \
513 reinterpret_cast<Object*>(new_code_object->instruction_start()); \ 513 reinterpret_cast<Object*>(new_code_object->instruction_start()); \
514 } else { \ 514 } else { \
515 DCHECK(space_number == CODE_SPACE); \
516 Cell* cell = Cell::cast(new_object); \ 515 Cell* cell = Cell::cast(new_object); \
517 new_object = reinterpret_cast<Object*>(cell->ValueAddress()); \ 516 new_object = reinterpret_cast<Object*>(cell->ValueAddress()); \
518 } \ 517 } \
519 } \ 518 } \
520 if (how == kFromCode) { \ 519 if (how == kFromCode) { \
521 Address location_of_branch_data = reinterpret_cast<Address>(current); \ 520 Address location_of_branch_data = reinterpret_cast<Address>(current); \
522 Assembler::deserialization_set_special_target_at( \ 521 Assembler::deserialization_set_special_target_at( \
523 isolate, location_of_branch_data, \ 522 isolate, location_of_branch_data, \
524 Code::cast(HeapObject::FromAddress(current_object_address)), \ 523 Code::cast(HeapObject::FromAddress(current_object_address)), \
525 reinterpret_cast<Address>(new_object)); \ 524 reinterpret_cast<Address>(new_object)); \
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 CASE_STATEMENT(where, how, within, space) \ 571 CASE_STATEMENT(where, how, within, space) \
573 CASE_BODY(where, how, within, space) 572 CASE_BODY(where, how, within, space)
574 573
575 // Deserialize a new object and write a pointer to it to the current 574 // Deserialize a new object and write a pointer to it to the current
576 // object. 575 // object.
577 ALL_SPACES(kNewObject, kPlain, kStartOfObject) 576 ALL_SPACES(kNewObject, kPlain, kStartOfObject)
578 // Support for direct instruction pointers in functions. It's an inner 577 // Support for direct instruction pointers in functions. It's an inner
579 // pointer because it points at the entry point, not at the start of the 578 // pointer because it points at the entry point, not at the start of the
580 // code object. 579 // code object.
581 SINGLE_CASE(kNewObject, kPlain, kInnerPointer, CODE_SPACE) 580 SINGLE_CASE(kNewObject, kPlain, kInnerPointer, CODE_SPACE)
581 // Support for pointers into a cell. It's an inner pointer because it
582 // points directly at the value field, not the start of the cell object.
583 SINGLE_CASE(kNewObject, kPlain, kInnerPointer, OLD_SPACE)
582 // Deserialize a new code object and write a pointer to its first 584 // Deserialize a new code object and write a pointer to its first
583 // instruction to the current code object. 585 // instruction to the current code object.
584 ALL_SPACES(kNewObject, kFromCode, kInnerPointer) 586 ALL_SPACES(kNewObject, kFromCode, kInnerPointer)
585 // Find a recently deserialized object using its offset from the current 587 // Find a recently deserialized object using its offset from the current
586 // allocation point and write a pointer to it to the current object. 588 // allocation point and write a pointer to it to the current object.
587 ALL_SPACES(kBackref, kPlain, kStartOfObject) 589 ALL_SPACES(kBackref, kPlain, kStartOfObject)
588 ALL_SPACES(kBackrefWithSkip, kPlain, kStartOfObject) 590 ALL_SPACES(kBackrefWithSkip, kPlain, kStartOfObject)
589 #if V8_CODE_EMBEDS_OBJECT_POINTER 591 #if V8_CODE_EMBEDS_OBJECT_POINTER
590 // Deserialize a new object from pointer found in code and write 592 // Deserialize a new object from pointer found in code and write
591 // a pointer to it to the current object. Required only for MIPS, PPC, ARM 593 // a pointer to it to the current object. Required only for MIPS, PPC, ARM
592 // or S390 with embedded constant pool, and omitted on the other 594 // or S390 with embedded constant pool, and omitted on the other
593 // architectures because it is fully unrolled and would cause bloat. 595 // architectures because it is fully unrolled and would cause bloat.
594 ALL_SPACES(kNewObject, kFromCode, kStartOfObject) 596 ALL_SPACES(kNewObject, kFromCode, kStartOfObject)
595 // Find a recently deserialized code object using its offset from the 597 // Find a recently deserialized code object using its offset from the
596 // current allocation point and write a pointer to it to the current 598 // current allocation point and write a pointer to it to the current
597 // object. Required only for MIPS, PPC, ARM or S390 with embedded 599 // object. Required only for MIPS, PPC, ARM or S390 with embedded
598 // constant pool. 600 // constant pool.
599 ALL_SPACES(kBackref, kFromCode, kStartOfObject) 601 ALL_SPACES(kBackref, kFromCode, kStartOfObject)
600 ALL_SPACES(kBackrefWithSkip, kFromCode, kStartOfObject) 602 ALL_SPACES(kBackrefWithSkip, kFromCode, kStartOfObject)
601 #endif 603 #endif
602 // Find a recently deserialized code object using its offset from the 604 // Find a recently deserialized code object using its offset from the
603 // current allocation point and write a pointer to its first instruction 605 // current allocation point and write a pointer to its first instruction
604 // to the current code object or the instruction pointer in a function 606 // to the current code object or the instruction pointer in a function
605 // object. 607 // object.
606 ALL_SPACES(kBackref, kFromCode, kInnerPointer) 608 ALL_SPACES(kBackref, kFromCode, kInnerPointer)
607 ALL_SPACES(kBackrefWithSkip, kFromCode, kInnerPointer) 609 ALL_SPACES(kBackrefWithSkip, kFromCode, kInnerPointer)
608 ALL_SPACES(kBackref, kPlain, kInnerPointer) 610 // Support for direct instruction pointers in functions.
609 ALL_SPACES(kBackrefWithSkip, kPlain, kInnerPointer) 611 SINGLE_CASE(kBackref, kPlain, kInnerPointer, CODE_SPACE)
612 SINGLE_CASE(kBackrefWithSkip, kPlain, kInnerPointer, CODE_SPACE)
613 // Support for pointers into a cell.
614 SINGLE_CASE(kBackref, kPlain, kInnerPointer, OLD_SPACE)
615 SINGLE_CASE(kBackrefWithSkip, kPlain, kInnerPointer, OLD_SPACE)
610 // Find an object in the roots array and write a pointer to it to the 616 // Find an object in the roots array and write a pointer to it to the
611 // current object. 617 // current object.
612 SINGLE_CASE(kRootArray, kPlain, kStartOfObject, 0) 618 SINGLE_CASE(kRootArray, kPlain, kStartOfObject, 0)
613 #if V8_CODE_EMBEDS_OBJECT_POINTER 619 #if V8_CODE_EMBEDS_OBJECT_POINTER
614 // Find an object in the roots array and write a pointer to it to in code. 620 // Find an object in the roots array and write a pointer to it to in code.
615 SINGLE_CASE(kRootArray, kFromCode, kStartOfObject, 0) 621 SINGLE_CASE(kRootArray, kFromCode, kStartOfObject, 0)
616 #endif 622 #endif
617 // Find an object in the partial snapshots cache and write a pointer to it 623 // Find an object in the partial snapshots cache and write a pointer to it
618 // to the current object. 624 // to the current object.
619 SINGLE_CASE(kPartialSnapshotCache, kPlain, kStartOfObject, 0) 625 SINGLE_CASE(kPartialSnapshotCache, kPlain, kStartOfObject, 0)
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 812
807 default: 813 default:
808 CHECK(false); 814 CHECK(false);
809 } 815 }
810 } 816 }
811 CHECK_EQ(limit, current); 817 CHECK_EQ(limit, current);
812 return true; 818 return true;
813 } 819 }
814 } // namespace internal 820 } // namespace internal
815 } // namespace v8 821 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698