Commit ca6e40d7 authored by jbroman's avatar jbroman Committed by Commit bot

Use a plain FixedArray rather than a SeededNumberDictionary for ValueDeserializer::id_map_.

In practice this is a dense array, because there is currently no provision
in the format for assigning IDs other than sequentially to every object.
Thus a FixedArray is more efficient than a general dictionary.

BUG=chromium:148757

Review-Url: https://codereview.chromium.org/2342293003
Cr-Commit-Position: refs/heads/master@{#39486}
parent 3165847e
...@@ -784,9 +784,8 @@ ValueDeserializer::ValueDeserializer(Isolate* isolate, ...@@ -784,9 +784,8 @@ ValueDeserializer::ValueDeserializer(Isolate* isolate,
position_(data.start()), position_(data.start()),
end_(data.start() + data.length()), end_(data.start() + data.length()),
pretenure_(data.length() > kPretenureThreshold ? TENURED : NOT_TENURED), pretenure_(data.length() > kPretenureThreshold ? TENURED : NOT_TENURED),
id_map_(Handle<SeededNumberDictionary>::cast( id_map_(Handle<FixedArray>::cast(isolate->global_handles()->Create(
isolate->global_handles()->Create( isolate_->heap()->empty_fixed_array()))) {}
*SeededNumberDictionary::New(isolate, 0)))) {}
ValueDeserializer::~ValueDeserializer() { ValueDeserializer::~ValueDeserializer() {
GlobalHandles::Destroy(Handle<Object>::cast(id_map_).location()); GlobalHandles::Destroy(Handle<Object>::cast(id_map_).location());
...@@ -1575,15 +1574,16 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties( ...@@ -1575,15 +1574,16 @@ Maybe<uint32_t> ValueDeserializer::ReadJSObjectProperties(
} }
bool ValueDeserializer::HasObjectWithID(uint32_t id) { bool ValueDeserializer::HasObjectWithID(uint32_t id) {
return id_map_->Has(isolate_, id); return id < static_cast<unsigned>(id_map_->length()) &&
!id_map_->get(id)->IsTheHole(isolate_);
} }
MaybeHandle<JSReceiver> ValueDeserializer::GetObjectWithID(uint32_t id) { MaybeHandle<JSReceiver> ValueDeserializer::GetObjectWithID(uint32_t id) {
int index = id_map_->FindEntry(isolate_, id); if (id >= static_cast<unsigned>(id_map_->length())) {
if (index == SeededNumberDictionary::kNotFound) {
return MaybeHandle<JSReceiver>(); return MaybeHandle<JSReceiver>();
} }
Object* value = id_map_->ValueAt(index); Object* value = id_map_->get(id);
if (value->IsTheHole(isolate_)) return MaybeHandle<JSReceiver>();
DCHECK(value->IsJSReceiver()); DCHECK(value->IsJSReceiver());
return Handle<JSReceiver>(JSReceiver::cast(value), isolate_); return Handle<JSReceiver>(JSReceiver::cast(value), isolate_);
} }
...@@ -1591,16 +1591,13 @@ MaybeHandle<JSReceiver> ValueDeserializer::GetObjectWithID(uint32_t id) { ...@@ -1591,16 +1591,13 @@ MaybeHandle<JSReceiver> ValueDeserializer::GetObjectWithID(uint32_t id) {
void ValueDeserializer::AddObjectWithID(uint32_t id, void ValueDeserializer::AddObjectWithID(uint32_t id,
Handle<JSReceiver> object) { Handle<JSReceiver> object) {
DCHECK(!HasObjectWithID(id)); DCHECK(!HasObjectWithID(id));
const bool used_as_prototype = false; Handle<FixedArray> new_array = FixedArray::SetAndGrow(id_map_, id, object);
Handle<SeededNumberDictionary> new_dictionary =
SeededNumberDictionary::AtNumberPut(id_map_, id, object,
used_as_prototype);
// If the dictionary was reallocated, update the global handle. // If the dictionary was reallocated, update the global handle.
if (!new_dictionary.is_identical_to(id_map_)) { if (!new_array.is_identical_to(id_map_)) {
GlobalHandles::Destroy(Handle<Object>::cast(id_map_).location()); GlobalHandles::Destroy(Handle<Object>::cast(id_map_).location());
id_map_ = Handle<SeededNumberDictionary>::cast( id_map_ = Handle<FixedArray>::cast(
isolate_->global_handles()->Create(*new_dictionary)); isolate_->global_handles()->Create(*new_array));
} }
} }
......
...@@ -253,7 +253,7 @@ class ValueDeserializer { ...@@ -253,7 +253,7 @@ class ValueDeserializer {
uint32_t next_id_ = 0; uint32_t next_id_ = 0;
// Always global handles. // Always global handles.
Handle<SeededNumberDictionary> id_map_; Handle<FixedArray> id_map_;
MaybeHandle<SeededNumberDictionary> array_buffer_transfer_map_; MaybeHandle<SeededNumberDictionary> array_buffer_transfer_map_;
DISALLOW_COPY_AND_ASSIGN(ValueDeserializer); DISALLOW_COPY_AND_ASSIGN(ValueDeserializer);
......
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