Return void from array setters since the return value needs to be ignored
BUG=v8:4137 LOG=n Review URL: https://codereview.chromium.org/1188073003 Cr-Commit-Position: refs/heads/master@{#29113}
This commit is contained in:
parent
370a8ea3f2
commit
72d6ed749b
@ -613,19 +613,19 @@ class ElementsAccessorBase : public ElementsAccessor {
|
||||
}
|
||||
}
|
||||
|
||||
virtual Handle<Object> Set(Handle<JSObject> holder, uint32_t key,
|
||||
Handle<FixedArrayBase> backing_store,
|
||||
Handle<Object> value) final {
|
||||
return ElementsAccessorSubclass::SetImpl(holder, key, backing_store, value);
|
||||
virtual void Set(Handle<JSObject> holder, uint32_t key,
|
||||
Handle<FixedArrayBase> backing_store,
|
||||
Handle<Object> value) final {
|
||||
ElementsAccessorSubclass::SetImpl(holder, key, backing_store, value);
|
||||
}
|
||||
|
||||
static Handle<Object> SetImpl(Handle<JSObject> obj, uint32_t key,
|
||||
Handle<FixedArrayBase> backing_store,
|
||||
Handle<Object> value) {
|
||||
static void SetImpl(Handle<JSObject> obj, uint32_t key,
|
||||
Handle<FixedArrayBase> backing_store,
|
||||
Handle<Object> value) {
|
||||
CHECK(key <
|
||||
ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store));
|
||||
return BackingStore::SetValue(
|
||||
obj, Handle<BackingStore>::cast(backing_store), key, value);
|
||||
BackingStore::SetValue(obj, Handle<BackingStore>::cast(backing_store), key,
|
||||
value);
|
||||
}
|
||||
|
||||
virtual MaybeHandle<AccessorPair> GetAccessorPair(
|
||||
@ -1447,15 +1447,13 @@ class DictionaryElementsAccessor
|
||||
return isolate->factory()->the_hole_value();
|
||||
}
|
||||
|
||||
static Handle<Object> SetImpl(Handle<JSObject> obj, uint32_t key,
|
||||
Handle<FixedArrayBase> store,
|
||||
Handle<Object> value) {
|
||||
static void SetImpl(Handle<JSObject> obj, uint32_t key,
|
||||
Handle<FixedArrayBase> store, Handle<Object> value) {
|
||||
Handle<SeededNumberDictionary> backing_store =
|
||||
Handle<SeededNumberDictionary>::cast(store);
|
||||
int entry = backing_store->FindEntry(key);
|
||||
DCHECK_NE(SeededNumberDictionary::kNotFound, entry);
|
||||
backing_store->ValueAtPut(entry, *value);
|
||||
return value;
|
||||
}
|
||||
|
||||
static MaybeHandle<AccessorPair> GetAccessorPairImpl(
|
||||
@ -1546,9 +1544,8 @@ class SloppyArgumentsElementsAccessor : public ElementsAccessorBase<
|
||||
}
|
||||
}
|
||||
|
||||
static Handle<Object> SetImpl(Handle<JSObject> obj, uint32_t key,
|
||||
Handle<FixedArrayBase> store,
|
||||
Handle<Object> value) {
|
||||
static void SetImpl(Handle<JSObject> obj, uint32_t key,
|
||||
Handle<FixedArrayBase> store, Handle<Object> value) {
|
||||
Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(store);
|
||||
Object* probe = GetParameterMapArg(*parameter_map, key);
|
||||
if (!probe->IsTheHole()) {
|
||||
@ -1556,11 +1553,10 @@ class SloppyArgumentsElementsAccessor : public ElementsAccessorBase<
|
||||
int context_index = Smi::cast(probe)->value();
|
||||
DCHECK(!context->get(context_index)->IsTheHole());
|
||||
context->set(context_index, *value);
|
||||
return value;
|
||||
} else {
|
||||
Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
|
||||
ElementsAccessor::ForArray(arguments)->Set(obj, key, arguments, value);
|
||||
}
|
||||
Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
|
||||
return ElementsAccessor::ForArray(arguments)
|
||||
->Set(obj, key, arguments, value);
|
||||
}
|
||||
|
||||
static MaybeHandle<AccessorPair> GetAccessorPairImpl(
|
||||
|
@ -43,9 +43,8 @@ class ElementsAccessor {
|
||||
return HasElement(holder, key, handle(holder->elements()));
|
||||
}
|
||||
|
||||
inline Handle<Object> Set(Handle<JSObject> holder, uint32_t key,
|
||||
Handle<Object> value) {
|
||||
return Set(holder, key, handle(holder->elements()), value);
|
||||
inline void Set(Handle<JSObject> holder, uint32_t key, Handle<Object> value) {
|
||||
Set(holder, key, handle(holder->elements()), value);
|
||||
}
|
||||
|
||||
// Returns the element with the specified key or undefined if there is no such
|
||||
@ -180,9 +179,9 @@ class ElementsAccessor {
|
||||
uint32_t index) = 0;
|
||||
virtual bool HasIndex(FixedArrayBase* backing_store, uint32_t key) = 0;
|
||||
|
||||
virtual Handle<Object> Set(Handle<JSObject> holder, uint32_t key,
|
||||
Handle<FixedArrayBase> backing_store,
|
||||
Handle<Object> value) = 0;
|
||||
virtual void Set(Handle<JSObject> holder, uint32_t key,
|
||||
Handle<FixedArrayBase> backing_store,
|
||||
Handle<Object> value) = 0;
|
||||
|
||||
private:
|
||||
static ElementsAccessor** elements_accessors_;
|
||||
|
@ -4002,9 +4002,9 @@ Handle<Object> FixedTypedArray<Traits>::get(
|
||||
|
||||
|
||||
template <class Traits>
|
||||
Handle<Object> FixedTypedArray<Traits>::SetValue(
|
||||
Handle<JSObject> holder, Handle<FixedTypedArray<Traits> > array,
|
||||
uint32_t index, Handle<Object> value) {
|
||||
void FixedTypedArray<Traits>::SetValue(Handle<JSObject> holder,
|
||||
Handle<FixedTypedArray<Traits> > array,
|
||||
uint32_t index, Handle<Object> value) {
|
||||
ElementType cast_value = Traits::defaultValue();
|
||||
Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder);
|
||||
if (!view->WasNeutered()) {
|
||||
@ -4023,7 +4023,6 @@ Handle<Object> FixedTypedArray<Traits>::SetValue(
|
||||
array->set(index, cast_value);
|
||||
}
|
||||
}
|
||||
return Traits::ToHandle(array->GetIsolate(), cast_value);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14713,24 +14713,20 @@ size_t JSTypedArray::element_size() {
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> FixedArray::SetValue(Handle<JSObject> holder,
|
||||
Handle<FixedArray> array, uint32_t index,
|
||||
Handle<Object> value) {
|
||||
void FixedArray::SetValue(Handle<JSObject> holder, Handle<FixedArray> array,
|
||||
uint32_t index, Handle<Object> value) {
|
||||
array->set(index, *value);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> FixedDoubleArray::SetValue(Handle<JSObject> holder,
|
||||
Handle<FixedDoubleArray> array,
|
||||
uint32_t index,
|
||||
Handle<Object> value) {
|
||||
void FixedDoubleArray::SetValue(Handle<JSObject> holder,
|
||||
Handle<FixedDoubleArray> array, uint32_t index,
|
||||
Handle<Object> value) {
|
||||
array->set(index, value->Number());
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> ExternalUint8ClampedArray::SetValue(
|
||||
void ExternalUint8ClampedArray::SetValue(
|
||||
Handle<JSObject> holder, Handle<ExternalUint8ClampedArray> array,
|
||||
uint32_t index, Handle<Object> value) {
|
||||
uint8_t clamped_value = 0;
|
||||
@ -14766,14 +14762,13 @@ Handle<Object> ExternalUint8ClampedArray::SetValue(
|
||||
array->set(index, clamped_value);
|
||||
}
|
||||
}
|
||||
return handle(Smi::FromInt(clamped_value), array->GetIsolate());
|
||||
}
|
||||
|
||||
|
||||
template <typename ExternalArrayClass, typename ValueType>
|
||||
static Handle<Object> ExternalArrayIntSetter(
|
||||
Isolate* isolate, Handle<JSObject> holder,
|
||||
Handle<ExternalArrayClass> receiver, uint32_t index, Handle<Object> value) {
|
||||
static void ExternalArrayIntSetter(Isolate* isolate, Handle<JSObject> holder,
|
||||
Handle<ExternalArrayClass> receiver,
|
||||
uint32_t index, Handle<Object> value) {
|
||||
ValueType cast_value = 0;
|
||||
Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder);
|
||||
if (!view->WasNeutered()) {
|
||||
@ -14792,59 +14787,52 @@ static Handle<Object> ExternalArrayIntSetter(
|
||||
receiver->set(index, cast_value);
|
||||
}
|
||||
}
|
||||
return isolate->factory()->NewNumberFromInt(cast_value);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> ExternalInt8Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalInt8Array> array,
|
||||
uint32_t index,
|
||||
Handle<Object> value) {
|
||||
return ExternalArrayIntSetter<ExternalInt8Array, int8_t>(
|
||||
void ExternalInt8Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalInt8Array> array,
|
||||
uint32_t index, Handle<Object> value) {
|
||||
ExternalArrayIntSetter<ExternalInt8Array, int8_t>(array->GetIsolate(), holder,
|
||||
array, index, value);
|
||||
}
|
||||
|
||||
|
||||
void ExternalUint8Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint8Array> array,
|
||||
uint32_t index, Handle<Object> value) {
|
||||
ExternalArrayIntSetter<ExternalUint8Array, uint8_t>(
|
||||
array->GetIsolate(), holder, array, index, value);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> ExternalUint8Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint8Array> array,
|
||||
uint32_t index,
|
||||
Handle<Object> value) {
|
||||
return ExternalArrayIntSetter<ExternalUint8Array, uint8_t>(
|
||||
void ExternalInt16Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalInt16Array> array,
|
||||
uint32_t index, Handle<Object> value) {
|
||||
ExternalArrayIntSetter<ExternalInt16Array, int16_t>(
|
||||
array->GetIsolate(), holder, array, index, value);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> ExternalInt16Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalInt16Array> array,
|
||||
uint32_t index,
|
||||
Handle<Object> value) {
|
||||
return ExternalArrayIntSetter<ExternalInt16Array, int16_t>(
|
||||
void ExternalUint16Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint16Array> array,
|
||||
uint32_t index, Handle<Object> value) {
|
||||
ExternalArrayIntSetter<ExternalUint16Array, uint16_t>(
|
||||
array->GetIsolate(), holder, array, index, value);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> ExternalUint16Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint16Array> array,
|
||||
uint32_t index,
|
||||
Handle<Object> value) {
|
||||
return ExternalArrayIntSetter<ExternalUint16Array, uint16_t>(
|
||||
void ExternalInt32Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalInt32Array> array,
|
||||
uint32_t index, Handle<Object> value) {
|
||||
ExternalArrayIntSetter<ExternalInt32Array, int32_t>(
|
||||
array->GetIsolate(), holder, array, index, value);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> ExternalInt32Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalInt32Array> array,
|
||||
uint32_t index,
|
||||
Handle<Object> value) {
|
||||
return ExternalArrayIntSetter<ExternalInt32Array, int32_t>(
|
||||
array->GetIsolate(), holder, array, index, value);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> ExternalUint32Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint32Array> array,
|
||||
uint32_t index,
|
||||
Handle<Object> value) {
|
||||
void ExternalUint32Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint32Array> array,
|
||||
uint32_t index, Handle<Object> value) {
|
||||
uint32_t cast_value = 0;
|
||||
Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder);
|
||||
if (!view->WasNeutered()) {
|
||||
@ -14863,13 +14851,12 @@ Handle<Object> ExternalUint32Array::SetValue(Handle<JSObject> holder,
|
||||
array->set(index, cast_value);
|
||||
}
|
||||
}
|
||||
return array->GetIsolate()->factory()->NewNumberFromUint(cast_value);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> ExternalFloat32Array::SetValue(
|
||||
Handle<JSObject> holder, Handle<ExternalFloat32Array> array, uint32_t index,
|
||||
Handle<Object> value) {
|
||||
void ExternalFloat32Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalFloat32Array> array,
|
||||
uint32_t index, Handle<Object> value) {
|
||||
float cast_value = std::numeric_limits<float>::quiet_NaN();
|
||||
Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder);
|
||||
if (!view->WasNeutered()) {
|
||||
@ -14888,13 +14875,12 @@ Handle<Object> ExternalFloat32Array::SetValue(
|
||||
array->set(index, cast_value);
|
||||
}
|
||||
}
|
||||
return array->GetIsolate()->factory()->NewNumber(cast_value);
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> ExternalFloat64Array::SetValue(
|
||||
Handle<JSObject> holder, Handle<ExternalFloat64Array> array, uint32_t index,
|
||||
Handle<Object> value) {
|
||||
void ExternalFloat64Array::SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalFloat64Array> array,
|
||||
uint32_t index, Handle<Object> value) {
|
||||
double double_value = std::numeric_limits<double>::quiet_NaN();
|
||||
Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder);
|
||||
if (!view->WasNeutered()) {
|
||||
@ -14909,7 +14895,6 @@ Handle<Object> ExternalFloat64Array::SetValue(
|
||||
array->set(index, double_value);
|
||||
}
|
||||
}
|
||||
return array->GetIsolate()->factory()->NewNumber(double_value);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2439,9 +2439,8 @@ class FixedArray: public FixedArrayBase {
|
||||
public:
|
||||
// Setter and getter for elements.
|
||||
inline Object* get(int index) const;
|
||||
static Handle<Object> SetValue(Handle<JSObject> holder,
|
||||
Handle<FixedArray> array, uint32_t index,
|
||||
Handle<Object> value);
|
||||
static void SetValue(Handle<JSObject> holder, Handle<FixedArray> array,
|
||||
uint32_t index, Handle<Object> value);
|
||||
static inline Handle<Object> get(Handle<FixedArray> array, int index);
|
||||
// Setter that uses write barrier.
|
||||
inline void set(int index, Object* value);
|
||||
@ -2564,9 +2563,8 @@ class FixedDoubleArray: public FixedArrayBase {
|
||||
inline uint64_t get_representation(int index);
|
||||
static inline Handle<Object> get(Handle<FixedDoubleArray> array, int index);
|
||||
// This accessor has to get a Number as |value|.
|
||||
static Handle<Object> SetValue(Handle<JSObject> holder,
|
||||
Handle<FixedDoubleArray> array, uint32_t index,
|
||||
Handle<Object> value);
|
||||
static void SetValue(Handle<JSObject> holder, Handle<FixedDoubleArray> array,
|
||||
uint32_t index, Handle<Object> value);
|
||||
inline void set(int index, double value);
|
||||
inline void set_the_hole(int index);
|
||||
|
||||
@ -4401,9 +4399,9 @@ class ExternalUint8ClampedArray: public ExternalArray {
|
||||
|
||||
// This accessor applies the correct conversion from Smi, HeapNumber
|
||||
// and undefined and clamps the converted value between 0 and 255.
|
||||
static Handle<Object> SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint8ClampedArray> array,
|
||||
uint32_t index, Handle<Object> value);
|
||||
static void SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint8ClampedArray> array, uint32_t index,
|
||||
Handle<Object> value);
|
||||
|
||||
DECLARE_CAST(ExternalUint8ClampedArray)
|
||||
|
||||
@ -4425,9 +4423,8 @@ class ExternalInt8Array: public ExternalArray {
|
||||
|
||||
// This accessor applies the correct conversion from Smi, HeapNumber
|
||||
// and undefined.
|
||||
static Handle<Object> SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalInt8Array> array,
|
||||
uint32_t index, Handle<Object> value);
|
||||
static void SetValue(Handle<JSObject> holder, Handle<ExternalInt8Array> array,
|
||||
uint32_t index, Handle<Object> value);
|
||||
|
||||
DECLARE_CAST(ExternalInt8Array)
|
||||
|
||||
@ -4449,9 +4446,9 @@ class ExternalUint8Array: public ExternalArray {
|
||||
|
||||
// This accessor applies the correct conversion from Smi, HeapNumber
|
||||
// and undefined.
|
||||
static Handle<Object> SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint8Array> array,
|
||||
uint32_t index, Handle<Object> value);
|
||||
static void SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint8Array> array, uint32_t index,
|
||||
Handle<Object> value);
|
||||
|
||||
DECLARE_CAST(ExternalUint8Array)
|
||||
|
||||
@ -4473,9 +4470,9 @@ class ExternalInt16Array: public ExternalArray {
|
||||
|
||||
// This accessor applies the correct conversion from Smi, HeapNumber
|
||||
// and undefined.
|
||||
static Handle<Object> SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalInt16Array> array,
|
||||
uint32_t index, Handle<Object> value);
|
||||
static void SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalInt16Array> array, uint32_t index,
|
||||
Handle<Object> value);
|
||||
|
||||
DECLARE_CAST(ExternalInt16Array)
|
||||
|
||||
@ -4498,9 +4495,9 @@ class ExternalUint16Array: public ExternalArray {
|
||||
|
||||
// This accessor applies the correct conversion from Smi, HeapNumber
|
||||
// and undefined.
|
||||
static Handle<Object> SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint16Array> array,
|
||||
uint32_t index, Handle<Object> value);
|
||||
static void SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint16Array> array, uint32_t index,
|
||||
Handle<Object> value);
|
||||
|
||||
DECLARE_CAST(ExternalUint16Array)
|
||||
|
||||
@ -4522,9 +4519,9 @@ class ExternalInt32Array: public ExternalArray {
|
||||
|
||||
// This accessor applies the correct conversion from Smi, HeapNumber
|
||||
// and undefined.
|
||||
static Handle<Object> SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalInt32Array> array,
|
||||
uint32_t index, Handle<Object> value);
|
||||
static void SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalInt32Array> array, uint32_t index,
|
||||
Handle<Object> value);
|
||||
|
||||
DECLARE_CAST(ExternalInt32Array)
|
||||
|
||||
@ -4547,9 +4544,9 @@ class ExternalUint32Array: public ExternalArray {
|
||||
|
||||
// This accessor applies the correct conversion from Smi, HeapNumber
|
||||
// and undefined.
|
||||
static Handle<Object> SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint32Array> array,
|
||||
uint32_t index, Handle<Object> value);
|
||||
static void SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalUint32Array> array, uint32_t index,
|
||||
Handle<Object> value);
|
||||
|
||||
DECLARE_CAST(ExternalUint32Array)
|
||||
|
||||
@ -4572,9 +4569,9 @@ class ExternalFloat32Array: public ExternalArray {
|
||||
|
||||
// This accessor applies the correct conversion from Smi, HeapNumber
|
||||
// and undefined.
|
||||
static Handle<Object> SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalFloat32Array> array,
|
||||
uint32_t index, Handle<Object> value);
|
||||
static void SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalFloat32Array> array, uint32_t index,
|
||||
Handle<Object> value);
|
||||
|
||||
DECLARE_CAST(ExternalFloat32Array)
|
||||
|
||||
@ -4597,9 +4594,9 @@ class ExternalFloat64Array: public ExternalArray {
|
||||
|
||||
// This accessor applies the correct conversion from Smi, HeapNumber
|
||||
// and undefined.
|
||||
static Handle<Object> SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalFloat64Array> array,
|
||||
uint32_t index, Handle<Object> value);
|
||||
static void SetValue(Handle<JSObject> holder,
|
||||
Handle<ExternalFloat64Array> array, uint32_t index,
|
||||
Handle<Object> value);
|
||||
|
||||
DECLARE_CAST(ExternalFloat64Array)
|
||||
|
||||
@ -4667,9 +4664,9 @@ class FixedTypedArray: public FixedTypedArrayBase {
|
||||
|
||||
// This accessor applies the correct conversion from Smi, HeapNumber
|
||||
// and undefined.
|
||||
static Handle<Object> SetValue(Handle<JSObject> holder,
|
||||
Handle<FixedTypedArray<Traits> > array,
|
||||
uint32_t index, Handle<Object> value);
|
||||
static void SetValue(Handle<JSObject> holder,
|
||||
Handle<FixedTypedArray<Traits> > array, uint32_t index,
|
||||
Handle<Object> value);
|
||||
|
||||
DECLARE_PRINTER(FixedTypedArray)
|
||||
DECLARE_VERIFIER(FixedTypedArray)
|
||||
|
Loading…
Reference in New Issue
Block a user