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

Side by Side Diff: src/objects-inl.h

Issue 1180753005: Cleanup typed array setters, the property is guaranteed to be there. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
« src/elements.h ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 4018 matching lines...) Expand 10 before | Expand all | Expand 10 after
4029 4029
4030 template <class Traits> 4030 template <class Traits>
4031 Handle<Object> FixedTypedArray<Traits>::get( 4031 Handle<Object> FixedTypedArray<Traits>::get(
4032 Handle<FixedTypedArray<Traits> > array, 4032 Handle<FixedTypedArray<Traits> > array,
4033 int index) { 4033 int index) {
4034 return Traits::ToHandle(array->GetIsolate(), array->get_scalar(index)); 4034 return Traits::ToHandle(array->GetIsolate(), array->get_scalar(index));
4035 } 4035 }
4036 4036
4037 4037
4038 template <class Traits> 4038 template <class Traits>
4039 void FixedTypedArray<Traits>::SetValue(Handle<JSObject> holder, 4039 void FixedTypedArray<Traits>::SetValue(Handle<FixedTypedArray<Traits> > array,
4040 Handle<FixedTypedArray<Traits> > array,
4041 uint32_t index, Handle<Object> value) { 4040 uint32_t index, Handle<Object> value) {
4042 ElementType cast_value = Traits::defaultValue(); 4041 ElementType cast_value = Traits::defaultValue();
4043 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); 4042 if (value->IsSmi()) {
4044 if (!view->WasNeutered()) { 4043 int int_value = Handle<Smi>::cast(value)->value();
4045 if (index < static_cast<uint32_t>(array->length())) { 4044 cast_value = from_int(int_value);
4046 if (value->IsSmi()) { 4045 } else if (value->IsHeapNumber()) {
4047 int int_value = Handle<Smi>::cast(value)->value(); 4046 double double_value = Handle<HeapNumber>::cast(value)->value();
4048 cast_value = from_int(int_value); 4047 cast_value = from_double(double_value);
4049 } else if (value->IsHeapNumber()) { 4048 } else {
4050 double double_value = Handle<HeapNumber>::cast(value)->value(); 4049 // Clamp undefined to the default value. All other types have been
4051 cast_value = from_double(double_value); 4050 // converted to a number type further up in the call chain.
4052 } else { 4051 DCHECK(value->IsUndefined());
4053 // Clamp undefined to the default value. All other types have been
4054 // converted to a number type further up in the call chain.
4055 DCHECK(value->IsUndefined());
4056 }
4057 array->set(index, cast_value);
4058 }
4059 } 4052 }
4053 array->set(index, cast_value);
4060 } 4054 }
4061 4055
4062 4056
4063 Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) { 4057 Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) {
4064 return handle(Smi::FromInt(scalar), isolate); 4058 return handle(Smi::FromInt(scalar), isolate);
4065 } 4059 }
4066 4060
4067 4061
4068 Handle<Object> Uint8ClampedArrayTraits::ToHandle(Isolate* isolate, 4062 Handle<Object> Uint8ClampedArrayTraits::ToHandle(Isolate* isolate,
4069 uint8_t scalar) { 4063 uint8_t scalar) {
(...skipping 3293 matching lines...) Expand 10 before | Expand all | Expand 10 after
7363 #undef READ_SHORT_FIELD 7357 #undef READ_SHORT_FIELD
7364 #undef WRITE_SHORT_FIELD 7358 #undef WRITE_SHORT_FIELD
7365 #undef READ_BYTE_FIELD 7359 #undef READ_BYTE_FIELD
7366 #undef WRITE_BYTE_FIELD 7360 #undef WRITE_BYTE_FIELD
7367 #undef NOBARRIER_READ_BYTE_FIELD 7361 #undef NOBARRIER_READ_BYTE_FIELD
7368 #undef NOBARRIER_WRITE_BYTE_FIELD 7362 #undef NOBARRIER_WRITE_BYTE_FIELD
7369 7363
7370 } } // namespace v8::internal 7364 } } // namespace v8::internal
7371 7365
7372 #endif // V8_OBJECTS_INL_H_ 7366 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/elements.h ('K') | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698