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

Side by Side Diff: src/x87/code-stubs-x87.cc

Issue 1897143003: X87: [Atomics] Remove Atomics code stubs; use TF ops. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « src/compiler/x87/instruction-selector-x87.cc ('k') | src/x87/interface-descriptors-x87.cc » ('j') | 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 #if V8_TARGET_ARCH_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/api-arguments.h" 8 #include "src/api-arguments.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 5489 matching lines...) Expand 10 before | Expand all | Expand 10 after
5500 ExternalReference::invoke_accessor_getter_callback(isolate()); 5500 ExternalReference::invoke_accessor_getter_callback(isolate());
5501 5501
5502 // +3 is to skip prolog, return address and name handle. 5502 // +3 is to skip prolog, return address and name handle.
5503 Operand return_value_operand( 5503 Operand return_value_operand(
5504 ebp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); 5504 ebp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize);
5505 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, 5505 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
5506 thunk_last_arg, kStackUnwindSpace, nullptr, 5506 thunk_last_arg, kStackUnwindSpace, nullptr,
5507 return_value_operand, NULL); 5507 return_value_operand, NULL);
5508 } 5508 }
5509 5509
5510 namespace {
5511
5512 void GetTypedArrayBackingStore(MacroAssembler* masm, Register backing_store,
5513 Register object, Register scratch) {
5514 Label offset_is_not_smi, done;
5515 __ mov(scratch, FieldOperand(object, JSTypedArray::kBufferOffset));
5516 __ mov(backing_store,
5517 FieldOperand(scratch, JSArrayBuffer::kBackingStoreOffset));
5518
5519 __ mov(scratch, FieldOperand(object, JSArrayBufferView::kByteOffsetOffset));
5520 __ JumpIfNotSmi(scratch, &offset_is_not_smi, Label::kNear);
5521 // Offset is smi.
5522 __ SmiUntag(scratch);
5523 __ add(backing_store, scratch);
5524 __ jmp(&done, Label::kNear);
5525
5526 // Offset is a heap number.
5527 __ bind(&offset_is_not_smi);
5528 // __ movsd(xmm0, FieldOperand(scratch, HeapNumber::kValueOffset));
5529 __ fld_d(FieldOperand(scratch, HeapNumber::kValueOffset));
5530 // __ cvttsd2si(scratch, xmm0);
5531 __ TruncateX87TOSToI(scratch);
5532 __ add(backing_store, scratch);
5533 __ bind(&done);
5534 }
5535
5536 void TypedArrayJumpTablePrologue(MacroAssembler* masm, Register object,
5537 Register scratch, Register scratch2,
5538 Label* table) {
5539 __ mov(scratch, FieldOperand(object, JSObject::kElementsOffset));
5540 __ mov(scratch, FieldOperand(scratch, HeapObject::kMapOffset));
5541 __ movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset));
5542 __ sub(scratch, Immediate(static_cast<uint8_t>(FIXED_INT8_ARRAY_TYPE)));
5543 __ Assert(above_equal, kOffsetOutOfRange);
5544 __ jmp(Operand::JumpTable(scratch, times_4, table));
5545 }
5546
5547 void TypedArrayJumpTableEpilogue(MacroAssembler* masm, Label* table, Label* i8,
5548 Label* u8, Label* i16, Label* u16, Label* i32,
5549 Label* u32, Label* u8c) {
5550 STATIC_ASSERT(FIXED_UINT8_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 1);
5551 STATIC_ASSERT(FIXED_INT16_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 2);
5552 STATIC_ASSERT(FIXED_UINT16_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 3);
5553 STATIC_ASSERT(FIXED_INT32_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 4);
5554 STATIC_ASSERT(FIXED_UINT32_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 5);
5555 STATIC_ASSERT(FIXED_FLOAT32_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 6);
5556 STATIC_ASSERT(FIXED_FLOAT64_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 7);
5557 STATIC_ASSERT(FIXED_UINT8_CLAMPED_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 8);
5558
5559 Label abort;
5560 __ bind(table);
5561 __ dd(i8); // Int8Array
5562 __ dd(u8); // Uint8Array
5563 __ dd(i16); // Int16Array
5564 __ dd(u16); // Uint16Array
5565 __ dd(i32); // Int32Array
5566 __ dd(u32); // Uint32Array
5567 __ dd(&abort); // Float32Array
5568 __ dd(&abort); // Float64Array
5569 __ dd(u8c); // Uint8ClampedArray
5570
5571 __ bind(&abort);
5572 __ Abort(kNoReason);
5573 }
5574
5575 void ReturnInteger32(MacroAssembler* masm, X87Register dst, Register value,
5576 Register scratch, Label* use_heap_number) {
5577 Label not_smi;
5578 if (!value.is(eax)) {
5579 __ mov(eax, value);
5580 }
5581 __ JumpIfNotValidSmiValue(eax, scratch, &not_smi, Label::kNear);
5582 __ SmiTag(eax);
5583 __ Ret();
5584
5585 __ bind(&not_smi);
5586 // __ Cvtsi2sd(dst, eax);
5587 __ push(eax);
5588 __ fld_s(MemOperand(esp, 0));
5589 __ pop(eax);
5590 __ jmp(use_heap_number);
5591 }
5592
5593 void ReturnUnsignedInteger32(MacroAssembler* masm, X87Register dst,
5594 Register value, X87Register scratch,
5595 Label* use_heap_number) {
5596 Label not_smi;
5597 if (!value.is(eax)) {
5598 __ mov(eax, value);
5599 }
5600 __ JumpIfUIntNotValidSmiValue(eax, &not_smi, Label::kNear);
5601 __ SmiTag(eax);
5602 __ Ret();
5603
5604 __ bind(&not_smi);
5605 // Convert [0, 2**32-1] -> [-2**31, 2**31-1].
5606 __ add(eax, Immediate(-0x7fffffff - 1)); // -0x80000000 parses incorrectly.
5607 // __ Cvtsi2sd(dst, eax);
5608 __ push(eax);
5609 __ fld_s(MemOperand(esp, 0));
5610 __ pop(eax);
5611
5612 __ mov(eax, Immediate(0x4f000000)); // 2**31 as IEEE float
5613 // __ movd(scratch, eax);
5614 __ push(eax);
5615 __ fld_s(MemOperand(esp, 0));
5616 __ pop(eax);
5617
5618 // __ cvtss2sd(scratch, scratch);
5619 __ sub(esp, Immediate(kDoubleSize));
5620 __ fstp_s(MemOperand(esp, 0));
5621 __ fld_s(MemOperand(esp, 0));
5622 __ add(esp, Immediate(kDoubleSize));
5623
5624 // __ addsd(dst, scratch);
5625 __ faddp();
5626 __ jmp(use_heap_number);
5627 }
5628
5629 void ReturnAllocatedHeapNumber(MacroAssembler* masm, X87Register value,
5630 Register scratch, Register scratch2) {
5631 Label call_runtime;
5632 __ AllocateHeapNumber(eax, scratch, scratch2, &call_runtime);
5633 // __ movsd(FieldOperand(eax, HeapNumber::kValueOffset), value);
5634 __ fst_d(FieldOperand(eax, HeapNumber::kValueOffset));
5635 __ Ret();
5636
5637 __ bind(&call_runtime);
5638 {
5639 FrameScope scope(masm, StackFrame::INTERNAL);
5640 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber);
5641 // __ movsd(FieldOperand(eax, HeapNumber::kValueOffset), value);
5642 __ fst_d(FieldOperand(eax, HeapNumber::kValueOffset));
5643 }
5644 __ Ret();
5645 }
5646
5647 } // anonymous namespace
5648
5649 void AtomicsLoadStub::Generate(MacroAssembler* masm) {
5650 Register object = edx;
5651 Register index = eax; // Index is an untagged word32.
5652 Register backing_store = ebx;
5653 Label table;
5654
5655 GetTypedArrayBackingStore(masm, backing_store, object, ecx);
5656 TypedArrayJumpTablePrologue(masm, object, ecx, esi, &table);
5657
5658 Label i8, u8, i16, u16, i32, u32;
5659
5660 __ bind(&i8);
5661 __ mov_b(eax, Operand(backing_store, index, times_1, 0));
5662 __ movsx_b(eax, eax);
5663 __ SmiTag(eax);
5664 __ Ret();
5665
5666 __ bind(&u8);
5667 __ mov_b(eax, Operand(backing_store, index, times_1, 0));
5668 __ movzx_b(eax, eax);
5669 __ SmiTag(eax);
5670 __ Ret();
5671
5672 __ bind(&i16);
5673 __ mov_w(eax, Operand(backing_store, index, times_2, 0));
5674 __ movsx_w(eax, eax);
5675 __ SmiTag(eax);
5676 __ Ret();
5677
5678 __ bind(&u16);
5679 __ mov_w(eax, Operand(backing_store, index, times_2, 0));
5680 __ movzx_w(eax, eax);
5681 __ SmiTag(eax);
5682 __ Ret();
5683
5684 Label use_heap_number;
5685
5686 __ bind(&i32);
5687 __ mov(eax, Operand(backing_store, index, times_4, 0));
5688 ReturnInteger32(masm, stX_0, eax, ecx, &use_heap_number);
5689
5690 __ bind(&u32);
5691 __ mov(eax, Operand(backing_store, index, times_4, 0));
5692 ReturnUnsignedInteger32(masm, stX_0, eax, stX_1, &use_heap_number);
5693
5694 __ bind(&use_heap_number);
5695 ReturnAllocatedHeapNumber(masm, stX_0, ecx, edx);
5696
5697 TypedArrayJumpTableEpilogue(masm, &table, &i8, &u8, &i16, &u16, &i32, &u32,
5698 &u8);
5699 }
5700
5701 #undef __ 5510 #undef __
5702 5511
5703 } // namespace internal 5512 } // namespace internal
5704 } // namespace v8 5513 } // namespace v8
5705 5514
5706 #endif // V8_TARGET_ARCH_X87 5515 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/compiler/x87/instruction-selector-x87.cc ('k') | src/x87/interface-descriptors-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698