| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #include <iomanip> | 5 #include <iomanip> |
| 6 #include <sstream> | 6 #include <sstream> |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
| (...skipping 13271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13282 case FAST_ELEMENTS: | 13282 case FAST_ELEMENTS: |
| 13283 case FAST_HOLEY_SMI_ELEMENTS: | 13283 case FAST_HOLEY_SMI_ELEMENTS: |
| 13284 case FAST_HOLEY_ELEMENTS: | 13284 case FAST_HOLEY_ELEMENTS: |
| 13285 return SetFastElement(object, index, value, language_mode, | 13285 return SetFastElement(object, index, value, language_mode, |
| 13286 check_prototype); | 13286 check_prototype); |
| 13287 case FAST_DOUBLE_ELEMENTS: | 13287 case FAST_DOUBLE_ELEMENTS: |
| 13288 case FAST_HOLEY_DOUBLE_ELEMENTS: | 13288 case FAST_HOLEY_DOUBLE_ELEMENTS: |
| 13289 return SetFastDoubleElement(object, index, value, language_mode, | 13289 return SetFastDoubleElement(object, index, value, language_mode, |
| 13290 check_prototype); | 13290 check_prototype); |
| 13291 | 13291 |
| 13292 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 13292 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 13293 case EXTERNAL_##TYPE##_ELEMENTS: { \ | 13293 case EXTERNAL_##TYPE##_ELEMENTS: { \ |
| 13294 Handle<External##Type##Array> array( \ | 13294 Handle<External##Type##Array> array( \ |
| 13295 External##Type##Array::cast(object->elements())); \ | 13295 External##Type##Array::cast(object->elements())); \ |
| 13296 return External##Type##Array::SetValue(array, index, value); \ | 13296 return External##Type##Array::SetValue(object, array, index, value); \ |
| 13297 } \ | 13297 } \ |
| 13298 case TYPE##_ELEMENTS: { \ | 13298 case TYPE##_ELEMENTS: { \ |
| 13299 Handle<Fixed##Type##Array> array( \ | 13299 Handle<Fixed##Type##Array> array( \ |
| 13300 Fixed##Type##Array::cast(object->elements())); \ | 13300 Fixed##Type##Array::cast(object->elements())); \ |
| 13301 return Fixed##Type##Array::SetValue(array, index, value); \ | 13301 return Fixed##Type##Array::SetValue(object, array, index, value); \ |
| 13302 } | 13302 } |
| 13303 | 13303 |
| 13304 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 13304 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 13305 | 13305 |
| 13306 #undef TYPED_ARRAY_CASE | 13306 #undef TYPED_ARRAY_CASE |
| 13307 | 13307 |
| 13308 case DICTIONARY_ELEMENTS: | 13308 case DICTIONARY_ELEMENTS: |
| 13309 return SetDictionaryElement(object, index, value, attributes, | 13309 return SetDictionaryElement(object, index, value, attributes, |
| 13310 language_mode, check_prototype, set_mode); | 13310 language_mode, check_prototype, set_mode); |
| 13311 case SLOPPY_ARGUMENTS_ELEMENTS: { | 13311 case SLOPPY_ARGUMENTS_ELEMENTS: { |
| 13312 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); | 13312 Handle<FixedArray> parameter_map(FixedArray::cast(object->elements())); |
| (...skipping 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15156 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE | 15156 #undef INSTANCE_TYPE_TO_ELEMENT_SIZE |
| 15157 | 15157 |
| 15158 default: | 15158 default: |
| 15159 UNREACHABLE(); | 15159 UNREACHABLE(); |
| 15160 return 0; | 15160 return 0; |
| 15161 } | 15161 } |
| 15162 } | 15162 } |
| 15163 | 15163 |
| 15164 | 15164 |
| 15165 Handle<Object> ExternalUint8ClampedArray::SetValue( | 15165 Handle<Object> ExternalUint8ClampedArray::SetValue( |
| 15166 Handle<ExternalUint8ClampedArray> array, | 15166 Handle<JSObject> holder, Handle<ExternalUint8ClampedArray> array, |
| 15167 uint32_t index, | 15167 uint32_t index, Handle<Object> value) { |
| 15168 Handle<Object> value) { | |
| 15169 uint8_t clamped_value = 0; | 15168 uint8_t clamped_value = 0; |
| 15170 if (index < static_cast<uint32_t>(array->length())) { | 15169 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15171 if (value->IsSmi()) { | 15170 if (view->buffer()->IsSmi() || |
| 15172 int int_value = Handle<Smi>::cast(value)->value(); | 15171 !JSArrayBuffer::cast(view->buffer())->was_neutered()) { |
| 15173 if (int_value < 0) { | 15172 if (index < static_cast<uint32_t>(array->length())) { |
| 15174 clamped_value = 0; | 15173 if (value->IsSmi()) { |
| 15175 } else if (int_value > 255) { | 15174 int int_value = Handle<Smi>::cast(value)->value(); |
| 15176 clamped_value = 255; | 15175 if (int_value < 0) { |
| 15176 clamped_value = 0; |
| 15177 } else if (int_value > 255) { |
| 15178 clamped_value = 255; |
| 15179 } else { |
| 15180 clamped_value = static_cast<uint8_t>(int_value); |
| 15181 } |
| 15182 } else if (value->IsHeapNumber()) { |
| 15183 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 15184 if (!(double_value > 0)) { |
| 15185 // NaN and less than zero clamp to zero. |
| 15186 clamped_value = 0; |
| 15187 } else if (double_value > 255) { |
| 15188 // Greater than 255 clamp to 255. |
| 15189 clamped_value = 255; |
| 15190 } else { |
| 15191 // Other doubles are rounded to the nearest integer. |
| 15192 clamped_value = static_cast<uint8_t>(lrint(double_value)); |
| 15193 } |
| 15177 } else { | 15194 } else { |
| 15178 clamped_value = static_cast<uint8_t>(int_value); | 15195 // Clamp undefined to zero (default). All other types have been |
| 15196 // converted to a number type further up in the call chain. |
| 15197 DCHECK(value->IsUndefined()); |
| 15179 } | 15198 } |
| 15180 } else if (value->IsHeapNumber()) { | 15199 array->set(index, clamped_value); |
| 15181 double double_value = Handle<HeapNumber>::cast(value)->value(); | |
| 15182 if (!(double_value > 0)) { | |
| 15183 // NaN and less than zero clamp to zero. | |
| 15184 clamped_value = 0; | |
| 15185 } else if (double_value > 255) { | |
| 15186 // Greater than 255 clamp to 255. | |
| 15187 clamped_value = 255; | |
| 15188 } else { | |
| 15189 // Other doubles are rounded to the nearest integer. | |
| 15190 clamped_value = static_cast<uint8_t>(lrint(double_value)); | |
| 15191 } | |
| 15192 } else { | |
| 15193 // Clamp undefined to zero (default). All other types have been | |
| 15194 // converted to a number type further up in the call chain. | |
| 15195 DCHECK(value->IsUndefined()); | |
| 15196 } | 15200 } |
| 15197 array->set(index, clamped_value); | |
| 15198 } | 15201 } |
| 15199 return handle(Smi::FromInt(clamped_value), array->GetIsolate()); | 15202 return handle(Smi::FromInt(clamped_value), array->GetIsolate()); |
| 15200 } | 15203 } |
| 15201 | 15204 |
| 15202 | 15205 |
| 15203 template<typename ExternalArrayClass, typename ValueType> | 15206 template <typename ExternalArrayClass, typename ValueType> |
| 15204 static Handle<Object> ExternalArrayIntSetter( | 15207 static Handle<Object> ExternalArrayIntSetter( |
| 15205 Isolate* isolate, | 15208 Isolate* isolate, Handle<JSObject> holder, |
| 15206 Handle<ExternalArrayClass> receiver, | 15209 Handle<ExternalArrayClass> receiver, uint32_t index, Handle<Object> value) { |
| 15207 uint32_t index, | |
| 15208 Handle<Object> value) { | |
| 15209 ValueType cast_value = 0; | 15210 ValueType cast_value = 0; |
| 15210 if (index < static_cast<uint32_t>(receiver->length())) { | 15211 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15211 if (value->IsSmi()) { | 15212 if (view->buffer()->IsSmi() || |
| 15212 int int_value = Handle<Smi>::cast(value)->value(); | 15213 !JSArrayBuffer::cast(view->buffer())->was_neutered()) { |
| 15213 cast_value = static_cast<ValueType>(int_value); | 15214 if (index < static_cast<uint32_t>(receiver->length())) { |
| 15214 } else if (value->IsHeapNumber()) { | 15215 if (value->IsSmi()) { |
| 15215 double double_value = Handle<HeapNumber>::cast(value)->value(); | 15216 int int_value = Handle<Smi>::cast(value)->value(); |
| 15216 cast_value = static_cast<ValueType>(DoubleToInt32(double_value)); | 15217 cast_value = static_cast<ValueType>(int_value); |
| 15217 } else { | 15218 } else if (value->IsHeapNumber()) { |
| 15218 // Clamp undefined to zero (default). All other types have been | 15219 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 15219 // converted to a number type further up in the call chain. | 15220 cast_value = static_cast<ValueType>(DoubleToInt32(double_value)); |
| 15220 DCHECK(value->IsUndefined()); | 15221 } else { |
| 15222 // Clamp undefined to zero (default). All other types have been |
| 15223 // converted to a number type further up in the call chain. |
| 15224 DCHECK(value->IsUndefined()); |
| 15225 } |
| 15226 receiver->set(index, cast_value); |
| 15221 } | 15227 } |
| 15222 receiver->set(index, cast_value); | |
| 15223 } | 15228 } |
| 15224 return isolate->factory()->NewNumberFromInt(cast_value); | 15229 return isolate->factory()->NewNumberFromInt(cast_value); |
| 15225 } | 15230 } |
| 15226 | 15231 |
| 15227 | 15232 |
| 15228 Handle<Object> ExternalInt8Array::SetValue(Handle<ExternalInt8Array> array, | 15233 Handle<Object> ExternalInt8Array::SetValue(Handle<JSObject> holder, |
| 15234 Handle<ExternalInt8Array> array, |
| 15229 uint32_t index, | 15235 uint32_t index, |
| 15230 Handle<Object> value) { | 15236 Handle<Object> value) { |
| 15231 return ExternalArrayIntSetter<ExternalInt8Array, int8_t>( | 15237 return ExternalArrayIntSetter<ExternalInt8Array, int8_t>( |
| 15232 array->GetIsolate(), array, index, value); | 15238 array->GetIsolate(), holder, array, index, value); |
| 15233 } | 15239 } |
| 15234 | 15240 |
| 15235 | 15241 |
| 15236 Handle<Object> ExternalUint8Array::SetValue(Handle<ExternalUint8Array> array, | 15242 Handle<Object> ExternalUint8Array::SetValue(Handle<JSObject> holder, |
| 15243 Handle<ExternalUint8Array> array, |
| 15237 uint32_t index, | 15244 uint32_t index, |
| 15238 Handle<Object> value) { | 15245 Handle<Object> value) { |
| 15239 return ExternalArrayIntSetter<ExternalUint8Array, uint8_t>( | 15246 return ExternalArrayIntSetter<ExternalUint8Array, uint8_t>( |
| 15240 array->GetIsolate(), array, index, value); | 15247 array->GetIsolate(), holder, array, index, value); |
| 15241 } | 15248 } |
| 15242 | 15249 |
| 15243 | 15250 |
| 15244 Handle<Object> ExternalInt16Array::SetValue(Handle<ExternalInt16Array> array, | 15251 Handle<Object> ExternalInt16Array::SetValue(Handle<JSObject> holder, |
| 15252 Handle<ExternalInt16Array> array, |
| 15245 uint32_t index, | 15253 uint32_t index, |
| 15246 Handle<Object> value) { | 15254 Handle<Object> value) { |
| 15247 return ExternalArrayIntSetter<ExternalInt16Array, int16_t>( | 15255 return ExternalArrayIntSetter<ExternalInt16Array, int16_t>( |
| 15248 array->GetIsolate(), array, index, value); | 15256 array->GetIsolate(), holder, array, index, value); |
| 15249 } | 15257 } |
| 15250 | 15258 |
| 15251 | 15259 |
| 15252 Handle<Object> ExternalUint16Array::SetValue(Handle<ExternalUint16Array> array, | 15260 Handle<Object> ExternalUint16Array::SetValue(Handle<JSObject> holder, |
| 15261 Handle<ExternalUint16Array> array, |
| 15253 uint32_t index, | 15262 uint32_t index, |
| 15254 Handle<Object> value) { | 15263 Handle<Object> value) { |
| 15255 return ExternalArrayIntSetter<ExternalUint16Array, uint16_t>( | 15264 return ExternalArrayIntSetter<ExternalUint16Array, uint16_t>( |
| 15256 array->GetIsolate(), array, index, value); | 15265 array->GetIsolate(), holder, array, index, value); |
| 15257 } | 15266 } |
| 15258 | 15267 |
| 15259 | 15268 |
| 15260 Handle<Object> ExternalInt32Array::SetValue(Handle<ExternalInt32Array> array, | 15269 Handle<Object> ExternalInt32Array::SetValue(Handle<JSObject> holder, |
| 15270 Handle<ExternalInt32Array> array, |
| 15261 uint32_t index, | 15271 uint32_t index, |
| 15262 Handle<Object> value) { | 15272 Handle<Object> value) { |
| 15263 return ExternalArrayIntSetter<ExternalInt32Array, int32_t>( | 15273 return ExternalArrayIntSetter<ExternalInt32Array, int32_t>( |
| 15264 array->GetIsolate(), array, index, value); | 15274 array->GetIsolate(), holder, array, index, value); |
| 15265 } | 15275 } |
| 15266 | 15276 |
| 15267 | 15277 |
| 15268 Handle<Object> ExternalUint32Array::SetValue( | 15278 Handle<Object> ExternalUint32Array::SetValue(Handle<JSObject> holder, |
| 15269 Handle<ExternalUint32Array> array, | 15279 Handle<ExternalUint32Array> array, |
| 15270 uint32_t index, | 15280 uint32_t index, |
| 15271 Handle<Object> value) { | 15281 Handle<Object> value) { |
| 15272 uint32_t cast_value = 0; | 15282 uint32_t cast_value = 0; |
| 15273 if (index < static_cast<uint32_t>(array->length())) { | 15283 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15274 if (value->IsSmi()) { | 15284 if (view->buffer()->IsSmi() || |
| 15275 int int_value = Handle<Smi>::cast(value)->value(); | 15285 !JSArrayBuffer::cast(view->buffer())->was_neutered()) { |
| 15276 cast_value = static_cast<uint32_t>(int_value); | 15286 if (index < static_cast<uint32_t>(array->length())) { |
| 15277 } else if (value->IsHeapNumber()) { | 15287 if (value->IsSmi()) { |
| 15278 double double_value = Handle<HeapNumber>::cast(value)->value(); | 15288 int int_value = Handle<Smi>::cast(value)->value(); |
| 15279 cast_value = static_cast<uint32_t>(DoubleToUint32(double_value)); | 15289 cast_value = static_cast<uint32_t>(int_value); |
| 15280 } else { | 15290 } else if (value->IsHeapNumber()) { |
| 15281 // Clamp undefined to zero (default). All other types have been | 15291 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 15282 // converted to a number type further up in the call chain. | 15292 cast_value = static_cast<uint32_t>(DoubleToUint32(double_value)); |
| 15283 DCHECK(value->IsUndefined()); | 15293 } else { |
| 15294 // Clamp undefined to zero (default). All other types have been |
| 15295 // converted to a number type further up in the call chain. |
| 15296 DCHECK(value->IsUndefined()); |
| 15297 } |
| 15298 array->set(index, cast_value); |
| 15284 } | 15299 } |
| 15285 array->set(index, cast_value); | |
| 15286 } | 15300 } |
| 15287 return array->GetIsolate()->factory()->NewNumberFromUint(cast_value); | 15301 return array->GetIsolate()->factory()->NewNumberFromUint(cast_value); |
| 15288 } | 15302 } |
| 15289 | 15303 |
| 15290 | 15304 |
| 15291 Handle<Object> ExternalFloat32Array::SetValue( | 15305 Handle<Object> ExternalFloat32Array::SetValue( |
| 15292 Handle<ExternalFloat32Array> array, | 15306 Handle<JSObject> holder, Handle<ExternalFloat32Array> array, uint32_t index, |
| 15293 uint32_t index, | |
| 15294 Handle<Object> value) { | 15307 Handle<Object> value) { |
| 15295 float cast_value = std::numeric_limits<float>::quiet_NaN(); | 15308 float cast_value = std::numeric_limits<float>::quiet_NaN(); |
| 15296 if (index < static_cast<uint32_t>(array->length())) { | 15309 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15297 if (value->IsSmi()) { | 15310 if (view->buffer()->IsSmi() || |
| 15298 int int_value = Handle<Smi>::cast(value)->value(); | 15311 !JSArrayBuffer::cast(view->buffer())->was_neutered()) { |
| 15299 cast_value = static_cast<float>(int_value); | 15312 if (index < static_cast<uint32_t>(array->length())) { |
| 15300 } else if (value->IsHeapNumber()) { | 15313 if (value->IsSmi()) { |
| 15301 double double_value = Handle<HeapNumber>::cast(value)->value(); | 15314 int int_value = Handle<Smi>::cast(value)->value(); |
| 15302 cast_value = static_cast<float>(double_value); | 15315 cast_value = static_cast<float>(int_value); |
| 15303 } else { | 15316 } else if (value->IsHeapNumber()) { |
| 15304 // Clamp undefined to NaN (default). All other types have been | 15317 double double_value = Handle<HeapNumber>::cast(value)->value(); |
| 15305 // converted to a number type further up in the call chain. | 15318 cast_value = static_cast<float>(double_value); |
| 15306 DCHECK(value->IsUndefined()); | 15319 } else { |
| 15320 // Clamp undefined to NaN (default). All other types have been |
| 15321 // converted to a number type further up in the call chain. |
| 15322 DCHECK(value->IsUndefined()); |
| 15323 } |
| 15324 array->set(index, cast_value); |
| 15307 } | 15325 } |
| 15308 array->set(index, cast_value); | |
| 15309 } | 15326 } |
| 15310 return array->GetIsolate()->factory()->NewNumber(cast_value); | 15327 return array->GetIsolate()->factory()->NewNumber(cast_value); |
| 15311 } | 15328 } |
| 15312 | 15329 |
| 15313 | 15330 |
| 15314 Handle<Object> ExternalFloat64Array::SetValue( | 15331 Handle<Object> ExternalFloat64Array::SetValue( |
| 15315 Handle<ExternalFloat64Array> array, | 15332 Handle<JSObject> holder, Handle<ExternalFloat64Array> array, uint32_t index, |
| 15316 uint32_t index, | |
| 15317 Handle<Object> value) { | 15333 Handle<Object> value) { |
| 15318 double double_value = std::numeric_limits<double>::quiet_NaN(); | 15334 double double_value = std::numeric_limits<double>::quiet_NaN(); |
| 15319 if (index < static_cast<uint32_t>(array->length())) { | 15335 Handle<JSArrayBufferView> view = Handle<JSArrayBufferView>::cast(holder); |
| 15320 if (value->IsNumber()) { | 15336 if (view->buffer()->IsSmi() || |
| 15321 double_value = value->Number(); | 15337 !JSArrayBuffer::cast(view->buffer())->was_neutered()) { |
| 15322 } else { | 15338 if (index < static_cast<uint32_t>(array->length())) { |
| 15323 // Clamp undefined to NaN (default). All other types have been | 15339 if (value->IsNumber()) { |
| 15324 // converted to a number type further up in the call chain. | 15340 double_value = value->Number(); |
| 15325 DCHECK(value->IsUndefined()); | 15341 } else { |
| 15342 // Clamp undefined to NaN (default). All other types have been |
| 15343 // converted to a number type further up in the call chain. |
| 15344 DCHECK(value->IsUndefined()); |
| 15345 } |
| 15346 array->set(index, double_value); |
| 15326 } | 15347 } |
| 15327 array->set(index, double_value); | |
| 15328 } | 15348 } |
| 15329 return array->GetIsolate()->factory()->NewNumber(double_value); | 15349 return array->GetIsolate()->factory()->NewNumber(double_value); |
| 15330 } | 15350 } |
| 15331 | 15351 |
| 15332 | 15352 |
| 15333 void GlobalObject::InvalidatePropertyCell(Handle<GlobalObject> global, | 15353 void GlobalObject::InvalidatePropertyCell(Handle<GlobalObject> global, |
| 15334 Handle<Name> name) { | 15354 Handle<Name> name) { |
| 15335 DCHECK(!global->HasFastProperties()); | 15355 DCHECK(!global->HasFastProperties()); |
| 15336 auto dictionary = handle(global->property_dictionary()); | 15356 auto dictionary = handle(global->property_dictionary()); |
| 15337 int entry = dictionary->FindEntry(name); | 15357 int entry = dictionary->FindEntry(name); |
| (...skipping 1541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16879 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 16899 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 16880 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 16900 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 16881 } | 16901 } |
| 16882 | 16902 |
| 16883 | 16903 |
| 16884 void JSArrayBuffer::Neuter() { | 16904 void JSArrayBuffer::Neuter() { |
| 16885 CHECK(is_neuterable()); | 16905 CHECK(is_neuterable()); |
| 16886 CHECK(is_external()); | 16906 CHECK(is_external()); |
| 16887 set_backing_store(NULL); | 16907 set_backing_store(NULL); |
| 16888 set_byte_length(Smi::FromInt(0)); | 16908 set_byte_length(Smi::FromInt(0)); |
| 16909 set_was_neutered(true); |
| 16889 } | 16910 } |
| 16890 | 16911 |
| 16891 | 16912 |
| 16892 void JSArrayBufferView::NeuterView() { | |
| 16893 CHECK(JSArrayBuffer::cast(buffer())->is_neuterable()); | |
| 16894 set_byte_offset(Smi::FromInt(0)); | |
| 16895 set_byte_length(Smi::FromInt(0)); | |
| 16896 } | |
| 16897 | |
| 16898 | |
| 16899 void JSDataView::Neuter() { | |
| 16900 NeuterView(); | |
| 16901 } | |
| 16902 | |
| 16903 | |
| 16904 void JSTypedArray::Neuter() { | |
| 16905 NeuterView(); | |
| 16906 set_length(Smi::FromInt(0)); | |
| 16907 set_elements(GetHeap()->EmptyExternalArrayForMap(map())); | |
| 16908 } | |
| 16909 | |
| 16910 | |
| 16911 static ElementsKind FixedToExternalElementsKind(ElementsKind elements_kind) { | 16913 static ElementsKind FixedToExternalElementsKind(ElementsKind elements_kind) { |
| 16912 switch (elements_kind) { | 16914 switch (elements_kind) { |
| 16913 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 16915 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
| 16914 case TYPE##_ELEMENTS: return EXTERNAL_##TYPE##_ELEMENTS; | 16916 case TYPE##_ELEMENTS: return EXTERNAL_##TYPE##_ELEMENTS; |
| 16915 | 16917 |
| 16916 TYPED_ARRAYS(TYPED_ARRAY_CASE) | 16918 TYPED_ARRAYS(TYPED_ARRAY_CASE) |
| 16917 #undef TYPED_ARRAY_CASE | 16919 #undef TYPED_ARRAY_CASE |
| 16918 | 16920 |
| 16919 default: | 16921 default: |
| 16920 UNREACHABLE(); | 16922 UNREACHABLE(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 16941 Runtime::SetupArrayBufferAllocatingData(isolate, buffer, | 16943 Runtime::SetupArrayBufferAllocatingData(isolate, buffer, |
| 16942 fixed_typed_array->DataSize(), false); | 16944 fixed_typed_array->DataSize(), false); |
| 16943 memcpy(buffer->backing_store(), | 16945 memcpy(buffer->backing_store(), |
| 16944 fixed_typed_array->DataPtr(), | 16946 fixed_typed_array->DataPtr(), |
| 16945 fixed_typed_array->DataSize()); | 16947 fixed_typed_array->DataSize()); |
| 16946 Handle<ExternalArray> new_elements = | 16948 Handle<ExternalArray> new_elements = |
| 16947 isolate->factory()->NewExternalArray( | 16949 isolate->factory()->NewExternalArray( |
| 16948 fixed_typed_array->length(), typed_array->type(), | 16950 fixed_typed_array->length(), typed_array->type(), |
| 16949 static_cast<uint8_t*>(buffer->backing_store())); | 16951 static_cast<uint8_t*>(buffer->backing_store())); |
| 16950 | 16952 |
| 16951 Heap* heap = isolate->heap(); | |
| 16952 if (heap->InNewSpace(*typed_array)) { | |
| 16953 DCHECK(typed_array->weak_next() == isolate->heap()->undefined_value()); | |
| 16954 typed_array->set_weak_next(heap->new_array_buffer_views_list()); | |
| 16955 heap->set_new_array_buffer_views_list(*typed_array); | |
| 16956 } else { | |
| 16957 buffer->set_weak_first_view(*typed_array); | |
| 16958 DCHECK(typed_array->weak_next() == isolate->heap()->undefined_value()); | |
| 16959 } | |
| 16960 typed_array->set_buffer(*buffer); | 16953 typed_array->set_buffer(*buffer); |
| 16961 JSObject::SetMapAndElements(typed_array, new_map, new_elements); | 16954 JSObject::SetMapAndElements(typed_array, new_map, new_elements); |
| 16962 | 16955 |
| 16963 return buffer; | 16956 return buffer; |
| 16964 } | 16957 } |
| 16965 | 16958 |
| 16966 | 16959 |
| 16967 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { | 16960 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { |
| 16968 Handle<Object> result(buffer(), GetIsolate()); | 16961 Handle<Object> result(buffer(), GetIsolate()); |
| 16969 if (*result != Smi::FromInt(0)) { | 16962 if (*result != Smi::FromInt(0)) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 17076 if (!invalidate && old_type == PropertyCellType::kConstant && | 17069 if (!invalidate && old_type == PropertyCellType::kConstant && |
| 17077 new_type != PropertyCellType::kConstant) { | 17070 new_type != PropertyCellType::kConstant) { |
| 17078 auto isolate = dictionary->GetIsolate(); | 17071 auto isolate = dictionary->GetIsolate(); |
| 17079 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 17072 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 17080 isolate, DependentCode::kPropertyCellChangedGroup); | 17073 isolate, DependentCode::kPropertyCellChangedGroup); |
| 17081 } | 17074 } |
| 17082 return value; | 17075 return value; |
| 17083 } | 17076 } |
| 17084 | 17077 |
| 17085 } } // namespace v8::internal | 17078 } } // namespace v8::internal |
| OLD | NEW |