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 2955 matching lines...) Loading... | |
2966 | 2966 |
2967 // Get a stack slot for the arguments. | 2967 // Get a stack slot for the arguments. |
2968 Node* arg_buffer = args_size_bytes == 0 && return_size_bytes == 0 | 2968 Node* arg_buffer = args_size_bytes == 0 && return_size_bytes == 0 |
2969 ? jsgraph()->IntPtrConstant(0) | 2969 ? jsgraph()->IntPtrConstant(0) |
2970 : graph()->NewNode(jsgraph()->machine()->StackSlot( | 2970 : graph()->NewNode(jsgraph()->machine()->StackSlot( |
2971 std::max(args_size_bytes, return_size_bytes))); | 2971 std::max(args_size_bytes, return_size_bytes))); |
2972 | 2972 |
2973 // Now store all our arguments to the buffer. | 2973 // Now store all our arguments to the buffer. |
2974 int param_index = 0; | 2974 int param_index = 0; |
2975 int offset = 0; | 2975 int offset = 0; |
2976 auto is_i64_as_two_params = [&](wasm::ValueType t) { | |
titzer
2017/03/07 10:21:55
Can you extract this to a utility function in Int6
Clemens Hammacher
2017/03/07 10:30:03
Int64Lowering current does the lowering unconditio
titzer
2017/03/07 11:51:52
What I meant is just a static function that takes
| |
2977 return jsgraph()->machine()->Is32() && t == wasm::kWasmI64; | |
2978 }; | |
2979 | |
2976 for (int i = 0; i < wasm_count; i++) { | 2980 for (int i = 0; i < wasm_count; i++) { |
2977 Node* param = Param(param_index++); | 2981 Node* param = Param(param_index++); |
2978 bool is_i64_as_two_params = | 2982 if (is_i64_as_two_params(sig->GetParam(i))) { |
2979 jsgraph()->machine()->Is32() && sig->GetParam(i) == wasm::kWasmI64; | |
2980 | |
2981 if (is_i64_as_two_params) { | |
2982 StoreRepresentation store_rep(wasm::kWasmI32, | 2983 StoreRepresentation store_rep(wasm::kWasmI32, |
2983 WriteBarrierKind::kNoWriteBarrier); | 2984 WriteBarrierKind::kNoWriteBarrier); |
2984 *effect_ = | 2985 *effect_ = |
2985 graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer, | 2986 graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer, |
2986 Int32Constant(offset + kInt64LowerHalfMemoryOffset), | 2987 Int32Constant(offset + kInt64LowerHalfMemoryOffset), |
2987 param, *effect_, *control_); | 2988 param, *effect_, *control_); |
2988 | 2989 |
2989 param = Param(param_index++); | 2990 param = Param(param_index++); |
2990 *effect_ = | 2991 *effect_ = |
2991 graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer, | 2992 graph()->NewNode(jsgraph()->machine()->Store(store_rep), arg_buffer, |
(...skipping 21 matching lines...) Loading... | |
3013 // call Smi::value on it, but just cast it to a byte pointer. | 3014 // call Smi::value on it, but just cast it to a byte pointer. |
3014 Node* parameters[] = { | 3015 Node* parameters[] = { |
3015 jsgraph()->HeapConstant(instance), // wasm instance | 3016 jsgraph()->HeapConstant(instance), // wasm instance |
3016 jsgraph()->SmiConstant(function_index), // function index | 3017 jsgraph()->SmiConstant(function_index), // function index |
3017 arg_buffer, // argument buffer | 3018 arg_buffer, // argument buffer |
3018 }; | 3019 }; |
3019 BuildCallToRuntime(Runtime::kWasmRunInterpreter, jsgraph(), parameters, | 3020 BuildCallToRuntime(Runtime::kWasmRunInterpreter, jsgraph(), parameters, |
3020 arraysize(parameters), effect_, *control_); | 3021 arraysize(parameters), effect_, *control_); |
3021 | 3022 |
3022 // Read back the return value. | 3023 // Read back the return value. |
3023 if (jsgraph()->machine()->Is32() && sig->return_count() > 0 && | 3024 if (sig->return_count() == 0) { |
3024 sig->GetReturn() == wasm::kWasmI64) { | 3025 Return(Int32Constant(0)); |
3026 } else if (is_i64_as_two_params(sig->GetReturn())) { | |
3025 MachineType load_rep = wasm::WasmOpcodes::MachineTypeFor(wasm::kWasmI32); | 3027 MachineType load_rep = wasm::WasmOpcodes::MachineTypeFor(wasm::kWasmI32); |
3026 Node* lower = | 3028 Node* lower = |
3027 graph()->NewNode(jsgraph()->machine()->Load(load_rep), arg_buffer, | 3029 graph()->NewNode(jsgraph()->machine()->Load(load_rep), arg_buffer, |
3028 Int32Constant(0), *effect_, *control_); | 3030 Int32Constant(0), *effect_, *control_); |
3029 Node* upper = | 3031 Node* upper = |
3030 graph()->NewNode(jsgraph()->machine()->Load(load_rep), arg_buffer, | 3032 graph()->NewNode(jsgraph()->machine()->Load(load_rep), arg_buffer, |
3031 Int32Constant(sizeof(int32_t)), *effect_, *control_); | 3033 Int32Constant(4), lower, *control_); |
titzer
2017/03/07 10:21:55
Can you keep the sizeof(int32_t) for documentation
Clemens Hammacher
2017/03/07 10:30:03
Done.
| |
3032 Return(upper, lower); | 3034 *effect_ = upper; |
3035 Return(lower, upper); | |
3033 } else { | 3036 } else { |
3034 Node* val; | 3037 MachineType load_rep = wasm::WasmOpcodes::MachineTypeFor(sig->GetReturn()); |
3035 if (sig->return_count() == 0) { | 3038 Node* val = |
3036 val = Int32Constant(0); | 3039 graph()->NewNode(jsgraph()->machine()->Load(load_rep), arg_buffer, |
3037 } else { | 3040 Int32Constant(0), *effect_, *control_); |
3038 MachineType load_rep = | |
3039 wasm::WasmOpcodes::MachineTypeFor(sig->GetReturn()); | |
3040 val = graph()->NewNode(jsgraph()->machine()->Load(load_rep), arg_buffer, | |
3041 Int32Constant(0), *effect_, *control_); | |
3042 } | |
3043 Return(val); | 3041 Return(val); |
3044 } | 3042 } |
3045 } | 3043 } |
3046 | 3044 |
3047 Node* WasmGraphBuilder::MemBuffer(uint32_t offset) { | 3045 Node* WasmGraphBuilder::MemBuffer(uint32_t offset) { |
3048 DCHECK(module_ && module_->instance); | 3046 DCHECK(module_ && module_->instance); |
3049 if (offset == 0) { | 3047 if (offset == 0) { |
3050 if (!mem_buffer_) { | 3048 if (!mem_buffer_) { |
3051 mem_buffer_ = jsgraph()->RelocatableIntPtrConstant( | 3049 mem_buffer_ = jsgraph()->RelocatableIntPtrConstant( |
3052 reinterpret_cast<uintptr_t>(module_->instance->mem_start), | 3050 reinterpret_cast<uintptr_t>(module_->instance->mem_start), |
(...skipping 1184 matching lines...) Loading... | |
4237 wasm::ErrorThrower* thrower, Isolate* isolate, | 4235 wasm::ErrorThrower* thrower, Isolate* isolate, |
4238 wasm::ModuleBytesEnv* module_env, const wasm::WasmFunction* function) { | 4236 wasm::ModuleBytesEnv* module_env, const wasm::WasmFunction* function) { |
4239 WasmCompilationUnit unit(isolate, module_env, function); | 4237 WasmCompilationUnit unit(isolate, module_env, function); |
4240 unit.ExecuteCompilation(); | 4238 unit.ExecuteCompilation(); |
4241 return unit.FinishCompilation(thrower); | 4239 return unit.FinishCompilation(thrower); |
4242 } | 4240 } |
4243 | 4241 |
4244 } // namespace compiler | 4242 } // namespace compiler |
4245 } // namespace internal | 4243 } // namespace internal |
4246 } // namespace v8 | 4244 } // namespace v8 |
OLD | NEW |