Lines Matching refs:Node
31 #include "src/compiler/node-matchers.h"
32 #include "src/compiler/node-origin-table.h"
93 void MergeControlToEnd(MachineGraph* mcgraph, Node* node) {
96 NodeProperties::MergeControlToEnd(g, mcgraph->common(), node);
98 g->SetEnd(g->NewNode(mcgraph->common()->End(1), node));
134 Node* WasmGraphBuilder::Error() { return mcgraph()->Dead(); }
136 Node* WasmGraphBuilder::Start(unsigned params) {
137 Node* start = graph()->NewNode(mcgraph()->common()->Start(params));
142 Node* WasmGraphBuilder::Param(unsigned index) {
147 Node* WasmGraphBuilder::Loop(Node* entry) {
151 Node* WasmGraphBuilder::Terminate(Node* effect, Node* control) {
152 Node* terminate =
158 bool WasmGraphBuilder::IsPhiWithMerge(Node* phi, Node* merge) {
163 bool WasmGraphBuilder::ThrowsException(Node* node, Node** if_success,
164 Node** if_exception) {
165 if (node->op()->HasProperty(compiler::Operator::kNoThrow)) {
169 *if_success = graph()->NewNode(mcgraph()->common()->IfSuccess(), node);
171 graph()->NewNode(mcgraph()->common()->IfException(), node, node);
176 void WasmGraphBuilder::AppendToMerge(Node* merge, Node* from) {
184 void WasmGraphBuilder::AppendToPhi(Node* phi, Node* from) {
192 Node* WasmGraphBuilder::Merge(unsigned count, Node** controls) {
196 Node* WasmGraphBuilder::Phi(wasm::ValueType type, unsigned count, Node** vals,
197 Node* control) {
199 Node** buf = Realloc(vals, count, count + 1);
207 Node* WasmGraphBuilder::EffectPhi(unsigned count, Node** effects,
208 Node* control) {
210 Node** buf = Realloc(effects, count, count + 1);
216 Node* WasmGraphBuilder::RefNull() {
220 Node* WasmGraphBuilder::NoContextConstant() {
225 Node* WasmGraphBuilder::Uint32Constant(uint32_t value) {
229 Node* WasmGraphBuilder::Int32Constant(int32_t value) {
233 Node* WasmGraphBuilder::Int64Constant(int64_t value) {
237 Node* WasmGraphBuilder::IntPtrConstant(intptr_t value) {
242 Node** effect, Node** control) {
252 // please also fix WasmStackCheckMatcher in node-matchers.h
254 Node* limit_address = graph()->NewNode(
258 Node* limit = graph()->NewNode(
262 Node* pointer = graph()->NewNode(mcgraph()->machine()->LoadStackPointer());
264 Node* check =
287 Node* call = graph()->NewNode(stack_check_call_operator_.get(),
293 Node* ephi = stack_check.EffectPhi(*effect, call);
302 Node* start = graph()->start();
303 // Place a stack check which uses a dummy node as control and effect.
304 Node* dummy = graph()->NewNode(mcgraph()->common()->Dead());
305 Node* control = dummy;
306 Node* effect = dummy;
315 // to use {effect} instead. Then rewire the dummy node to use start instead.
320 Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right,
589 Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input,
666 Node* reversed = graph()->NewNode(m->Word32ReverseBits().op(), input);
667 Node* result = graph()->NewNode(m->Word32Clz(), reversed);
778 Node* reversed = graph()->NewNode(m->Word64ReverseBits().op(), input);
779 Node* result = graph()->NewNode(m->Word64Clz(), reversed);
871 Node* WasmGraphBuilder::Float32Constant(float value) {
875 Node* WasmGraphBuilder::Float64Constant(double value) {
880 Node* Branch(MachineGraph* mcgraph, Node* cond, Node** true_node,
881 Node** false_node, Node* control, BranchHint hint) {
884 Node* branch =
892 Node* WasmGraphBuilder::BranchNoHint(Node* cond, Node** true_node,
893 Node** false_node) {
898 Node* WasmGraphBuilder::BranchExpectTrue(Node* cond, Node** true_node,
899 Node** false_node) {
904 Node* WasmGraphBuilder::BranchExpectFalse(Node* cond, Node** true_node,
905 Node** false_node) {
934 Node* WasmGraphBuilder::TrapIfTrue(wasm::TrapReason reason, Node* cond,
937 Node* node = SetControl(graph()->NewNode(mcgraph()->common()->TrapIf(trap_id),
939 SetSourcePosition(node, position);
940 return node;
943 Node* WasmGraphBuilder::TrapIfFalse(wasm::TrapReason reason, Node* cond,
946 Node* node = SetControl(graph()->NewNode(
948 SetSourcePosition(node, position);
949 return node;
952 // Add a check that traps if {node} is equal to {val}.
953 Node* WasmGraphBuilder::TrapIfEq32(wasm::TrapReason reason, Node* node,
956 Int32Matcher m(node);
959 return TrapIfFalse(reason, node, position);
963 node, mcgraph()->Int32Constant(val)),
968 // Add a check that traps if {node} is zero.
969 Node* WasmGraphBuilder::ZeroCheck32(wasm::TrapReason reason, Node* node,
971 return TrapIfEq32(reason, node, 0, position);
974 // Add a check that traps if {node} is equal to {val}.
975 Node* WasmGraphBuilder::TrapIfEq64(wasm::TrapReason reason, Node* node,
978 Int64Matcher m(node);
981 graph()->NewNode(mcgraph()->machine()->Word64Equal(), node,
986 // Add a check that traps if {node} is zero.
987 Node* WasmGraphBuilder::ZeroCheck64(wasm::TrapReason reason, Node* node,
989 return TrapIfEq64(reason, node, 0, position);
992 Node* WasmGraphBuilder::Switch(unsigned count, Node* key) {
996 Node* WasmGraphBuilder::IfValue(int32_t value, Node* sw) {
1001 Node* WasmGraphBuilder::IfDefault(Node* sw) {
1006 Node* WasmGraphBuilder::Return(unsigned count, Node** vals) {
1008 Node* stack_buffer[kStackAllocatedNodeBufferSize];
1009 std::vector<Node*> heap_buffer;
1011 Node** buf = stack_buffer;
1021 Node* ret =
1028 Node* WasmGraphBuilder::ReturnVoid() { return Return(0, nullptr); }
1030 Node* WasmGraphBuilder::Unreachable(wasm::WasmCodePosition position) {
1036 Node* WasmGraphBuilder::MaskShiftCount32(Node* node) {
1040 Int32Matcher match(node);
1043 if (match.Value() != masked) node = mcgraph()->Int32Constant(masked);
1045 node = graph()->NewNode(mcgraph()->machine()->Word32And(), node,
1049 return node;
1052 Node* WasmGraphBuilder::MaskShiftCount64(Node* node) {
1056 Int64Matcher match(node);
1059 if (match.Value() != masked) node = mcgraph()->Int64Constant(masked);
1061 node = graph()->NewNode(mcgraph()->machine()->Word64And(), node,
1065 return node;
1082 Node* WasmGraphBuilder::BuildChangeEndiannessStore(
1083 Node* node, MachineRepresentation mem_rep, wasm::ValueType wasmtype) {
1084 Node* result;
1085 Node* value = node;
1093 value = graph()->NewNode(m->BitcastFloat64ToInt64(), node);
1100 value = graph()->NewNode(m->BitcastFloat32ToInt32(), node);
1115 // No need to change endianness for byte size, return original node
1116 return node;
1146 Node* byte_reversed_lanes[4];
1173 Node* shiftLower;
1174 Node* shiftHigher;
1175 Node* lowerByte;
1176 Node* higherByte;
1230 Node* WasmGraphBuilder::BuildChangeEndiannessLoad(Node* node,
1233 Node* result;
1234 Node* value = node;
1242 value = graph()->NewNode(m->BitcastFloat64ToInt64(), node);
1249 value = graph()->NewNode(m->BitcastFloat32ToInt32(), node);
1257 // No need to change endianness for byte size, return original node
1258 return node;
1286 Node* byte_reversed_lanes[4];
1312 Node* shiftLower;
1313 Node* shiftHigher;
1314 Node* lowerByte;
1315 Node* higherByte;
1370 Node* shiftBitCount;
1395 Node* WasmGraphBuilder::BuildF32CopySign(Node* left, Node* right) {
1396 Node* result = Unop(
1407 Node* WasmGraphBuilder::BuildF64CopySign(Node* left, Node* right) {
1409 Node* result = Unop(
1421 Node* high_word_left = graph()->NewNode(m->Float64ExtractHighWord32(), left);
1422 Node* high_word_right =
1425 Node* new_high_word = Binop(wasm::kExprI32Ior,
1564 Node* Zero(WasmGraphBuilder* builder, const MachineType& ty) {
1579 Node* Min(WasmGraphBuilder* builder, const MachineType& ty) {
1594 Node* Max(WasmGraphBuilder* builder, const MachineType& ty) {
1642 Node* ConvertTrapTest(WasmGraphBuilder* builder, wasm::WasmOpcode opcode,
1644 Node* trunc, Node* converted_value) {
1646 Node* check = builder->Unop(ConvertBackOp(opcode), converted_value);
1653 Node* ConvertSaturateTest(WasmGraphBuilder* builder, wasm::WasmOpcode opcode,
1655 const MachineType& float_ty, Node* trunc,
1656 Node* converted_value) {
1657 Node* test = ConvertTrapTest(builder, opcode, int_ty, float_ty, trunc,
1667 Node* WasmGraphBuilder::BuildIntConvertFloat(Node* input,
1673 Node* trunc = nullptr;
1674 Node* converted_value = nullptr;
1686 Node* test =
1695 Node* test = ConvertSaturateTest(this, opcode, int_ty, float_ty, trunc,
1699 Node* nan_test = Binop(NeOp(float_ty), input, input);
1702 Node* neg_test = Binop(LtOp(float_ty), input, Zero(this, float_ty));
1705 Node* sat_val =
1707 Node* nan_val =
1712 Node* WasmGraphBuilder::BuildI32AsmjsSConvertF32(Node* input) {
1719 Node* WasmGraphBuilder::BuildI32AsmjsSConvertF64(Node* input) {
1725 Node* WasmGraphBuilder::BuildI32AsmjsUConvertF32(Node* input) {
1732 Node* WasmGraphBuilder::BuildI32AsmjsUConvertF64(Node* input) {
1738 Node* WasmGraphBuilder::BuildBitCountingCall(Node* input, ExternalReference ref,
1740 Node* stack_slot_param =
1752 Node* function = graph()->NewNode(mcgraph()->common()->ExternalConstant(ref));
1757 Node* WasmGraphBuilder::BuildI32Ctz(Node* input) {
1762 Node* WasmGraphBuilder::BuildI64Ctz(Node* input) {
1768 Node* WasmGraphBuilder::BuildI32Popcnt(Node* input) {
1773 Node* WasmGraphBuilder::BuildI64Popcnt(Node* input) {
1780 Node* WasmGraphBuilder::BuildF32Trunc(Node* input) {
1787 Node* WasmGraphBuilder::BuildF32Floor(Node* input) {
1793 Node* WasmGraphBuilder::BuildF32Ceil(Node* input) {
1799 Node* WasmGraphBuilder::BuildF32NearestInt(Node* input) {
1805 Node* WasmGraphBuilder::BuildF64Trunc(Node* input) {
1811 Node* WasmGraphBuilder::BuildF64Floor(Node* input) {
1817 Node* WasmGraphBuilder::BuildF64Ceil(Node* input) {
1823 Node* WasmGraphBuilder::BuildF64NearestInt(Node* input) {
1829 Node* WasmGraphBuilder::BuildF64Acos(Node* input) {
1835 Node* WasmGraphBuilder::BuildF64Asin(Node* input) {
1841 Node* WasmGraphBuilder::BuildF64Pow(Node* left, Node* right) {
1847 Node* WasmGraphBuilder::BuildF64Mod(Node* left, Node* right) {
1853 Node* WasmGraphBuilder::BuildCFuncInstruction(ExternalReference ref,
1854 MachineType type, Node* input0,
1855 Node* input1) {
1865 Node* stack_slot =
1873 Node* function = graph()->NewNode(mcgraph()->common()->ExternalConstant(ref));
1890 Node* WasmGraphBuilder::BuildF32SConvertI64(Node* input) {
1896 NodeNode* input) {
1902 Node* WasmGraphBuilder::BuildF64SConvertI64(Node* input) {
1907 Node* WasmGraphBuilder::BuildF64UConvertI64(Node* input) {
1913 Node* WasmGraphBuilder::BuildIntToFloatConversionInstruction(
1914 Node* input, ExternalReference ref,
1920 Node* stack_slot =
1928 Node* function = graph()->NewNode(mcgraph()->common()->ExternalConstant(ref));
1959 Node* WasmGraphBuilder::BuildCcallConvertFloat(Node* input,
1967 Node* stack_slot =
1975 Node* function =
1977 Node* overflow = BuildCCall(&sig, function, stack_slot);
1984 Node* test = Binop(wasm::kExprI32Eq, overflow, Int32Constant(0), position);
1987 Node* nan_test = Binop(NeOp(float_ty), input, input);
1990 Node* neg_test = Binop(LtOp(float_ty), input, Zero(this, float_ty));
1993 Node* sat_val =
1995 Node* load =
1998 Node* nan_val =
2003 Node* WasmGraphBuilder::GrowMemory(Node* input) {
2016 Node* call_target = mcgraph()->RelocatableIntPtrConstant(
2037 Node* WasmGraphBuilder::Throw(uint32_t tag,
2039 const Vector<Node*> values) {
2042 Node* create_parameters[] = {
2051 Node* value = values[i];
2063 Node* upper32 = graph()->NewNode(
2067 Node* lower32 = graph()->NewNode(m->TruncateInt64ToInt32(), value);
2080 Node* value) {
2082 Node* upper_parameters[] = {
2090 Node* lower_parameters[] = {
2100 Node* WasmGraphBuilder::BuildDecodeException32BitValue(Node* const* values,
2103 Node* upper = BuildChangeSmiToInt32(values[*index]);
2106 Node* lower = BuildChangeSmiToInt32(values[*index]);
2108 Node* value = graph()->NewNode(machine->Word32Or(), upper, lower);
2112 Node* WasmGraphBuilder::Rethrow() {
2114 Node* result = BuildCallToRuntime(Runtime::kWasmThrow, nullptr, 0);
2118 Node* WasmGraphBuilder::ConvertExceptionTagToRuntimeId(uint32_t tag) {
2124 Node* WasmGraphBuilder::GetExceptionRuntimeId() {
2130 Node** WasmGraphBuilder::GetExceptionValues(
2138 Node** values = Buffer(encoded_size);
2140 Node* parameters[] = {BuildChangeUint31ToSmi(Uint32Constant(i))};
2149 Node* value = BuildDecodeException32BitValue(values, &index);
2159 Node* upper =
2162 Node* lower = Unop(wasm::kExprI64UConvertI32,
2179 Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right,
2183 Node* before = Control();
2184 Node* denom_is_m1;
2185 Node* denom_is_not_m1;
2200 Node* WasmGraphBuilder::BuildI32RemS(Node* left, Node* right,
2216 Node* WasmGraphBuilder::BuildI32DivU(Node* left, Node* right,
2223 Node* WasmGraphBuilder::BuildI32RemU(Node* left, Node* right,
2230 Node* WasmGraphBuilder::BuildI32AsmjsDivS(Node* left, Node* right) {
2262 Node* div = graph()->NewNode(m->Int32Div(), left, right, z.if_false);
2263 Node* neg =
2271 Node* WasmGraphBuilder::BuildI32AsmjsRemS(Node* left, Node* right) {
2274 Node* const zero = mcgraph()->Int32Constant(0);
2304 Node* const minus_one = mcgraph()->Int32Constant(-1);
2309 Node* check0 = graph()->NewNode(m->Int32LessThan(), zero, right);
2310 Node* branch0 =
2313 Node* if_true0 = graph()->NewNode(c->IfTrue(), branch0);
2314 Node* true0;
2316 Node* msk = graph()->NewNode(m->Int32Add(), right, minus_one);
2318 Node* check1 = graph()->NewNode(m->Word32And(), right, msk);
2319 Node* branch1 = graph()->NewNode(c->Branch(), check1, if_true0);
2321 Node* if_true1 = graph()->NewNode(c->IfTrue(), branch1);
2322 Node* true1 = graph()->NewNode(m->Int32Mod(), left, right, if_true1);
2324 Node* if_false1 = graph()->NewNode(c->IfFalse(), branch1);
2325 Node* false1;
2327 Node* check2 = graph()->NewNode(m->Int32LessThan(), left, zero);
2328 Node* branch2 =
2331 Node* if_true2 = graph()->NewNode(c->IfTrue(), branch2);
2332 Node* true2 = graph()->NewNode(
2337 Node* if_false2 = graph()->NewNode(c->IfFalse(), branch2);
2338 Node* false2 = graph()->NewNode(m->Word32And(), left, msk);
2348 Node* if_false0 = graph()->NewNode(c->IfFalse(), branch0);
2349 Node* false0;
2351 Node* check1 = graph()->NewNode(m->Int32LessThan(), right, minus_one);
2352 Node* branch1 =
2355 Node* if_true1 = graph()->NewNode(c->IfTrue(), branch1);
2356 Node* true1 = graph()->NewNode(m->Int32Mod(), left, right, if_true1);
2358 Node* if_false1 = graph()->NewNode(c->IfFalse(), branch1);
2359 Node* false1 = zero;
2365 Node* merge0 = graph()->NewNode(merge_op, if_true0, if_false0);
2369 Node* WasmGraphBuilder::BuildI32AsmjsDivU(Node* left, Node* right) {
2388 Node* WasmGraphBuilder::BuildI32AsmjsRemU(Node* left, Node* right) {
2397 Node* rem = graph()->NewNode(mcgraph()->machine()->Uint32Mod(), left, right,
2403 Node* WasmGraphBuilder::BuildI64DivS(Node* left, Node* right,
2410 Node* before = Control();
2411 Node* denom_is_m1;
2412 Node* denom_is_not_m1;
2429 Node* WasmGraphBuilder::BuildI64RemS(Node* left, Node* right,
2442 Node* rem = graph()->NewNode(mcgraph()->machine()->Int64Mod(), left, right,
2449 Node* WasmGraphBuilder::BuildI64DivU(Node* left, Node* right,
2458 Node* WasmGraphBuilder::BuildI64RemU(Node* left, Node* right,
2468 Node* WasmGraphBuilder::BuildDiv64Call(Node* left, Node* right,
2473 Node* stack_slot =
2487 Node* function = graph()->NewNode(mcgraph()->common()->ExternalConstant(ref));
2488 Node* call = BuildCCall(&sig, function, stack_slot);
2498 Node* WasmGraphBuilder::BuildCCall(MachineSignature* sig, Node* function,
2502 Node* const call_args[] = {function, args..., Effect(), Control()};
2511 Node* WasmGraphBuilder::BuildWasmCall(wasm::FunctionSig* sig, Node** args,
2512 Node*** rets,
2514 Node* instance_node,
2529 memmove(&args[2], &args[1], params * sizeof(Node*));
2539 Node* call = SetEffect(graph()->NewNode(op, static_cast<int>(count), args));
2560 Node* WasmGraphBuilder::BuildImportWasmCall(wasm::FunctionSig* sig, Node** args,
2561 Node*** rets,
2565 Node* imported_instances = LOAD_INSTANCE_FIELD(ImportedFunctionInstances,
2567 Node* instance_node = LOAD_FIXED_ARRAY_SLOT(imported_instances, func_index);
2570 Node* imported_targets =
2572 Node* target_node = SetEffect(graph()->NewNode(
2581 Node* WasmGraphBuilder::BuildImportWasmCall(wasm::FunctionSig* sig, Node** args,
2582 Node*** rets,
2584 Node* func_index) {
2586 Node* imported_instances = LOAD_INSTANCE_FIELD(ImportedFunctionInstances,
2589 Node* imported_instances_data =
2592 Node* func_index_times_pointersize = graph()->NewNode(
2595 Node* instance_node = SetEffect(
2602 Node* imported_targets =
2604 Node* target_node = SetEffect(graph()->NewNode(
2612 Node* WasmGraphBuilder::CallDirect(uint32_t index, Node** args, Node*** rets,
2630 Node* WasmGraphBuilder::CallIndirect(uint32_t sig_index, Node** args,
2631 Node*** rets,
2639 Node* ift_size =
2643 Node* key = args[0];
2646 Node* in_bounds = graph()->NewNode(machine->Uint32LessThan(), key, ift_size);
2652 Node* neg_key =
2654 Node* masked_diff = graph()->NewNode(
2657 Node* mask =
2663 Node* ift_sig_ids =
2667 Node* scaled_key = Uint32ToUintptr(
2670 Node* loaded_sig =
2673 Node* sig_match = graph()->NewNode(machine->WordEqual(), loaded_sig,
2678 Node* ift_targets =
2680 Node* ift_instances = LOAD_INSTANCE_FIELD(IndirectFunctionTableInstances,
2686 Node* target =
2691 Node* target_instance = SetEffect(graph()->NewNode(
2702 Node* WasmGraphBuilder::BuildI32Rol(Node* left, Node* right) {
2715 Node* WasmGraphBuilder::BuildI64Rol(Node* left, Node* right) {
2728 Node* WasmGraphBuilder::Invert(Node* node) {
2729 return Unop(wasm::kExprI32Eqz, node);
2732 bool CanCover(Node* value, IrOpcode::Value opcode) {
2745 Node* WasmGraphBuilder::BuildChangeInt32ToIntPtr(Node* value) {
2752 Node* WasmGraphBuilder::BuildChangeInt32ToSmi(Node* value) {
2758 Node* WasmGraphBuilder::BuildChangeUint31ToSmi(Node* value) {
2763 Node* WasmGraphBuilder::BuildSmiShiftBitsConstant() {
2767 Node* WasmGraphBuilder::BuildChangeSmiToInt32(Node* value) {
2807 WasmInstanceCacheNodes* instance_cache, Node* control) {
2823 Node* merge) {
2826 Node* vals[] = {to->field, from->field, merge}; \
2841 Node* merge) {
2852 Node* WasmGraphBuilder::CreateOrMergeIntoPhi(MachineRepresentation rep,
2853 Node* merge, Node* tnode,
2854 Node* fnode) {
2859 // + 1 for the merge node.
2860 Node** vals = Buffer(count + 1);
2870 Node* WasmGraphBuilder::CreateOrMergeIntoEffectPhi(Node* merge, Node* tnode,
2871 Node* fnode) {
2876 Node** effects = Buffer(count);
2888 Node** base_node,
2889 Node** offset_node) {
2936 Node* WasmGraphBuilder::MemBuffer(uint32_t offset) {
2938 Node* mem_start = instance_cache_->mem_start;
2945 Node* WasmGraphBuilder::CurrentMemoryPages() {
2949 Node* mem_size = instance_cache_->mem_size;
2951 Node* result =
2963 Node* WasmGraphBuilder::BuildCallToRuntimeWithContext(Runtime::FunctionId f,
2964 Node* js_context,
2965 Node** parameters,
2974 Node* centry_stub =
2980 Node* inputs[kMaxParams + 6];
2997 Node* WasmGraphBuilder::BuildCallToRuntime(Runtime::FunctionId f,
2998 Node** parameters,
3004 Node* WasmGraphBuilder::GetGlobal(uint32_t index) {
3007 Node* base = nullptr;
3008 Node* offset = nullptr;
3011 Node* load = SetEffect(graph()->NewNode(mcgraph()->machine()->Load(mem_type),
3020 Node* WasmGraphBuilder::SetGlobal(uint32_t index, Node* val) {
3023 Node* base = nullptr;
3024 Node* offset = nullptr;
3037 Node* WasmGraphBuilder::CheckBoundsAndAlignment(
3038 uint8_t access_size, Node* index, uint32_t offset,
3044 Node* effective_address =
3050 Node* cond =
3060 Node* WasmGraphBuilder::BoundsCheckMem(uint8_t access_size, Node* index,
3080 Node* end_offset_node = IntPtrConstant(end_offset);
3092 Node* mem_size = instance_cache_->mem_size;
3096 Node* cond = graph()->NewNode(m->UintLessThan(), end_offset_node, mem_size);
3113 Node* effective_size =
3117 Node* cond = graph()->NewNode(m->UintLessThan(), index, effective_size);
3122 Node* mem_mask = instance_cache_->mem_mask;
3152 Node* WasmGraphBuilder::TraceMemoryOperation(bool is_store,
3154 Node* index, uint32_t offset,
3157 Node* info = graph()->NewNode(
3160 Node* address = graph()->NewNode(mcgraph()->machine()->Int32Add(),
3162 auto store = [&](int offset, MachineRepresentation rep, Node* data) {
3177 Node* call = BuildCallToRuntime(Runtime::kWasmTraceMemory, &info, 1);
3182 Node* WasmGraphBuilder::LoadMem(wasm::ValueType type, MachineType memtype,
3183 Node* index, uint32_t offset,
3186 Node* load;
3237 Node* WasmGraphBuilder::StoreMem(MachineRepresentation mem_rep, Node* index,
3238 uint32_t offset, uint32_t alignment, Node* val,
3241 Node* store;
3282 Node* GetAsmJsOOBValue(MachineRepresentation rep, MachineGraph* mcgraph) {
3300 Node* WasmGraphBuilder::BuildAsmjsLoadMem(MachineType type, Node* index) {
3302 Node* mem_start = instance_cache_->mem_start;
3303 Node* mem_size = instance_cache_->mem_size;
3322 Node* mem_mask = instance_cache_->mem_mask;
3327 Node* load = graph()->NewNode(mcgraph()->machine()->Load(type), mem_start,
3335 Node* WasmGraphBuilder::Uint32ToUintptr(Node* node) {
3336 if (mcgraph()->machine()->Is32()) return node;
3338 Uint32Matcher matcher(node);
3343 return graph()->NewNode(mcgraph()->machine()->ChangeUint32ToUint64(), node);
3346 Node* WasmGraphBuilder::BuildAsmjsStoreMem(MachineType type, Node* index,
3347 Node* val) {
3349 Node* mem_start = instance_cache_->mem_start;
3350 Node* mem_size = instance_cache_->mem_size;
3366 Node* mem_mask = instance_cache_->mem_mask;
3375 Node* store = graph()->NewNode(store_op, mem_start, index, val, Effect(),
3382 void WasmGraphBuilder::PrintDebugName(Node* node) {
3383 PrintF("#%d:%s", node->id(), node->op()->mnemonic());
3417 void WasmGraphBuilder::SetSourcePosition(Node* node,
3421 source_position_table_->SetSourcePosition(node, SourcePosition(position));
3424 Node* WasmGraphBuilder::S128Zero() {
3429 Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode, Node* const* inputs) {
3754 Node* WasmGraphBuilder::SimdLaneOp(wasm::WasmOpcode opcode, uint8_t lane,
3755 Node* const* inputs) {
3787 Node* WasmGraphBuilder::SimdShiftOp(wasm::WasmOpcode opcode, uint8_t shift,
3788 Node* const* inputs) {
3820 Node* WasmGraphBuilder::Simd8x16ShuffleOp(const uint8_t shuffle[16],
3821 Node* const* inputs) {
3898 Node* WasmGraphBuilder::AtomicOp(wasm::WasmOpcode opcode, Node* const* inputs,
3901 Node* node;
3905 Node* index = CheckBoundsAndAlignment( \
3908 node = graph()->NewNode( \
3918 Node* index = CheckBoundsAndAlignment( \
3921 node = graph()->NewNode( \
3932 Node* index = CheckBoundsAndAlignment( \
3935 node = graph()->NewNode( \
3945 Node* index = CheckBoundsAndAlignment( \
3948 node = graph()->NewNode( \
3958 return SetEffect(node);
3971 void Decorate(Node* node) final {
3973 node, NodeOrigin("wasm graph creation", "n/a",
4029 Node* BuildAllocateHeapNumberWithValue(Node* value, Node* control) {
4032 Node* target = (stub_mode_ == StubCallMode::kCallWasmRuntimeStub)
4044 Node* heap_number = graph()->NewNode(allocate_heap_number_operator_.get(),
4054 Node* BuildChangeSmiToFloat64(Node* value) {
4059 Node* BuildTestHeapObject(Node* value) {
4064 Node* BuildLoadHeapNumberValue(Node* value) {
4070 Node* BuildHeapNumberValueIndexConstant() {
4074 Node* BuildChangeInt32ToTagged(Node* value) {
4083 Node* effect = Effect();
4084 Node* control = Control();
4085 Node* add = graph()->NewNode(machine->Int32AddWithOverflow(), value, value,
4088 Node* ovf = graph()->NewNode(common->Projection(1), add, graph()->start());
4089 Node* branch =
4092 Node* if_true = graph()->NewNode(common->IfTrue(), branch);
4093 Node* vtrue = BuildAllocateHeapNumberWithValue(
4095 Node* etrue = Effect();
4097 Node* if_false = graph()->NewNode(common->IfFalse(), branch);
4098 Node* vfalse = graph()->NewNode(common->Projection(0), add, if_false);
4101 Node* merge =
4108 Node* BuildChangeFloat64ToTagged(Node* value) {
4123 Node* effect = Effect();
4124 Node* control = Control();
4125 Node* value32 = graph()->NewNode(machine->RoundFloat64ToInt32(), value);
4126 Node* check_i32 = graph()->NewNode(
4129 Node* branch_i32 = graph()->NewNode(common->Branch(), check_i32, control);
4131 Node* if_i32 = graph()->NewNode(common->IfTrue(), branch_i32);
4132 Node* if_not_i32 = graph()->NewNode(common->IfFalse(), branch_i32);
4135 Node* check_zero = graph()->NewNode(machine->Word32Equal(), value32,
4137 Node* branch_zero = graph()->NewNode(common->Branch(BranchHint::kFalse),
4140 Node* if_zero = graph()->NewNode(common->IfTrue(), branch_zero);
4141 Node* if_not_zero = graph()->NewNode(common->IfFalse(), branch_zero);
4144 Node* check_negative = graph()->NewNode(
4148 Node* branch_negative = graph()->NewNode(common->Branch(BranchHint::kFalse),
4151 Node* if_negative = graph()->NewNode(common->IfTrue(), branch_negative);
4152 Node* if_not_negative =
4156 Node* if_smi =
4158 Node* if_box = graph()->NewNode(common->Merge(2), if_not_i32, if_negative);
4163 Node* vsmi;
4168 Node* smi_tag = graph()->NewNode(machine->Int32AddWithOverflow(), value32,
4171 Node* check_ovf =
4173 Node* branch_ovf = graph()->NewNode(common->Branch(BranchHint::kFalse),
4176 Node* if_ovf = graph()->NewNode(common->IfTrue(), branch_ovf);
4185 Node* vbox = BuildAllocateHeapNumberWithValue(value, if_box);
4186 Node* ebox = Effect();
4188 Node* merge =
4195 int AddArgumentNodes(Node** args, int pos, int param_count,
4199 Node* param =
4206 Node* BuildJavaScriptToNumber(Node* node, Node* js_context) {
4210 Node* stub_code =
4216 Node* result = SetEffect(
4218 node, js_context, Effect(), Control()));
4225 Node* BuildChangeTaggedToFloat64(Node* value) {
4236 Node* check_heap_object = BuildTestHeapObject(value);
4242 Node* orig_effect = Effect();
4244 Node* undefined_node =
4246 Node* check_undefined =
4248 Node* effect_tagged = Effect();
4254 Node* vheap_number = BuildLoadHeapNumberValue(value);
4255 Node* effect_undefined = Effect();
4258 Node* vundefined =
4260 Node* vtagged = is_undefined.Phi(MachineRepresentation::kFloat64,
4266 Node* vfrom_smi = BuildChangeSmiToFloat64(value);
4274 Node* ToJS(Node* node, wasm::ValueType type) {
4277 return BuildChangeInt32ToTagged(node);
4282 node = graph()->NewNode(mcgraph()->machine()->ChangeFloat32ToFloat64(),
4283 node);
4284 return BuildChangeFloat64ToTagged(node);
4286 return BuildChangeFloat64ToTagged(node);
4288 return node;
4294 Node* FromJS(Node* node, Node* js_context, wasm::ValueType type) {
4299 return node;
4303 Node* num = BuildJavaScriptToNumber(node, js_context);
4331 Node* thread_in_wasm_flag_address_address =
4335 Node* thread_in_wasm_flag_address = SetEffect(graph()->NewNode(
4346 Node* BuildLoadFunctionDataFromExportedFunction(Node* closure) {
4347 Node* shared = SetEffect(graph()->NewNode(
4359 Node* BuildLoadInstanceFromExportedFunctionData(Node* function_data) {
4367 Node* BuildLoadFunctionIndexFromExportedFunctionData(Node* function_data) {
4368 Node* function_index_smi = SetEffect(graph()->NewNode(
4373 Node* function_index = BuildChangeSmiToInt32(function_index_smi);
4377 Node* BuildLoadJumpTableOffsetFromExportedFunctionData(Node* function_data) {
4378 Node* jump_table_offset_smi = SetEffect(graph()->NewNode(
4383 Node* jump_table_offset = BuildChangeSmiToInt32(jump_table_offset_smi);
4394 Node* js_closure =
4398 Node* js_context = graph()->NewNode(
4403 // Create the instance_node node to pass as parameter. It is loaded from
4407 Node* function_data = BuildLoadFunctionDataFromExportedFunction(js_closure);
4422 Node** args = Buffer(args_count);
4423 Node** rets;
4427 Node* param = Param(i + 1);
4428 Node* wasm_param = FromJS(param, js_context, sig_->GetParam(i));
4438 Node* function_index =
4445 Node* jump_table_start =
4447 Node* jump_table_offset =
4449 Node* jump_table_slot = graph()->NewNode(
4460 Node* jsval = sig_->return_count() == 0 ? jsgraph()->UndefinedConstant()
4476 Node* callables_node = LOAD_INSTANCE_FIELD(ImportedFunctionCallables,
4478 Node* callable_node = LOAD_FIXED_ARRAY_SLOT(callables_node, index);
4479 Node* undefined_node =
4481 Node* native_context =
4495 Node** args = Buffer(wasm_count + 9);
4496 Node* call = nullptr;
4503 Node* function_context = SetEffect(graph()->NewNode(
4517 Node* global_proxy = LOAD_FIXED_ARRAY_SLOT(
4550 Node* global_proxy = LOAD_FIXED_ARRAY_SLOT(
4607 Node* val = sig_->return_count() == 0
4642 Node* arg_buffer =
4664 Node* parameters[] = {
4678 Node* val = SetEffect(
4692 Node* foreign_code_obj = Param(CWasmEntryParameters::kCodeObject + 1);
4694 Node* code_obj = graph()->NewNode(
4698 Node* instance_node = Param(CWasmEntryParameters::kWasmInstance + 1);
4699 Node* arg_buffer = Param(CWasmEntryParameters::kArgumentsBuffer + 1);
4703 Node** args = Buffer(arg_count);
4711 Node* arg_load = SetEffect(
4725 Node* call = SetEffect(graph()->NewNode(
4784 Node* control = nullptr;
4785 Node* effect = nullptr;
4857 Node* control = nullptr;
4858 Node* effect = nullptr;
4932 Node* control = nullptr;
4933 Node* effect = nullptr;
4994 Node* control = nullptr;
4995 Node* effect = nullptr;