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/code-stub-assembler.h" | 5 #include "src/code-stub-assembler.h" |
6 #include "src/code-factory.h" | 6 #include "src/code-factory.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 | 10 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 SmiTag(size_in_bytes)); | 368 SmiTag(size_in_bytes)); |
369 } | 369 } |
370 result.Bind(runtime_result); | 370 result.Bind(runtime_result); |
371 Goto(&merge_runtime); | 371 Goto(&merge_runtime); |
372 | 372 |
373 // When there is enough space, return `top' and bump it up. | 373 // When there is enough space, return `top' and bump it up. |
374 Bind(&no_runtime_call); | 374 Bind(&no_runtime_call); |
375 Node* no_runtime_result = top; | 375 Node* no_runtime_result = top; |
376 StoreNoWriteBarrier(MachineType::PointerRepresentation(), top_address, | 376 StoreNoWriteBarrier(MachineType::PointerRepresentation(), top_address, |
377 new_top); | 377 new_top); |
378 result.Bind(BitcastWordToTagged(no_runtime_result)); | 378 no_runtime_result = BitcastWordToTagged( |
| 379 IntPtrAdd(no_runtime_result, IntPtrConstant(kHeapObjectTag))); |
| 380 result.Bind(no_runtime_result); |
379 Goto(&merge_runtime); | 381 Goto(&merge_runtime); |
380 | 382 |
381 Bind(&merge_runtime); | 383 Bind(&merge_runtime); |
382 return result.value(); | 384 return result.value(); |
383 } | 385 } |
384 | 386 |
385 Node* CodeStubAssembler::AllocateRawAligned(Node* size_in_bytes, | 387 Node* CodeStubAssembler::AllocateRawAligned(Node* size_in_bytes, |
386 AllocationFlags flags, | 388 AllocationFlags flags, |
387 Node* top_address, | 389 Node* top_address, |
388 Node* limit_address) { | 390 Node* limit_address) { |
389 Node* top = Load(MachineType::Pointer(), top_address); | 391 Node* top = Load(MachineType::Pointer(), top_address); |
390 Node* limit = Load(MachineType::Pointer(), limit_address); | 392 Node* limit = Load(MachineType::Pointer(), limit_address); |
391 Variable adjusted_size(this, MachineType::PointerRepresentation()); | 393 Variable adjusted_size(this, MachineType::PointerRepresentation()); |
392 adjusted_size.Bind(size_in_bytes); | 394 adjusted_size.Bind(size_in_bytes); |
393 if (flags & kDoubleAlignment) { | 395 if (flags & kDoubleAlignment) { |
394 // TODO(epertoso): Simd128 alignment. | 396 // TODO(epertoso): Simd128 alignment. |
395 Label aligned(this), not_aligned(this), merge(this, &adjusted_size); | 397 Label aligned(this), not_aligned(this), merge(this, &adjusted_size); |
396 Branch(WordAnd(IntPtrSub(top, IntPtrConstant(kHeapObjectTag)), | 398 Branch(WordAnd(top, IntPtrConstant(kDoubleAlignmentMask)), ¬_aligned, |
397 IntPtrConstant(kDoubleAlignmentMask)), | 399 &aligned); |
398 ¬_aligned, &aligned); | |
399 | 400 |
400 Bind(¬_aligned); | 401 Bind(¬_aligned); |
401 Node* not_aligned_size = | 402 Node* not_aligned_size = |
402 IntPtrAdd(size_in_bytes, IntPtrConstant(kPointerSize)); | 403 IntPtrAdd(size_in_bytes, IntPtrConstant(kPointerSize)); |
403 adjusted_size.Bind(not_aligned_size); | 404 adjusted_size.Bind(not_aligned_size); |
404 Goto(&merge); | 405 Goto(&merge); |
405 | 406 |
406 Bind(&aligned); | 407 Bind(&aligned); |
407 Goto(&merge); | 408 Goto(&merge); |
408 | 409 |
409 Bind(&merge); | 410 Bind(&merge); |
410 } | 411 } |
411 | 412 |
412 Variable address(this, MachineRepresentation::kTagged); | 413 Variable address(this, MachineRepresentation::kTagged); |
413 address.Bind(AllocateRawUnaligned(adjusted_size.value(), kNone, top, limit)); | 414 address.Bind(AllocateRawUnaligned(adjusted_size.value(), kNone, top, limit)); |
414 | 415 |
415 Label needs_filler(this), doesnt_need_filler(this), | 416 Label needs_filler(this), doesnt_need_filler(this), |
416 merge_address(this, &address); | 417 merge_address(this, &address); |
417 Branch(IntPtrEqual(adjusted_size.value(), size_in_bytes), &doesnt_need_filler, | 418 Branch(IntPtrEqual(adjusted_size.value(), size_in_bytes), &doesnt_need_filler, |
418 &needs_filler); | 419 &needs_filler); |
419 | 420 |
420 Bind(&needs_filler); | 421 Bind(&needs_filler); |
421 // Store a filler and increase the address by kPointerSize. | 422 // Store a filler and increase the address by kPointerSize. |
422 // TODO(epertoso): this code assumes that we only align to kDoubleSize. Change | 423 // TODO(epertoso): this code assumes that we only align to kDoubleSize. Change |
423 // it when Simd128 alignment is supported. | 424 // it when Simd128 alignment is supported. |
424 StoreNoWriteBarrier(MachineType::PointerRepresentation(), | 425 StoreNoWriteBarrier(MachineType::PointerRepresentation(), top, |
425 IntPtrSub(top, IntPtrConstant(1)), | |
426 LoadRoot(Heap::kOnePointerFillerMapRootIndex)); | 426 LoadRoot(Heap::kOnePointerFillerMapRootIndex)); |
427 address.Bind(BitcastWordToTagged( | 427 address.Bind(BitcastWordToTagged( |
428 IntPtrAdd(address.value(), IntPtrConstant(kPointerSize)))); | 428 IntPtrAdd(address.value(), IntPtrConstant(kPointerSize)))); |
429 Goto(&merge_address); | 429 Goto(&merge_address); |
430 | 430 |
431 Bind(&doesnt_need_filler); | 431 Bind(&doesnt_need_filler); |
432 Goto(&merge_address); | 432 Goto(&merge_address); |
433 | 433 |
434 Bind(&merge_address); | 434 Bind(&merge_address); |
435 // Update the top. | 435 // Update the top. |
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1978 } | 1978 } |
1979 return IntPtrAdd( | 1979 return IntPtrAdd( |
1980 IntPtrConstant(base_size), | 1980 IntPtrConstant(base_size), |
1981 (element_size_shift >= 0) | 1981 (element_size_shift >= 0) |
1982 ? WordShl(index_node, IntPtrConstant(element_size_shift)) | 1982 ? WordShl(index_node, IntPtrConstant(element_size_shift)) |
1983 : WordShr(index_node, IntPtrConstant(-element_size_shift))); | 1983 : WordShr(index_node, IntPtrConstant(-element_size_shift))); |
1984 } | 1984 } |
1985 | 1985 |
1986 } // namespace internal | 1986 } // namespace internal |
1987 } // namespace v8 | 1987 } // namespace v8 |
OLD | NEW |