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

Side by Side Diff: src/builtins/builtins-sharedarraybuffer.cc

Issue 2623633003: [Atomics] Make Atomics.exchange a builtin using TF (Closed)
Patch Set: [Atomics] Make Atomics.exchange a builtin using TF Created 3 years, 11 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
OLDNEW
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
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(&i8);
303 a.Return(a.SmiFromWord32(a.AtomicExchange(MachineType::Int8(), backing_store,
304 index_word, value_word32)));
305
306 a.Bind(&u8);
307 a.Return(a.SmiFromWord32(a.AtomicExchange(MachineType::Uint8(), backing_store,
308 index_word, value_word32)));
309
310 a.Bind(&i16);
311 a.Return(a.SmiFromWord32(a.AtomicExchange(MachineType::Int16(), backing_store,
312 a.WordShl(index_word, 1),
313 value_word32)));
314
315 a.Bind(&u16);
316 a.Return(a.SmiFromWord32(
317 a.AtomicExchange(MachineType::Uint16(), backing_store,
318 a.WordShl(index_word, 1), value_word32)));
319
320 a.Bind(&i32);
321 a.Return(a.ChangeInt32ToTagged(
322 a.AtomicExchange(MachineType::Int32(), backing_store,
323 a.WordShl(index_word, 2), value_word32)));
324
325 a.Bind(&u32);
326 a.Return(a.ChangeUint32ToTagged(
327 a.AtomicExchange(MachineType::Uint32(), 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698