compiler: Check scoped call argument construction
4d3903cdf3959ce2c2fd6ef66297f3af9b897d87e93eb17ccf779795f7686592
1 parent
6bebd6db
lib/std/lang/lower.rad
+11 -11
| 7047 | 7047 | let layout = resolver::getTypeLayout(*allocation.item); |
|
| 7048 | 7048 | let size = layout.size if layout.size > 0 else 1; |
|
| 7049 | 7049 | let alignment = layout.alignment if layout.alignment > 0 else 1; |
|
| 7050 | 7050 | let runtime = allocation.traitInfo.methods[allocation.methodIndex].fnType; |
|
| 7051 | 7051 | let mut args = callArgs(self, runtime); |
|
| 7052 | - | args.append(il::Val::Reg(dataReg), alloc::arenaAllocator(self.arena)); |
|
| 7053 | - | args.append(il::Val::Imm(size as i64), alloc::arenaAllocator(self.arena)); |
|
| 7054 | - | args.append(il::Val::Imm(alignment as i64), alloc::arenaAllocator(self.arena)); |
|
| 7052 | + | args.append(il::Val::Reg(dataReg), self.allocator); |
|
| 7053 | + | args.append(il::Val::Imm(size as i64), self.allocator); |
|
| 7054 | + | args.append(il::Val::Imm(alignment as i64), self.allocator); |
|
| 7055 | 7055 | if slice { |
|
| 7056 | - | args.append(count, alloc::arenaAllocator(self.arena)); |
|
| 7056 | + | args.append(count, self.allocator); |
|
| 7057 | 7057 | } |
|
| 7058 | 7058 | let result = try emitCallValue(self, il::Val::Reg(functionReg), runtime, args); |
|
| 7059 | 7059 | return SessionInitialization { allocation, result, value, count }; |
|
| 7060 | 7060 | } |
|
| 7061 | 7061 |
| 7181 | 7181 | }); |
|
| 7182 | 7182 | let methodFnType = traitInfo.methods[methodIndex].fnType; |
|
| 7183 | 7183 | ||
| 7184 | 7184 | // Build args: optional return param slot + data pointer (receiver) + user args. |
|
| 7185 | 7185 | let mut args = callArgs(self, methodFnType); |
|
| 7186 | - | args.append(il::Val::Reg(dataReg), alloc::arenaAllocator(self.arena)); |
|
| 7186 | + | args.append(il::Val::Reg(dataReg), self.allocator); |
|
| 7187 | 7187 | ||
| 7188 | 7188 | for arg, i in call.args { |
|
| 7189 | 7189 | let value = try lowerCallArg( |
|
| 7190 | 7190 | self, arg, i + 1 < call.args.len |
|
| 7191 | 7191 | ); |
|
| 7192 | - | args.append(value, alloc::arenaAllocator(self.arena)); |
|
| 7192 | + | args.append(value, self.allocator); |
|
| 7193 | 7193 | } |
|
| 7194 | 7194 | return try emitCallValue(self, il::Val::Reg(fnPtrReg), methodFnType, args); |
|
| 7195 | 7195 | } |
|
| 7196 | 7196 | ||
| 7197 | 7197 | /// Lower a call argument, snapshotting aggregate place expressions before |
| 7211 | 7211 | } |
|
| 7212 | 7212 | return val; |
|
| 7213 | 7213 | } |
|
| 7214 | 7214 | ||
| 7215 | 7215 | /// Start an argument table with a placeholder for the hidden return pointer. |
|
| 7216 | - | unsafe fn callArgs 'arena 'phase 'function ( |
|
| 7216 | + | fn callArgs 'arena 'phase 'function ( |
|
| 7217 | 7217 | self: &mut FnLowerer 'arena 'phase 'function, |
|
| 7218 | 7218 | fnInfo: *resolver::FnType |
|
| 7219 | 7219 | ) -> *mut [il::Val] where 'arena: 'phase, 'phase: 'function { |
|
| 7220 | 7220 | let mut args: *mut [il::Val] = &mut []; |
|
| 7221 | 7221 | if requiresReturnParam(fnInfo) { |
|
| 7222 | - | args.append(il::Val::Undef, alloc::arenaAllocator(self.arena)); |
|
| 7222 | + | args.append(il::Val::Undef, self.allocator); |
|
| 7223 | 7223 | } |
|
| 7224 | 7224 | return args; |
|
| 7225 | 7225 | } |
|
| 7226 | 7226 | ||
| 7227 | 7227 | /// Emit a function call with return-parameter and small-aggregate handling. |
| 7342 | 7342 | let qualName = instanceMethodName(self.low, nil, method.concreteTypeName, method.name); |
|
| 7343 | 7343 | let fnInfo = method.fullFnType; |
|
| 7344 | 7344 | ||
| 7345 | 7345 | // Build args: optional return param slot + receiver + user args. |
|
| 7346 | 7346 | let mut args = callArgs(self, fnInfo); |
|
| 7347 | - | args.append(receiverVal, alloc::arenaAllocator(self.arena)); |
|
| 7347 | + | args.append(receiverVal, self.allocator); |
|
| 7348 | 7348 | for arg, i in call.args { |
|
| 7349 | 7349 | let value = try lowerCallArg( |
|
| 7350 | 7350 | self, arg, i + 1 < call.args.len |
|
| 7351 | 7351 | ); |
|
| 7352 | - | args.append(value, alloc::arenaAllocator(self.arena)); |
|
| 7352 | + | args.append(value, self.allocator); |
|
| 7353 | 7353 | } |
|
| 7354 | 7354 | return try emitCallValue(self, il::Val::FnAddr(qualName), fnInfo, args); |
|
| 7355 | 7355 | } |
|
| 7356 | 7356 | ||
| 7357 | 7357 | /// Check if a call is to a compiler intrinsic and lower it directly. |
| 7463 | 7463 | let mut args = callArgs(self, fnInfo); |
|
| 7464 | 7464 | for arg, i in call.args { |
|
| 7465 | 7465 | let value = try lowerCallArg( |
|
| 7466 | 7466 | self, arg, i + 1 < call.args.len |
|
| 7467 | 7467 | ); |
|
| 7468 | - | args.append(value, alloc::arenaAllocator(self.arena)); |
|
| 7468 | + | args.append(value, self.allocator); |
|
| 7469 | 7469 | } |
|
| 7470 | 7470 | ||
| 7471 | 7471 | return try emitCallValue(self, callee, fnInfo, args); |
|
| 7472 | 7472 | } |
|
| 7473 | 7473 |