Refactor script size checks to CompileContext