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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "src/assembler-inl.h" | 9 #include "src/assembler-inl.h" |
| 10 #include "src/base/platform/elapsed-timer.h" | 10 #include "src/base/platform/elapsed-timer.h" |
| (...skipping 2958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2969 | 2969 |
| 2970 // Now store all our arguments to the buffer. | 2970 // Now store all our arguments to the buffer. |
| 2971 int param_index = 0; | 2971 int param_index = 0; |
| 2972 int offset = 0; | 2972 int offset = 0; |
| 2973 for (int i = 0; i < wasm_count; i++) { | 2973 for (int i = 0; i < wasm_count; i++) { |
| 2974 Node* param = Param(param_index++); | 2974 Node* param = Param(param_index++); |
| 2975 bool is_i64_as_two_params = | 2975 bool is_i64_as_two_params = |
| 2976 jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kWasmI64; | 2976 jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kWasmI64; |
| 2977 MachineRepresentation param_rep = | 2977 MachineRepresentation param_rep = |
| 2978 is_i64_as_two_params ? wasm::kWasmI32 : sig->GetParam(i); | 2978 is_i64_as_two_params ? wasm::kWasmI32 : sig->GetParam(i); |
| 2979 StoreRepresentation store_rep(param_rep, WriteBarrierKind::kNoWriteBarrier); | 2979 |
| 2980 *effect_ = | 2980 int alignment = offset % (1 << ElementSizeLog2Of(param_rep)); |
|
titzer
2017/02/23 20:44:46
What about just aligning all arguments to 64-bits?
ivica.bogosavljevic
2017/02/24 09:37:56
Pfiffig!
| |
| 2981 graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer, | 2981 bool offset_aligned = (alignment == 0); |
| 2982 Int32Constant(offset), param, *effect_, *control_); | 2982 |
| 2983 if (offset_aligned || | |
| 2984 jsgraph()->machine()->UnalignedStoreSupported( | |
| 2985 MachineType::TypeForRepresentation(param_rep), 0)) { | |
| 2986 StoreRepresentation store_rep(param_rep, | |
| 2987 WriteBarrierKind::kNoWriteBarrier); | |
| 2988 *effect_ = | |
| 2989 graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer, | |
| 2990 Int32Constant(offset), param, *effect_, *control_); | |
| 2991 } else { | |
| 2992 UnalignedStoreRepresentation store_rep(param_rep); | |
| 2993 *effect_ = graph()->NewNode( | |
| 2994 jsgraph()->machine()->UnalignedStore(store_rep), arg_buffer, | |
| 2995 Int32Constant(offset), param, *effect_, *control_); | |
| 2996 } | |
| 2997 | |
| 2983 offset += 1 << ElementSizeLog2Of(param_rep); | 2998 offset += 1 << ElementSizeLog2Of(param_rep); |
| 2999 | |
| 2984 // TODO(clemensh): Respect endianess here. Might need to swap upper and | 3000 // TODO(clemensh): Respect endianess here. Might need to swap upper and |
| 2985 // lower word. | 3001 // lower word. |
| 2986 if (is_i64_as_two_params) { | 3002 if (is_i64_as_two_params) { |
| 2987 // Also store the upper half. | 3003 // Also store the upper half. |
| 2988 param = Param(param_index++); | 3004 param = Param(param_index++); |
| 2989 StoreRepresentation store_rep(wasm::kWasmI32, | 3005 |
| 2990 WriteBarrierKind::kNoWriteBarrier); | 3006 alignment = offset % (1 << ElementSizeLog2Of(wasm::kWasmI32)); |
| 2991 *effect_ = | 3007 offset_aligned = (alignment == 0); |
| 2992 graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer, | 3008 |
| 2993 Int32Constant(offset), param, *effect_, *control_); | 3009 if (offset_aligned || |
| 3010 jsgraph()->machine()->UnalignedStoreSupported( | |
| 3011 MachineType::TypeForRepresentation(wasm::kWasmI32), 0)) { | |
| 3012 StoreRepresentation store_rep(wasm::kWasmI32, | |
| 3013 WriteBarrierKind::kNoWriteBarrier); | |
| 3014 *effect_ = | |
| 3015 graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer, | |
| 3016 Int32Constant(offset), param, *effect_, *control_); | |
| 3017 } else { | |
| 3018 UnalignedStoreRepresentation store_rep(wasm::kWasmI32); | |
| 3019 *effect_ = graph()->NewNode( | |
| 3020 jsgraph()->machine()->UnalignedStore(store_rep), arg_buffer, | |
| 3021 Int32Constant(offset), param, *effect_, *control_); | |
| 3022 } | |
| 2994 offset += 1 << ElementSizeLog2Of(wasm::kWasmI32); | 3023 offset += 1 << ElementSizeLog2Of(wasm::kWasmI32); |
| 2995 } | 3024 } |
| 2996 } | 3025 } |
| 2997 DCHECK_EQ(param_count, param_index); | 3026 DCHECK_EQ(param_count, param_index); |
| 2998 DCHECK_EQ(args_size_bytes, offset); | 3027 DCHECK_EQ(args_size_bytes, offset); |
| 2999 | 3028 |
| 3000 // We are passing the raw arg_buffer here. To the GC and other parts, it looks | 3029 // We are passing the raw arg_buffer here. To the GC and other parts, it looks |
| 3001 // like a Smi (lowest bit not set). In the runtime function however, don't | 3030 // like a Smi (lowest bit not set). In the runtime function however, don't |
| 3002 // call Smi::value on it, but just cast it to a byte pointer. | 3031 // call Smi::value on it, but just cast it to a byte pointer. |
| 3003 Node* parameters[] = { | 3032 Node* parameters[] = { |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3887 | 3916 |
| 3888 Handle<Code> CompileWasmInterpreterEntry(Isolate* isolate, uint32_t func_index, | 3917 Handle<Code> CompileWasmInterpreterEntry(Isolate* isolate, uint32_t func_index, |
| 3889 wasm::FunctionSig* sig, | 3918 wasm::FunctionSig* sig, |
| 3890 Handle<WasmInstanceObject> instance) { | 3919 Handle<WasmInstanceObject> instance) { |
| 3891 //---------------------------------------------------------------------------- | 3920 //---------------------------------------------------------------------------- |
| 3892 // Create the Graph | 3921 // Create the Graph |
| 3893 //---------------------------------------------------------------------------- | 3922 //---------------------------------------------------------------------------- |
| 3894 Zone zone(isolate->allocator(), ZONE_NAME); | 3923 Zone zone(isolate->allocator(), ZONE_NAME); |
| 3895 Graph graph(&zone); | 3924 Graph graph(&zone); |
| 3896 CommonOperatorBuilder common(&zone); | 3925 CommonOperatorBuilder common(&zone); |
| 3897 MachineOperatorBuilder machine(&zone); | 3926 MachineOperatorBuilder machine( |
| 3927 &zone, MachineType::PointerRepresentation(), | |
| 3928 InstructionSelector::SupportedMachineOperatorFlags(), | |
| 3929 InstructionSelector::AlignmentRequirements()); | |
| 3898 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); | 3930 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); |
| 3899 | 3931 |
| 3900 Node* control = nullptr; | 3932 Node* control = nullptr; |
| 3901 Node* effect = nullptr; | 3933 Node* effect = nullptr; |
| 3902 | 3934 |
| 3903 WasmGraphBuilder builder(nullptr, &zone, &jsgraph, sig); | 3935 WasmGraphBuilder builder(nullptr, &zone, &jsgraph, sig); |
| 3904 builder.set_control_ptr(&control); | 3936 builder.set_control_ptr(&control); |
| 3905 builder.set_effect_ptr(&effect); | 3937 builder.set_effect_ptr(&effect); |
| 3906 builder.BuildWasmInterpreterEntry(func_index, sig, instance); | 3938 builder.BuildWasmInterpreterEntry(func_index, sig, instance); |
| 3907 | 3939 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4143 function_->code_start_offset), | 4175 function_->code_start_offset), |
| 4144 compile_ms); | 4176 compile_ms); |
| 4145 } | 4177 } |
| 4146 | 4178 |
| 4147 return code; | 4179 return code; |
| 4148 } | 4180 } |
| 4149 | 4181 |
| 4150 } // namespace compiler | 4182 } // namespace compiler |
| 4151 } // namespace internal | 4183 } // namespace internal |
| 4152 } // namespace v8 | 4184 } // namespace v8 |
| OLD | NEW |