Commit 46290669 authored by yangguo's avatar yangguo Committed by Commit bot

[serializer] allow duplicate API external references.

Due to link-time optimizations functions with same code
can be folded into one, resulting in duplicate references.

R=jochen@chromium.org, peria@chromium.org
BUG=chromium:617892

Review-Url: https://codereview.chromium.org/2707903002
Cr-Commit-Position: refs/heads/master@{#43317}
parent 17ef406d
......@@ -443,6 +443,7 @@ void ExternalReferenceTable::AddDeoptEntries(Isolate* isolate) {
void ExternalReferenceTable::AddApiReferences(Isolate* isolate) {
// Add external references provided by the embedder (a null-terminated
// array).
api_refs_start_ = size();
intptr_t* api_external_references = isolate->api_external_references();
if (api_external_references != nullptr) {
while (*api_external_references != 0) {
......
......@@ -22,6 +22,7 @@ class ExternalReferenceTable {
uint32_t size() const { return static_cast<uint32_t>(refs_.length()); }
Address address(uint32_t i) { return refs_[i].address; }
const char* name(uint32_t i) { return refs_[i].name; }
bool is_api_reference(uint32_t i) { return i >= api_refs_start_; }
#ifdef DEBUG
void increment_count(uint32_t i) { refs_[i].count++; }
......@@ -64,6 +65,7 @@ class ExternalReferenceTable {
void AddApiReferences(Isolate* isolate);
List<ExternalReferenceEntry> refs_;
uint32_t api_refs_start_;
DISALLOW_COPY_AND_ASSIGN(ExternalReferenceTable);
};
......
......@@ -21,6 +21,8 @@ ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) {
ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate);
for (uint32_t i = 0; i < table->size(); ++i) {
Address addr = table->address(i);
// Ignore duplicate API references.
if (table->is_api_reference(i) && !map_->Get(addr).IsNothing()) continue;
DCHECK(map_->Get(addr).IsNothing());
map_->Set(addr, i);
DCHECK(map_->Get(addr).IsJust());
......
......@@ -1986,6 +1986,7 @@ intptr_t original_external_references[] = {
reinterpret_cast<intptr_t>(&NamedPropertyGetterForSerialization),
reinterpret_cast<intptr_t>(&AccessorForSerialization),
reinterpret_cast<intptr_t>(&SerializedExtension::FunctionCallback),
reinterpret_cast<intptr_t>(&serialized_static_field), // duplicate entry
0};
intptr_t replaced_external_references[] = {
......@@ -1994,6 +1995,7 @@ intptr_t replaced_external_references[] = {
reinterpret_cast<intptr_t>(&NamedPropertyGetterForSerialization),
reinterpret_cast<intptr_t>(&AccessorForSerialization),
reinterpret_cast<intptr_t>(&SerializedExtension::FunctionCallback),
reinterpret_cast<intptr_t>(&serialized_static_field),
0};
TEST(SnapshotCreatorExternalReferences) {
......
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