TODO: Maybe separate null handling and non-null-handling so that it is easier to insert a different null handling mechanism (for example in hash tables when structs are supported there).
| 960 | // a different null handling mechanism (for example in hash tables when structs are |
| 961 | // supported there). |
| 962 | void SlotDescriptor::CodegenWriteToSlotHelper( |
| 963 | const CodegenAnyValReadWriteInfo& read_write_info, |
| 964 | llvm::Value* main_tuple_llvm_struct_ptr, llvm::Value* tuple_llvm_struct_ptr, |
| 965 | llvm::Value* pool_val, |
| 966 | const NonWritableBasicBlock& insert_before) const { |
| 967 | DCHECK(main_tuple_llvm_struct_ptr->getType()->isPointerTy()); |
| 968 | DCHECK(main_tuple_llvm_struct_ptr->getType()->getPointerElementType()->isStructTy()); |
| 969 | DCHECK(tuple_llvm_struct_ptr->getType()->isPointerTy()); |
| 970 | DCHECK(tuple_llvm_struct_ptr->getType()->getPointerElementType()->isStructTy()); |
| 971 | LlvmBuilder* builder = read_write_info.builder(); |
| 972 | |
| 973 | // Non-null block: write slot |
| 974 | builder->SetInsertPoint(read_write_info.non_null_block()); |
| 975 | llvm::Value* slot = builder->CreateStructGEP(nullptr, tuple_llvm_struct_ptr, |
| 976 | llvm_field_idx(), "slot"); |
| 977 | if (read_write_info.type().IsStructType()) { |
| 978 | CodegenStoreStructToNativePtr(read_write_info, main_tuple_llvm_struct_ptr, |
| 979 | slot, pool_val, insert_before); |
| 980 | } else { |
| 981 | CodegenStoreNonNullAnyVal(read_write_info, slot, pool_val, this, insert_before); |
| 982 | |
| 983 | // We only need this branch if we are not a struct, because for structs, the last leaf |
| 984 | // (non-struct) field will add this branch. |
| 985 | insert_before.BranchTo(builder); |
| 986 | } |
| 987 | |
| 988 | // Null block: set null bit |
| 989 | builder->SetInsertPoint(read_write_info.null_block()); |
| 990 | CodegenSetToNull(read_write_info, main_tuple_llvm_struct_ptr); |
| 991 | insert_before.BranchTo(builder); |
| 992 | } |
| 993 | |
| 994 | void SlotDescriptor::CodegenStoreStructToNativePtr( |
| 995 | const CodegenAnyValReadWriteInfo& read_write_info, llvm::Value* main_tuple_ptr, |
no test coverage detected