Lines Matching refs:Node
27 #include "src/compiler/node-matchers.h"
59 void MergeControlToEnd(JSGraph* jsgraph, Node* node) {
62 NodeProperties::MergeControlToEnd(g, jsgraph->common(), node);
64 g->SetEnd(g->NewNode(jsgraph->common()->End(1), node));
70 Node* BuildCallToRuntimeWithContext(Runtime::FunctionId f, JSGraph* jsgraph,
71 Node* context, Node** parameters,
72 int parameter_count, Node** effect_ptr,
73 Node* control) {
85 Node* inputs[kMaxParams + 6];
98 Node* node =
100 *effect_ptr = node;
101 return node;
104 Node* BuildCallToRuntime(Runtime::FunctionId f, JSGraph* jsgraph,
105 Node** parameters, int parameter_count,
106 Node** effect_ptr, Node* control) {
142 // Add a check that traps if {node} is equal to {val}.
143 Node* TrapIfEq32(wasm::TrapReason reason, Node* node, int32_t val,
145 Int32Matcher m(node);
148 AddTrapIfFalse(reason, node, position);
151 graph()->NewNode(jsgraph()->machine()->Word32Equal(), node,
158 // Add a check that traps if {node} is zero.
159 Node* ZeroCheck32(wasm::TrapReason reason, Node* node,
161 return TrapIfEq32(reason, node, 0, position);
164 // Add a check that traps if {node} is equal to {val}.
165 Node* TrapIfEq64(wasm::TrapReason reason, Node* node, int64_t val,
167 Int64Matcher m(node);
170 node, jsgraph()->Int64Constant(val)),
175 // Add a check that traps if {node} is zero.
176 Node* ZeroCheck64(wasm::TrapReason reason, Node* node,
178 return TrapIfEq64(reason, node, 0, position);
209 void AddTrapIfTrue(wasm::TrapReason reason, Node* cond,
214 Node* node = graph()->NewNode(common()->TrapIf(trap_id), cond,
216 *builder_->control_ = node;
217 builder_->SetSourcePosition(node, position);
225 void AddTrapIfFalse(wasm::TrapReason reason, Node* cond,
231 Node* node = graph()->NewNode(common()->TrapUnless(trap_id), cond,
233 *builder_->control_ = node;
234 builder_->SetSourcePosition(node, position);
243 void BuildTrapIf(wasm::TrapReason reason, Node* cond, bool iftrue,
245 Node** effect_ptr = builder_->effect_;
246 Node** control_ptr = builder_->control_;
247 Node* before = *effect_ptr;
249 Node* branch = graph()->NewNode(common()->Branch(hint), cond, *control_ptr);
250 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
251 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
259 Node* GetTrapValue(wasm::FunctionSig* sig) {
267 Node* GetTrapValue(wasm::ValueType type) {
291 Node* trap_merge_ = nullptr;
292 Node* trap_effect_;
293 Node* trap_reason_;
294 Node* trap_position_;
302 Node* reason_node = builder_->Int32Constant(
304 Node* position_node = builder_->Int32Constant(position);
316 void BuildTrapCode(Node* reason_node, Node* position_node) {
317 Node** control_ptr = builder_->control_;
318 Node** effect_ptr = builder_->effect_;
332 Node* trap_reason_smi = builder_->BuildChangeInt32ToSmi(trap_reason_);
333 Node* trap_position_smi = builder_->BuildChangeInt32ToSmi(trap_position_);
336 Node* parameters[] = {trap_reason_smi, // message id
343 Node* thrw =
349 Node* ret_value = GetTrapValue(builder_->GetFunctionSignature());
379 Node* WasmGraphBuilder::Error() { return jsgraph()->Dead(); }
381 Node* WasmGraphBuilder::Start(unsigned params) {
382 Node* start = graph()->NewNode(jsgraph()->common()->Start(params));
387 Node* WasmGraphBuilder::Param(unsigned index) {
392 Node* WasmGraphBuilder::Loop(Node* entry) {
396 Node* WasmGraphBuilder::Terminate(Node* effect, Node* control) {
397 Node* terminate =
403 unsigned WasmGraphBuilder::InputCount(Node* node) {
404 return static_cast<unsigned>(node->InputCount());
407 bool WasmGraphBuilder::IsPhiWithMerge(Node* phi, Node* merge) {
412 bool WasmGraphBuilder::ThrowsException(Node* node, Node** if_success,
413 Node** if_exception) {
414 if (node->op()->HasProperty(compiler::Operator::kNoThrow)) {
418 *if_success = graph()->NewNode(jsgraph()->common()->IfSuccess(), node);
420 graph()->NewNode(jsgraph()->common()->IfException(), node, node);
425 void WasmGraphBuilder::AppendToMerge(Node* merge, Node* from) {
433 void WasmGraphBuilder::AppendToPhi(Node* phi, Node* from) {
441 Node* WasmGraphBuilder::Merge(unsigned count, Node** controls) {
445 Node* WasmGraphBuilder::Phi(wasm::ValueType type, unsigned count, Node** vals,
446 Node* control) {
448 Node** buf = Realloc(vals, count, count + 1);
454 Node* WasmGraphBuilder::EffectPhi(unsigned count, Node** effects,
455 Node* control) {
457 Node** buf = Realloc(effects, count, count + 1);
463 Node* WasmGraphBuilder::NumberConstant(int32_t value) {
467 Node* WasmGraphBuilder::Uint32Constant(uint32_t value) {
471 Node* WasmGraphBuilder::Int32Constant(int32_t value) {
475 Node* WasmGraphBuilder::Int64Constant(int64_t value) {
480 Node** effect, Node** control) {
487 Node* limit = graph()->NewNode(
492 Node* pointer = graph()->NewNode(jsgraph()->machine()->LoadStackPointer());
494 Node* check =
499 Node* effect_true = *effect;
507 Node* stub_code = jsgraph()->HeapConstant(code);
509 Node* context = jsgraph()->NoContextConstant();
510 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), stub_code,
515 Node* ephi = graph()->NewNode(jsgraph()->common()->EffectPhi(2), effect_true,
522 Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right,
791 Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input,
867 Node* reversed = graph()->NewNode(m->Word32ReverseBits().op(), input);
868 Node* result = graph()->NewNode(m->Word32Clz(), reversed);
979 Node* reversed = graph()->NewNode(m->Word64ReverseBits().op(), input);
980 Node* result = graph()->NewNode(m->Word64Clz(), reversed);
1052 Node* WasmGraphBuilder::Float32Constant(float value) {
1056 Node* WasmGraphBuilder::Float64Constant(double value) {
1060 Node* WasmGraphBuilder::HeapConstant(Handle<HeapObject> value) {
1065 Node* Branch(JSGraph* jsgraph, Node* cond, Node** true_node, Node** false_node,
1066 Node* control, BranchHint hint) {
1069 Node* branch =
1077 Node* WasmGraphBuilder::BranchNoHint(Node* cond, Node** true_node,
1078 Node** false_node) {
1083 Node* WasmGraphBuilder::BranchExpectTrue(Node* cond, Node** true_node,
1084 Node** false_node) {
1089 Node* WasmGraphBuilder::BranchExpectFalse(Node* cond, Node** true_node,
1090 Node** false_node) {
1095 Node* WasmGraphBuilder::Switch(unsigned count, Node* key) {
1099 Node* WasmGraphBuilder::IfValue(int32_t value, Node* sw) {
1104 Node* WasmGraphBuilder::IfDefault(Node* sw) {
1109 Node* WasmGraphBuilder::Return(unsigned count, Node** vals) {
1114 Node* stack_buffer[kStackAllocatedNodeBufferSize];
1115 std::vector<Node*> heap_buffer;
1117 Node** buf = stack_buffer;
1127 Node* ret =
1134 Node* WasmGraphBuilder::ReturnVoid() { return Return(0, Buffer(0)); }
1136 Node* WasmGraphBuilder::Unreachable(wasm::WasmCodePosition position) {
1141 Node* WasmGraphBuilder::MaskShiftCount32(Node* node) {
1145 Int32Matcher match(node);
1148 if (match.Value() != masked) node = jsgraph()->Int32Constant(masked);
1150 node = graph()->NewNode(jsgraph()->machine()->Word32And(), node,
1154 return node;
1157 Node* WasmGraphBuilder::MaskShiftCount64(Node* node) {
1161 Int64Matcher match(node);
1164 if (match.Value() != masked) node = jsgraph()->Int64Constant(masked);
1166 node = graph()->NewNode(jsgraph()->machine()->Word64And(), node,
1170 return node;
1186 Node* WasmGraphBuilder::BuildChangeEndianness(Node* node, MachineType memtype,
1188 Node* result;
1189 Node* value = node;
1197 value = graph()->NewNode(m->BitcastFloat64ToInt64(), node);
1203 value = graph()->NewNode(m->BitcastFloat32ToInt32(), node);
1210 // No need to change endianness for byte size, return original node
1211 return node;
1241 Node* shiftLower;
1242 Node* shiftHigher;
1243 Node* lowerByte;
1244 Node* higherByte;
1299 Node* shiftBitCount;
1324 Node* WasmGraphBuilder::BuildF32CopySign(Node* left, Node* right) {
1325 Node* result = Unop(
1336 Node* WasmGraphBuilder::BuildF64CopySign(Node* left, Node* right) {
1338 Node* result = Unop(
1350 Node* high_word_left = graph()->NewNode(m->Float64ExtractHighWord32(), left);
1351 Node* high_word_right =
1354 Node* new_high_word =
1364 Node* WasmGraphBuilder::BuildI32SConvertF32(Node* input,
1368 Node* trunc = Unop(wasm::kExprF32Trunc, input);
1369 Node* result = graph()->NewNode(m->TruncateFloat32ToInt32(), trunc);
1373 Node* check = Unop(wasm::kExprF32SConvertI32, result);
1374 Node* overflow = Binop(wasm::kExprF32Ne, trunc, check);
1380 Node* WasmGraphBuilder::BuildI32SConvertF64(Node* input,
1384 Node* trunc = Unop(wasm::kExprF64Trunc, input);
1385 Node* result = graph()->NewNode(m->ChangeFloat64ToInt32(), trunc);
1389 Node* check = Unop(wasm::kExprF64SConvertI32, result);
1390 Node* overflow = Binop(wasm::kExprF64Ne, trunc, check);
1396 Node* WasmGraphBuilder::BuildI32UConvertF32(Node* input,
1400 Node* trunc = Unop(wasm::kExprF32Trunc, input);
1401 Node* result = graph()->NewNode(m->TruncateFloat32ToUint32(), trunc);
1405 Node* check = Unop(wasm::kExprF32UConvertI32, result);
1406 Node* overflow = Binop(wasm::kExprF32Ne, trunc, check);
1412 Node* WasmGraphBuilder::BuildI32UConvertF64(Node* input,
1416 Node* trunc = Unop(wasm::kExprF64Trunc, input);
1417 Node* result = graph()->NewNode(m->TruncateFloat64ToUint32(), trunc);
1421 Node* check = Unop(wasm::kExprF64UConvertI32, result);
1422 Node* overflow = Binop(wasm::kExprF64Ne, trunc, check);
1428 Node* WasmGraphBuilder::BuildI32AsmjsSConvertF32(Node* input) {
1435 Node* WasmGraphBuilder::BuildI32AsmjsSConvertF64(Node* input) {
1441 Node* WasmGraphBuilder::BuildI32AsmjsUConvertF32(Node* input) {
1448 Node* WasmGraphBuilder::BuildI32AsmjsUConvertF64(Node* input) {
1454 Node* WasmGraphBuilder::BuildBitCountingCall(Node* input, ExternalReference ref,
1456 Node* stack_slot_param =
1469 Node* function = graph()->NewNode(jsgraph()->common()->ExternalConstant(ref));
1470 Node* args[] = {function, stack_slot_param};
1475 Node* WasmGraphBuilder::BuildI32Ctz(Node* input) {
1481 Node* WasmGraphBuilder::BuildI64Ctz(Node* input) {
1488 Node* WasmGraphBuilder::BuildI32Popcnt(Node* input) {
1494 Node* WasmGraphBuilder::BuildI64Popcnt(Node* input) {
1501 Node* WasmGraphBuilder::BuildF32Trunc(Node* input) {
1509 Node* WasmGraphBuilder::BuildF32Floor(Node* input) {
1516 Node* WasmGraphBuilder::BuildF32Ceil(Node* input) {
1523 Node* WasmGraphBuilder::BuildF32NearestInt(Node* input) {
1530 Node* WasmGraphBuilder::BuildF64Trunc(Node* input) {
1537 Node* WasmGraphBuilder::BuildF64Floor(Node* input) {
1544 Node* WasmGraphBuilder::BuildF64Ceil(Node* input) {
1551 Node* WasmGraphBuilder::BuildF64NearestInt(Node* input) {
1558 Node* WasmGraphBuilder::BuildF64Acos(Node* input) {
1565 Node* WasmGraphBuilder::BuildF64Asin(Node* input) {
1572 Node* WasmGraphBuilder::BuildF64Pow(Node* left, Node* right) {
1579 Node* WasmGraphBuilder::BuildF64Mod(Node* left, Node* right) {
1586 Node* WasmGraphBuilder::BuildCFuncInstruction(ExternalReference ref,
1587 MachineType type, Node* input0,
1588 Node* input1) {
1596 Node* stack_slot_param0 =
1605 Node* function = graph()->NewNode(jsgraph()->common()->ExternalConstant(ref));
1606 Node** args = Buffer(5);
1612 Node* stack_slot_param1 = graph()->NewNode(
1633 Node* load =
1640 Node* WasmGraphBuilder::BuildF32SConvertI64(Node* input) {
1646 Node* WasmGraphBuilder::BuildF32UConvertI64(Node* input) {
1652 Node* WasmGraphBuilder::BuildF64SConvertI64(Node* input) {
1657 Node* WasmGraphBuilder::BuildF64UConvertI64(Node* input) {
1663 Node* WasmGraphBuilder::BuildIntToFloatConversionInstruction(
1664 Node* input, ExternalReference ref,
1667 Node* stack_slot_param = graph()->NewNode(
1669 Node* stack_slot_result = graph()->NewNode(
1679 Node* function = graph()->NewNode(jsgraph()->common()->ExternalConstant(ref));
1680 Node* args[] = {function, stack_slot_param, stack_slot_result};
1683 Node* load =
1690 Node* WasmGraphBuilder::BuildI64SConvertF32(Node* input,
1697 Node* trunc = graph()->NewNode(
1699 Node* result = graph()->NewNode(jsgraph()->common()->Projection(0), trunc,
1701 Node* overflow = graph()->NewNode(jsgraph()->common()->Projection(1), trunc,
1708 Node* WasmGraphBuilder::BuildI64UConvertF32(Node* input,
1715 Node* trunc = graph()->NewNode(
1717 Node* result = graph()->NewNode(jsgraph()->common()->Projection(0), trunc,
1719 Node* overflow = graph()->NewNode(jsgraph()->common()->Projection(1), trunc,
1726 Node* WasmGraphBuilder::BuildI64SConvertF64(Node* input,
1733 Node* trunc = graph()->NewNode(
1735 Node* result = graph()->NewNode(jsgraph()->common()->Projection(0), trunc,
1737 Node* overflow = graph()->NewNode(jsgraph()->common()->Projection(1), trunc,
1744 Node* WasmGraphBuilder::BuildI64UConvertF64(Node* input,
1751 Node* trunc = graph()->NewNode(
1753 Node* result = graph()->NewNode(jsgraph()->common()->Projection(0), trunc,
1755 Node* overflow = graph()->NewNode(jsgraph()->common()->Projection(1), trunc,
1762 Node* WasmGraphBuilder::BuildFloatToIntConversionInstruction(
1763 Node* input, ExternalReference ref,
1766 Node* stack_slot_param = graph()->NewNode(
1768 Node* stack_slot_result = graph()->NewNode(
1779 Node* function = graph()->NewNode(jsgraph()->common()->ExternalConstant(ref));
1780 Node* args[] = {function, stack_slot_param, stack_slot_result};
1784 Node* load =
1791 Node* WasmGraphBuilder::GrowMemory(Node* input) {
1800 Node* parameters[] = {BuildChangeUint32ToSmi(input)};
1801 Node* old_effect = *effect_;
1802 Node* call = BuildCallToRuntime(Runtime::kWasmGrowMemory, jsgraph(),
1806 Node* result = BuildChangeSmiToInt32(call);
1816 Node* WasmGraphBuilder::Throw(Node* input) {
1828 Node* upper = BuildChangeInt32ToSmi(
1830 Node* lower = BuildChangeInt32ToSmi(
1833 Node* parameters[] = {lower, upper}; // thrown value
1838 Node* WasmGraphBuilder::Catch(Node* input, wasm::WasmCodePosition position) {
1841 Node* parameters[] = {input}; // caught value
1842 Node* value =
1846 Node* is_smi;
1847 Node* is_heap;
1851 Node* smi_i32 = BuildChangeSmiToInt32(value);
1852 Node* is_smi_effect = *effect_;
1856 Node* heap_f64 = BuildLoadHeapNumberValue(value, is_heap);
1860 // control node.
1861 Node* heap_i32 = BuildI32SConvertF64(heap_f64, position);
1862 // *control_ contains the control node that should be used when merging the
1864 // BuildI32SConvertF64 may introduce a new control node (used for trapping if
1867 Node* is_heap_effect = *effect_;
1869 Node* merge = graph()->NewNode(common->Merge(2), is_heap, is_smi);
1870 Node* effect_merge = graph()->NewNode(common->EffectPhi(2), is_heap_effect,
1873 Node* value_i32 = graph()->NewNode(
1881 Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right,
1885 Node* before = *control_;
1886 Node* denom_is_m1;
1887 Node* denom_is_not_m1;
1902 Node* WasmGraphBuilder::BuildI32RemS(Node* left, Node* right,
1918 Node* WasmGraphBuilder::BuildI32DivU(Node* left, Node* right,
1926 Node* WasmGraphBuilder::BuildI32RemU(Node* left, Node* right,
1934 Node* WasmGraphBuilder::BuildI32AsmjsDivS(Node* left, Node* right) {
1966 Node* div = graph()->NewNode(m->Int32Div(), left, right, z.if_false);
1967 Node* neg =
1975 Node* WasmGraphBuilder::BuildI32AsmjsRemS(Node* left, Node* right) {
1978 Node* const zero = jsgraph()->Int32Constant(0);
2008 Node* const minus_one = jsgraph()->Int32Constant(-1);
2013 Node* check0 = graph()->NewNode(m->Int32LessThan(), zero, right);
2014 Node* branch0 =
2017 Node* if_true0 = graph()->NewNode(c->IfTrue(), branch0);
2018 Node* true0;
2020 Node* msk = graph()->NewNode(m->Int32Add(), right, minus_one);
2022 Node* check1 = graph()->NewNode(m->Word32And(), right, msk);
2023 Node* branch1 = graph()->NewNode(c->Branch(), check1, if_true0);
2025 Node* if_true1 = graph()->NewNode(c->IfTrue(), branch1);
2026 Node* true1 = graph()->NewNode(m->Int32Mod(), left, right, if_true1);
2028 Node* if_false1 = graph()->NewNode(c->IfFalse(), branch1);
2029 Node* false1;
2031 Node* check2 = graph()->NewNode(m->Int32LessThan(), left, zero);
2032 Node* branch2 =
2035 Node* if_true2 = graph()->NewNode(c->IfTrue(), branch2);
2036 Node* true2 = graph()->NewNode(
2041 Node* if_false2 = graph()->NewNode(c->IfFalse(), branch2);
2042 Node* false2 = graph()->NewNode(m->Word32And(), left, msk);
2052 Node* if_false0 = graph()->NewNode(c->IfFalse(), branch0);
2053 Node* false0;
2055 Node* check1 = graph()->NewNode(m->Int32LessThan(), right, minus_one);
2056 Node* branch1 =
2059 Node* if_true1 = graph()->NewNode(c->IfTrue(), branch1);
2060 Node* true1 = graph()->NewNode(m->Int32Mod(), left, right, if_true1);
2062 Node* if_false1 = graph()->NewNode(c->IfFalse(), branch1);
2063 Node* false1 = zero;
2069 Node* merge0 = graph()->NewNode(merge_op, if_true0, if_false0);
2073 Node* WasmGraphBuilder::BuildI32AsmjsDivU(Node* left, Node* right) {
2092 Node* WasmGraphBuilder::BuildI32AsmjsRemU(Node* left, Node* right) {
2101 Node* rem = graph()->NewNode(jsgraph()->machine()->Uint32Mod(), left, right,
2107 Node* WasmGraphBuilder::BuildI64DivS(Node* left, Node* right,
2115 Node* before = *control_;
2116 Node* denom_is_m1;
2117 Node* denom_is_not_m1;
2134 Node* WasmGraphBuilder::BuildI64RemS(Node* left, Node* right,
2148 Node* rem = graph()->NewNode(jsgraph()->machine()->Int64Mod(), left, right,
2155 Node* WasmGraphBuilder::BuildI64DivU(Node* left, Node* right,
2166 Node* WasmGraphBuilder::BuildI64RemU(Node* left, Node* right,
2178 Node* WasmGraphBuilder::BuildDiv64Call(Node* left, Node* right,
2182 Node* stack_slot_dst = graph()->NewNode(
2184 Node* stack_slot_src = graph()->NewNode(
2201 Node* function = graph()->NewNode(jsgraph()->common()->ExternalConstant(ref));
2202 Node* args[] = {function, stack_slot_dst, stack_slot_src};
2204 Node* call = BuildCCall(sig_builder.Build(), args);
2211 Node* load =
2218 Node* WasmGraphBuilder::BuildCCall(MachineSignature* sig, Node** args) {
2234 Node* call = graph()->NewNode(op, static_cast<int>(count), args);
2239 Node* WasmGraphBuilder::BuildWasmCall(wasm::FunctionSig* sig, Node** args,
2240 Node*** rets,
2256 Node* call = graph()->NewNode(op, static_cast<int>(count), args);
2277 Node* WasmGraphBuilder::CallDirect(uint32_t index, Node** args, Node*** rets,
2290 Node* WasmGraphBuilder::CallIndirect(uint32_t sig_index, Node** args,
2291 Node*** rets,
2304 Node* key = args[0];
2307 Node* size = function_table_sizes_[table_index];
2308 Node* in_bounds = graph()->NewNode(machine->Uint32LessThan(), key, size);
2310 Node* table = function_tables_[table_index];
2311 Node* signatures = signature_tables_[table_index];
2319 Node* load_sig = graph()->NewNode(
2328 Node* sig_match = graph()->NewNode(
2335 Node* load_code = graph()->NewNode(
2347 Node* WasmGraphBuilder::BuildI32Rol(Node* left, Node* right) {
2360 Node* WasmGraphBuilder::BuildI64Rol(Node* left, Node* right) {
2373 Node* WasmGraphBuilder::Invert(Node* node) {
2374 return Unop(wasm::kExprI32Eqz, node);
2377 Node* WasmGraphBuilder::BuildChangeInt32ToTagged(Node* value) {
2385 Node* add = graph()->NewNode(machine->Int32AddWithOverflow(), value, value,
2388 Node* ovf = graph()->NewNode(common->Projection(1), add, graph()->start());
2389 Node* branch = graph()->NewNode(common->Branch(BranchHint::kFalse), ovf,
2392 Node* if_true = graph()->NewNode(common->IfTrue(), branch);
2393 Node* vtrue = BuildAllocateHeapNumberWithValue(
2396 Node* if_false = graph()->NewNode(common->IfFalse(), branch);
2397 Node* vfalse = graph()->NewNode(common->Projection(0), add, if_false);
2399 Node* merge = graph()->NewNode(common->Merge(2), if_true, if_false);
2400 Node* phi = graph()->NewNode(common->Phi(MachineRepresentation::kTagged, 2),
2405 Node* WasmGraphBuilder::BuildChangeFloat64ToTagged(Node* value) {
2409 Node* value32 = graph()->NewNode(machine->RoundFloat64ToInt32(), value);
2410 Node* check_same = graph()->NewNode(
2413 Node* branch_same =
2416 Node* if_smi = graph()->NewNode(common->IfTrue(), branch_same);
2417 Node* vsmi;
2418 Node* if_box = graph()->NewNode(common->IfFalse(), branch_same);
2419 Node* vbox;
2422 Node* check_zero = graph()->NewNode(machine->Word32Equal(), value32,
2424 Node* branch_zero =
2427 Node* if_zero = graph()->NewNode(common->IfTrue(), branch_zero);
2428 Node* if_notzero = graph()->NewNode(common->IfFalse(), branch_zero);
2431 Node* check_negative = graph()->NewNode(
2435 Node* branch_negative = graph()->NewNode(common->Branch(BranchHint::kFalse),
2438 Node* if_negative = graph()->NewNode(common->IfTrue(), branch_negative);
2439 Node* if_notnegative = graph()->NewNode(common->IfFalse(), branch_negative);
2450 Node* smi_tag = graph()->NewNode(machine->Int32AddWithOverflow(), value32,
2453 Node* check_ovf = graph()->NewNode(common->Projection(1), smi_tag, if_smi);
2454 Node* branch_ovf =
2457 Node* if_ovf = graph()->NewNode(common->IfTrue(), branch_ovf);
2467 Node* control = graph()->NewNode(common->Merge(2), if_smi, if_box);
2473 Node* WasmGraphBuilder::ToJS(Node* node, wasm::ValueType type) {
2476 return BuildChangeInt32ToTagged(node);
2481 node = graph()->NewNode(jsgraph()->machine()->ChangeFloat32ToFloat64(),
2482 node);
2483 return BuildChangeFloat64ToTagged(node);
2485 return BuildChangeFloat64ToTagged(node);
2494 Node* WasmGraphBuilder::BuildJavaScriptToNumber(Node* node, Node* context) {
2499 Node* stub_code = jsgraph()->HeapConstant(callable.code());
2501 Node* result = graph()->NewNode(jsgraph()->common()->Call(desc), stub_code,
2502 node, context, *effect_, *control_);
2511 bool CanCover(Node* value, IrOpcode::Value opcode) {
2524 Node* WasmGraphBuilder::BuildChangeTaggedToFloat64(Node* value) {
2534 Node* object = NodeProperties::GetValueInput(value, 0);
2535 Node* context = NodeProperties::GetContextInput(value);
2536 Node* frame_state = NodeProperties::GetFrameStateInput(value);
2537 Node* effect = NodeProperties::GetEffectInput(value);
2538 Node* control = NodeProperties::GetControlInput(value);
2544 Node* check1 = BuildTestNotSmi(object);
2545 Node* branch1 =
2548 Node* if_true1 = graph()->NewNode(common->IfTrue(), branch1);
2549 Node* vtrue1 = graph()->NewNode(value->op(), object, context, frame_state,
2551 Node* etrue1 = vtrue1;
2553 Node* check2 = BuildTestNotSmi(vtrue1);
2554 Node* branch2 = graph()->NewNode(common->Branch(), check2, if_true1);
2556 Node* if_true2 = graph()->NewNode(common->IfTrue(), branch2);
2557 Node* vtrue2 = BuildLoadHeapNumberValue(vtrue1, if_true2);
2559 Node* if_false2 = graph()->NewNode(common->IfFalse(), branch2);
2560 Node* vfalse2 = BuildChangeSmiToFloat64(vtrue1);
2565 Node* if_false1 = graph()->NewNode(common->IfFalse(), branch1);
2566 Node* vfalse1 = BuildChangeSmiToFloat64(object);
2567 Node* efalse1 = effect;
2569 Node* merge1 = graph()->NewNode(merge_op, if_true1, if_false1);
2570 Node* ephi1 = graph()->NewNode(ephi_op, etrue1, efalse1, merge1);
2571 Node* phi1 = graph()->NewNode(phi_op, vtrue1, vfalse1, merge1);
2577 // the node and places it inside the diamond. Come up with a helper method!
2578 for (Node* use : etrue1->uses()) {
2587 Node* check = BuildTestNotSmi(value);
2588 Node* branch = graph()->NewNode(common->Branch(BranchHint::kFalse), check,
2591 Node* if_not_smi = graph()->NewNode(common->IfTrue(), branch);
2593 Node* vnot_smi;
2594 Node* check_undefined = graph()->NewNode(machine->WordEqual(), value,
2596 Node* branch_undefined = graph()->NewNode(common->Branch(BranchHint::kFalse),
2599 Node* if_undefined = graph()->NewNode(common->IfTrue(), branch_undefined);
2600 Node* vundefined =
2603 Node* if_not_undefined =
2605 Node* vheap_number = BuildLoadHeapNumberValue(value, if_not_undefined);
2612 Node* if_smi = graph()->NewNode(common->IfFalse(), branch);
2613 Node* vfrom_smi = BuildChangeSmiToFloat64(value);
2615 Node* merge = graph()->NewNode(common->Merge(2), if_not_smi, if_smi);
2616 Node* phi = graph()->NewNode(common->Phi(MachineRepresentation::kFloat64, 2),
2622 Node* WasmGraphBuilder::FromJS(Node* node, Node* context,
2627 Node* num = BuildJavaScriptToNumber(node, context);
2655 Node* WasmGraphBuilder::BuildChangeInt32ToSmi(Node* value) {
2663 Node* WasmGraphBuilder::BuildChangeSmiToInt32(Node* value) {
2673 Node* WasmGraphBuilder::BuildChangeUint32ToSmi(Node* value) {
2682 Node* WasmGraphBuilder::BuildChangeSmiToFloat64(Node* value) {
2687 Node* WasmGraphBuilder::BuildTestNotSmi(Node* value) {
2694 Node* WasmGraphBuilder::BuildSmiShiftBitsConstant() {
2698 Node* WasmGraphBuilder::BuildAllocateHeapNumberWithValue(Node* value,
2699 Node* control) {
2705 Node* target = jsgraph()->HeapConstant(callable.code());
2706 Node* context = jsgraph()->NoContextConstant();
2707 Node* effect =
2716 Node* heap_number = graph()->NewNode(allocate_heap_number_operator_.get(),
2718 Node* store =
2726 Node* WasmGraphBuilder::BuildLoadHeapNumberValue(Node* value, Node* control) {
2732 Node* WasmGraphBuilder::BuildHeapNumberValueIndexConstant() {
2758 Node** args = Buffer(count);
2761 Node* start = Start(wasm_count + 5);
2766 Node* context = graph()->NewNode(
2800 Node* param = Param(i + 1);
2801 Node* wasm_param = FromJS(param, context, sig->GetParam(i));
2812 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), count, args);
2814 Node* retval = call;
2815 Node* jsval = ToJS(
2820 int WasmGraphBuilder::AddParameterNodes(Node** args, int pos, int param_count,
2825 Node* param = Param(param_index++);
2840 Node* start = Start(wasm_count + 3);
2847 Node* context =
2855 Node** args = Buffer(wasm_count + 7);
2857 Node* call;
2925 Node* i32_zero = jsgraph()->Int32Constant(0);
2926 Node* val = sig->return_count() == 0
2942 Node* start = Start(param_count + 3);
2961 Node* arg_buffer = args_size_bytes == 0 && return_size_bytes == 0
2970 Node* param = Param(param_index++);
3007 Node* parameters[] = {
3019 Node* lower =
3022 Node* upper =
3027 Node* val;
3040 Node* WasmGraphBuilder::MemBuffer(uint32_t offset) {
3056 Node* WasmGraphBuilder::CurrentMemoryPages() {
3063 Node* inputs[] = {
3071 Node* call = graph()->NewNode(jsgraph()->common()->Call(desc),
3074 Node* result = BuildChangeSmiToInt32(call);
3080 Node* WasmGraphBuilder::MemSize(uint32_t offset) {
3111 Node* WasmGraphBuilder::GetGlobal(uint32_t index) {
3114 Node* addr = jsgraph()->RelocatableIntPtrConstant(
3119 Node* node = graph()->NewNode(op, addr, jsgraph()->Int32Constant(0), *effect_,
3121 *effect_ = node;
3122 return node;
3125 Node* WasmGraphBuilder::SetGlobal(uint32_t index, Node* val) {
3128 Node* addr = jsgraph()->RelocatableIntPtrConstant(
3134 Node* node = graph()->NewNode(op, addr, jsgraph()->Int32Constant(0), val,
3136 *effect_ = node;
3137 return node;
3140 void WasmGraphBuilder::BoundsCheckMem(MachineType memtype, Node* index,
3165 Node* cond = graph()->NewNode(jsgraph()->machine()->Uint32LessThan(),
3188 Node* cond = graph()->NewNode(jsgraph()->machine()->Uint32LessThan(), index,
3195 Node* WasmGraphBuilder::LoadMem(wasm::ValueType type, MachineType memtype,
3196 Node* index, uint32_t offset,
3199 Node* load;
3212 Node* position_node = jsgraph()->Int32Constant(position);
3250 Node* WasmGraphBuilder::StoreMem(MachineType memtype, Node* index,
3251 uint32_t offset, uint32_t alignment, Node* val,
3253 Node* store;
3271 Node* position_node = jsgraph()->Int32Constant(position);
3295 Node* WasmGraphBuilder::BuildAsmjsLoadMem(MachineType type, Node* index) {
3299 Node* load = graph()->NewNode(op, MemBuffer(0), index, MemSize(0), *effect_,
3305 Node* WasmGraphBuilder::BuildAsmjsStoreMem(MachineType type, Node* index,
3306 Node* val) {
3311 Node* store = graph()->NewNode(op, MemBuffer(0), index, MemSize(0), val,
3317 void WasmGraphBuilder::PrintDebugName(Node* node) {
3318 PrintF("#%d:%s", node->id(), node->op()->mnemonic());
3321 Node* WasmGraphBuilder::String(const char* string) {
3342 void WasmGraphBuilder::SetSourcePosition(Node* node,
3346 source_position_table_->SetSourcePosition(node, SourcePosition(position));
3349 Node* WasmGraphBuilder::CreateS128Value(int32_t value) {
3358 Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode,
3620 Node* WasmGraphBuilder::SimdLaneOp(wasm::WasmOpcode opcode, uint8_t lane,
3653 Node* WasmGraphBuilder::SimdShiftOp(wasm::WasmOpcode opcode, uint8_t shift,
3689 Node* WasmGraphBuilder::SimdSwizzleOp(wasm::WasmOpcode opcode, uint32_t swizzle,
3742 Node* control = nullptr;
3743 Node* effect = nullptr;
3818 Node* control = nullptr;
3819 Node* effect = nullptr;
3906 Node* control = nullptr;
3907 Node* effect = nullptr;
4052 // Create and cache this node in the main thread.