Commit 2aa0f934 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

Remove FixedArray::GetValue

The semantics of that method are not obvious (it returns an empty
MaybeHandle if the element is undefined, otherwise it assumes it is of
type T). Since there is only a single use of that method in the whole
code base, just having that logic there explicitly is much simpler.

Potential future uses of that method are probably also easier to
understand if they just to the checks explicitly.

Drive-by: Document semantics of {FixedArray::GetValueChecked}. Also for
this method it's quesionable whether it is useful overall.
Drive-by^2: Avoid else after return (see style guide).

R=mstarzinger@chromium.org

Bug: v8:9183
Change-Id: I88dcb0f080d728bbe55932f17cf4d7eb25ab5928
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1619761
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61686}
parent 786ce263
...@@ -287,20 +287,20 @@ MaybeHandle<JSObject> ProbeInstantiationsCache(Isolate* isolate, ...@@ -287,20 +287,20 @@ MaybeHandle<JSObject> ProbeInstantiationsCache(Isolate* isolate,
if (serial_number <= TemplateInfo::kFastTemplateInstantiationsCacheSize) { if (serial_number <= TemplateInfo::kFastTemplateInstantiationsCacheSize) {
Handle<FixedArray> fast_cache = Handle<FixedArray> fast_cache =
isolate->fast_template_instantiations_cache(); isolate->fast_template_instantiations_cache();
return fast_cache->GetValue<JSObject>(isolate, serial_number - 1); Handle<Object> object{fast_cache->get(serial_number - 1), isolate};
} else if (caching_mode == CachingMode::kUnlimited || if (object->IsUndefined(isolate)) return {};
(serial_number <= return Handle<JSObject>::cast(object);
TemplateInfo::kSlowTemplateInstantiationsCacheSize)) { }
if (caching_mode == CachingMode::kUnlimited ||
(serial_number <= TemplateInfo::kSlowTemplateInstantiationsCacheSize)) {
Handle<SimpleNumberDictionary> slow_cache = Handle<SimpleNumberDictionary> slow_cache =
isolate->slow_template_instantiations_cache(); isolate->slow_template_instantiations_cache();
int entry = slow_cache->FindEntry(isolate, serial_number); int entry = slow_cache->FindEntry(isolate, serial_number);
if (entry == SimpleNumberDictionary::kNotFound) { if (entry != SimpleNumberDictionary::kNotFound) {
return MaybeHandle<JSObject>(); return handle(JSObject::cast(slow_cache->ValueAt(entry)), isolate);
} }
return handle(JSObject::cast(slow_cache->ValueAt(entry)), isolate);
} else {
return MaybeHandle<JSObject>();
} }
return {};
} }
void CacheTemplateInstantiation(Isolate* isolate, int serial_number, void CacheTemplateInstantiation(Isolate* isolate, int serial_number,
......
...@@ -128,13 +128,6 @@ Handle<Object> FixedArray::get(FixedArray array, int index, Isolate* isolate) { ...@@ -128,13 +128,6 @@ Handle<Object> FixedArray::get(FixedArray array, int index, Isolate* isolate) {
return handle(array->get(index), isolate); return handle(array->get(index), isolate);
} }
template <class T>
MaybeHandle<T> FixedArray::GetValue(Isolate* isolate, int index) const {
Object obj = get(index);
if (obj->IsUndefined(isolate)) return MaybeHandle<T>();
return Handle<T>(T::cast(obj), isolate);
}
template <class T> template <class T>
Handle<T> FixedArray::GetValueChecked(Isolate* isolate, int index) const { Handle<T> FixedArray::GetValueChecked(Isolate* isolate, int index) const {
Object obj = get(index); Object obj = get(index);
......
...@@ -115,9 +115,9 @@ class FixedArray : public FixedArrayBase { ...@@ -115,9 +115,9 @@ class FixedArray : public FixedArrayBase {
inline Object get(int index) const; inline Object get(int index) const;
static inline Handle<Object> get(FixedArray array, int index, static inline Handle<Object> get(FixedArray array, int index,
Isolate* isolate); Isolate* isolate);
template <class T>
MaybeHandle<T> GetValue(Isolate* isolate, int index) const;
// CHECK that the element at {index} is not undefined and return that element
// in a handle.
template <class T> template <class T>
Handle<T> GetValueChecked(Isolate* isolate, int index) const; Handle<T> GetValueChecked(Isolate* isolate, int index) const;
......
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