Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/compiler/wasm-compiler.h" | 5 #include "src/compiler/wasm-compiler.h" |
| 6 | 6 |
| 7 #include "src/isolate-inl.h" | 7 #include "src/isolate-inl.h" |
| 8 | 8 |
| 9 #include "src/base/platform/elapsed-timer.h" | 9 #include "src/base/platform/elapsed-timer.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 2744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2755 | 2755 |
| 2756 if (aligned || | 2756 if (aligned || |
| 2757 jsgraph()->machine()->UnalignedLoadSupported(memtype, alignment)) { | 2757 jsgraph()->machine()->UnalignedLoadSupported(memtype, alignment)) { |
| 2758 load = graph()->NewNode(jsgraph()->machine()->Load(memtype), | 2758 load = graph()->NewNode(jsgraph()->machine()->Load(memtype), |
| 2759 MemBuffer(offset), index, *effect_, *control_); | 2759 MemBuffer(offset), index, *effect_, *control_); |
| 2760 *effect_ = load; | 2760 *effect_ = load; |
| 2761 } else { | 2761 } else { |
| 2762 load = BuildUnalignedLoad(type, memtype, index, offset, alignment); | 2762 load = BuildUnalignedLoad(type, memtype, index, offset, alignment); |
| 2763 } | 2763 } |
| 2764 | 2764 |
| 2765 #if defined(V8_TARGET_BIG_ENDIAN) | |
| 2766 int numberOfBytes = 1 << ElementSizeLog2Of(memtype.representation()); | |
| 2767 | |
| 2768 switch (numberOfBytes) { | |
|
ivica.bogosavljevic
2016/07/06 11:28:48
You are missing here proper handling of floating-p
| |
| 2769 case 1: | |
| 2770 break; | |
| 2771 case 2: | |
| 2772 load = graph()->NewNode(jsgraph()->machine()->Word16ReverseBytes().op(), | |
| 2773 load); | |
| 2774 if (memtype.IsSigned()) | |
| 2775 load = | |
| 2776 graph()->NewNode(jsgraph()->machine()->Word32Sar(), | |
| 2777 graph()->NewNode(jsgraph()->machine()->Word32Shl(), | |
| 2778 load, Int32Constant(16)), | |
| 2779 Int32Constant(16)); | |
| 2780 break; | |
| 2781 case 4: | |
| 2782 load = graph()->NewNode(jsgraph()->machine()->Word32ReverseBytes().op(), | |
| 2783 load); | |
| 2784 break; | |
| 2785 case 8: | |
| 2786 load = graph()->NewNode(jsgraph()->machine()->Word64ReverseBytes().op(), | |
| 2787 load); | |
|
ivica.bogosavljevic
2016/06/29 14:21:59
32 bit architectures don't have Word64ReverseByte
| |
| 2788 break; | |
| 2789 default: | |
| 2790 UNREACHABLE(); | |
| 2791 } | |
| 2792 #endif | |
| 2793 | |
| 2765 if (type == wasm::kAstI64 && | 2794 if (type == wasm::kAstI64 && |
| 2766 ElementSizeLog2Of(memtype.representation()) < 3) { | 2795 ElementSizeLog2Of(memtype.representation()) < 3) { |
| 2767 // TODO(titzer): TF zeroes the upper bits of 64-bit loads for subword sizes. | 2796 // TODO(titzer): TF zeroes the upper bits of 64-bit loads for subword sizes. |
| 2768 if (memtype.IsSigned()) { | 2797 if (memtype.IsSigned()) { |
| 2769 // sign extend | 2798 // sign extend |
| 2770 load = graph()->NewNode(jsgraph()->machine()->ChangeInt32ToInt64(), load); | 2799 load = graph()->NewNode(jsgraph()->machine()->ChangeInt32ToInt64(), load); |
| 2771 } else { | 2800 } else { |
| 2772 // zero extend | 2801 // zero extend |
| 2773 load = | 2802 load = |
| 2774 graph()->NewNode(jsgraph()->machine()->ChangeUint32ToUint64(), load); | 2803 graph()->NewNode(jsgraph()->machine()->ChangeUint32ToUint64(), load); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2871 } | 2900 } |
| 2872 | 2901 |
| 2873 Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index, | 2902 Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index, |
| 2874 uint32_t offset, uint32_t alignment, Node* val, | 2903 uint32_t offset, uint32_t alignment, Node* val, |
| 2875 wasm::WasmCodePosition position) { | 2904 wasm::WasmCodePosition position) { |
| 2876 Node* store; | 2905 Node* store; |
| 2877 | 2906 |
| 2878 // WASM semantics throw on OOB. Introduce explicit bounds check. | 2907 // WASM semantics throw on OOB. Introduce explicit bounds check. |
| 2879 BoundsCheckMem(memtype, index, offset, position); | 2908 BoundsCheckMem(memtype, index, offset, position); |
| 2880 StoreRepresentation rep(memtype.representation(), kNoWriteBarrier); | 2909 StoreRepresentation rep(memtype.representation(), kNoWriteBarrier); |
| 2910 | |
| 2911 #if defined(V8_TARGET_BIG_ENDIAN) | |
| 2912 int numberOfBytes = 1 << ElementSizeLog2Of(memtype.representation()); | |
| 2913 | |
| 2914 switch (numberOfBytes) { | |
| 2915 case 1: | |
| 2916 break; | |
| 2917 case 2: | |
| 2918 val = graph()->NewNode( | |
| 2919 memtype.IsSigned() ? jsgraph()->machine()->Word32Sar() | |
| 2920 : jsgraph()->machine()->Word32Shr(), | |
| 2921 graph()->NewNode(jsgraph()->machine()->Word32ReverseBytes().op(), | |
| 2922 val), | |
| 2923 jsgraph()->Int32Constant(32 - numberOfBytes * 8)); | |
| 2924 break; | |
| 2925 case 4: | |
| 2926 val = graph()->NewNode(jsgraph()->machine()->Word32ReverseBytes().op(), | |
| 2927 val); | |
| 2928 break; | |
| 2929 case 8: | |
| 2930 val = graph()->NewNode(jsgraph()->machine()->Word64ReverseBytes().op(), | |
| 2931 val); | |
| 2932 break; | |
| 2933 default: | |
| 2934 UNREACHABLE(); | |
| 2935 } | |
| 2936 #endif | |
| 2937 | |
| 2881 bool aligned = static_cast<int>(alignment) >= | 2938 bool aligned = static_cast<int>(alignment) >= |
| 2882 ElementSizeLog2Of(memtype.representation()); | 2939 ElementSizeLog2Of(memtype.representation()); |
| 2883 | 2940 |
| 2884 if (aligned || | 2941 if (aligned || |
| 2885 jsgraph()->machine()->UnalignedStoreSupported(memtype, alignment)) { | 2942 jsgraph()->machine()->UnalignedStoreSupported(memtype, alignment)) { |
| 2886 StoreRepresentation rep(memtype.representation(), kNoWriteBarrier); | 2943 StoreRepresentation rep(memtype.representation(), kNoWriteBarrier); |
| 2887 store = | 2944 store = |
| 2888 graph()->NewNode(jsgraph()->machine()->Store(rep), MemBuffer(offset), | 2945 graph()->NewNode(jsgraph()->machine()->Store(rep), MemBuffer(offset), |
| 2889 index, val, *effect_, *control_); | 2946 index, val, *effect_, *control_); |
| 2890 *effect_ = store; | 2947 *effect_ = store; |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3298 function_->code_start_offset), | 3355 function_->code_start_offset), |
| 3299 compile_ms); | 3356 compile_ms); |
| 3300 } | 3357 } |
| 3301 | 3358 |
| 3302 return code; | 3359 return code; |
| 3303 } | 3360 } |
| 3304 | 3361 |
| 3305 } // namespace compiler | 3362 } // namespace compiler |
| 3306 } // namespace internal | 3363 } // namespace internal |
| 3307 } // namespace v8 | 3364 } // namespace v8 |
| OLD | NEW |