Not sure what that circuit is doing, or trying to do; the current paths are all over the place, and high voltages exposed to MOS gates will instantly turn them into slag. It's not a sensible approach I'm afraid.
I would suggest something like a depletion MOS current limiter, as a more likely part of a solution. Have a well-defined current flow path (part of having a reliable logic input state, is being able to draw some current from whatever the source is), set that current with such an element, then pass that current through some logic element that handles other aspects -- filtering and de-glitching, hysteresis, isolation, etc. The above examples with optoisolators are a fine way to go: the current flow path is isolated to the input circuit and nothing else, and only a low capacitance is shared between that circuit and your main circuit.
The current flow remark is most explicit in control schemes like 4-20mA current loops, where the voltage is modest (typically 5-30V, but historical examples go up to 100V+ and 100mA or so -- back in the days of electromechanical teletype), but also includes modern industrial examples like AC control voltages (typically feeding relay coils, and electronic surrogates), and arguably even digital standards like LVDS or CANbus (current or voltage feeding a terminated bus), or even TTL logic (the inputs of which draw some current).
TTL is kind of an interesting example here, because the input current is designed to be more of a nuisance -- an acceptable compromise, moreso than a matter of confidence; but as it happens, many systems use default-high signals as a default, powered but inactive, state, asserting those signals only when low (hence all the active-low signals on your typical vintage CPU bus). So what starts as a quirk of the logic family in use, can still be turned into a kind of confidence measure.
This doesn't apply to CMOS of course, where the inputs draw very little current indeed, and can float freely up or down; '0' or '1' are equally probable in an open-circuit condition, or in the presence of noise. (Or, at least, equally probable given no further information about the devices themselves. It may well be that CMOS inputs tend to drift high, or that input thresholds cluster towards the low end of the input voltage range, etc. I don't actually know these offhand, I certainly haven't measured enough gates to have any feel for it. Not that it's something you should be designing based upon, anyway.

)
Anyway, regarding likely applications here, some input resistance or current draw is likely desirable, as otherwise-open-circuit or nominally-off AC lines, typically have some voltage on them regardless; whether because of solid-state switches or snubbers (some current leaks through the capacitance or leakage current), or because wiring is arranged in cables or raceways and capacitive coupling partially energizes the circuit, to the same end. Whether such resistance should be always-present, or optional whether by jumper or switch on the device, or applied externally (a common domestic situation is, SSR-switched LED lights not going fully off, but instead charging up slowly until reaching the start threshold and flashing slowly -- the standard solution is to leave one incandescent light in the circuit so its resistance shorts out the leakage), that's a matter of system design and typical use.
In any case, a likely circuit might have, either an anti-series pair of depletion MOS to limit current on the AC side, or a FWB rectifier then a single DMOS to limit DC current following the rectifier, then feeding an opto-isolator, which can be bidirectional or unidirectional LED type (respectively), with phototransistor output most likely. Output current can be measured, or sent into a pull-up resistor and the voltage measured, and digital filtering can be applied, as well as analog filtering at the input. Transient protection is highly desirable as mains is a dirty environment; some (maximal) series resistance might be used to set minimum input voltage threshold and limit peak surge current simultaneously, and a small MOV can be employed to protect the DMOS.
A series resistor and shunt MOV also helps to extend the input voltage withstand (momentary or continuous), depending on ratings. It's a blunt instrument however, so be careful calculating values and compromising between V_IH(min) vs. Vin(max).
Some RC or LC filtering may be desirable too, as even without the rectifier, DMOS have some rectifying effect, and RF on the line will cause a false positive reading. (Note that MOVs have some capacitance, so the above already has some value in this respect.) Some common-mode filtering with respect to the chassis (or other suitable ground reference) may also be desirable to mitigate interference into the optoisolator itself. Probably, these would be important considerations in the 10s of V (or V/m) level of immunity testing, so might be relevant to industrial or heavy-duty applications, but wouldn't be necessary for commercial purposes (typically 3V / V/m immunity); I would still insist on the surge protection steps (as surge of 1-2kV is typical).
---
An even more general point, we should ask along these lines is: not only "what is the bit value?", but "how well do we know the bit value?" -- what confidence level, what likelihood of correctness, does that bit have? Perhaps this level of consideration is rather over-the-top here (or trivial, i.e. a simple '1' or '0' suffices -- essentially, you need only a very low confidence level
in the confidence level, you don't care whether it's a well-defined value or not, just as long as it *is* some value at any given point in time), but it's a level of nuance that becomes critical in the design of radio systems, where unreliable reception is not merely unavoidable but indeed an intended part of the design; and we can apply the same principle even if the signal is direct wired, as the wiring itself can be unreliable, or signal source (by circumstance of what happens to be wired up at any given time, or mis-wired as the case may be) can be inconsistent or unreliable, or interference can be strong enough to bring the reading into question.
Tim