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/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 | 10 |
(...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1661 BuildCCall(sig_builder.Build(), args), position); | 1661 BuildCCall(sig_builder.Build(), args), position); |
1662 const Operator* load_op = jsgraph()->machine()->Load(result_type); | 1662 const Operator* load_op = jsgraph()->machine()->Load(result_type); |
1663 Node* load = | 1663 Node* load = |
1664 graph()->NewNode(load_op, stack_slot_result, jsgraph()->Int32Constant(0), | 1664 graph()->NewNode(load_op, stack_slot_result, jsgraph()->Int32Constant(0), |
1665 *effect_, *control_); | 1665 *effect_, *control_); |
1666 *effect_ = load; | 1666 *effect_ = load; |
1667 return load; | 1667 return load; |
1668 } | 1668 } |
1669 | 1669 |
1670 Node* WasmGraphBuilder::BuildGrowMemory(Node* input) { | 1670 Node* WasmGraphBuilder::BuildGrowMemory(Node* input) { |
1671 Diamond check_input_range( | |
1672 graph(), jsgraph()->common(), | |
1673 graph()->NewNode( | |
1674 jsgraph()->machine()->Uint32LessThanOrEqual(), input, | |
1675 jsgraph()->Uint32Constant(wasm::WasmModule::kMaxMemPages)), | |
1676 BranchHint::kTrue); | |
gdeepti
2016/08/30 02:19:56
This makes the first check in the GrowMemory runti
ahaas
2016/08/30 06:49:53
I replaced the check in runtime-wasm.cc with a DCH
| |
1677 | |
1671 Runtime::FunctionId function_id = Runtime::kWasmGrowMemory; | 1678 Runtime::FunctionId function_id = Runtime::kWasmGrowMemory; |
1672 const Runtime::Function* function = Runtime::FunctionForId(function_id); | 1679 const Runtime::Function* function = Runtime::FunctionForId(function_id); |
1673 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( | 1680 CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor( |
1674 jsgraph()->zone(), function_id, function->nargs, Operator::kNoThrow, | 1681 jsgraph()->zone(), function_id, function->nargs, Operator::kNoThrow, |
1675 CallDescriptor::kNoFlags); | 1682 CallDescriptor::kNoFlags); |
1676 Node** control_ptr = control_; | |
1677 Node** effect_ptr = effect_; | |
1678 wasm::ModuleEnv* module = module_; | 1683 wasm::ModuleEnv* module = module_; |
1679 input = BuildChangeUint32ToSmi(input); | 1684 input = BuildChangeUint32ToSmi(input); |
titzer
2016/08/29 16:57:58
If I remember correctly this will also have a chec
ahaas
2016/08/30 06:49:53
I do not understand this comment, do you mean the
titzer
2016/08/30 08:25:47
Sorry, I was thinking that BuildChangeUint32ToSmi(
| |
1680 Node* inputs[] = { | 1685 Node* inputs[] = { |
1681 jsgraph()->CEntryStubConstant(function->result_size), input, // C entry | 1686 jsgraph()->CEntryStubConstant(function->result_size), input, // C entry |
1682 jsgraph()->ExternalConstant( | 1687 jsgraph()->ExternalConstant( |
1683 ExternalReference(function_id, jsgraph()->isolate())), // ref | 1688 ExternalReference(function_id, jsgraph()->isolate())), // ref |
1684 jsgraph()->Int32Constant(function->nargs), // arity | 1689 jsgraph()->Int32Constant(function->nargs), // arity |
1685 jsgraph()->HeapConstant(module->instance->context), // context | 1690 jsgraph()->HeapConstant(module->instance->context), // context |
1686 *effect_ptr, | 1691 *effect_, |
1687 *control_ptr}; | 1692 check_input_range.if_true}; |
1688 Node* node = graph()->NewNode(jsgraph()->common()->Call(desc), | 1693 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), |
1689 static_cast<int>(arraysize(inputs)), inputs); | 1694 static_cast<int>(arraysize(inputs)), inputs); |
1690 *effect_ptr = node; | 1695 |
1691 node = BuildChangeSmiToInt32(node); | 1696 Node* result = BuildChangeSmiToInt32(call); |
1692 return node; | 1697 |
1698 result = check_input_range.Phi(MachineRepresentation::kWord32, result, | |
1699 jsgraph()->Int32Constant(-1)); | |
1700 *effect_ = graph()->NewNode(jsgraph()->common()->EffectPhi(2), call, *effect_, | |
1701 check_input_range.merge); | |
1702 *control_ = check_input_range.merge; | |
1703 return result; | |
1693 } | 1704 } |
1694 | 1705 |
1695 Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right, | 1706 Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right, |
1696 wasm::WasmCodePosition position) { | 1707 wasm::WasmCodePosition position) { |
1697 MachineOperatorBuilder* m = jsgraph()->machine(); | 1708 MachineOperatorBuilder* m = jsgraph()->machine(); |
1698 trap_->ZeroCheck32(wasm::kTrapDivByZero, right, position); | 1709 trap_->ZeroCheck32(wasm::kTrapDivByZero, right, position); |
1699 Node* before = *control_; | 1710 Node* before = *control_; |
1700 Node* denom_is_m1; | 1711 Node* denom_is_m1; |
1701 Node* denom_is_not_m1; | 1712 Node* denom_is_not_m1; |
1702 Branch( | 1713 Branch( |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3236 function_->code_start_offset), | 3247 function_->code_start_offset), |
3237 compile_ms); | 3248 compile_ms); |
3238 } | 3249 } |
3239 | 3250 |
3240 return code; | 3251 return code; |
3241 } | 3252 } |
3242 | 3253 |
3243 } // namespace compiler | 3254 } // namespace compiler |
3244 } // namespace internal | 3255 } // namespace internal |
3245 } // namespace v8 | 3256 } // namespace v8 |
OLD | NEW |