Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 "src/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
| 6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 a.Bind(&u32); | 259 a.Bind(&u32); |
| 260 a.AtomicStore(MachineRepresentation::kWord32, backing_store, | 260 a.AtomicStore(MachineRepresentation::kWord32, backing_store, |
| 261 a.WordShl(index_word, 2), value_word32); | 261 a.WordShl(index_word, 2), value_word32); |
| 262 a.Return(value_integer); | 262 a.Return(value_integer); |
| 263 | 263 |
| 264 // This shouldn't happen, we've already validated the type. | 264 // This shouldn't happen, we've already validated the type. |
| 265 a.Bind(&other); | 265 a.Bind(&other); |
| 266 a.Return(a.SmiConstant(0)); | 266 a.Return(a.SmiConstant(0)); |
| 267 } | 267 } |
| 268 | 268 |
| 269 void Builtins::Generate_AtomicsExchange(compiler::CodeAssemblerState* state) { | |
| 270 using compiler::Node; | |
| 271 CodeStubAssembler a(state); | |
| 272 Node* array = a.Parameter(1); | |
| 273 Node* index = a.Parameter(2); | |
| 274 Node* value = a.Parameter(3); | |
| 275 Node* context = a.Parameter(4 + 2); | |
| 276 | |
| 277 Node* instance_type; | |
| 278 Node* backing_store; | |
| 279 ValidateSharedTypedArray(&a, array, context, &instance_type, &backing_store); | |
| 280 | |
| 281 Node* index_word32 = ConvertTaggedAtomicIndexToWord32(&a, index, context); | |
| 282 Node* array_length_word32 = a.TruncateTaggedToWord32( | |
| 283 context, a.LoadObjectField(array, JSTypedArray::kLengthOffset)); | |
| 284 ValidateAtomicIndex(&a, index_word32, array_length_word32, context); | |
| 285 Node* index_word = a.ChangeUint32ToWord(index_word32); | |
| 286 | |
| 287 Node* value_integer = a.ToInteger(context, value); | |
| 288 Node* value_word32 = a.TruncateTaggedToWord32(context, value_integer); | |
| 289 | |
| 290 CodeStubAssembler::Label i8(&a), u8(&a), i16(&a), u16(&a), i32(&a), u32(&a), | |
| 291 other(&a); | |
| 292 int32_t case_values[] = { | |
| 293 FIXED_INT8_ARRAY_TYPE, FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE, | |
| 294 FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE, | |
| 295 }; | |
| 296 CodeStubAssembler::Label* case_labels[] = { | |
| 297 &i8, &u8, &i16, &u16, &i32, &u32, | |
| 298 }; | |
| 299 a.Switch(instance_type, &other, case_values, case_labels, | |
| 300 arraysize(case_labels)); | |
| 301 | |
| 302 a.Bind(&u8); | |
|
binji
2017/01/13 00:08:50
nit: I'd prefer matching the order of the case lab
aseemgarg
2017/01/14 01:48:19
Done.
| |
| 303 a.Return(a.SmiFromWord32(a.AtomicExchange(MachineType::Uint8(), backing_store, | |
| 304 index_word, value_word32))); | |
| 305 | |
| 306 a.Bind(&i8); | |
| 307 a.Return(a.SmiFromWord32(a.AtomicExchange(MachineType::Int8(), backing_store, | |
| 308 index_word, value_word32))); | |
| 309 | |
| 310 a.Bind(&u16); | |
| 311 a.Return(a.SmiFromWord32( | |
| 312 a.AtomicExchange(MachineType::Uint16(), backing_store, | |
| 313 a.WordShl(index_word, 1), value_word32))); | |
| 314 | |
| 315 a.Bind(&i16); | |
| 316 a.Return(a.SmiFromWord32(a.AtomicExchange(MachineType::Int16(), backing_store, | |
| 317 a.WordShl(index_word, 1), | |
| 318 value_word32))); | |
| 319 | |
| 320 a.Bind(&u32); | |
| 321 a.Return(a.ChangeUint32ToTagged( | |
| 322 a.AtomicExchange(MachineType::Uint32(), backing_store, | |
| 323 a.WordShl(index_word, 2), value_word32))); | |
| 324 | |
| 325 a.Bind(&i32); | |
| 326 a.Return(a.ChangeInt32ToTagged( | |
| 327 a.AtomicExchange(MachineType::Int32(), backing_store, | |
| 328 a.WordShl(index_word, 2), value_word32))); | |
| 329 | |
| 330 // This shouldn't happen, we've already validated the type. | |
| 331 a.Bind(&other); | |
| 332 a.Return(a.SmiConstant(0)); | |
| 333 } | |
| 334 | |
| 269 } // namespace internal | 335 } // namespace internal |
| 270 } // namespace v8 | 336 } // namespace v8 |
| OLD | NEW |